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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user