sdm660-common: XiaomiDoze: Fix pickup status for raise to wake

Signed-off-by: AnierinB <anierinb@evolution-x.org>
Signed-off-by: OdSazib <odsazib@gmail.com>
This commit is contained in:
AnierinB 2020-08-11 10:21:56 +06:00 committed by OdSazib
parent f441fa06a2
commit 297de8da99
No known key found for this signature in database
GPG key ID: A2D2E5C18BB04462
2 changed files with 7 additions and 6 deletions

View file

@ -131,7 +131,7 @@ public class DozeSettingsFragment extends PreferenceFragment implements OnPrefer
Utils.checkDozeService(getActivity()); Utils.checkDozeService(getActivity());
if (Utils.GESTURE_RAISE_TO_WAKE_KEY.equals(preference.getKey())) { if (Utils.GESTURE_RAISE_TO_WAKE_KEY.equals(preference.getKey())) {
Utils.setPickUp(getActivity(), (Boolean) newValue); Utils.setPickUp(findPreference(Utils.GESTURE_PICK_UP_KEY), (Boolean) newValue);
} }
return true; return true;
} }

View file

@ -19,10 +19,11 @@ package org.lineageos.settings.doze;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.UserHandle; import android.os.UserHandle;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.preference.SwitchPreference;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
@ -104,10 +105,10 @@ public final class Utils {
return isGestureEnabled(context, GESTURE_PICK_UP_KEY); return isGestureEnabled(context, GESTURE_PICK_UP_KEY);
} }
protected static void setPickUp(Context context, boolean value) { protected static void setPickUp(Preference preference, boolean value) {
SharedPreferences.Editor e = PreferenceManager.getDefaultSharedPreferences(context).edit(); SwitchPreference pickup = (SwitchPreference)preference;
e.putBoolean(GESTURE_PICK_UP_KEY, value); pickup.setChecked(value);
e.commit(); pickup.setEnabled(!value);
} }
protected static boolean isRaiseToWakeEnabled(Context context) { protected static boolean isRaiseToWakeEnabled(Context context) {