diff options
author | Jon Evans <jon@craftyjon.com> | 2014-11-30 15:29:13 -0500 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:29 -0700 |
commit | e0c17471b56570ca7c65527345d2b97331204b50 (patch) | |
tree | 3a5b78bd3bc8731fa026b1b257391be7782abf0a | |
parent | be78b3901d14be044c35cf06d8efa9562441e131 (diff) | |
download | packages_apps_Settings-e0c17471b56570ca7c65527345d2b97331204b50.zip packages_apps_Settings-e0c17471b56570ca7c65527345d2b97331204b50.tar.gz packages_apps_Settings-e0c17471b56570ca7c65527345d2b97331204b50.tar.bz2 |
Port: Wake on plug (2/2)
Change-Id: I22ee2a05040561cca796814573adc5226f1f03d4
-rw-r--r-- | res/values/cm_strings.xml | 4 | ||||
-rw-r--r-- | res/xml/display_settings.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 18 |
3 files changed, 28 insertions, 0 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 585541e..49672e2 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -413,4 +413,8 @@ <!-- Proximity wake --> <string name="proximity_wake_title">Prevent accidental wake-up</string> <string name="proximity_wake_summary">Check the proximity sensor prior to waking up screen</string> + + <!-- Turn on display when power connected; turn off display when power disconnected --> + <string name="wake_when_plugged_or_unplugged_title">Wake on plug</string> + <string name="wake_when_plugged_or_unplugged_summary">Turn the screen on when connecting or disconnecting a power source</string> </resources> diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml index 6dfaac6..3912d37 100644 --- a/res/xml/display_settings.xml +++ b/res/xml/display_settings.xml @@ -116,5 +116,11 @@ android:title="@string/double_tap_to_sleep_title" android:summary="@string/double_tap_to_sleep_summary" android:defaultValue="true" /> + + <SwitchPreference + android:key="wake_when_plugged_or_unplugged" + android:title="@string/wake_when_plugged_or_unplugged_title" + android:summary="@string/wake_when_plugged_or_unplugged_summary" + android:defaultValue="false" /> </PreferenceCategory> </PreferenceScreen> diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index ff2aad2..01eed08 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -82,6 +82,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private static final String KEY_NIGHT_MODE = "night_mode"; private static final String KEY_TAP_TO_WAKE = "double_tap_wake_gesture"; private static final String KEY_PROXIMITY_WAKE = "proximity_on_wake"; + private static final String KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED = "wake_when_plugged_or_unplugged"; private static final String CATEGORY_ADVANCED = "advanced_display_prefs"; @@ -99,6 +100,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private SwitchPreference mTapToWakePreference; private SwitchPreference mAutoBrightnessPreference; private SwitchPreference mTapToWake; + private SwitchPreference mWakeWhenPluggedOrUnplugged; @Override protected int getMetricsCategory() { @@ -220,6 +222,9 @@ public class DisplaySettings extends SettingsPreferenceFragment implements advancedPrefs.removePreference(findPreference(KEY_PROXIMITY_WAKE)); Settings.System.putInt(getContentResolver(), Settings.System.PROXIMITY_ON_WAKE, 1); } + + mWakeWhenPluggedOrUnplugged = + (SwitchPreference) findPreference(KEY_WAKE_WHEN_PLUGGED_OR_UNPLUGGED); } private static boolean allowAllRotations(Context context) { @@ -346,6 +351,14 @@ public class DisplaySettings extends SettingsPreferenceFragment implements mTapToWake.setChecked(TapToWake.isEnabled()); } + // Default value for wake-on-plug behavior from config.xml + boolean wakeUpWhenPluggedOrUnpluggedConfig = getResources().getBoolean( + com.android.internal.R.bool.config_unplugTurnsOnScreen); + + mWakeWhenPluggedOrUnplugged.setChecked(Settings.Global.getInt(getContentResolver(), + Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED, + (wakeUpWhenPluggedOrUnpluggedConfig ? 1 : 0)) == 1); + updateState(); } @@ -422,6 +435,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mTapToWake) { return TapToWake.setEnabled(mTapToWake.isChecked()); + } else if (preference == mWakeWhenPluggedOrUnplugged) { + Settings.Global.putInt(getContentResolver(), + Settings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED, + mWakeWhenPluggedOrUnplugged.isChecked() ? 1 : 0); + return true; } return super.onPreferenceTreeClick(preferenceScreen, preference); |