Merge "Uncheck unselected radio buttons." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
69e0d82994
@@ -576,14 +576,27 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
if (DEBUG) Log.d(mTag, "Selecting a default");
|
if (DEBUG) Log.d(mTag, "Selecting a default");
|
||||||
final int favoriteIndex = mPrefs.getMinuteIndex();
|
final int favoriteIndex = mPrefs.getMinuteIndex();
|
||||||
if (favoriteIndex == -1 || !mCountdownConditionSupported) {
|
if (favoriteIndex == -1 || !mCountdownConditionSupported) {
|
||||||
foreverTag.rb.setChecked(true);
|
setChecked(foreverTag.rb, true);
|
||||||
} else {
|
} else {
|
||||||
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
|
mTimeCondition = ZenModeConfig.toTimeCondition(mContext,
|
||||||
MINUTE_BUCKETS[favoriteIndex], ActivityManager.getCurrentUser());
|
MINUTE_BUCKETS[favoriteIndex], ActivityManager.getCurrentUser());
|
||||||
mBucketIndex = favoriteIndex;
|
mBucketIndex = favoriteIndex;
|
||||||
bind(mTimeCondition, mZenConditions.getChildAt(COUNTDOWN_CONDITION_INDEX),
|
bind(mTimeCondition, mZenConditions.getChildAt(COUNTDOWN_CONDITION_INDEX),
|
||||||
COUNTDOWN_CONDITION_INDEX);
|
COUNTDOWN_CONDITION_INDEX);
|
||||||
getConditionTagAt(COUNTDOWN_CONDITION_INDEX).rb.setChecked(true);
|
setChecked(getConditionTagAt(COUNTDOWN_CONDITION_INDEX).rb, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setChecked(RadioButton rb, boolean checked) {
|
||||||
|
final int N = getVisibleConditions();
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
final ConditionTag tag = getConditionTagAt(i);
|
||||||
|
if (tag != null && tag.rb.isChecked() && !Objects.equals(tag.rb, rb)) {
|
||||||
|
tag.rb.setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rb.isChecked() != checked) {
|
||||||
|
rb.setChecked(checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,13 +627,8 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
if (mExpanded && isChecked) {
|
if (mExpanded && isChecked) {
|
||||||
|
setChecked(tag.rb, isChecked);
|
||||||
if (DEBUG) Log.d(mTag, "onCheckedChanged " + conditionId);
|
if (DEBUG) Log.d(mTag, "onCheckedChanged " + conditionId);
|
||||||
final int N = getVisibleConditions();
|
|
||||||
for (int i = 0; i < N; i++) {
|
|
||||||
final ConditionTag childTag = getConditionTagAt(i);
|
|
||||||
if (childTag == null || childTag == tag) continue;
|
|
||||||
childTag.rb.setChecked(false);
|
|
||||||
}
|
|
||||||
MetricsLogger.action(mContext, MetricsEvent.QS_DND_CONDITION_SELECT);
|
MetricsLogger.action(mContext, MetricsEvent.QS_DND_CONDITION_SELECT);
|
||||||
select(tag.condition);
|
select(tag.condition);
|
||||||
announceConditionSelection(tag);
|
announceConditionSelection(tag);
|
||||||
@@ -670,7 +678,7 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
tag.lines.setOnClickListener(new OnClickListener() {
|
tag.lines.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
tag.rb.setChecked(true);
|
setChecked(tag.rb, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -759,7 +767,7 @@ public class ZenModePanel extends LinearLayout {
|
|||||||
}
|
}
|
||||||
mTimeCondition = newCondition;
|
mTimeCondition = newCondition;
|
||||||
bind(mTimeCondition, row, rowId);
|
bind(mTimeCondition, row, rowId);
|
||||||
tag.rb.setChecked(true);
|
setChecked(tag.rb, true);
|
||||||
select(mTimeCondition);
|
select(mTimeCondition);
|
||||||
announceConditionSelection(tag);
|
announceConditionSelection(tag);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user