From 94fa1df7135eea68d2aae41634567c57833d6a47 Mon Sep 17 00:00:00 2001 From: Muyuan Li Date: Wed, 23 Mar 2016 12:09:38 -0700 Subject: [PATCH] sysui: refactor for extensibility Split button creation code from init in ZenModePanel Bug: 27101250 Change-Id: Id4bbd505b4e311fdcd2d330f20b73d2338fa9686 (cherry picked from commit 80870e93a49c08f4f4e57d2c0902d2308faa3f7a) --- .../com/android/systemui/volume/ZenModePanel.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index 6976c0b1d3124..467bff4666764 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -86,7 +86,7 @@ public class ZenModePanel extends LinearLayout { = new Intent(Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS); private final Context mContext; - private final LayoutInflater mInflater; + protected final LayoutInflater mInflater; private final H mHandler = new H(); private final ZenPrefs mPrefs; private final TransitionHelper mTransitionHelper = new TransitionHelper(); @@ -100,7 +100,7 @@ public class ZenModePanel extends LinearLayout { private TextView mZenIntroductionMessage; private View mZenIntroductionConfirm; private TextView mZenIntroductionCustomize; - private LinearLayout mZenConditions; + protected LinearLayout mZenConditions; private TextView mZenAlarmWarning; private Callback mCallback; @@ -302,14 +302,18 @@ public class ZenModePanel extends LinearLayout { } } + protected void addZenConditions(int count) { + for (int i = 0; i < count; i++) { + mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false)); + } + } + public void init(ZenModeController controller) { mController = controller; mCountdownConditionSupported = mController.isCountdownConditionSupported(); final int countdownDelta = mCountdownConditionSupported ? COUNTDOWN_CONDITION_COUNT : 0; final int minConditions = 1 /*forever*/ + countdownDelta; - for (int i = 0; i < minConditions; i++) { - mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false)); - } + addZenConditions(minConditions); mSessionZen = getSelectedZen(-1); handleUpdateManualRule(mController.getManualRule()); if (DEBUG) Log.d(mTag, "init mExitCondition=" + mExitCondition);