summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java37
1 files changed, 27 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index f7dfc0a771db..fffcc087223f 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -289,13 +289,20 @@ public class ZenModePanel extends FrameLayout {
}
}
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (DEBUG) Log.d(mTag, "onAttachedToWindow");
+ private void onAttach() {
setExpanded(true);
mAttached = true;
- mAttachedZen = getSelectedZen(-1);
+ for (int i = 0; i < mZenRadioGroupContent.getChildCount(); i++) {
+ ConditionTag tag = getConditionTagAt(i);
+ if (tag != null) tag.rb.setChecked(false);
+ mZenRadioGroupContent.getChildAt(i).setTag(null);
+ }
+ mAttachedZen = mController.getZen();
+ ZenRule manualRule = mController.getManualRule();
+ mExitCondition = manualRule != null ? manualRule.condition : null;
+ if (DEBUG) Log.d(mTag, "onAttach " + mAttachedZen + " " + manualRule);
+ handleUpdateManualRule(manualRule);
+ mZenButtons.setSelectedValue(mAttachedZen, false);
mSessionZen = mAttachedZen;
mTransitionHelper.clear();
mController.addCallback(mZenCallback);
@@ -304,10 +311,8 @@ public class ZenModePanel extends FrameLayout {
setRequestingConditions(!mHidden);
}
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (DEBUG) Log.d(mTag, "onDetachedFromWindow");
+ private void onDetach() {
+ if (DEBUG) Log.d(mTag, "onDetach");
setExpanded(false);
checkForAttachedZenChange();
mAttached = false;
@@ -319,6 +324,17 @@ public class ZenModePanel extends FrameLayout {
mTransitionHelper.clear();
}
+ @Override
+ public void onVisibilityAggregated(boolean isVisible) {
+ super.onVisibilityAggregated(isVisible);
+ if (isVisible == mAttached) return;
+ if (isVisible) {
+ onAttach();
+ } else {
+ onDetach();
+ }
+ }
+
private void setSessionExitCondition(Condition condition) {
if (Objects.equals(condition, mSessionExitCondition)) return;
if (DEBUG) Log.d(mTag, "mSessionExitCondition=" + getConditionId(condition));
@@ -680,7 +696,8 @@ public class ZenModePanel extends FrameLayout {
final int favoriteIndex = mPrefs.getMinuteIndex();
if (mExitCondition != null && mExitCondition.equals(mTimeCondition)) {
getConditionTagAt(COUNTDOWN_CONDITION_INDEX).rb.setChecked(true);
- } else if (favoriteIndex == -1 || !mCountdownConditionSupported) {
+ } else if (favoriteIndex == -1 || !mCountdownConditionSupported ||
+ mAttachedZen != Global.ZEN_MODE_OFF) {
foreverTag.rb.setChecked(true);
} else {
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,