From 822a32f529126d6a18e84de1d35b5bd1a16a8fff Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 17 Oct 2023 22:30:25 +0200 Subject: [PATCH] Wear CWF Add ShowDate preferences to CWF for AAPS v2 compatibility --- .../rx/weardata/CustomWatchfaceFormat.kt | 3 ++- core/interfaces/src/main/res/values/strings.xml | 1 + .../app/aaps/wear/watchfaces/CustomWatchface.kt | 17 +++++++++-------- .../res/xml/watch_face_configuration_custom.xml | 7 +++++++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/CustomWatchfaceFormat.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/CustomWatchfaceFormat.kt index 1343206001..0cae6aa73d 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/CustomWatchfaceFormat.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/weardata/CustomWatchfaceFormat.kt @@ -170,7 +170,8 @@ enum class CwfMetadataKey(val key: String, @StringRes val label: Int, val isPref CWF_PREF_WATCH_SHOW_AGO("key_show_ago", R.string.pref_show_ago, true), CWF_PREF_WATCH_SHOW_BG("key_show_bg", R.string.pref_show_bg, true), CWF_PREF_WATCH_SHOW_LOOP_STATUS("key_show_loop_status", R.string.pref_show_loop_status, true), - CWF_PREF_WATCH_SHOW_WEEK_NUMBER("key_show_week_number", R.string.pref_show_week_number, true); + CWF_PREF_WATCH_SHOW_WEEK_NUMBER("key_show_week_number", R.string.pref_show_week_number, true), + CWF_PREF_WATCH_SHOW_DATE("key_show_date", R.string.pref_show_date, true); companion object { diff --git a/core/interfaces/src/main/res/values/strings.xml b/core/interfaces/src/main/res/values/strings.xml index 25af997279..343e299d31 100644 --- a/core/interfaces/src/main/res/values/strings.xml +++ b/core/interfaces/src/main/res/values/strings.xml @@ -66,6 +66,7 @@ Show Direction Arrow Show Ago Show Week number + Show Date Default watchface, you can click on EXPORT WATCHFACE button to generate a template Default Watchface Background image 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 3a7a602544..62fa6701f0 100644 --- a/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt +++ b/wear/src/main/kotlin/app/aaps/wear/watchfaces/CustomWatchface.kt @@ -106,15 +106,15 @@ class CustomWatchface : BaseWatchFace() { override fun setColorDark() { setWatchfaceStyle() - if ((ViewMap.SGV.dynData?.stepFontColor ?: 0) == 0) + if ((ViewMap.SGV.dynData?.stepFontColor ?: 0) <= 0) binding.sgv.setTextColor(bgColor) - if ((ViewMap.DIRECTION.dynData?.stepColor ?: 0) == 0) + if ((ViewMap.DIRECTION.dynData?.stepColor ?: 0) <= 0) binding.direction2.colorFilter = changeDrawableColor(bgColor) - if (ageLevel != 1 && (ViewMap.TIMESTAMP.dynData?.stepFontColor ?: 0) == 0) + if (ageLevel != 1 && (ViewMap.TIMESTAMP.dynData?.stepFontColor ?: 0) <= 0) binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_TimestampOld)) - if (status.batteryLevel != 1 && (ViewMap.UPLOADER_BATTERY.dynData?.stepFontColor ?: 0) == 0) + if (status.batteryLevel != 1 && (ViewMap.UPLOADER_BATTERY.dynData?.stepFontColor ?: 0) <= 0) binding.uploaderBattery.setTextColor(lowBatColor) - if ((ViewMap.LOOP.dynData?.stepDraw ?: 0) == 0) // Apply automatic background image only if no dynData or no step images + if ((ViewMap.LOOP.dynData?.stepDraw ?: 0) <= 0) // Apply automatic background image only if no dynData or no step images when (loopLevel) { -1 -> binding.loop.setBackgroundResource(R.drawable.loop_grey_25) 1 -> binding.loop.setBackgroundResource(R.drawable.loop_green_25) @@ -393,10 +393,10 @@ class CustomWatchface : BaseWatchFace() { MINUTE(ViewKeys.MINUTE.key, R.id.minute), SECOND(ViewKeys.SECOND.key, R.id.second, R.string.key_show_seconds), TIMEPERIOD(ViewKeys.TIMEPERIOD.key, R.id.timePeriod), - DAY_NAME(ViewKeys.DAY_NAME.key, R.id.day_name), - DAY(ViewKeys.DAY.key, R.id.day), + DAY_NAME(ViewKeys.DAY_NAME.key, R.id.day_name, R.string.key_show_date), + DAY(ViewKeys.DAY.key, R.id.day, R.string.key_show_date), WEEKNUMBER(ViewKeys.WEEKNUMBER.key, R.id.week_number, R.string.key_show_week_number), - MONTH(ViewKeys.MONTH.key, R.id.month), + MONTH(ViewKeys.MONTH.key, R.id.month, R.string.key_show_date), LOOP(ViewKeys.LOOP.key, R.id.loop, R.string.key_show_external_status), DIRECTION(ViewKeys.DIRECTION.key, R.id.direction2, R.string.key_show_direction), TIMESTAMP(ViewKeys.TIMESTAMP.key, R.id.timestamp, R.string.key_show_ago), @@ -673,6 +673,7 @@ class CustomWatchface : BaseWatchFace() { SHOW_BGI(CwfMetadataKey.CWF_PREF_WATCH_SHOW_BGI.key, R.string.key_show_bgi, true), SHOW_LOOP_STATUS(CwfMetadataKey.CWF_PREF_WATCH_SHOW_LOOP_STATUS.key, R.string.key_show_external_status, true), SHOW_WEEK_NUMBER(CwfMetadataKey.CWF_PREF_WATCH_SHOW_WEEK_NUMBER.key, R.string.key_show_week_number, true), + SHOW_DATE(CwfMetadataKey.CWF_PREF_WATCH_SHOW_DATE.key, R.string.key_show_date, true), PREF_UNITS(JsonKeyValues.PREF_UNITS.key, R.string.key_units_mgdl, true), PREF_DARK(JsonKeyValues.PREF_DARK.key, R.string.key_dark, true), PREF_MATCH_DIVIDER(JsonKeyValues.PREF_MATCH_DIVIDER.key, R.string.key_match_divider, true); diff --git a/wear/src/main/res/xml/watch_face_configuration_custom.xml b/wear/src/main/res/xml/watch_face_configuration_custom.xml index 9cafa3ad48..e6e2f3408d 100644 --- a/wear/src/main/res/xml/watch_face_configuration_custom.xml +++ b/wear/src/main/res/xml/watch_face_configuration_custom.xml @@ -31,6 +31,13 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on" /> + +