diff options
author | John Spurlock <jspurlock@google.com> | 2014-09-16 21:54:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-16 21:54:02 +0000 |
commit | 386831dc3cab38552501724c7c88ae1f3ab1c80a (patch) | |
tree | c7200211505469b504b243ed60a83c9f9aa387e0 /packages | |
parent | 6663d4f9732634bea584bcea3896433330f8bfbb (diff) | |
parent | 4291fb79c70ba77af4357d53dac2e5626eabba45 (diff) | |
download | frameworks_base-386831dc3cab38552501724c7c88ae1f3ab1c80a.zip frameworks_base-386831dc3cab38552501724c7c88ae1f3ab1c80a.tar.gz frameworks_base-386831dc3cab38552501724c7c88ae1f3ab1c80a.tar.bz2 |
Merge "Zen: Fix recent regression in mode selection after reboot." into lmp-dev
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/SegmentedButtons.java | 10 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java | 15 |
2 files changed, 15 insertions, 10 deletions
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 @@ import java.util.Objects; 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 class SegmentedButtons extends LinearLayout { 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 @@ public class SegmentedButtons extends LinearLayout { 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 @@ public class ZenModePanel extends LinearLayout { 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 @@ public class ZenModePanel extends LinearLayout { 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 class ZenModePanel extends LinearLayout { } public void updateLocale() { - mZenButtons.removeAllViews(); - addZenButtons(); + mZenButtons.updateLocale(); } private void setExitCondition(Condition exitCondition) { |