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
This commit is contained in:
fgerber 2023-07-30 15:19:02 +02:00
parent c0cc1e5649
commit 44b0cccbd9
5 changed files with 87 additions and 22 deletions

View File

@ -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,9 +81,12 @@ class FoldingListAdapter(
fun bind(el: Pair<GeoLoc, Boolean>, 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
else if (el.first.children.any { visited.visited(it) }) MaterialCheckBox.STATE_INDETERMINATE
@ -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() }
}

View File

@ -0,0 +1,11 @@
<vector
android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
</vector>

View File

@ -5,6 +5,47 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
app:css="" >
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textStyle="bold"
android:textSize="18sp"
android:text="@string/app_name" />
<ImageView
android:id="@+id/edit"
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription="Edit"
android:scaleX="0.35"
android:scaleY="0.35"
android:visibility="visible"
app:layout_constraintEnd_toStartOf="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/design_default_color_primary"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/edit" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.caverock.androidsvg.SVGImageView
android:id="@+id/map"
android:layout_width="match_parent"
@ -15,7 +56,7 @@
<androidx.core.widget.NestedScrollView
android:id="@+id/sv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView

View File

@ -14,14 +14,34 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:contentDescription=">"
android:scaleX="0.5"
android:scaleY="0.5"
android:scaleX="0.35"
android:scaleY="0.35"
android:visibility="visible"
app:layout_constraintEnd_toStartOf="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/design_default_color_primary"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
tools:ignore="HardcodedText" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="start|center_vertical"
android:textColor="@color/design_default_color_on_primary"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
android:paddingStart="10dp"
app:layout_constraintBottom_toBottomOf="@id/checkBox"
app:layout_constraintEnd_toStartOf="@+id/checkBox"
app:layout_constraintStart_toEndOf="@+id/expand"
app:layout_constraintTop_toTopOf="@+id/expand"
app:layout_constraintVertical_bias="1.0" />
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
@ -34,23 +54,11 @@
app:layout_constraintTop_toTopOf="@+id/textView"
app:layout_constraintVertical_bias="0.5" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="start|center_vertical"
android:textColor="@color/design_default_color_on_primary"
app:layout_constraintBottom_toBottomOf="@id/checkBox"
app:layout_constraintEnd_toStartOf="@+id/checkBox"
app:layout_constraintStart_toEndOf="@+id/expand"
app:layout_constraintTop_toTopOf="@+id/expand"
app:layout_constraintVertical_bias="1.0" />
<LinearLayout
android:id="@+id/sub_item"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="32dp"
android:layout_marginStart="0dp"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Beendroid</string>
<string name="app_name">BeenDroid</string>
<string name="action_settings">Settings</string>
<string name="welcome">Welcome!</string>