diff --git a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerAdapter.kt b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerAdapter.kt index a29959f4..ddca15f7 100644 --- a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerAdapter.kt +++ b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerAdapter.kt @@ -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 diff --git a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragment.kt b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragment.kt index 4a815d5b..2d4eb8d5 100644 --- a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragment.kt +++ b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragment.kt @@ -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 ) { diff --git a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragmentVM.kt b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragmentVM.kt index f4402404..2ff4a035 100644 --- a/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragmentVM.kt +++ b/app/src/main/java/eu/darken/capod/profiles/ui/DeviceManagerFragmentVM.kt @@ -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" } } diff --git a/app/src/main/java/eu/darken/capod/profiles/ui/PriorityHintVH.kt b/app/src/main/java/eu/darken/capod/profiles/ui/PriorityHintVH.kt new file mode 100644 index 00000000..22d9341e --- /dev/null +++ b/app/src/main/java/eu/darken/capod/profiles/ui/PriorityHintVH.kt @@ -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( + R.layout.device_manager_priority_hint_item, + parent + ) { + + override val viewBinding = lazy { DeviceManagerPriorityHintItemBinding.bind(itemView) } + + override val onBindData: DeviceManagerPriorityHintItemBinding.( + item: Item, + payloads: List + ) -> 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() + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/device_manager_fragment.xml b/app/src/main/res/layout/device_manager_fragment.xml index 0074a489..656d0b51 100644 --- a/app/src/main/res/layout/device_manager_fragment.xml +++ b/app/src/main/res/layout/device_manager_fragment.xml @@ -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" /> diff --git a/app/src/main/res/layout/device_manager_priority_hint_item.xml b/app/src/main/res/layout/device_manager_priority_hint_item.xml new file mode 100644 index 00000000..a40c4976 --- /dev/null +++ b/app/src/main/res/layout/device_manager_priority_hint_item.xml @@ -0,0 +1,27 @@ + + + + + + + + \ 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 a312ff15..c946f0ea 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -242,6 +242,7 @@ 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. Invalid key format Expected format: %1$s + Profile order determines priority. Drag profiles to reorder them - profiles higher in the list take precedence when multiple devices match. Unsaved Changes