OmniGears: add missing initial enablement for battery light
Change-Id: If2534de249a085f43d14d2761530edca11204cf2
diff --git a/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java b/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
index 7e46b0b..451b678 100644
--- a/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
+++ b/src/org/omnirom/omnigears/batterylight/BatteryLightSettings.java
@@ -117,6 +117,9 @@
prefSet.removePreference(prefSet.findPreference("colors_list"));
resetColors();
}
+ boolean showOnlyWhenFull = Settings.System.getInt(resolver,
+ Settings.System.BATTERY_LIGHT_ONLY_FULLY_CHARGED, 0) != 0;
+ updateEnablement(showOnlyWhenFull);
}
@Override
@@ -229,15 +232,7 @@
} else if (preference == mOnlyFullPref) {
boolean value = (Boolean) objValue;
// If enabled, disable all but really full color preference.
- if (mLowColorPref != null) {
- mLowColorPref.setEnabled(!value);
- }
- if (mMediumColorPref != null) {
- mMediumColorPref.setEnabled(!value);
- }
- if (mFullColorPref != null) {
- mFullColorPref.setEnabled(!value);
- }
+ updateEnablement(value);
} else {
BatteryLightPreference lightPref = (BatteryLightPreference) preference;
updateValues(lightPref.getKey(), lightPref.getColor());
@@ -245,6 +240,19 @@
return true;
}
+ private void updateEnablement(boolean showOnlyWhenFull) {
+ // If enabled, disable all but really full color preference.
+ if (mLowColorPref != null) {
+ mLowColorPref.setEnabled(!showOnlyWhenFull);
+ }
+ if (mMediumColorPref != null) {
+ mMediumColorPref.setEnabled(!showOnlyWhenFull);
+ }
+ if (mFullColorPref != null) {
+ mFullColorPref.setEnabled(!showOnlyWhenFull);
+ }
+ }
+
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override