[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
This commit is contained in:
Zoey Chen
2023-04-12 13:19:31 +00:00
parent 11648c709e
commit e9f6efa2b6
4 changed files with 31 additions and 31 deletions

View File

@@ -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;
}

View File

@@ -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