diff options
author | Luca Stefani <luca.stefani.ge1@gmail.com> | 2019-01-08 14:56:52 +0100 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2020-04-30 00:49:34 +0300 |
commit | 053dcc969f8d7b7bd3a20cadbd0b61a82f02aba0 (patch) | |
tree | 7f2be99c1b7dd7e1ccc05dfa659614ed16b1d9a8 /doze | |
parent | 209c00e9db61d1931b8b34f9ab815358d6fc0530 (diff) |
sdm660-common: doze: Move DozeUtils.checkDozeService in an handler
* There's no need to manually write to the gestures prefs
as long we are sure the handler is run after we return true
in the onPreferenceChangeListner
Change-Id: I090c0c6c91267aff69c45365b95b5f5e26d07b07
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Signed-off-by: Akhil Narang <akhilnarang.1999@gmail.com>
Signed-off-by: Anunay Maheshwari <anunaym14@gmail.com>
Diffstat (limited to 'doze')
-rw-r--r-- | doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java | 6 | ||||
-rw-r--r-- | doze/src/org/lineageos/settings/doze/Utils.java | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java index d7db2dd..2af38a8 100644 --- a/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java +++ b/doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; @@ -49,6 +50,8 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer private SwitchPreference mHandwavePreference; private SwitchPreference mPocketPreference; + private Handler mHandler = new Handler(); + @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.doze_settings); @@ -115,8 +118,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - Utils.enableGesture(getActivity(), preference.getKey(), (Boolean) newValue); - Utils.checkDozeService(getActivity()); + mHandler.post(() -> Utils.checkDozeService(getActivity())); return true; } diff --git a/doze/src/org/lineageos/settings/doze/Utils.java b/doze/src/org/lineageos/settings/doze/Utils.java index 7aa6884..8c333f2 100644 --- a/doze/src/org/lineageos/settings/doze/Utils.java +++ b/doze/src/org/lineageos/settings/doze/Utils.java @@ -87,11 +87,6 @@ public final class Utils { new UserHandle(UserHandle.USER_CURRENT)); } - protected static void enableGesture(Context context, String gesture, boolean enable) { - PreferenceManager.getDefaultSharedPreferences(context).edit() - .putBoolean(gesture, enable).apply(); - } - protected static boolean isGestureEnabled(Context context, String gesture) { return PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(gesture, false); |