From 58b96cbdeeeebfe4d864fe36535816eefafdb344 Mon Sep 17 00:00:00 2001 From: darken Date: Tue, 27 Jun 2023 21:12:16 +0200 Subject: [PATCH] Fix "Missing show time" > Your app does not display the time of day clearly at the top of the app home screen and any ongoing activity screens. We recommend that you display the time of day at the top of all activities except dialog and confirmation screens. For more information, see Show the time. --- .../eu/darken/capod/wear/core/UserTime.kt | 18 +++++++++++++++ .../wear/ui/overview/OverviewFragmentVM.kt | 9 +++++++- .../ui/overview/cards/MissingMainDeviceVH.kt | 8 +++++-- .../ui/overview/cards/pods/DualPodsCardVH.kt | 5 ++++ .../overview/cards/pods/SinglePodsCardVH.kt | 4 ++++ .../res/layout/overview_nomaindevice_item.xml | 23 ++++++++++++++----- .../res/layout/overview_pods_dual_item.xml | 19 +++++++++++---- .../res/layout/overview_pods_single_item.xml | 15 ++++++++++-- app-wear/src/main/res/values/styles.xml | 6 +++++ 9 files changed, 91 insertions(+), 16 deletions(-) create mode 100644 app-wear/src/main/java/eu/darken/capod/wear/core/UserTime.kt diff --git a/app-wear/src/main/java/eu/darken/capod/wear/core/UserTime.kt b/app-wear/src/main/java/eu/darken/capod/wear/core/UserTime.kt new file mode 100644 index 00000000..960f6806 --- /dev/null +++ b/app-wear/src/main/java/eu/darken/capod/wear/core/UserTime.kt @@ -0,0 +1,18 @@ +package eu.darken.capod.wear.core + +import android.content.Context +import java.time.Instant +import java.time.ZoneId +import java.time.format.DateTimeFormatter +import java.time.format.FormatStyle +import java.util.Locale + +data class UserTime( + val time: Instant = Instant.now(), +) { + fun toFormatted(context: Context): String = DateTimeFormatter + .ofLocalizedTime(FormatStyle.SHORT) + .withLocale(Locale.getDefault()) + .withZone(ZoneId.systemDefault()) + .format(time) +} diff --git a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/OverviewFragmentVM.kt b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/OverviewFragmentVM.kt index 4ae9de9e..97171547 100644 --- a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/OverviewFragmentVM.kt +++ b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/OverviewFragmentVM.kt @@ -17,6 +17,7 @@ import eu.darken.capod.main.core.PermissionTool import eu.darken.capod.monitor.core.PodMonitor import eu.darken.capod.pods.core.DualPodDevice import eu.darken.capod.pods.core.SinglePodDevice +import eu.darken.capod.wear.core.UserTime import eu.darken.capod.wear.ui.overview.cards.BluetoothDisabledVH import eu.darken.capod.wear.ui.overview.cards.MissingMainDeviceVH import eu.darken.capod.wear.ui.overview.cards.PermissionCardVH @@ -86,14 +87,20 @@ class OverviewFragmentVM @Inject constructor( device = podToShow, showDebug = isDebugMode, isMainPod = true, + userTime = UserTime(), ) + is SinglePodDevice -> SinglePodsCardVH.Item( now = now, device = podToShow, showDebug = isDebugMode, isMainPod = true, + userTime = UserTime(), + ) + + else -> MissingMainDeviceVH.Item( + userTime = UserTime(), ) - else -> MissingMainDeviceVH.Item } items.add(pod) diff --git a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/MissingMainDeviceVH.kt b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/MissingMainDeviceVH.kt index 71dddf65..8157283c 100644 --- a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/MissingMainDeviceVH.kt +++ b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/MissingMainDeviceVH.kt @@ -5,6 +5,7 @@ import eu.darken.capod.R import eu.darken.capod.common.lists.binding import eu.darken.capod.common.lists.differ.DifferItem import eu.darken.capod.databinding.OverviewNomaindeviceItemBinding +import eu.darken.capod.wear.core.UserTime import eu.darken.capod.wear.ui.overview.OverviewAdapter class MissingMainDeviceVH(parent: ViewGroup) : @@ -21,11 +22,14 @@ class MissingMainDeviceVH(parent: ViewGroup) : item: Item, payloads: List ) -> Unit = binding(payload = true) { item -> + userTime.text = item.userTime.toFormatted(context) } - object Item : OverviewAdapter.Item { - override val stableId: Long = Item::class.hashCode().toLong() + data class Item( + val userTime: UserTime, + ) : OverviewAdapter.Item { + override val stableId: Long = this.hashCode().toLong() override val payloadProvider: ((DifferItem, DifferItem) -> DifferItem?) get() = { old, new -> if (new::class.isInstance(old)) new else null } diff --git a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/DualPodsCardVH.kt b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/DualPodsCardVH.kt index 3b5dc08e..c42dfc84 100644 --- a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/DualPodsCardVH.kt +++ b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/DualPodsCardVH.kt @@ -9,6 +9,7 @@ import eu.darken.capod.common.lists.binding import eu.darken.capod.databinding.OverviewPodsDualItemBinding import eu.darken.capod.pods.core.* import eu.darken.capod.pods.core.apple.DualApplePods +import eu.darken.capod.wear.core.UserTime import java.time.Instant class DualPodsCardVH(parent: ViewGroup) : @@ -20,7 +21,10 @@ class DualPodsCardVH(parent: ViewGroup) : override val viewBinding = lazy { OverviewPodsDualItemBinding.bind(itemView) } override val onBindData = binding(payload = true) { item: Item -> + userTime.text = item.userTime.toFormatted(context) + val device = item.device + name.apply { val sb = StringBuilder(device.getLabel(context)) if (device is HasPodStyle && item.showDebug) { @@ -127,5 +131,6 @@ class DualPodsCardVH(parent: ViewGroup) : override val device: DualPodDevice, override val showDebug: Boolean, override val isMainPod: Boolean, + val userTime: UserTime, ) : PodDeviceVH.Item } \ No newline at end of file diff --git a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/SinglePodsCardVH.kt b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/SinglePodsCardVH.kt index 5ce985e2..39b2347d 100644 --- a/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/SinglePodsCardVH.kt +++ b/app-wear/src/main/java/eu/darken/capod/wear/ui/overview/cards/pods/SinglePodsCardVH.kt @@ -8,6 +8,7 @@ import eu.darken.capod.R import eu.darken.capod.common.lists.binding import eu.darken.capod.databinding.OverviewPodsSingleItemBinding import eu.darken.capod.pods.core.* +import eu.darken.capod.wear.core.UserTime import java.time.Instant class SinglePodsCardVH(parent: ViewGroup) : @@ -19,6 +20,8 @@ class SinglePodsCardVH(parent: ViewGroup) : override val viewBinding = lazy { OverviewPodsSingleItemBinding.bind(itemView) } override val onBindData = binding(payload = true) { item: Item -> + userTime.text = item.userTime.toFormatted(context) + val device = item.device name.apply { @@ -75,5 +78,6 @@ class SinglePodsCardVH(parent: ViewGroup) : override val device: SinglePodDevice, override val showDebug: Boolean, override val isMainPod: Boolean, + val userTime: UserTime, ) : PodDeviceVH.Item } \ No newline at end of file diff --git a/app-wear/src/main/res/layout/overview_nomaindevice_item.xml b/app-wear/src/main/res/layout/overview_nomaindevice_item.xml index 59c68ec3..e25fd9a8 100644 --- a/app-wear/src/main/res/layout/overview_nomaindevice_item.xml +++ b/app-wear/src/main/res/layout/overview_nomaindevice_item.xml @@ -1,34 +1,45 @@ + + + app:layout_constraintTop_toBottomOf="@id/title" /> diff --git a/app-wear/src/main/res/layout/overview_pods_dual_item.xml b/app-wear/src/main/res/layout/overview_pods_dual_item.xml index b5e2f0dd..8757a988 100644 --- a/app-wear/src/main/res/layout/overview_pods_dual_item.xml +++ b/app-wear/src/main/res/layout/overview_pods_dual_item.xml @@ -7,14 +7,23 @@ android:layout_margin="8dp" tools:context=".wear.ui.MainActivity"> + + @@ -36,15 +45,15 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginHorizontal="8dp" - android:gravity="center" - app:lineHeight="14sp" android:layout_marginBottom="4dp" + android:gravity="center" android:lines="2" android:maxLines="2" app:layout_constraintBottom_toTopOf="@id/barrier_top" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/name" + app:lineHeight="14sp" tools:text="Music Active, Case Closed" /> + + center end + + \ No newline at end of file