Bug 1403347: Set dialog titles in createDialogItems. r=liuche

We manipulate the data before the dialog is shown, rather than manipulating the
Views after the dialog is shown: this is more stable.

One question is what is the value of isHidden, which we branch on, when we're
manipulating the data. isHidden is set:
- When the preference is constructed (previous commit)
- When the preference is set as the default (e.g. the default panel was hidden)
- When "Hide" or "Show" is clicked in the preference

Thus the preference (and hidden state) outlives the dialog and each time we
reread the value of isHidden to set the dialog items.

This would fix the bug but the dialog values are actually cached so we'll
need to fix/remove that cache: coming up in the next changeset.

MozReview-Commit-ID: 86v1RDNFZHZ

--HG--
extra : rebase_source : 3cc0d80e9fa5d569320b8ebbf583204dbb7dd467
This commit is contained in:
Michael Comella 2017-09-26 16:22:21 -07:00
parent e242a49a9c
commit 9cc3aa1fa0

View File

@ -40,9 +40,6 @@ public class PanelsPreference extends CustomListPreference {
private static final int INDEX_MOVE_UP_BUTTON = 0;
private static final int INDEX_MOVE_DOWN_BUTTON = 1;
private String LABEL_HIDE;
private String LABEL_SHOW;
private View preferenceView;
protected boolean mIsHidden;
private final boolean mIsRemovable;
@ -106,10 +103,9 @@ public class PanelsPreference extends CustomListPreference {
}
// Built-in panels can't be removed, so use show/hide options.
LABEL_HIDE = res.getString(R.string.pref_panels_hide);
LABEL_SHOW = res.getString(R.string.pref_panels_show);
final String labelShowHide = res.getString(mIsHidden ? R.string.pref_panels_show : R.string.pref_panels_hide);
return new String[] { LABEL_SET_AS_DEFAULT, LABEL_HIDE, labelReorder };
return new String[] { LABEL_SET_AS_DEFAULT, labelShowHide, labelReorder };
}
@Override
@ -155,18 +151,6 @@ public class PanelsPreference extends CustomListPreference {
}
}
@Override
protected void configureShownDialog() {
super.configureShownDialog();
// Handle Show/Hide buttons.
if (!mIsRemovable) {
final TextView hideButton = (TextView) mDialog.getListView().getChildAt(INDEX_DISPLAY_BUTTON);
hideButton.setText(mIsHidden ? LABEL_SHOW : LABEL_HIDE);
}
}
private Dialog makeReorderDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());