From 44b0cccbd9c2d1a5de4f00408f721085cf7574da Mon Sep 17 00:00:00 2001 From: fgerber Date: Sun, 30 Jul 2023 15:19:02 +0200 Subject: [PATCH] Perform some layout changes The idea is to make it as practical as possible for the user: - I would use the long click for something else, maybe a small menu about the continent/country - The edit button at the top should enable/disable the checkboxes (but it should be aligned on the right) - Issue: When enabling a country, then the whole continent it belongs to, and then disabling the continent again, there is no undetermined state anymore, the box is unchecked --- .../beendroid/activity/FoldingListAdapter.kt | 13 ++++-- app/src/main/res/drawable/edit.xml | 11 +++++ app/src/main/res/layout/activity_main.xml | 45 ++++++++++++++++++- app/src/main/res/layout/item_list.xml | 38 +++++++++------- app/src/main/res/values/en.xml | 2 +- 5 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 app/src/main/res/drawable/edit.xml diff --git a/app/src/main/java/net/helcel/beendroid/activity/FoldingListAdapter.kt b/app/src/main/java/net/helcel/beendroid/activity/FoldingListAdapter.kt index c7cca73..42f4914 100644 --- a/app/src/main/java/net/helcel/beendroid/activity/FoldingListAdapter.kt +++ b/app/src/main/java/net/helcel/beendroid/activity/FoldingListAdapter.kt @@ -1,6 +1,7 @@ package net.helcel.beendroid.activity import android.content.Context +import android.graphics.Typeface import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -12,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.checkbox.MaterialCheckBox import net.helcel.beendroid.R import net.helcel.beendroid.countries.GeoLoc +import net.helcel.beendroid.countries.LocType import net.helcel.beendroid.countries.Visited import java.util.* @@ -79,11 +81,14 @@ class FoldingListAdapter( fun bind(el: Pair, parentLambda: () -> Unit) { expand.rotation = if(el.second) 90f else 0f subItemView.visibility = if (el.second) View.VISIBLE else View.GONE - expand.visibility = if(!el.first.isEnd) View.VISIBLE else View.GONE + expand.visibility = if(!el.first.isEnd) View.VISIBLE else View.INVISIBLE textView.text = el.first.fullName + if (el.first.type == LocType.GROUP) { + textView.setTypeface(null, Typeface.BOLD) + } checkBox.checkedState = - if(visited.visited(el.first)) MaterialCheckBox.STATE_CHECKED + if (visited.visited(el.first)) MaterialCheckBox.STATE_CHECKED else if (el.first.children.any { visited.visited(it) }) MaterialCheckBox.STATE_INDETERMINATE else MaterialCheckBox.STATE_UNCHECKED @@ -93,12 +98,12 @@ class FoldingListAdapter( fun addListeners(expandLambda: ()->Boolean, visitedLambda: (Boolean)->Unit) { - textView.setOnClickListener { checkBox.toggle() } + textView.setOnClickListener { expandLambda() } checkBox.addOnCheckedStateChangedListener { _, e -> visitedLambda(e == MaterialCheckBox.STATE_CHECKED) } - textView.setOnLongClickListener{ expandLambda() } + //textView.setOnLongClickListener{ checkBox.toggle(); true } expand.setOnClickListener { expandLambda() } } diff --git a/app/src/main/res/drawable/edit.xml b/app/src/main/res/drawable/edit.xml new file mode 100644 index 0000000..a4df5f3 --- /dev/null +++ b/app/src/main/res/drawable/edit.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ea24711..30c760d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,7 +5,48 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> - + + + + + + + + + + + + + + + - - - Beendroid + BeenDroid Settings Welcome!