dashboard quick actions are now drawer only
Auto Tag on Version Change / check-version (push) Successful in 7s
Auto Tag on Version Change / check-version (push) Successful in 7s
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#CC0000"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Thijooree Debug</string>
|
||||||
|
</resources>
|
||||||
@@ -126,6 +126,12 @@ class DashboardFragment : Fragment() {
|
|||||||
|
|
||||||
private fun refreshQuickActions() {
|
private fun refreshQuickActions() {
|
||||||
val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
val prefs = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE)
|
||||||
|
val isBottom = prefs.getBoolean("bottom_nav", false)
|
||||||
|
if (isBottom) {
|
||||||
|
binding.buttonBar.visibility = View.GONE
|
||||||
|
return
|
||||||
|
}
|
||||||
|
binding.buttonBar.visibility = View.VISIBLE
|
||||||
val ids = NavCustomization.getQuickActions(prefs)
|
val ids = NavCustomization.getQuickActions(prefs)
|
||||||
listOf(binding.btnQuickAction1, binding.btnQuickAction2).forEachIndexed { i, btn ->
|
listOf(binding.btnQuickAction1, binding.btnQuickAction2).forEachIndexed { i, btn ->
|
||||||
val def = NavCustomization.ALL_SWAPPABLE.find { it.id == ids[i] }
|
val def = NavCustomization.ALL_SWAPPABLE.find { it.id == ids[i] }
|
||||||
|
|||||||
@@ -54,19 +54,29 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
// Quick actions
|
// Quick actions
|
||||||
quickActions.clear()
|
quickActions.clear()
|
||||||
quickActions.addAll(NavCustomization.getQuickActions(prefs))
|
quickActions.addAll(NavCustomization.getQuickActions(prefs))
|
||||||
quickActionAdapter = NavItemAdapter(quickActions) {
|
quickActionAdapter = NavItemAdapter(
|
||||||
NavCustomization.saveQuickActions(prefs, quickActions)
|
items = quickActions,
|
||||||
|
onSave = { NavCustomization.saveQuickActions(prefs, quickActions) },
|
||||||
|
isEnabled = { !prefs.getBoolean("bottom_nav", false) }
|
||||||
|
)
|
||||||
|
setupNavItemRecyclerView(binding.rvQuickActions, quickActionAdapter, quickActions) {
|
||||||
|
!prefs.getBoolean("bottom_nav", false)
|
||||||
}
|
}
|
||||||
setupNavItemRecyclerView(binding.rvQuickActions, quickActionAdapter, quickActions)
|
|
||||||
|
|
||||||
// Bottom bar shortcuts
|
// Bottom bar shortcuts
|
||||||
slots.clear()
|
slots.clear()
|
||||||
slots.addAll(NavCustomization.getSlots(prefs))
|
slots.addAll(NavCustomization.getSlots(prefs))
|
||||||
slotAdapter = NavItemAdapter(slots) {
|
slotAdapter = NavItemAdapter(
|
||||||
NavCustomization.saveSlots(prefs, slots)
|
items = slots,
|
||||||
(activity as? HomeActivity)?.rebuildBottomNav(prefs)
|
onSave = {
|
||||||
|
NavCustomization.saveSlots(prefs, slots)
|
||||||
|
(activity as? HomeActivity)?.rebuildBottomNav(prefs)
|
||||||
|
},
|
||||||
|
isEnabled = { prefs.getBoolean("bottom_nav", false) }
|
||||||
|
)
|
||||||
|
setupNavItemRecyclerView(binding.rvNavSlots, slotAdapter, slots) {
|
||||||
|
prefs.getBoolean("bottom_nav", false)
|
||||||
}
|
}
|
||||||
setupNavItemRecyclerView(binding.rvNavSlots, slotAdapter, slots)
|
|
||||||
// Show labels toggle
|
// Show labels toggle
|
||||||
val showLabels = prefs.getBoolean("bottom_nav_show_labels", true)
|
val showLabels = prefs.getBoolean("bottom_nav_show_labels", true)
|
||||||
binding.switchShowLabels.isChecked = showLabels
|
binding.switchShowLabels.isChecked = showLabels
|
||||||
@@ -109,13 +119,18 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
private fun setupNavItemRecyclerView(
|
private fun setupNavItemRecyclerView(
|
||||||
rv: RecyclerView,
|
rv: RecyclerView,
|
||||||
adapter: NavItemAdapter,
|
adapter: NavItemAdapter,
|
||||||
items: MutableList<Int>
|
items: MutableList<Int>,
|
||||||
|
isEnabled: () -> Boolean
|
||||||
) {
|
) {
|
||||||
rv.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
rv.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||||
rv.adapter = adapter
|
rv.adapter = adapter
|
||||||
ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(
|
ItemTouchHelper(object : ItemTouchHelper.SimpleCallback(
|
||||||
ItemTouchHelper.START or ItemTouchHelper.END, 0
|
ItemTouchHelper.START or ItemTouchHelper.END, 0
|
||||||
) {
|
) {
|
||||||
|
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
||||||
|
if (!isEnabled()) return 0
|
||||||
|
return super.getMovementFlags(recyclerView, viewHolder)
|
||||||
|
}
|
||||||
override fun onMove(
|
override fun onMove(
|
||||||
rv: RecyclerView,
|
rv: RecyclerView,
|
||||||
from: RecyclerView.ViewHolder,
|
from: RecyclerView.ViewHolder,
|
||||||
@@ -134,11 +149,17 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
|
|
||||||
private fun updateShortcutsVisibility() {
|
private fun updateShortcutsVisibility() {
|
||||||
val isBottom = prefs.getBoolean("bottom_nav", false)
|
val isBottom = prefs.getBoolean("bottom_nav", false)
|
||||||
|
binding.sectionQuickActions.alpha = if (isBottom) 0.38f else 1f
|
||||||
binding.sectionBottomBarShortcuts.alpha = if (isBottom) 1f else 0.38f
|
binding.sectionBottomBarShortcuts.alpha = if (isBottom) 1f else 0.38f
|
||||||
|
binding.switchShowLabels.isClickable = isBottom
|
||||||
|
quickActionAdapter.notifyDataSetChanged()
|
||||||
|
slotAdapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showItemPicker(items: MutableList<Int>, slotIndex: Int, adapter: NavItemAdapter) {
|
private fun showItemPicker(items: MutableList<Int>, slotIndex: Int, adapter: NavItemAdapter) {
|
||||||
if (items === slots && !prefs.getBoolean("bottom_nav", false)) return
|
val isBottom = prefs.getBoolean("bottom_nav", false)
|
||||||
|
if (items === slots && !isBottom) return
|
||||||
|
if (items === quickActions && isBottom) return
|
||||||
val ctx = requireContext()
|
val ctx = requireContext()
|
||||||
val otherIds = items.filterIndexed { i, _ -> i != slotIndex }.toSet()
|
val otherIds = items.filterIndexed { i, _ -> i != slotIndex }.toSet()
|
||||||
val available = NavCustomization.ALL_SWAPPABLE.filter { it.id !in otherIds }
|
val available = NavCustomization.ALL_SWAPPABLE.filter { it.id !in otherIds }
|
||||||
@@ -169,7 +190,8 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
|
|
||||||
private inner class NavItemAdapter(
|
private inner class NavItemAdapter(
|
||||||
val items: MutableList<Int>,
|
val items: MutableList<Int>,
|
||||||
val onSave: () -> Unit
|
val onSave: () -> Unit,
|
||||||
|
val isEnabled: () -> Boolean = { true }
|
||||||
) : RecyclerView.Adapter<NavItemAdapter.VH>() {
|
) : RecyclerView.Adapter<NavItemAdapter.VH>() {
|
||||||
|
|
||||||
inner class VH(view: View) : RecyclerView.ViewHolder(view) {
|
inner class VH(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
@@ -191,7 +213,12 @@ class SettingsAppearanceFragment : Fragment() {
|
|||||||
val def = NavCustomization.ALL_SWAPPABLE.find { it.id == items[position] } ?: return
|
val def = NavCustomization.ALL_SWAPPABLE.find { it.id == items[position] } ?: return
|
||||||
holder.ivNavIcon.setImageResource(def.iconRes)
|
holder.ivNavIcon.setImageResource(def.iconRes)
|
||||||
holder.tvNavLabel.setText(def.titleRes)
|
holder.tvNavLabel.setText(def.titleRes)
|
||||||
holder.itemView.setOnClickListener { showItemPicker(items, holder.adapterPosition, this) }
|
val enabled = isEnabled()
|
||||||
|
holder.itemView.setOnClickListener(
|
||||||
|
if (enabled) View.OnClickListener { showItemPicker(items, holder.adapterPosition, this) }
|
||||||
|
else null
|
||||||
|
)
|
||||||
|
holder.itemView.isClickable = enabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,22 +45,30 @@
|
|||||||
|
|
||||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||||
|
|
||||||
<!-- Quick actions (always active) -->
|
<!-- Quick actions — shown only when drawer nav is active -->
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/sectionQuickActions"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/dashboard_quick_actions"
|
|
||||||
android:textAppearance="?attr/textAppearanceTitleMedium"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="12dp" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rvQuickActions"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:nestedScrollingEnabled="false"
|
android:orientation="vertical"
|
||||||
android:overScrollMode="never"
|
android:layout_marginBottom="16dp">
|
||||||
android:layout_marginBottom="16dp" />
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dashboard_quick_actions"
|
||||||
|
android:textAppearance="?attr/textAppearanceTitleMedium"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvQuickActions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
android:overScrollMode="never" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Bottom bar shortcuts — shown only when bottom nav is active -->
|
<!-- Bottom bar shortcuts — shown only when bottom nav is active -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
Reference in New Issue
Block a user