diff options
4 files changed, 33 insertions, 24 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java index 600b75087e0d..0e21457a6547 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java @@ -31,6 +31,7 @@ public interface ZenModeController { void setUserId(int userId); boolean isZenAvailable(); ComponentName getEffectsSuppressor(); + boolean isCountdownConditionSupported(); public static class Callback { public void onZenChanged(int zen) {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java index 37ed7d8c6b6a..dbdb57827049 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java @@ -169,6 +169,12 @@ public class ZenModeControllerImpl implements ZenModeController { return NotificationManager.from(mContext).getEffectsSuppressor(); } + @Override + public boolean isCountdownConditionSupported() { + return NotificationManager.from(mContext) + .isSystemConditionProviderEnabled(ZenModeConfig.COUNTDOWN_PATH); + } + private void fireNextAlarmChanged() { for (Callback cb : mCallbacks) { cb.onNextAlarmChanged(); diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java index 0ad92b360874..31264eed49a4 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 d40a2c050698..5726fa7b0a42 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); |