summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doze/src/org/lineageos/settings/doze/DozeSettingsFragment.java6
-rw-r--r--doze/src/org/lineageos/settings/doze/Utils.java5
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);