Merge "Status bar blacklist: fix items resetting" into nyc-mr1-dev

This commit is contained in:
TreeHugger Robot
2016-06-30 20:16:53 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 2 deletions

View File

@@ -47,9 +47,9 @@ public class BatteryPreference extends DropDownPreference implements TunerServic
@Override
public void onAttached() {
super.onAttached();
TunerService.get(getContext()).addTunable(this, StatusBarIconController.ICON_BLACKLIST);
mHasPercentage = Settings.System.getInt(getContext().getContentResolver(),
SHOW_PERCENT_SETTING, 0) != 0;
TunerService.get(getContext()).addTunable(this, StatusBarIconController.ICON_BLACKLIST);
}
@Override

View File

@@ -32,6 +32,8 @@ public class ClockPreference extends DropDownPreference implements TunerService.
private boolean mHasSeconds;
private ArraySet<String> mBlacklist;
private boolean mHasSetValue;
private boolean mReceivedSeconds;
private boolean mReceivedClock;
public ClockPreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -55,12 +57,14 @@ public class ClockPreference extends DropDownPreference implements TunerService.
@Override
public void onTuningChanged(String key, String newValue) {
if (StatusBarIconController.ICON_BLACKLIST.equals(key)) {
mReceivedClock = true;
mBlacklist = StatusBarIconController.getIconBlacklist(newValue);
mClockEnabled = !mBlacklist.contains(mClock);
} else if (Clock.CLOCK_SECONDS.equals(key)) {
mReceivedSeconds = true;
mHasSeconds = newValue != null && Integer.parseInt(newValue) != 0;
}
if (!mHasSetValue) {
if (!mHasSetValue && mReceivedClock && mReceivedSeconds) {
// Because of the complicated tri-state it can end up looping and setting state back to
// what the user didn't choose. To avoid this, just set the state once and rely on the
// preference to handle updates.