From e9f6efa2b6630d07534551ae8cf38d8d9cec0578 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Wed, 12 Apr 2023 13:19:31 +0000 Subject: [PATCH] [Settings] Fix the layout index The index of language label's layout is 0 and index of num layout is 1, so the select tp speak will read the language label first. The root cause of the incorrect index is, the language label's layout starts with the parent layout instead of the num layout in the hierarchy view. Adjust the language label's layout and add these views one by one in the parent view. Also fix the layout's jumping when user switches the page to "Remove language" Bug: 277173513 Test: local test Change-Id: I0d5879a07183713fa50b38f6321a15dd32582518 --- res/layout/locale_drag_cell.xml | 43 +++++++++++-------- res/values/styles.xml | 3 +- .../settings/localepicker/LocaleDragCell.java | 14 +++--- .../LocaleLinearLayoutManager.java | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/res/layout/locale_drag_cell.xml b/res/layout/locale_drag_cell.xml index f5a280b82b9..98fc8dfeb9a 100644 --- a/res/layout/locale_drag_cell.xml +++ b/res/layout/locale_drag_cell.xml @@ -26,29 +26,35 @@ android:layoutDirection="locale" android:textDirection="locale"> - - - + android:paddingStart="?android:attr/listPreferredItemPaddingStart"> + + + + + android:layout_toStartOf="@+id/dragHandle" + android:layout_toEndOf="@+id/numberLayout" + android:paddingStart="32dp"> + style="@style/LanguageCheckboxAndLabel"/> diff --git a/src/com/android/settings/localepicker/LocaleDragCell.java b/src/com/android/settings/localepicker/LocaleDragCell.java index 2f4cfefefb1..d0b7cfb152e 100644 --- a/src/com/android/settings/localepicker/LocaleDragCell.java +++ b/src/com/android/settings/localepicker/LocaleDragCell.java @@ -63,13 +63,7 @@ class LocaleDragCell extends RelativeLayout { public void setShowCheckbox(boolean showCheckbox) { // "Opposite" visibility for label / checkbox - if (showCheckbox) { - mCheckbox.setVisibility(VISIBLE); - mLabel.setVisibility(INVISIBLE); - } else { - mCheckbox.setVisibility(INVISIBLE); - mLabel.setVisibility(VISIBLE); - } + mCheckbox.setVisibility(showCheckbox ? VISIBLE : GONE); invalidate(); requestLayout(); } @@ -91,9 +85,7 @@ class LocaleDragCell extends RelativeLayout { public void setLabelAndDescription(String labelText, String description) { mLabel.setText(labelText); - mCheckbox.setText(labelText); mLabel.setContentDescription(description); - mCheckbox.setContentDescription(description); invalidate(); } @@ -114,6 +106,10 @@ class LocaleDragCell extends RelativeLayout { return mDragHandle; } + public TextView getLabelView() { + return mLabel; + } + public CheckBox getCheckbox() { return mCheckbox; } diff --git a/src/com/android/settings/localepicker/LocaleLinearLayoutManager.java b/src/com/android/settings/localepicker/LocaleLinearLayoutManager.java index 5fb9440e014..8795bf97e70 100644 --- a/src/com/android/settings/localepicker/LocaleLinearLayoutManager.java +++ b/src/com/android/settings/localepicker/LocaleLinearLayoutManager.java @@ -86,7 +86,7 @@ public class LocaleLinearLayoutManager extends LinearLayoutManager { // any language can handle it. And we want the position to be part of it. // So we use something like "2, French (France)" final String description = - (position + 1) + ", " + dragCell.getCheckbox().getContentDescription(); + (position + 1) + ", " + dragCell.getLabelView().getContentDescription(); info.setContentDescription(description); if (mAdapter.isRemoveMode()) { // We don't move things around in remove mode