Status bar blacklist: fix items resetting

Change-Id: Id3f287ce3b0fed4e3a7d0abff5fce025f16d9a1e
Fixes: 27600379
This commit is contained in:
Jason Monk
2016-06-30 14:37:10 -04:00
parent 650cc68f10
commit 0570e36b3b
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.