import android.app.ActionBar;
import android.os.Bundle;
+import android.os.Handler;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
private SwitchPreference mHandwavePreference;
private SwitchPreference mPocketPreference;
+ private Handler mHandler = new Handler();
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.gesture_panel);
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (Utils.ALWAYS_ON_DISPLAY.equals(preference.getKey())) {
Utils.enableAlwaysOn(getActivity(), (Boolean) newValue);
- } else {
- Utils.enableGesture(getActivity(), preference.getKey(), (Boolean) newValue);
}
- Utils.checkDozeService(getActivity());
+ mHandler.post(() -> Utils.checkDozeService(getActivity()));
return true;
}
DOZE_ENABLED, enable ? 1 : 0);
}
- protected static void enableGesture(Context context, String gesture, boolean enable) {
- PreferenceManager.getDefaultSharedPreferences(context).edit()
- .putBoolean(gesture, enable).apply();
- }
-
protected static boolean isAnyGestureEnabled(Context context) {
return isHandwaveGestureEnabled(context) || isPocketGestureEnabled(context);
}