From acfc23ddf87cabd7d7506b68f5e2f5405ecd6bb6 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 3 Oct 2023 18:24:30 +0200 Subject: [PATCH] Wear CWF Authorize DynColor in ImageView and background image for chart --- .../kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt index 3c85dbc303..c65366d85b 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt @@ -510,15 +510,15 @@ class CustomWatchface : BaseWatchFace() { customizeViewCommon(view, viewJson) view.clearColorFilter() drawable?.let { - if (viewJson.has(COLOR.key)) // Note only works on bitmap (png or jpg) or xml included into res, not for svg files - it.colorFilter = cwf.changeDrawableColor(cwf.getColor(viewJson.optString(COLOR.key))) + if (viewJson.has(COLOR.key) || (dynData?.stepColor ?: 0) > 0) // Note only works on bitmap (png or jpg) or xml included into res, not for svg files + it.colorFilter = cwf.changeDrawableColor(dynData?.getColor() ?: cwf.getColor(viewJson.optString(COLOR.key))) else it.clearColorFilter() view.setImageDrawable(it) } ?: apply { view.setImageDrawable(defaultDrawable?.let { cwf.resources.getDrawable(it) }) - if (viewJson.has(COLOR.key)) - view.setColorFilter(cwf.getColor(viewJson.optString(COLOR.key))) + if (viewJson.has(COLOR.key) || (dynData?.stepColor ?: 0) > 0) + view.setColorFilter(dynData?.getColor() ?: cwf.getColor(viewJson.optString(COLOR.key))) else view.clearColorFilter() } @@ -527,6 +527,7 @@ class CustomWatchface : BaseWatchFace() { fun customizeGraphView(view: lecho.lib.hellocharts.view.LineChartView, viewJson: JSONObject) { customizeViewCommon(view, viewJson) view.setBackgroundColor(dynData?.getColor() ?: cwf.getColor(viewJson.optString(COLOR.key, "#0000000000"),Color.TRANSPARENT)) + view.background = dynData?.getDrawable() ?: textDrawable(viewJson) } }