Show custom watchface only if Wear Watch connected
This commit is contained in:
parent
b309109090
commit
9bf6545f5d
3 changed files with 115 additions and 116 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
|
@ -73,128 +73,126 @@
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
|
||||||
<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"
|
|
||||||
android:layout_marginStart="4dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
app:cardCornerRadius="4dp"
|
|
||||||
app:contentPadding="2dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardUseCompatPadding="false"
|
|
||||||
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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingStart="15dp"
|
|
||||||
android:paddingEnd="15dp"
|
|
||||||
android:layout_marginBottom="0dp"
|
|
||||||
android:text="@string/wear_custom_watchface" />
|
|
||||||
|
|
||||||
<androidx.gridlayout.widget.GridLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:padding="10dip"
|
|
||||||
app:columnCount="2">
|
|
||||||
|
|
||||||
<info.nightscout.core.ui.elements.SingleClickButton
|
|
||||||
android:id="@+id/load_custom"
|
|
||||||
style="@style/GrayButton"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawableTop="@drawable/load_custom"
|
|
||||||
android:paddingStart="0dp"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:text="@string/wear_load_watchface"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_columnWeight="1"
|
|
||||||
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"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawableTop="@drawable/send_custom"
|
|
||||||
android:paddingStart="0dp"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:text="@string/wear_send_watchface"
|
|
||||||
android:textSize="11sp"
|
|
||||||
app:layout_column="1"
|
|
||||||
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"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawableTop="@drawable/export_custom"
|
|
||||||
android:paddingStart="0dp"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:text="@string/wear_export_watchface"
|
|
||||||
android:textSize="11sp"
|
|
||||||
android:visibility="visible"
|
|
||||||
app:layout_columnWeight="1"
|
|
||||||
app:layout_gravity="fill"
|
|
||||||
app:layout_row="0"
|
|
||||||
app:layout_column="1" />
|
|
||||||
|
|
||||||
<info.nightscout.core.ui.elements.SingleClickButton
|
|
||||||
android:id="@+id/default_custom"
|
|
||||||
style="@style/GrayButton"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:drawableTop="@drawable/set_default"
|
|
||||||
android:paddingStart="0dp"
|
|
||||||
android:paddingEnd="0dp"
|
|
||||||
android:text="@string/wear_default_watchface"
|
|
||||||
android:textSize="11sp"
|
|
||||||
android:visibility="visible"
|
|
||||||
app:layout_columnWeight="1"
|
|
||||||
app:layout_gravity="fill"
|
|
||||||
app:layout_row="1"
|
|
||||||
app:layout_column="0" />
|
|
||||||
|
|
||||||
</androidx.gridlayout.widget.GridLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/custom_layout"
|
android:id="@+id/custom_watchface_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:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/cover_chart"
|
style="@style/Widget.MaterialComponents.CardView"
|
||||||
android:tag="cover_chart"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
app:cardCornerRadius="4dp"
|
||||||
|
app:contentPadding="2dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:cardUseCompatPadding="false"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/custom_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="15dp"
|
||||||
|
android:paddingEnd="15dp"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:text="@string/wear_custom_watchface" />
|
||||||
|
|
||||||
|
<androidx.gridlayout.widget.GridLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:padding="10dip"
|
||||||
|
app:columnCount="2">
|
||||||
|
|
||||||
|
<info.nightscout.core.ui.elements.SingleClickButton
|
||||||
|
android:id="@+id/load_custom"
|
||||||
|
style="@style/GrayButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/load_custom"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:text="@string/wear_load_watchface"
|
||||||
|
android:textSize="11sp"
|
||||||
|
app:layout_columnWeight="1"
|
||||||
|
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"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/send_custom"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:text="@string/wear_send_watchface"
|
||||||
|
android:textSize="11sp"
|
||||||
|
app:layout_column="1"
|
||||||
|
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"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/export_custom"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:text="@string/wear_export_watchface"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_columnWeight="1"
|
||||||
|
app:layout_gravity="fill"
|
||||||
|
app:layout_row="0"
|
||||||
|
app:layout_column="1" />
|
||||||
|
|
||||||
|
<info.nightscout.core.ui.elements.SingleClickButton
|
||||||
|
android:id="@+id/default_custom"
|
||||||
|
style="@style/GrayButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/set_default"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:paddingEnd="0dp"
|
||||||
|
android:text="@string/wear_default_watchface"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:layout_columnWeight="1"
|
||||||
|
app:layout_gravity="fill"
|
||||||
|
app:layout_row="1"
|
||||||
|
app:layout_column="0" />
|
||||||
|
|
||||||
|
</androidx.gridlayout.widget.GridLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
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:src="@drawable/watchface_custom"
|
android:padding="20dp"
|
||||||
android:visibility="visible"
|
android:orientation="vertical">
|
||||||
android:orientation="vertical" />
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/cover_chart"
|
||||||
|
android:tag="cover_chart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@drawable/watchface_custom"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue