Show custom watchface only if Wear Watch connected

This commit is contained in:
Philoul 2023-08-07 14:17:34 +02:00
parent b309109090
commit 9bf6545f5d
3 changed files with 115 additions and 116 deletions

View file

@ -19,6 +19,7 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.weardata.CustomWatchfaceDrawableDataKey import info.nightscout.rx.weardata.CustomWatchfaceDrawableDataKey
import info.nightscout.rx.weardata.CustomWatchfaceMetadataKey import info.nightscout.rx.weardata.CustomWatchfaceMetadataKey
import info.nightscout.rx.weardata.EventData import info.nightscout.rx.weardata.EventData
import info.nightscout.shared.extensions.toVisibility
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
@ -109,6 +110,7 @@ class WearFragment : DaggerFragment() {
binding.coverChart.setImageDrawable(null) binding.coverChart.setImageDrawable(null)
} }
binding.connectedDevice.text = wearPlugin.connectedDevice binding.connectedDevice.text = wearPlugin.connectedDevice
binding.customWatchfaceLayout.visibility = (wearPlugin.connectedDevice != rh.gs(R.string.no_watch_connected)).toVisibility()
} }
private fun loadCustom(cwf: EventData.ActionSetCustomWatchface) { private fun loadCustom(cwf: EventData.ActionSetCustomWatchface) {

View file

@ -55,7 +55,6 @@ class WearPlugin @Inject constructor(
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
var connectedDevice = "---" var connectedDevice = "---"
var customWatchfaceSerialized = ""
var savedCustomWatchface: CustomWatchfaceData? = null var savedCustomWatchface: CustomWatchfaceData? = null
override fun onStart() { override fun onStart() {

View file

@ -73,9 +73,13 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<LinearLayout
android:id="@+id/custom_watchface_Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/custom_watchface"
style="@style/Widget.MaterialComponents.CardView" style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -89,11 +93,6 @@
android:layout_gravity="center"> android:layout_gravity="center">
<LinearLayout
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/custom_name" android:id="@+id/custom_name"
@ -125,7 +124,7 @@
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" app:layout_row="0"
app:layout_column="0" /> app:layout_column="0" />
<!-- <!--
<info.nightscout.core.ui.elements.SingleClickButton <info.nightscout.core.ui.elements.SingleClickButton
android:id="@+id/send_custom" android:id="@+id/send_custom"
style="@style/GrayButton" style="@style/GrayButton"
@ -140,7 +139,7 @@
app:layout_columnWeight="1" app:layout_columnWeight="1"
app:layout_gravity="fill" app:layout_gravity="fill"
app:layout_row="0" /> app:layout_row="0" />
--> -->
<info.nightscout.core.ui.elements.SingleClickButton <info.nightscout.core.ui.elements.SingleClickButton
android:id="@+id/export_custom" android:id="@+id/export_custom"
style="@style/GrayButton" style="@style/GrayButton"
@ -175,15 +174,12 @@
</androidx.gridlayout.widget.GridLayout> </androidx.gridlayout.widget.GridLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<LinearLayout <LinearLayout
android:id="@+id/custom_layout" android:id="@+id/custom_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center"
android:padding="20dp" android:padding="20dp"
android:orientation="vertical"> android:orientation="vertical">
@ -198,4 +194,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>