Add priority hint to device profiles list

- Shows hint when 2+ profiles exist explaining order determines priority
- Appears as flat list item at bottom, less intrusive than card
- Prevents dragging hint item, keeps it at bottom
- Uses book icon for informational guidance
This commit is contained in:
darken
2025-09-29 13:37:01 +02:00
parent 132b3996fc
commit fbbbf751c5
7 changed files with 68 additions and 4 deletions
@@ -23,6 +23,7 @@ class DeviceManagerAdapter @Inject constructor() :
modules.add(DataBinderMod(data))
modules.add(TypedVHCreatorMod({ data[it] is DeviceProfileVH.Item }) { DeviceProfileVH(it) })
modules.add(TypedVHCreatorMod({ data[it] is NoProfilesCardVH.Item }) { NoProfilesCardVH(it) })
modules.add(TypedVHCreatorMod({ data[it] is PriorityHintVH.Item }) { PriorityHintVH(it) })
}
override fun getItemCount(): Int = data.size
@@ -68,7 +68,7 @@ class DeviceManagerFragment : Fragment3(R.layout.device_manager_fragment) {
val fromPosition = viewHolder.adapterPosition
val toPosition = target.adapterPosition
// Only allow reordering of profile items, not empty state cards
// Only allow reordering of profile items, not empty state cards or hints
if (adapter.data[fromPosition] is DeviceProfileVH.Item &&
adapter.data[toPosition] is DeviceProfileVH.Item
) {
@@ -30,12 +30,19 @@ class DeviceManagerFragmentVM @Inject constructor(
)
)
} else {
profiles.map { profile ->
val profileItems = profiles.map { profile ->
DeviceProfileVH.Item(
profile = profile,
onItemClick = { onEditProfile(it) }
)
}
// Add priority hint at the end if there are 2+ profiles
if (profiles.size >= 2) {
profileItems + PriorityHintVH.Item()
} else {
profileItems
}
}
}
.onEach { log(TAG) { "Profiles updated: ${it.size} items" } }
@@ -0,0 +1,28 @@
package eu.darken.capod.profiles.ui
import android.view.ViewGroup
import eu.darken.capod.R
import eu.darken.capod.common.lists.BindableVH
import eu.darken.capod.databinding.DeviceManagerPriorityHintItemBinding
class PriorityHintVH(parent: ViewGroup) :
DeviceManagerAdapter.BaseVH<PriorityHintVH.Item, DeviceManagerPriorityHintItemBinding>(
R.layout.device_manager_priority_hint_item,
parent
) {
override val viewBinding = lazy { DeviceManagerPriorityHintItemBinding.bind(itemView) }
override val onBindData: DeviceManagerPriorityHintItemBinding.(
item: Item,
payloads: List<Any>
) -> Unit = { _, _ ->
// Nothing to bind - the layout already shows the static hint text
}
data class Item(
val dummy: Unit = Unit
) : DeviceManagerAdapter.Item {
override val stableId: Long = this.javaClass.hashCode().toLong()
}
}
@@ -21,8 +21,8 @@
android:id="@+id/list"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingBottom="80dp"
android:clipToPadding="false"
android:paddingBottom="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -35,7 +35,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="Add device"
android:contentDescription="@string/profiles_add_action"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_baseline_add_24" />
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="12dp"
android:contentDescription="@null"
android:src="@drawable/ic_baseline_book_24"
app:tint="?attr/colorOnSurfaceVariant" />
<com.google.android.material.textview.MaterialTextView
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/profiles_priority_hint"
android:textColor="?attr/colorOnSurfaceVariant" />
</LinearLayout>
+1
View File
@@ -242,6 +242,7 @@
<string name="profiles_maindevice_encryptionkey_explanation">AirPods send a status message, part of which is encrypted. The encryption key allows CAPod to decrypt the full message. You need one-time access to a MacBook.</string>
<string name="profiles_key_invalid_format">Invalid key format</string>
<string name="profiles_key_expected_format">Expected format: %1$s</string>
<string name="profiles_priority_hint">Profile order determines priority. Drag profiles to reorder them - profiles higher in the list take precedence when multiple devices match.</string>
<!-- Unsaved changes dialog -->
<string name="general_unsaved_changes_title">Unsaved Changes</string>