diff options
author | John Spurlock <jspurlock@google.com> | 2015-01-30 15:48:15 -0500 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2015-02-09 18:39:49 -0500 |
commit | ad680d46be19cbee16d42cbed4d2ed250648ac0b (patch) | |
tree | c1befb925cff993b0d7d4a9e1ceff47bd69a3066 /packages/SystemUI/src/com/android/systemui/volume | |
parent | 0fa412cdd21d90caec5332f88302a657fae9bcfd (diff) | |
download | frameworks_base-ad680d46be19cbee16d42cbed4d2ed250648ac0b.zip frameworks_base-ad680d46be19cbee16d42cbed4d2ed250648ac0b.tar.gz frameworks_base-ad680d46be19cbee16d42cbed4d2ed250648ac0b.tar.bz2 |
Small changes to make VolumePanel more testable.
- Put a zen call requiring status_bar_service behind
the controller.
- Make the dialog window params overridable by subclasses.
Bug: 19260237
Change-Id: I2b75cde8a2f7efcd8ac001f181c151597bb7a978
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/volume')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java | 20 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java | 30 |
2 files changed, 26 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java index 0ad92b3..31264ee 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java @@ -350,6 +350,17 @@ public class VolumePanel extends Handler implements DemoMode { }; } + protected LayoutParams getDialogLayoutParams(Window window, Resources res) { + final LayoutParams lp = window.getAttributes(); + lp.token = null; + lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); + lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; + lp.format = PixelFormat.TRANSLUCENT; + lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; + lp.setTitle(TAG); + return lp; + } + public VolumePanel(Context context, ZenModeController zenController) { mTag = String.format("%s.%08x", TAG, hashCode()); mContext = context; @@ -408,14 +419,7 @@ public class VolumePanel extends Handler implements DemoMode { mDialog.create(); - final LayoutParams lp = window.getAttributes(); - lp.token = null; - lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); - lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; - lp.format = PixelFormat.TRANSLUCENT; - lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; - lp.setTitle(TAG); - window.setAttributes(lp); + window.setAttributes(getDialogLayoutParams(window, res)); updateWidth(); diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index d40a2c0..5726fa7 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -19,7 +19,6 @@ package com.android.systemui.volume; import android.animation.LayoutTransition; import android.animation.LayoutTransition.TransitionListener; import android.app.ActivityManager; -import android.app.NotificationManager; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -85,10 +84,6 @@ public class ZenModePanel extends LinearLayout { private final int mSubheadWarningColor; private final int mSubheadColor; private final Interpolator mInterpolator; - private final int mMaxConditions; - private final int mMaxOptionalConditions; - private final boolean mCountdownConditionSupported; - private final int mFirstConditionIndex; private final TransitionHelper mTransitionHelper = new TransitionHelper(); private final Uri mForeverId; @@ -103,6 +98,10 @@ public class ZenModePanel extends LinearLayout { private Callback mCallback; private ZenModeController mController; + private boolean mCountdownConditionSupported; + private int mMaxConditions; + private int mMaxOptionalConditions; + private int mFirstConditionIndex; private boolean mRequestingConditions; private Condition mExitCondition; private String mExitConditionText; @@ -127,14 +126,6 @@ public class ZenModePanel extends LinearLayout { mSubheadColor = res.getColor(R.color.qs_subhead); mInterpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.fast_out_slow_in); - mCountdownConditionSupported = NotificationManager.from(mContext) - .isSystemConditionProviderEnabled(ZenModeConfig.COUNTDOWN_PATH); - final int countdownDelta = mCountdownConditionSupported ? 1 : 0; - mFirstConditionIndex = COUNTDOWN_CONDITION_INDEX + countdownDelta; - final int minConditions = 1 /*forever*/ + countdownDelta; - mMaxConditions = MathUtils.constrain(res.getInteger(R.integer.zen_mode_max_conditions), - minConditions, 100); - mMaxOptionalConditions = mMaxConditions - minConditions; mForeverId = Condition.newId(mContext).appendPath("forever").build(); if (DEBUG) Log.d(mTag, "new ZenModePanel"); } @@ -192,9 +183,6 @@ public class ZenModePanel extends LinearLayout { Interaction.register(mMoreSettings, mInteractionCallback); mZenConditions = (LinearLayout) findViewById(R.id.zen_conditions); - for (int i = 0; i < mMaxConditions; i++) { - mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false)); - } setLayoutTransition(newLayoutTransition(mTransitionHelper)); } @@ -306,6 +294,16 @@ public class ZenModePanel extends LinearLayout { public void init(ZenModeController controller) { mController = controller; + mCountdownConditionSupported = mController.isCountdownConditionSupported(); + final int countdownDelta = mCountdownConditionSupported ? 1 : 0; + mFirstConditionIndex = COUNTDOWN_CONDITION_INDEX + countdownDelta; + final int minConditions = 1 /*forever*/ + countdownDelta; + mMaxConditions = MathUtils.constrain(mContext.getResources() + .getInteger(R.integer.zen_mode_max_conditions), minConditions, 100); + mMaxOptionalConditions = mMaxConditions - minConditions; + for (int i = 0; i < mMaxConditions; i++) { + mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false)); + } setExitCondition(mController.getExitCondition()); refreshExitConditionText(); mSessionZen = getSelectedZen(-1); |