diff options
author | Jason Monk <jmonk@google.com> | 2015-03-31 16:39:28 -0400 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2015-04-28 09:48:14 -0400 |
commit | 86dd6bab5b4200095fca20baac2cd2d3d4b10823 (patch) | |
tree | c5a4f42ee1de38b4ecfea17a18e283f5fd5ffa4d /src | |
parent | 79670bbe68dbc6c6cc1da9f1d093dabb8099e7f5 (diff) | |
download | packages_apps_Settings-86dd6bab5b4200095fca20baac2cd2d3d4b10823.zip packages_apps_Settings-86dd6bab5b4200095fca20baac2cd2d3d4b10823.tar.gz packages_apps_Settings-86dd6bab5b4200095fca20baac2cd2d3d4b10823.tar.bz2 |
Add tap to wake setting
Depends on Ic1ad910dd38acbc68ef040b2acdf3696ec2c2e4e
Bug: 16875464
Change-Id: Iae929099256e9077f8a4747a41fb965b8f9a72fb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 7ad3832..d9b6447 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -22,6 +22,7 @@ import com.android.settings.DropDownPreference.Callback; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; +import static android.provider.Settings.Secure.DOUBLE_TAP_TO_WAKE; import static android.provider.Settings.Secure.DOZE_ENABLED; import static android.provider.Settings.Secure.WAKE_GESTURE_ENABLED; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE; @@ -69,6 +70,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private static final String KEY_SCREEN_SAVER = "screensaver"; private static final String KEY_LIFT_TO_WAKE = "lift_to_wake"; private static final String KEY_DOZE = "doze"; + private static final String KEY_TAP_TO_WAKE = "tap_to_wake"; private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness"; private static final String KEY_AUTO_ROTATE = "auto_rotate"; private static final String KEY_NIGHT_MODE = "night_mode"; @@ -84,6 +86,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private Preference mScreenSaverPreference; private SwitchPreference mLiftToWakePreference; private SwitchPreference mDozePreference; + private SwitchPreference mTapToWakePreference; private SwitchPreference mAutoBrightnessPreference; @Override @@ -139,6 +142,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements removePreference(KEY_DOZE); } + if (isTapToWakeAvailable(getResources())) { + mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE); + mTapToWakePreference.setOnPreferenceChangeListener(this); + } else { + removePreference(KEY_TAP_TO_WAKE); + } + if (RotationPolicy.isRotationLockToggleVisible(activity)) { DropDownPreference rotatePreference = (DropDownPreference) findPreference(KEY_AUTO_ROTATE); @@ -201,6 +211,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements return !TextUtils.isEmpty(name); } + private static boolean isTapToWakeAvailable(Resources res) { + return res.getBoolean(com.android.internal.R.bool.config_supportDoubleTapWake); + } + private static boolean isAutomaticBrightnessAvailable(Resources res) { return res.getBoolean(com.android.internal.R.bool.config_automatic_brightness_available); } @@ -345,6 +359,12 @@ public class DisplaySettings extends SettingsPreferenceFragment implements int value = Settings.Secure.getInt(getContentResolver(), DOZE_ENABLED, 1); mDozePreference.setChecked(value != 0); } + + // Update tap to wake if it is available. + if (mTapToWakePreference != null) { + int value = Settings.Secure.getInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, 0); + mTapToWakePreference.setChecked(value != 0); + } } private void updateScreenSaverSummary() { @@ -396,6 +416,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements boolean value = (Boolean) objValue; Settings.Secure.putInt(getContentResolver(), DOZE_ENABLED, value ? 1 : 0); } + if (preference == mTapToWakePreference) { + boolean value = (Boolean) objValue; + Settings.Secure.putInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0); + } if (preference == mNightModePreference) { try { final int value = Integer.parseInt((String) objValue); |