Settings preference for choosing long-term conditions.

Requires change Icba2b8b2 in frameworks/base

Change-Id: I9d7a4f668e3b0e721646e42fa080f201c53a7fe9
This commit is contained in:
John Spurlock
2014-05-01 09:09:05 -04:00
parent 312c4573c3
commit 23e221cd93
5 changed files with 239 additions and 19 deletions

View File

@@ -72,19 +72,19 @@ public class ZenModeConditionSelection extends RadioGroup {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
requestZenModeConditions(true);
requestZenModeConditions(Condition.FLAG_RELEVANT_NOW);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
requestZenModeConditions(false);
requestZenModeConditions(0 /*none*/);
}
protected void requestZenModeConditions(boolean requested) {
if (DEBUG) Log.d(TAG, "requestZenModeConditions " + requested);
protected void requestZenModeConditions(int relevance) {
if (DEBUG) Log.d(TAG, "requestZenModeConditions " + Condition.relevanceToString(relevance));
try {
mNoMan.requestZenModeConditions(mListener, requested);
mNoMan.requestZenModeConditions(mListener, relevance);
} catch (RemoteException e) {
// noop
}
@@ -93,14 +93,14 @@ public class ZenModeConditionSelection extends RadioGroup {
protected void handleConditions(Condition[] conditions) {
for (final Condition c : conditions) {
RadioButton v = (RadioButton) findViewWithTag(c.id);
if (c.state == Condition.STATE_FALSE || c.state == Condition.STATE_UNKNOWN) {
if (c.state == Condition.STATE_TRUE || c.state == Condition.STATE_UNKNOWN) {
if (v == null) {
v = newRadioButton(c.id);
}
}
if (v != null) {
v.setText(c.caption);
v.setEnabled(c.state == Condition.STATE_FALSE);
v.setEnabled(c.state == Condition.STATE_TRUE);
}
}
}