summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java43
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/Util.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java116
8 files changed, 133 insertions, 95 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
index 64730c2..8aa0d7a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java
@@ -85,9 +85,9 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
@Override
public void handleClick() {
if (mState.value) {
- mController.setZen(Global.ZEN_MODE_OFF);
+ mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
} else {
- mController.setZen(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ mController.setZen(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null, TAG);
showDetail(true);
}
}
@@ -199,7 +199,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
@Override
public void setToggleState(boolean state) {
if (!state) {
- mController.setZen(Global.ZEN_MODE_OFF);
+ mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
showDetail(false);
}
}
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 0e21457..67cc788 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeController.java
@@ -17,16 +17,19 @@
package com.android.systemui.statusbar.policy;
import android.content.ComponentName;
+import android.net.Uri;
import android.service.notification.Condition;
+import android.service.notification.ZenModeConfig;
+import android.service.notification.ZenModeConfig.ZenRule;
public interface ZenModeController {
void addCallback(Callback callback);
void removeCallback(Callback callback);
- void setZen(int zen);
+ void setZen(int zen, Uri conditionId, String reason);
int getZen();
void requestConditions(boolean request);
- void setExitCondition(Condition exitCondition);
- Condition getExitCondition();
+ ZenRule getManualRule();
+ ZenModeConfig getConfig();
long getNextAlarm();
void setUserId(int userId);
boolean isZenAvailable();
@@ -35,10 +38,11 @@ public interface ZenModeController {
public static class Callback {
public void onZenChanged(int zen) {}
- public void onExitConditionChanged(Condition exitCondition) {}
public void onConditionsChanged(Condition[] conditions) {}
public void onNextAlarmChanged() {}
public void onZenAvailableChanged(boolean available) {}
public void onEffectsSupressorChanged() {}
+ public void onManualRuleChanged(ZenRule rule) {}
+ public void onConfigChanged(ZenModeConfig config) {}
}
} \ No newline at end of file
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 bea0c86..830a197 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ZenModeControllerImpl.java
@@ -33,6 +33,7 @@ import android.provider.Settings.Secure;
import android.service.notification.Condition;
import android.service.notification.IConditionListener;
import android.service.notification.ZenModeConfig;
+import android.service.notification.ZenModeConfig.ZenRule;
import android.util.Log;
import android.util.Slog;
@@ -40,6 +41,7 @@ import com.android.systemui.qs.GlobalSetting;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.Objects;
/** Platform implementation of the zen mode controller. **/
public class ZenModeControllerImpl implements ZenModeController {
@@ -58,6 +60,7 @@ public class ZenModeControllerImpl implements ZenModeController {
private int mUserId;
private boolean mRequesting;
private boolean mRegistered;
+ private ZenModeConfig mConfig;
public ZenModeControllerImpl(Context context, Handler handler) {
mContext = context;
@@ -70,12 +73,13 @@ public class ZenModeControllerImpl implements ZenModeController {
mConfigSetting = new GlobalSetting(mContext, handler, Global.ZEN_MODE_CONFIG_ETAG) {
@Override
protected void handleValueChanged(int value) {
- fireExitConditionChanged();
+ updateZenModeConfig();
}
};
+ mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ mConfig = mNoMan.getZenModeConfig();
mModeSetting.setListening(true);
mConfigSetting.setListening(true);
- mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
mSetupObserver = new SetupObserver(handler);
mSetupObserver.register();
@@ -97,8 +101,8 @@ public class ZenModeControllerImpl implements ZenModeController {
}
@Override
- public void setZen(int zen) {
- mModeSetting.setValue(zen);
+ public void setZen(int zen, Uri conditionId, String reason) {
+ mNoMan.setZenMode(zen, conditionId, reason);
}
@Override
@@ -116,13 +120,13 @@ public class ZenModeControllerImpl implements ZenModeController {
}
@Override
- public void setExitCondition(Condition exitCondition) {
- mNoMan.setZenModeCondition(exitCondition);
+ public ZenRule getManualRule() {
+ return mConfig == null ? null : mConfig.manualRule;
}
@Override
- public Condition getExitCondition() {
- return mNoMan.getZenModeCondition();
+ public ZenModeConfig getConfig() {
+ return mConfig;
}
@Override
@@ -185,11 +189,15 @@ public class ZenModeControllerImpl implements ZenModeController {
}
}
- private void fireExitConditionChanged() {
- final Condition exitCondition = getExitCondition();
- if (DEBUG) Slog.d(TAG, "exitCondition changed: " + exitCondition);
+ private void fireManualRuleChanged(ZenRule rule) {
+ for (Callback cb : mCallbacks) {
+ cb.onManualRuleChanged(rule);
+ }
+ }
+
+ private void fireConfigChanged(ZenModeConfig config) {
for (Callback cb : mCallbacks) {
- cb.onExitConditionChanged(exitCondition);
+ cb.onConfigChanged(config);
}
}
@@ -203,6 +211,17 @@ public class ZenModeControllerImpl implements ZenModeController {
mConditions.values().toArray(new Condition[mConditions.values().size()]));
}
+ private void updateZenModeConfig() {
+ final ZenModeConfig config = mNoMan.getZenModeConfig();
+ if (Objects.equals(config, mConfig)) return;
+ final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null;
+ mConfig = config;
+ fireConfigChanged(config);
+ final ZenRule newRule = config != null ? config.manualRule : null;
+ if (Objects.equals(oldRule, newRule)) return;
+ fireManualRuleChanged(newRule);
+ }
+
private final IConditionListener mListener = new IConditionListener.Stub() {
@Override
public void onConditionsReceived(Condition[] conditions) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/Util.java b/packages/SystemUI/src/com/android/systemui/volume/Util.java
index 78baf67..216a4da 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/Util.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/Util.java
@@ -21,7 +21,6 @@ import android.media.MediaMetadata;
import android.media.VolumeProvider;
import android.media.session.MediaController.PlaybackInfo;
import android.media.session.PlaybackState;
-import android.service.notification.ZenModeConfig.DowntimeInfo;
import android.view.View;
import android.widget.TextView;
@@ -145,10 +144,6 @@ class Util {
return HMMAA.format(new Date(millis));
}
- public static String getShortTime(DowntimeInfo info) {
- return ((info.endHour + 1) % 12) + ":" + (info.endMinute < 10 ? " " : "") + info.endMinute;
- }
-
public static void setText(TextView tv, CharSequence text) {
if (Objects.equals(tv.getText(), text)) return;
tv.setText(text);
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
index 7dd05c5..539fec8 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
@@ -38,7 +38,6 @@ import android.os.Message;
import android.os.SystemClock;
import android.provider.Settings.Global;
import android.service.notification.ZenModeConfig;
-import android.service.notification.ZenModeConfig.DowntimeInfo;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseBooleanArray;
@@ -606,14 +605,6 @@ public class VolumeDialog {
text = mContext.getString(R.string.volume_dnd_ends_at,
Util.getShortTime(countdown));
action = mContext.getString(R.string.volume_end_now);
- } else {
- final DowntimeInfo info = ZenModeConfig.tryParseDowntimeConditionId(mState.
- exitCondition.id);
- if (info != null) {
- text = mContext.getString(R.string.volume_dnd_ends_at,
- Util.getShortTime(info));
- action = mContext.getString(R.string.volume_end_now);
- }
}
}
if (text == null) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
index 265e2c6..5bc8c3e 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java
@@ -41,6 +41,7 @@ import android.os.RemoteException;
import android.os.Vibrator;
import android.provider.Settings;
import android.service.notification.Condition;
+import android.service.notification.ZenModeConfig;
import android.util.Log;
import android.util.SparseArray;
@@ -393,8 +394,15 @@ public class VolumeDialogController {
return stream == AudioManager.STREAM_RING || stream == AudioManager.STREAM_NOTIFICATION;
}
+ private Condition getExitCondition() {
+ final ZenModeConfig config = mNoMan.getZenModeConfig();
+ return config == null ? null
+ : config.manualRule == null ? null
+ : config.manualRule.condition;
+ }
+
private boolean updateExitConditionW() {
- final Condition exitCondition = mNoMan.getZenModeCondition();
+ final Condition exitCondition = getExitCondition();
if (Objects.equals(mState.exitCondition, exitCondition)) return false;
mState.exitCondition = exitCondition;
return true;
@@ -476,12 +484,12 @@ public class VolumeDialogController {
}
private void onSetExitConditionW(Condition condition) {
- mNoMan.setZenModeCondition(condition);
+ mNoMan.setZenMode(mState.zenMode, condition != null ? condition.id : null, TAG);
}
private void onSetZenModeW(int mode) {
if (D.BUG) Log.d(TAG, "onSetZenModeW " + mode);
- mNoMan.setZenMode(mode);
+ mNoMan.setZenMode(mode, null, TAG);
}
private void onDismissRequestedW(int reason) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
index f99eb6d..ef8257c 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java
@@ -17,10 +17,11 @@ package com.android.systemui.volume;
import android.animation.LayoutTransition;
import android.animation.ValueAnimator;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings.Global;
-import android.service.notification.Condition;
+import android.service.notification.ZenModeConfig;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
@@ -34,6 +35,8 @@ import android.widget.TextView;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ZenModeController;
+import java.util.Objects;
+
/**
* Switch bar + zen mode panel (conditions) attached to the bottom of the volume dialog.
*/
@@ -57,6 +60,7 @@ public class ZenFooter extends LinearLayout {
private TextView mSummaryLine2;
private boolean mFooterExpanded;
private int mZen = -1;
+ private ZenModeConfig mConfig;
private Callback mCallback;
public ZenFooter(Context context, AttributeSet attrs) {
@@ -102,8 +106,8 @@ public class ZenFooter extends LinearLayout {
setZen(zen);
}
@Override
- public void onExitConditionChanged(Condition exitCondition) {
- update();
+ public void onConfigChanged(ZenModeConfig config) {
+ setConfig(config);
}
});
mSwitchBar.setOnClickListener(new OnClickListener() {
@@ -129,6 +133,7 @@ public class ZenFooter extends LinearLayout {
}
});
mZen = mController.getZen();
+ mConfig = mController.getConfig();
update();
}
@@ -138,6 +143,12 @@ public class ZenFooter extends LinearLayout {
update();
}
+ private void setConfig(ZenModeConfig config) {
+ if (Objects.equals(mConfig, config)) return;
+ mConfig = config;
+ update();
+ }
+
public boolean isZen() {
return isZenPriority() || isZenAlarms() || isZenNone();
}
@@ -196,7 +207,9 @@ public class ZenFooter extends LinearLayout {
: isZenNone() ? mContext.getString(R.string.interruption_level_none)
: null;
Util.setText(mSummaryLine1, line1);
- Util.setText(mSummaryLine2, mZenModePanel.getExitConditionText());
+ final String line2 = ZenModeConfig.getConditionSummary(mContext, mConfig,
+ ActivityManager.getCurrentUser());
+ Util.setText(mSummaryLine2, line2);
}
private final OnCheckedChangeListener mCheckedListener = new OnCheckedChangeListener() {
@@ -208,7 +221,7 @@ public class ZenFooter extends LinearLayout {
: Global.ZEN_MODE_OFF;
mZen = newZen; // this one's optimistic
setFooterExpanded(isChecked);
- mController.setZen(newZen);
+ mController.setZen(newZen, null, TAG);
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index cb6c29f..f6d4c36 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -32,6 +32,7 @@ import android.provider.Settings;
import android.provider.Settings.Global;
import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
+import android.service.notification.ZenModeConfig.ZenRule;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.AttributeSet;
@@ -157,7 +158,6 @@ public class ZenModePanel extends LinearLayout {
}
mZenButtons.getChildAt(3).setVisibility(mEmbedded ? GONE : VISIBLE);
mZenEmbeddedDivider.setVisibility(mEmbedded ? VISIBLE : GONE);
- setExpanded(mEmbedded);
updateWidgets();
}
@@ -278,7 +278,7 @@ public class ZenModePanel extends LinearLayout {
if (expanded == mExpanded) return;
if (DEBUG) Log.d(mTag, "setExpanded " + expanded);
mExpanded = expanded;
- if (mExpanded) {
+ if (mExpanded && isShown()) {
ensureSelection();
}
updateWidgets();
@@ -299,7 +299,7 @@ public class ZenModePanel extends LinearLayout {
});
}
if (mRequestingConditions) {
- mTimeCondition = parseExistingTimeCondition(mExitCondition);
+ mTimeCondition = parseExistingTimeCondition(mContext, mExitCondition);
if (mTimeCondition != null) {
mBucketIndex = -1;
} else {
@@ -327,10 +327,9 @@ public class ZenModePanel extends LinearLayout {
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);
- handleUpdateZen(mController.getZen());
+ handleUpdateManualRule(mController.getManualRule());
if (DEBUG) Log.d(mTag, "init mExitCondition=" + mExitCondition);
hideAllConditions();
mController.addCallback(mZenCallback);
@@ -352,6 +351,10 @@ public class ZenModePanel extends LinearLayout {
return condition != null ? condition.id : null;
}
+ private Uri getRealConditionId(Condition condition) {
+ return isForever(condition) ? null : getConditionId(condition);
+ }
+
private static boolean sameConditionId(Condition lhs, Condition rhs) {
return lhs == null ? rhs == null : rhs != null && lhs.id.equals(rhs.id);
}
@@ -360,18 +363,18 @@ public class ZenModePanel extends LinearLayout {
return condition == null ? null : condition.copy();
}
- public String getExitConditionText() {
- return mExitConditionText;
+ private void refreshExitConditionText() {
+ mExitConditionText = getExitConditionText(mContext, mExitCondition);
}
- private void refreshExitConditionText() {
- if (mExitCondition == null) {
- mExitConditionText = foreverSummary();
- } else if (isCountdown(mExitCondition)) {
- final Condition condition = parseExistingTimeCondition(mExitCondition);
- mExitConditionText = condition != null ? condition.summary : foreverSummary();
+ public static String getExitConditionText(Context context, Condition exitCondition) {
+ if (exitCondition == null) {
+ return foreverSummary(context);
+ } else if (isCountdown(exitCondition)) {
+ final Condition condition = parseExistingTimeCondition(context, exitCondition);
+ return condition != null ? condition.summary : foreverSummary(context);
} else {
- mExitConditionText = mExitCondition.summary;
+ return exitCondition.summary;
}
}
@@ -386,9 +389,16 @@ public class ZenModePanel extends LinearLayout {
mIconPulser.start(noneButton);
}
+ private void handleUpdateManualRule(ZenRule rule) {
+ final int zen = rule != null ? rule.zenMode : Global.ZEN_MODE_OFF;
+ handleUpdateZen(zen);
+ final Condition c = rule != null ? rule.condition : null;
+ handleExitConditionChanged(c);
+ }
+
private void handleUpdateZen(int zen) {
if (mSessionZen != -1 && mSessionZen != zen) {
- setExpanded(mEmbedded || zen != Global.ZEN_MODE_OFF);
+ setExpanded(mEmbedded && isShown() || !mEmbedded && zen != Global.ZEN_MODE_OFF);
mSessionZen = zen;
}
mZenButtons.setSelectedValue(zen);
@@ -402,6 +412,20 @@ public class ZenModePanel extends LinearLayout {
}
}
+ private void handleExitConditionChanged(Condition exitCondition) {
+ setExitCondition(exitCondition);
+ if (DEBUG) Log.d(mTag, "handleExitConditionChanged " + mExitCondition);
+ final int N = getVisibleConditions();
+ for (int i = 0; i < N; i++) {
+ final ConditionTag tag = getConditionTagAt(i);
+ if (tag != null) {
+ if (sameConditionId(tag.condition, mExitCondition)) {
+ bind(exitCondition, mZenConditions.getChildAt(i));
+ }
+ }
+ }
+ }
+
private Condition getSelectedCondition() {
final int N = getVisibleConditions();
for (int i = 0; i < N; i++) {
@@ -447,14 +471,14 @@ public class ZenModePanel extends LinearLayout {
? mSubheadWarningColor : mSubheadColor);
}
- private Condition parseExistingTimeCondition(Condition condition) {
+ private static Condition parseExistingTimeCondition(Context context, Condition condition) {
if (condition == null) return null;
final long time = ZenModeConfig.tryParseCountdownConditionId(condition.id);
if (time == 0) return null;
final long now = System.currentTimeMillis();
final long span = time - now;
if (span <= 0 || span > MAX_BUCKET_MINUTES * MINUTES_MS) return null;
- return ZenModeConfig.toTimeCondition(mContext,
+ return ZenModeConfig.toTimeCondition(context,
time, Math.round(span / (float) MINUTES_MS), now, ActivityManager.getCurrentUser());
}
@@ -514,18 +538,18 @@ public class ZenModePanel extends LinearLayout {
mZenConditions.getChildAt(i).setVisibility(GONE);
}
// ensure something is selected
- if (mExpanded) {
+ if (mExpanded && isShown()) {
ensureSelection();
}
}
private Condition forever() {
- return new Condition(mForeverId, foreverSummary(), "", "", 0 /*icon*/, Condition.STATE_TRUE,
- 0 /*flags*/);
+ return new Condition(mForeverId, foreverSummary(mContext), "", "", 0 /*icon*/,
+ Condition.STATE_TRUE, 0 /*flags*/);
}
- private String foreverSummary() {
- return mContext.getString(com.android.internal.R.string.zen_mode_forever);
+ private static String foreverSummary(Context context) {
+ return context.getString(com.android.internal.R.string.zen_mode_forever);
}
private ConditionTag getConditionTagAt(int index) {
@@ -574,21 +598,7 @@ public class ZenModePanel extends LinearLayout {
}
}
- private void handleExitConditionChanged(Condition exitCondition) {
- setExitCondition(exitCondition);
- if (DEBUG) Log.d(mTag, "handleExitConditionChanged " + mExitCondition);
- final int N = getVisibleConditions();
- for (int i = 0; i < N; i++) {
- final ConditionTag tag = getConditionTagAt(i);
- if (tag != null) {
- if (sameConditionId(tag.condition, mExitCondition)) {
- bind(exitCondition, mZenConditions.getChildAt(i));
- }
- }
- }
- }
-
- private boolean isCountdown(Condition c) {
+ private static boolean isCountdown(Condition c) {
return c != null && ZenModeConfig.isValidCountdownConditionId(c.id);
}
@@ -770,17 +780,21 @@ public class ZenModePanel extends LinearLayout {
private void select(final Condition condition) {
if (DEBUG) Log.d(mTag, "select " + condition);
- final boolean isForever = isForever(condition);
+ if (mSessionZen == -1 || mSessionZen == Global.ZEN_MODE_OFF) {
+ if (DEBUG) Log.d(mTag, "Ignoring condition selection outside of manual zen");
+ return;
+ }
+ final Uri realConditionId = getRealConditionId(condition);
if (mController != null) {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
- mController.setExitCondition(isForever ? null : condition);
+ mController.setZen(mSessionZen, realConditionId, TAG + ".selectCondition");
}
});
}
setExitCondition(condition);
- if (isForever) {
+ if (realConditionId == null) {
mPrefs.setMinuteIndex(-1);
} else if (isCountdown(condition) && mBucketIndex != -1) {
mPrefs.setMinuteIndex(mBucketIndex);
@@ -808,24 +822,19 @@ public class ZenModePanel extends LinearLayout {
private final ZenModeController.Callback mZenCallback = new ZenModeController.Callback() {
@Override
- public void onZenChanged(int zen) {
- mHandler.obtainMessage(H.UPDATE_ZEN, zen, 0).sendToTarget();
- }
- @Override
public void onConditionsChanged(Condition[] conditions) {
mHandler.obtainMessage(H.UPDATE_CONDITIONS, conditions).sendToTarget();
}
@Override
- public void onExitConditionChanged(Condition exitCondition) {
- mHandler.obtainMessage(H.EXIT_CONDITION_CHANGED, exitCondition).sendToTarget();
+ public void onManualRuleChanged(ZenRule rule) {
+ mHandler.obtainMessage(H.MANUAL_RULE_CHANGED, rule).sendToTarget();
}
};
private final class H extends Handler {
private static final int UPDATE_CONDITIONS = 1;
- private static final int EXIT_CONDITION_CHANGED = 2;
- private static final int UPDATE_ZEN = 3;
+ private static final int MANUAL_RULE_CHANGED = 2;
private H() {
super(Looper.getMainLooper());
@@ -835,10 +844,8 @@ public class ZenModePanel extends LinearLayout {
public void handleMessage(Message msg) {
if (msg.what == UPDATE_CONDITIONS) {
handleUpdateConditions((Condition[]) msg.obj);
- } else if (msg.what == EXIT_CONDITION_CHANGED) {
- handleExitConditionChanged((Condition) msg.obj);
- } else if (msg.what == UPDATE_ZEN) {
- handleUpdateZen(msg.arg1);
+ } else if (msg.what == MANUAL_RULE_CHANGED) {
+ handleUpdateManualRule((ZenRule) msg.obj);
}
}
}
@@ -930,12 +937,13 @@ public class ZenModePanel extends LinearLayout {
private final SegmentedButtons.Callback mZenButtonsCallback = new SegmentedButtons.Callback() {
@Override
public void onSelected(final Object value) {
- if (value != null && mZenButtons.isShown()) {
+ if (value != null && mZenButtons.isShown() && isAttachedToWindow()) {
if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + value);
+ final Uri realConditionId = getRealConditionId(mSessionExitCondition);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
- mController.setZen((Integer) value);
+ mController.setZen((Integer) value, realConditionId, TAG + ".selectZen");
}
});
}