diff --git a/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewAdapter.kt b/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewAdapter.kt index ee9b6f3e..2620bb77 100644 --- a/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewAdapter.kt +++ b/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewAdapter.kt @@ -12,6 +12,7 @@ import eu.darken.capod.common.lists.modular.ModularAdapter import eu.darken.capod.common.lists.modular.mods.DataBinderMod import eu.darken.capod.common.lists.modular.mods.TypedVHCreatorMod import eu.darken.capod.main.ui.overview.cards.BluetoothDisabledVH +import eu.darken.capod.main.ui.overview.cards.MonitoringActiveVH import eu.darken.capod.main.ui.overview.cards.NoProfilesVH import eu.darken.capod.main.ui.overview.cards.PermissionCardVH import eu.darken.capod.main.ui.overview.cards.UnmatchedDevicesCardVH @@ -33,6 +34,7 @@ class OverviewAdapter @Inject constructor() : modules.add(TypedVHCreatorMod({ data[it] is SinglePodsCardVH.Item }) { SinglePodsCardVH(it) }) modules.add(TypedVHCreatorMod({ data[it] is NoProfilesVH.Item }) { NoProfilesVH(it) }) modules.add(TypedVHCreatorMod({ data[it] is BluetoothDisabledVH.Item }) { BluetoothDisabledVH(it) }) + modules.add(TypedVHCreatorMod({ data[it] is MonitoringActiveVH.Item }) { MonitoringActiveVH(it) }) modules.add(TypedVHCreatorMod({ data[it] is UnmatchedDevicesCardVH.Item }) { UnmatchedDevicesCardVH(it) }) modules.add(TypedVHCreatorMod({ data[it] is UnknownPodDeviceCardVH.Item }) { UnknownPodDeviceCardVH(it) }) } @@ -42,7 +44,7 @@ class OverviewAdapter @Inject constructor() : abstract class BaseVH( @LayoutRes layoutId: Int, parent: ViewGroup - ) : ModularAdapter.VH(layoutId, parent), BindableVH + ) : VH(layoutId, parent), BindableVH interface Item : DifferItem diff --git a/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewFragmentVM.kt b/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewFragmentVM.kt index 04efe362..7f4ae3b1 100644 --- a/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewFragmentVM.kt +++ b/app/src/main/java/eu/darken/capod/main/ui/overview/OverviewFragmentVM.kt @@ -15,11 +15,11 @@ import eu.darken.capod.common.livedata.SingleLiveEvent import eu.darken.capod.common.permissions.Permission import eu.darken.capod.common.uix.ViewModel3 import eu.darken.capod.common.upgrade.UpgradeRepo -import eu.darken.capod.profiles.core.DeviceProfilesRepo import eu.darken.capod.main.core.GeneralSettings import eu.darken.capod.main.core.MonitorMode import eu.darken.capod.main.core.PermissionTool import eu.darken.capod.main.ui.overview.cards.BluetoothDisabledVH +import eu.darken.capod.main.ui.overview.cards.MonitoringActiveVH import eu.darken.capod.main.ui.overview.cards.NoProfilesVH import eu.darken.capod.main.ui.overview.cards.PermissionCardVH import eu.darken.capod.main.ui.overview.cards.UnmatchedDevicesCardVH @@ -31,6 +31,7 @@ import eu.darken.capod.monitor.core.worker.MonitorControl import eu.darken.capod.pods.core.DualPodDevice import eu.darken.capod.pods.core.PodDevice import eu.darken.capod.pods.core.SinglePodDevice +import eu.darken.capod.profiles.core.DeviceProfilesRepo import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch @@ -176,7 +177,11 @@ class OverviewFragmentVM @Inject constructor( ) } }.run { items.addAll(this) } - + + if (profiles.isNotEmpty() && devices.isEmpty()) { + items.add(MonitoringActiveVH.Item) + } + // Add unmatched devices section if any exist if (unmatchedDevices.isNotEmpty()) { items.add(UnmatchedDevicesCardVH.Item( diff --git a/app/src/main/java/eu/darken/capod/main/ui/overview/cards/MonitoringActiveVH.kt b/app/src/main/java/eu/darken/capod/main/ui/overview/cards/MonitoringActiveVH.kt new file mode 100644 index 00000000..3f9b0119 --- /dev/null +++ b/app/src/main/java/eu/darken/capod/main/ui/overview/cards/MonitoringActiveVH.kt @@ -0,0 +1,33 @@ +package eu.darken.capod.main.ui.overview.cards + +import android.view.ViewGroup +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.OverviewMonitoringActiveItemBinding +import eu.darken.capod.main.ui.overview.OverviewAdapter + +class MonitoringActiveVH(parent: ViewGroup) : + OverviewAdapter.BaseVH( + R.layout.overview_monitoring_active_item, + parent + ) { + + override val viewBinding = lazy { + OverviewMonitoringActiveItemBinding.bind(itemView) + } + + override val onBindData: OverviewMonitoringActiveItemBinding.( + item: Item, + payloads: List + ) -> Unit = binding(payload = true) { item -> + // No actions needed for this card - it's purely informational + } + + object Item : OverviewAdapter.Item { + override val stableId: Long = Item::class.hashCode().toLong() + + override val payloadProvider: ((DifferItem, DifferItem) -> DifferItem?) + get() = { old, new -> if (new::class.isInstance(old)) new else null } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/overview_monitoring_active_item.xml b/app/src/main/res/layout/overview_monitoring_active_item.xml new file mode 100644 index 00000000..a33d7ddb --- /dev/null +++ b/app/src/main/res/layout/overview_monitoring_active_item.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c946f0ea..4a53b6f3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -140,7 +140,7 @@ You can upgrade to CAPod Pro to gain extra features and support development. -CAPod + CAPod CAPod Pro CAPod FOSS @@ -153,6 +153,8 @@ Configure your device to start monitoring battery levels and enable additional features. Bluetooth is disabled Bluetooth is disabled, enable it ;) + Monitoring for devices + Make sure your device is nearby and active. Unmatched devices 1 device without matching profile %d devices without matching profile