mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
Some ui highlighting for main pod device (e.g. yours)
This commit is contained in:
@@ -92,6 +92,7 @@ class OverviewFragmentVM @Inject constructor(
|
||||
) { tick, permissions, pods, isDebugMode, showAll ->
|
||||
val items = mutableListOf<OverviewAdapter.Item>()
|
||||
|
||||
val mainPod = podMonitor.mainDevice.first()
|
||||
val now = Instant.now()
|
||||
pods
|
||||
.map {
|
||||
@@ -99,21 +100,26 @@ class OverviewFragmentVM @Inject constructor(
|
||||
is DualApplePods -> DualApplePodsCardVH.Item(
|
||||
now = now,
|
||||
device = it,
|
||||
showDebug = isDebugMode
|
||||
showDebug = isDebugMode,
|
||||
isMainPod = it == mainPod,
|
||||
)
|
||||
is SingleApplePods -> SingleApplePodsCardVH.Item(
|
||||
now = now,
|
||||
device = it,
|
||||
showDebug = isDebugMode
|
||||
showDebug = isDebugMode,
|
||||
isMainPod = it == mainPod,
|
||||
)
|
||||
is BasicSingleApplePods -> BasicSingleApplePodsCardVH.Item(
|
||||
now = now,
|
||||
device = it,
|
||||
showDebug = isDebugMode
|
||||
showDebug = isDebugMode,
|
||||
isMainPod = it == mainPod,
|
||||
)
|
||||
else -> UnknownPodDeviceCardVH.Item(
|
||||
now = now,
|
||||
device = it
|
||||
device = it,
|
||||
showDebug = isDebugMode,
|
||||
isMainPod = it == mainPod,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -1,5 +1,6 @@
|
||||
package eu.darken.capod.main.ui.overview.cards.pods
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isGone
|
||||
import eu.darken.capod.R
|
||||
@@ -22,7 +23,12 @@ class BasicSingleApplePodsCardVH(parent: ViewGroup) :
|
||||
override val onBindData = binding(payload = true) { item: Item ->
|
||||
val device = item.device
|
||||
|
||||
name.text = device.getLabel(context)
|
||||
name.apply {
|
||||
text = device.getLabel(context)
|
||||
if (item.isMainPod) setTypeface(typeface, Typeface.BOLD)
|
||||
else setTypeface(typeface, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
deviceIcon.setImageResource(device.iconRes)
|
||||
|
||||
lastSeen.text = device.lastSeenFormatted(item.now)
|
||||
@@ -50,5 +56,6 @@ class BasicSingleApplePodsCardVH(parent: ViewGroup) :
|
||||
override val now: Instant,
|
||||
override val device: BasicSingleApplePods,
|
||||
override val showDebug: Boolean,
|
||||
override val isMainPod: Boolean,
|
||||
) : PodDeviceVH.Item
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.darken.capod.main.ui.overview.cards.pods
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.view.ViewGroup
|
||||
import eu.darken.capod.R
|
||||
import eu.darken.capod.common.lists.binding
|
||||
@@ -27,6 +28,8 @@ class DualApplePodsCardVH(parent: ViewGroup) :
|
||||
sb.append(" (${device.getDeviceColorLabel(context)})")
|
||||
}
|
||||
text = sb
|
||||
if (item.isMainPod) setTypeface(typeface, Typeface.BOLD)
|
||||
else setTypeface(typeface, Typeface.NORMAL)
|
||||
}
|
||||
deviceIcon.setImageResource(device.iconRes)
|
||||
|
||||
@@ -89,5 +92,6 @@ class DualApplePodsCardVH(parent: ViewGroup) :
|
||||
override val now: Instant,
|
||||
override val device: DualApplePods,
|
||||
override val showDebug: Boolean,
|
||||
override val isMainPod: Boolean,
|
||||
) : PodDeviceVH.Item
|
||||
}
|
||||
@@ -23,6 +23,8 @@ abstract class PodDeviceVH<D : PodDeviceVH.Item, B : ViewBinding>(
|
||||
|
||||
val showDebug: Boolean
|
||||
|
||||
val isMainPod: Boolean
|
||||
|
||||
override val stableId: Long get() = device.identifier.hashCode().toLong()
|
||||
|
||||
override val payloadProvider: ((DifferItem, DifferItem) -> DifferItem?)?
|
||||
|
||||
+8
-1
@@ -1,5 +1,6 @@
|
||||
package eu.darken.capod.main.ui.overview.cards.pods
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isGone
|
||||
import eu.darken.capod.R
|
||||
@@ -22,7 +23,12 @@ class SingleApplePodsCardVH(parent: ViewGroup) :
|
||||
override val onBindData = binding(payload = true) { item: Item ->
|
||||
val device = item.device
|
||||
|
||||
name.text = device.getLabel(context)
|
||||
name.apply {
|
||||
text = device.getLabel(context)
|
||||
if (item.isMainPod) setTypeface(typeface, Typeface.BOLD)
|
||||
else setTypeface(typeface, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
deviceIcon.setImageResource(device.iconRes)
|
||||
|
||||
lastSeen.text = device.lastSeenFormatted(item.now)
|
||||
@@ -55,5 +61,6 @@ class SingleApplePodsCardVH(parent: ViewGroup) :
|
||||
override val now: Instant,
|
||||
override val device: SingleApplePods,
|
||||
override val showDebug: Boolean,
|
||||
override val isMainPod: Boolean,
|
||||
) : PodDeviceVH.Item
|
||||
}
|
||||
+8
-2
@@ -1,5 +1,6 @@
|
||||
package eu.darken.capod.main.ui.overview.cards.pods
|
||||
|
||||
import android.graphics.Typeface
|
||||
import android.view.ViewGroup
|
||||
import eu.darken.capod.R
|
||||
import eu.darken.capod.common.lists.binding
|
||||
@@ -21,7 +22,11 @@ class UnknownPodDeviceCardVH(parent: ViewGroup) :
|
||||
|
||||
override val onBindData = binding(payload = true) { item ->
|
||||
val device = item.device
|
||||
name.text = device.getLabel(context)
|
||||
name.apply {
|
||||
text = device.getLabel(context)
|
||||
if (item.isMainPod) setTypeface(typeface, Typeface.BOLD)
|
||||
else setTypeface(typeface, Typeface.NORMAL)
|
||||
}
|
||||
|
||||
lastSeen.text = device.lastSeenFormatted(item.now)
|
||||
|
||||
@@ -33,6 +38,7 @@ class UnknownPodDeviceCardVH(parent: ViewGroup) :
|
||||
data class Item(
|
||||
override val now: Instant,
|
||||
override val device: PodDevice,
|
||||
override val showDebug: Boolean = false
|
||||
override val showDebug: Boolean = false,
|
||||
override val isMainPod: Boolean = false,
|
||||
) : PodDeviceVH.Item
|
||||
}
|
||||
Reference in New Issue
Block a user