Zen: Fix recent regression in mode selection after reboot.
Bug:17509473
Change-Id: I761cd90384c490c7ab07fb633133535846701ce6
diff --git a/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java b/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java
index 6d30bce..66e1e15 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java
@@ -32,6 +32,7 @@
public class SegmentedButtons extends LinearLayout {
private static final Typeface MEDIUM = Typeface.create("sans-serif-medium", Typeface.NORMAL);
private static final Typeface BOLD = Typeface.create("sans-serif", Typeface.BOLD);
+ private static final int LABEL_RES_KEY = R.id.label;
private final Context mContext;
private final LayoutInflater mInflater;
@@ -69,6 +70,7 @@
public void addButton(int labelResId, Object value) {
final Button b = (Button) mInflater.inflate(R.layout.segmented_button, this, false);
+ b.setTag(LABEL_RES_KEY, labelResId);
b.setText(labelResId);
final LayoutParams lp = (LayoutParams) b.getLayoutParams();
if (getChildCount() == 0) {
@@ -80,6 +82,14 @@
b.setOnClickListener(mClick);
}
+ public void updateLocale() {
+ for (int i = 0; i < getChildCount(); i++) {
+ final Button b = (Button) getChildAt(i);
+ final int labelResId = (Integer) b.getTag(LABEL_RES_KEY);
+ b.setText(labelResId);
+ }
+ }
+
private void fireOnSelected() {
if (mCallback != null) {
mCallback.onSelected(mSelectedValue);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index f829994..2b541d3 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -120,7 +120,10 @@
super.onFinishInflate();
mZenButtons = (SegmentedButtons) findViewById(R.id.zen_buttons);
- addZenButtons();
+ mZenButtons.addButton(R.string.interruption_level_none, Global.ZEN_MODE_NO_INTERRUPTIONS);
+ mZenButtons.addButton(R.string.interruption_level_priority,
+ Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ mZenButtons.addButton(R.string.interruption_level_all, Global.ZEN_MODE_OFF);
mZenButtons.setCallback(mZenButtonsCallback);
mZenSubhead = findViewById(R.id.zen_subhead);
@@ -170,13 +173,6 @@
setExpanded(false);
}
- private void addZenButtons() {
- mZenButtons.addButton(R.string.interruption_level_none, Global.ZEN_MODE_NO_INTERRUPTIONS);
- mZenButtons.addButton(R.string.interruption_level_priority,
- Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
- mZenButtons.addButton(R.string.interruption_level_all, Global.ZEN_MODE_OFF);
- }
-
public void setHidden(boolean hidden) {
if (mHidden == hidden) return;
mHidden = hidden;
@@ -238,8 +234,7 @@
}
public void updateLocale() {
- mZenButtons.removeAllViews();
- addZenButtons();
+ mZenButtons.updateLocale();
}
private void setExitCondition(Condition exitCondition) {