From 9bf6545f5db78659fa4f20935914c0d0786c7798 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 7 Aug 2023 14:17:34 +0200 Subject: [PATCH] Show custom watchface only if Wear Watch connected --- .../plugins/general/wear/WearFragment.kt | 2 + .../plugins/general/wear/WearPlugin.kt | 1 - .../src/main/res/layout/wear_fragment.xml | 228 +++++++++--------- 3 files changed, 115 insertions(+), 116 deletions(-) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt index 85c620eb94..b3bc0008b8 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearFragment.kt @@ -19,6 +19,7 @@ import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.weardata.CustomWatchfaceDrawableDataKey import info.nightscout.rx.weardata.CustomWatchfaceMetadataKey import info.nightscout.rx.weardata.EventData +import info.nightscout.shared.extensions.toVisibility import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.utils.DateUtil @@ -109,6 +110,7 @@ class WearFragment : DaggerFragment() { binding.coverChart.setImageDrawable(null) } binding.connectedDevice.text = wearPlugin.connectedDevice + binding.customWatchfaceLayout.visibility = (wearPlugin.connectedDevice != rh.gs(R.string.no_watch_connected)).toVisibility() } private fun loadCustom(cwf: EventData.ActionSetCustomWatchface) { diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearPlugin.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearPlugin.kt index 156f791da6..9b7bd88101 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearPlugin.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/wear/WearPlugin.kt @@ -55,7 +55,6 @@ class WearPlugin @Inject constructor( private val disposable = CompositeDisposable() var connectedDevice = "---" - var customWatchfaceSerialized = "" var savedCustomWatchface: CustomWatchfaceData? = null override fun onStart() { diff --git a/plugins/main/src/main/res/layout/wear_fragment.xml b/plugins/main/src/main/res/layout/wear_fragment.xml index a8c23efcd7..4730a02599 100644 --- a/plugins/main/src/main/res/layout/wear_fragment.xml +++ b/plugins/main/src/main/res/layout/wear_fragment.xml @@ -73,128 +73,126 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + android:padding="20dp" + android:orientation="vertical"> + + + +