[android] Improved touch target size (#6776)

* [android] Solving the touch target size issues for different UI elements

Signed-off-by: Bibek Bhujel <biekbhujel077@gmail.com>

* [android] Ensure proper toggle of 'more' button visibility based on the expansion state of the description text

Signed-off-by: Bibek Bhujel <biekbhujel077@gmail.com>

* Undone the changes on the onmap downloader component button

Signed-off-by: Bibek Bhujel <94971168+SigmaZardan@users.noreply.github.com>

* Update onmap_downloader.xml

Signed-off-by: Bibek Bhujel <94971168+SigmaZardan@users.noreply.github.com>

---------

Signed-off-by: Bibek Bhujel <biekbhujel077@gmail.com>
Signed-off-by: Bibek Bhujel <94971168+SigmaZardan@users.noreply.github.com>
Co-authored-by: Bibek Bhujel <biekbhujel077@gmail.com>
This commit is contained in:
Bibek Bhujel 2023-12-26 23:22:02 +05:45 committed by GitHub
parent 55aab6cc11
commit 1b9c33f4cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 49 additions and 25 deletions

View file

@ -428,10 +428,14 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
View desc = inflater.inflate(R.layout.item_category_description, parent, false);
TextView moreBtn = desc.findViewById(R.id.more_btn);
TextView text = desc.findViewById(R.id.text);
TextView title = desc.findViewById(R.id.title);
TextView author = desc.findViewById(R.id.author);
setMoreButtonVisibility(text, moreBtn);
holder = new Holders.DescriptionViewHolder(desc, mSectionsDataSource.getCategory());
text.setOnClickListener(v -> onMoreButtonClicked(text));
moreBtn.setOnClickListener(v -> onMoreButtonClicked(text));
text.setOnClickListener(v -> onMoreButtonClicked(text, moreBtn));
moreBtn.setOnClickListener(v -> onMoreButtonClicked(text, moreBtn));
title.setOnClickListener(v -> onMoreButtonClicked(text, moreBtn));
author.setOnClickListener(v -> onMoreButtonClicked(text, moreBtn));
break;
}
@ -532,11 +536,17 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
});
}
private void onMoreButtonClicked(TextView text)
private void onMoreButtonClicked(TextView text, TextView moreBtn)
{
if (text.getMaxLines() == MAX_VISIBLE_LINES)
{
text.setMaxLines(Integer.MAX_VALUE);
moreBtn.setVisibility(View.GONE);
}
else
{
text.setMaxLines(MAX_VISIBLE_LINES);
moreBtn.setVisibility(View.VISIBLE);
}
}
}

View file

@ -24,6 +24,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textCapSentences"
android:padding="@dimen/margin_half_double_plus"
android:maxLength="100"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>

View file

@ -30,7 +30,7 @@
android:id="@+id/sort_by_default"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half_plus"
android:padding="@dimen/margin_half_double_plus"
android:checked="true"
android:text="@string/by_default"/>
@ -39,7 +39,7 @@
android:id="@+id/sort_by_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half_plus"
android:padding="@dimen/margin_half_double_plus"
android:checked="false"
android:text="@string/by_type"/>
@ -48,7 +48,7 @@
android:id="@+id/sort_by_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half_plus"
android:padding="@dimen/margin_half_double_plus"
android:checked="false"
android:text="@string/by_distance"/>
@ -57,7 +57,7 @@
android:id="@+id/sort_by_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half_plus"
android:padding="@dimen/margin_half_double_plus"
android:checked="false"
android:text="@string/by_date"/>
</RadioGroup>

View file

@ -26,6 +26,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/name"
android:padding="@dimen/margin_half_double_plus"
android:inputType="textCapSentences"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
@ -55,6 +56,7 @@
android:clickable="true"
android:paddingTop="@dimen/margin_quarter_plus"
android:paddingBottom="@dimen/margin_half_plus"
android:padding="@dimen/margin_half_double_plus"
android:textAppearance="@style/MwmTextAppearance.Body1"
app:drawableEndCompat="@drawable/ic_arrow_down" />
<View
@ -87,6 +89,7 @@
style="@style/MwmWidget.PlacePage.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half_double_plus"
android:hint="@string/edit_description_hint"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>

View file

@ -35,7 +35,8 @@
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/avoid_tolls_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:padding="@dimen/margin_half_double_plus"/>
</LinearLayout>
<include layout="@layout/list_divider"/>
<LinearLayout
@ -56,7 +57,8 @@
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/avoid_dirty_roads_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:padding="@dimen/margin_half_double_plus"/>
</LinearLayout>
<include layout="@layout/list_divider"/>
<LinearLayout
@ -77,7 +79,8 @@
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/avoid_ferries_btn"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:padding="@dimen/margin_half_double_plus"/>
</LinearLayout>
<include layout="@layout/list_divider"/>
<LinearLayout
@ -98,6 +101,7 @@
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/avoid_motorways_btn"
android:layout_width="wrap_content"
android:padding="@dimen/margin_half_double_plus"
android:layout_height="match_parent"/>
</LinearLayout>
</LinearLayout>

View file

@ -36,6 +36,7 @@
android:layout_height="wrap_content"
android:hint="@string/edit_description_hint"
android:includeFontPadding="false"
android:padding="@dimen/margin_base"
android:inputType="textMultiLine"
android:textColorHint="?android:textColorSecondary" />
</FrameLayout>

View file

@ -9,8 +9,8 @@
android:gravity="center_vertical">
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/margin_half_plus"
android:layout_marginEnd="0dp"

View file

@ -11,6 +11,7 @@
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="@dimen/margin_half"
android:layout_marginStart="@dimen/margin_half_plus"
android:layout_marginEnd="@dimen/margin_base_plus" />
<LinearLayout

View file

@ -41,6 +41,7 @@
android:background="@android:color/transparent"
android:clickable="true"
android:gravity="start|top"
android:padding="@dimen/margin_base"
android:text="@string/category_desc_more"
android:textColor="?attr/colorAccent"
android:layout_marginTop="2dp" />

View file

@ -10,8 +10,8 @@
<CheckBox
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="@dimen/margin_double"/>
<TextView

View file

@ -18,6 +18,7 @@
android:id="@+id/input"
style="@style/MwmWidget.Editor.FieldLayout.EditText"
tools:hint="Hint"
android:padding="@dimen/margin_half_double_plus"
tools:text="Input" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>

View file

@ -20,6 +20,7 @@
style="@style/MwmWidget.Editor.FieldLayout.EditText"
android:hint="@string/editor_edit_place_name_hint"
android:inputType="textCapSentences"
android:padding="@dimen/margin_base"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
@ -27,7 +28,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless"
android:padding="@dimen/margin_half"
android:padding="@dimen/margin_half_plus"
android:src="@drawable/ic_close"
app:tint="@color/base_red" />
</LinearLayout>

View file

@ -12,8 +12,8 @@
<RadioButton
android:id="@+id/selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/margin_base"/>

View file

@ -171,8 +171,8 @@
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/sw__allday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="48dp"
android:layout_height="48dp"/>
</LinearLayout>

View file

@ -11,6 +11,7 @@
style="@style/MwmWidget.Button.Primary"
android:layout_gravity="center"
android:enabled="false"
android:padding="@dimen/margin_base"
android:text="@string/editor_time_add"/>
</FrameLayout>

View file

@ -49,7 +49,7 @@
<FrameLayout
android:id="@+id/downloader_controls_frame"
android:layout_width="180dp"
android:layout_height="@dimen/downloader_status_size"
android:layout_height="48dp"
android:clipChildren="false">
<Button
android:id="@+id/downloader_button"

View file

@ -97,8 +97,8 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/share_button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="@dimen/place_page_top_button"
android:layout_height="@dimen/place_page_top_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/share"
android:insetLeft="0dp"
@ -115,8 +115,8 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/close_button"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="@dimen/place_page_top_button"
android:layout_height="@dimen/place_page_top_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="@dimen/margin_quarter"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/close"

View file

@ -28,7 +28,7 @@
android:hint="@string/search"
android:imeOptions="actionSearch|flagNoExtractUi"
android:inputType="text"
android:padding="@dimen/margin_quarter"
android:padding="@dimen/margin_half_plus"
android:singleLine="true"
android:textCursorDrawable="@drawable/cursor_drawable"
tools:ignore="UnusedAttribute"/>