support: Always persist values for switch preferences

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
diff --git a/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java b/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
index 7504996..d38ee96 100644
--- a/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
+++ b/src/com/bliss/support/preferences/SecureSettingSwitchPreference.java
@@ -23,6 +23,7 @@
 import android.util.AttributeSet;
 
 public class SecureSettingSwitchPreference extends SwitchPreference {
+
     public SecureSettingSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
@@ -37,23 +38,13 @@
 
     @Override
     protected boolean persistBoolean(boolean value) {
-        if (shouldPersist()) {
-            if (value == getPersistedBoolean(!value)) {
-                // It's already there, so the same as persisting
-                return true;
-            }
-            Settings.Secure.putIntForUser(getContext().getContentResolver(),
-                getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
-            return true;
-        }
-        return false;
+        Settings.Secure.putIntForUser(getContext().getContentResolver(),
+            getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
+        return true;
     }
 
     @Override
     protected boolean getPersistedBoolean(boolean defaultReturnValue) {
-        if (!shouldPersist()) {
-            return defaultReturnValue;
-        }
         return Settings.Secure.getIntForUser(getContext().getContentResolver(),
                 getKey(), defaultReturnValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
     }
diff --git a/src/com/bliss/support/preferences/SecureSettingsStore.java b/src/com/bliss/support/preferences/SecureSettingsStore.java
index 14b9d17..8b31f47 100644
--- a/src/com/bliss/support/preferences/SecureSettingsStore.java
+++ b/src/com/bliss/support/preferences/SecureSettingsStore.java
@@ -31,7 +31,7 @@
     }
 
     public boolean getBoolean(String key, boolean defValue) {
-        return getInt(key, defValue ? 1 : 0) != 0;
+        return Settings.Secure.getIntForUser(mContentResolver, key, defValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
     }
 
     public float getFloat(String key, float defValue) {
diff --git a/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java b/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
index f83f3db..42de247 100644
--- a/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
+++ b/src/com/bliss/support/preferences/SystemSettingSwitchPreference.java
@@ -23,37 +23,31 @@
 import android.util.AttributeSet;
 
 public class SystemSettingSwitchPreference extends SwitchPreference {
+
     public SystemSettingSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
+        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
     }
 
     public SystemSettingSwitchPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
+        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
     }
 
     public SystemSettingSwitchPreference(Context context) {
         super(context, null);
+        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
     }
 
     @Override
     protected boolean persistBoolean(boolean value) {
-        if (shouldPersist()) {
-            if (value == getPersistedBoolean(!value)) {
-                // It's already there, so the same as persisting
-                return true;
-            }
-            Settings.System.putIntForUser(getContext().getContentResolver(),
-                getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
-            return true;
-        }
-        return false;
+        Settings.System.putIntForUser(getContext().getContentResolver(),
+            getKey(), value ? 1 : 0, UserHandle.USER_CURRENT);
+        return true;
     }
 
     @Override
     protected boolean getPersistedBoolean(boolean defaultReturnValue) {
-        if (!shouldPersist()) {
-            return defaultReturnValue;
-        }
         return Settings.System.getIntForUser(getContext().getContentResolver(),
                 getKey(), defaultReturnValue ? 1 : 0, UserHandle.USER_CURRENT) != 0;
     }