From fbb3d6ff392e9cd13fea49f85f12efd0a304d448 Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Thu, 17 Jul 2014 11:17:11 -0400 Subject: [PATCH] Zen: Maintain selection throughout rocker session. While the panel is visible, allow toggling between none + priority (and even 'all') without resetting the exit condition. Bug:16350606 Change-Id: I830be8ccad1ba95a64239f00a72f773c4fe739f2 --- .../android/systemui/volume/ZenModePanel.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index cf04219931d9a..2e93c5b6f0039 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -92,7 +92,8 @@ public class ZenModePanel extends LinearLayout { private Uri mExitConditionId; private int mBucketIndex = -1; private boolean mExpanded; - private int mAttachedZen; + private int mSessionZen; + private Uri mSessionExitConditionId; private String mExitConditionText; public ZenModePanel(Context context, AttributeSet attrs) { @@ -150,7 +151,8 @@ public class ZenModePanel extends LinearLayout { protected void onAttachedToWindow() { super.onAttachedToWindow(); if (DEBUG) Log.d(mTag, "onAttachedToWindow"); - mAttachedZen = getSelectedZen(-1); + mSessionZen = getSelectedZen(-1); + mSessionExitConditionId = mExitConditionId; refreshExitConditionText(); updateWidgets(); } @@ -159,7 +161,8 @@ public class ZenModePanel extends LinearLayout { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (DEBUG) Log.d(mTag, "onDetachedFromWindow"); - mAttachedZen = -1; + mSessionZen = -1; + mSessionExitConditionId = null; setExpanded(false); } @@ -202,7 +205,7 @@ public class ZenModePanel extends LinearLayout { updateTag(); setExitConditionId(mController.getExitConditionId()); refreshExitConditionText(); - mAttachedZen = getSelectedZen(-1); + mSessionZen = getSelectedZen(-1); handleUpdateZen(mController.getZen()); if (DEBUG) Log.d(mTag, "init mExitConditionId=" + mExitConditionId); mZenConditions.removeAllViews(); @@ -248,9 +251,9 @@ public class ZenModePanel extends LinearLayout { } private void handleUpdateZen(int zen) { - if (mAttachedZen != -1 && mAttachedZen != zen) { + if (mSessionZen != -1 && mSessionZen != zen) { setExpanded(zen != Global.ZEN_MODE_OFF); - mAttachedZen = zen; + mSessionZen = zen; } mZenButtons.setSelectedValue(zen); updateWidgets(); @@ -328,6 +331,8 @@ public class ZenModePanel extends LinearLayout { // are we left without anything selected? if so, set a default for (int i = 0; i < mZenConditions.getChildCount(); i++) { if (getConditionTagAt(i).rb.isChecked()) { + if (DEBUG) Log.d(mTag, "Not selecting a default, checked=" + + getConditionTagAt(i).conditionId); return; } } @@ -371,7 +376,7 @@ public class ZenModePanel extends LinearLayout { } tag.conditionId = condition != null ? condition.id : null; tag.rb.setEnabled(enabled); - if (Objects.equals(tag.conditionId, mExitConditionId)) { + if (mSessionExitConditionId != null && mSessionExitConditionId.equals(tag.conditionId)) { tag.rb.setChecked(true); } tag.rb.setOnCheckedChangeListener(new OnCheckedChangeListener() { @@ -484,6 +489,7 @@ public class ZenModePanel extends LinearLayout { } else if (ZenModeConfig.isValidCountdownConditionId(conditionId) && mBucketIndex != -1) { mFavorites.setMinuteIndex(mBucketIndex); } + mSessionExitConditionId = conditionId; } private void fireMoreSettings() { @@ -601,7 +607,6 @@ public class ZenModePanel extends LinearLayout { if (value != null && mZenButtons.isShown()) { if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + value); mController.setZen((Integer) value); - mController.setExitConditionId(null); } } };