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:
		| @@ -1,6 +1,7 @@ | |||||||
| package net.helcel.beendroid.activity | package net.helcel.beendroid.activity | ||||||
|  |  | ||||||
| import android.content.Context | import android.content.Context | ||||||
|  | import android.graphics.Typeface | ||||||
| import android.view.LayoutInflater | import android.view.LayoutInflater | ||||||
| import android.view.View | import android.view.View | ||||||
| import android.view.ViewGroup | import android.view.ViewGroup | ||||||
| @@ -12,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView | |||||||
| import com.google.android.material.checkbox.MaterialCheckBox | import com.google.android.material.checkbox.MaterialCheckBox | ||||||
| import net.helcel.beendroid.R | import net.helcel.beendroid.R | ||||||
| import net.helcel.beendroid.countries.GeoLoc | import net.helcel.beendroid.countries.GeoLoc | ||||||
|  | import net.helcel.beendroid.countries.LocType | ||||||
| import net.helcel.beendroid.countries.Visited | import net.helcel.beendroid.countries.Visited | ||||||
| import java.util.* | import java.util.* | ||||||
|  |  | ||||||
| @@ -79,11 +81,14 @@ class FoldingListAdapter( | |||||||
|         fun bind(el: Pair<GeoLoc, Boolean>, parentLambda: () -> Unit) { |         fun bind(el: Pair<GeoLoc, Boolean>, parentLambda: () -> Unit) { | ||||||
|             expand.rotation = if(el.second) 90f else 0f |             expand.rotation = if(el.second) 90f else 0f | ||||||
|             subItemView.visibility = if (el.second) View.VISIBLE else View.GONE |             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 |             textView.text = el.first.fullName | ||||||
|  |             if (el.first.type == LocType.GROUP) { | ||||||
|  |                 textView.setTypeface(null, Typeface.BOLD) | ||||||
|  |             } | ||||||
|             checkBox.checkedState = |             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 if (el.first.children.any { visited.visited(it) }) MaterialCheckBox.STATE_INDETERMINATE | ||||||
|                 else MaterialCheckBox.STATE_UNCHECKED |                 else MaterialCheckBox.STATE_UNCHECKED | ||||||
|  |  | ||||||
| @@ -93,12 +98,12 @@ class FoldingListAdapter( | |||||||
|  |  | ||||||
|         fun addListeners(expandLambda: ()->Boolean, visitedLambda: (Boolean)->Unit) { |         fun addListeners(expandLambda: ()->Boolean, visitedLambda: (Boolean)->Unit) { | ||||||
|  |  | ||||||
|             textView.setOnClickListener { checkBox.toggle() } |             textView.setOnClickListener { expandLambda() } | ||||||
|             checkBox.addOnCheckedStateChangedListener { _, e -> |             checkBox.addOnCheckedStateChangedListener { _, e -> | ||||||
|                 visitedLambda(e == MaterialCheckBox.STATE_CHECKED) |                 visitedLambda(e == MaterialCheckBox.STATE_CHECKED) | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             textView.setOnLongClickListener{ expandLambda() } |             //textView.setOnLongClickListener{ checkBox.toggle(); true } | ||||||
|             expand.setOnClickListener { expandLambda() } |             expand.setOnClickListener { expandLambda() } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								app/src/main/res/drawable/edit.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/src/main/res/drawable/edit.xml
									
									
									
									
									
										Normal 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> | ||||||
| @@ -5,7 +5,48 @@ | |||||||
|     android:layout_width="fill_parent" |     android:layout_width="fill_parent" | ||||||
|     android:layout_height="fill_parent"> |     android:layout_height="fill_parent"> | ||||||
|  |  | ||||||
|     <com.caverock.androidsvg.SVGImageView |     <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:id="@+id/map" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
| @@ -15,7 +56,7 @@ | |||||||
|     <androidx.core.widget.NestedScrollView |     <androidx.core.widget.NestedScrollView | ||||||
|         android:id="@+id/sv" |         android:id="@+id/sv" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="match_parent" | ||||||
|         android:layout_weight="1"> |         android:layout_weight="1"> | ||||||
|  |  | ||||||
|         <androidx.recyclerview.widget.RecyclerView |         <androidx.recyclerview.widget.RecyclerView | ||||||
|   | |||||||
| @@ -14,14 +14,34 @@ | |||||||
|             android:layout_width="48dp" |             android:layout_width="48dp" | ||||||
|             android:layout_height="48dp" |             android:layout_height="48dp" | ||||||
|             android:contentDescription=">" |             android:contentDescription=">" | ||||||
|             android:scaleX="0.5" |             android:scaleX="0.35" | ||||||
|             android:scaleY="0.5" |             android:scaleY="0.35" | ||||||
|             android:visibility="visible" |             android:visibility="visible" | ||||||
|             app:layout_constraintEnd_toStartOf="@+id/textView" |             app:layout_constraintEnd_toStartOf="@+id/textView" | ||||||
|             app:layout_constraintStart_toStartOf="parent" |             app:layout_constraintStart_toStartOf="parent" | ||||||
|             app:layout_constraintTop_toTopOf="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" /> |             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 |         <com.google.android.material.checkbox.MaterialCheckBox | ||||||
|             android:id="@+id/checkBox" |             android:id="@+id/checkBox" | ||||||
|             android:layout_width="wrap_content" |             android:layout_width="wrap_content" | ||||||
| @@ -34,23 +54,11 @@ | |||||||
|             app:layout_constraintTop_toTopOf="@+id/textView" |             app:layout_constraintTop_toTopOf="@+id/textView" | ||||||
|             app:layout_constraintVertical_bias="0.5" /> |             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 |         <LinearLayout | ||||||
|             android:id="@+id/sub_item" |             android:id="@+id/sub_item" | ||||||
|             android:layout_width="0dp" |             android:layout_width="0dp" | ||||||
|             android:layout_height="match_parent" |             android:layout_height="match_parent" | ||||||
|             android:layout_marginStart="32dp" |             android:layout_marginStart="0dp" | ||||||
|             android:orientation="vertical" |             android:orientation="vertical" | ||||||
|             android:visibility="gone" |             android:visibility="gone" | ||||||
|             app:layout_constraintBottom_toBottomOf="parent" |             app:layout_constraintBottom_toBottomOf="parent" | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <resources> | <resources> | ||||||
|     <string name="app_name">Beendroid</string> |     <string name="app_name">BeenDroid</string> | ||||||
|     <string name="action_settings">Settings</string> |     <string name="action_settings">Settings</string> | ||||||
|  |  | ||||||
|     <string name="welcome">Welcome!</string> |     <string name="welcome">Welcome!</string> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user