fix: resize Ollama logo to 20x20dp on widget for square aspect ratio
This commit is contained in:
parent
f7662d065a
commit
e0301aad1d
@ -7,6 +7,7 @@ import android.content.ComponentName
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
import android.util.TypedValue
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import com.rainy.token.MainActivity
|
import com.rainy.token.MainActivity
|
||||||
import com.rainy.token.R
|
import com.rainy.token.R
|
||||||
@ -90,6 +91,14 @@ class OpenCodeGoWidgetProvider : AppWidgetProvider() {
|
|||||||
views.setTextViewText(R.id.widget_switch, shortName(selectedService))
|
views.setTextViewText(R.id.widget_switch, shortName(selectedService))
|
||||||
views.setTextViewText(R.id.widget_service_title, "${selectedService.displayName} · 额度")
|
views.setTextViewText(R.id.widget_service_title, "${selectedService.displayName} · 额度")
|
||||||
views.setImageViewResource(R.id.widget_logo, widgetLogo(selectedService))
|
views.setImageViewResource(R.id.widget_logo, widgetLogo(selectedService))
|
||||||
|
// Ollama logo 是正方形,需要动态调整 ImageView 尺寸
|
||||||
|
if (selectedService == ServiceType.OLLAMA) {
|
||||||
|
views.setViewLayoutWidth(R.id.widget_logo, 20f, TypedValue.COMPLEX_UNIT_DIP)
|
||||||
|
views.setViewLayoutHeight(R.id.widget_logo, 20f, TypedValue.COMPLEX_UNIT_DIP)
|
||||||
|
} else {
|
||||||
|
views.setViewLayoutWidth(R.id.widget_logo, 22f, TypedValue.COMPLEX_UNIT_DIP)
|
||||||
|
views.setViewLayoutHeight(R.id.widget_logo, 12f, TypedValue.COMPLEX_UNIT_DIP)
|
||||||
|
}
|
||||||
val cached = cache.get(selectedService)
|
val cached = cache.get(selectedService)
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
selectedHasCachedData = true
|
selectedHasCachedData = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user