omnigears: fixed notification lights
The settings value must be written else framwork will not
enable them
Change-Id: Idc146a2fd8a70ccf7af6115bbf0f4c85f9b852cd
diff --git a/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java b/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
index 0cbeacd..70019bb 100644
--- a/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
+++ b/src/org/omnirom/omnigears/notificationlight/NotificationLightSettings.java
@@ -116,9 +116,13 @@
mEnabledPref = (CheckBoxPreference)
findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE);
+ mEnabledPref.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.NOTIFICATION_LIGHT_PULSE, 0) != 0);
mEnabledPref.setOnPreferenceChangeListener(this);
mCustomEnabledPref = (CheckBoxPreference)
findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
+ mCustomEnabledPref.setChecked(Settings.System.getInt(getContentResolver(),
+ Settings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE, 0) != 0);
mCustomEnabledPref.setOnPreferenceChangeListener(this);
mDefaultPref = (ApplicationLightPreference) findPreference(DEFAULT_PREF);
@@ -351,6 +355,18 @@
public boolean onPreferenceChange(Preference preference, Object objValue) {
if (preference == mEnabledPref || preference == mCustomEnabledPref) {
getActivity().invalidateOptionsMenu();
+
+ boolean enabled = (Boolean) objValue;
+
+ if (preference == mEnabledPref){
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_LIGHT_PULSE, enabled?1:0);
+ mApplicationPrefList.setEnabled(enabled && mCustomEnabledPref.isChecked());
+ } else if(preference == mCustomEnabledPref){
+ Settings.System.putInt(getContentResolver(),
+ Settings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE, enabled?1:0);
+ mApplicationPrefList.setEnabled(enabled);
+ }
} else {
ApplicationLightPreference lightPref = (ApplicationLightPreference) preference;
updateValues(lightPref.getKey(), lightPref.getColor(),