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.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) {

View file

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

View file

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