diff options
author | HazouPH <jgrharbers@gmail.com> | 2015-06-07 21:09:11 +0200 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:31 -0700 |
commit | 2d5ce26e6c369d3fdeaae1a0fa65e3eea1522a92 (patch) | |
tree | 6b4af40013deade4e4fce89a996e241e4d5b8dcc | |
parent | 86ec224cb4e5aef5a5b230bd4948ca8fb1d16b0d (diff) | |
download | packages_apps_Settings-2d5ce26e6c369d3fdeaae1a0fa65e3eea1522a92.zip packages_apps_Settings-2d5ce26e6c369d3fdeaae1a0fa65e3eea1522a92.tar.gz packages_apps_Settings-2d5ce26e6c369d3fdeaae1a0fa65e3eea1522a92.tar.bz2 |
[2/2] Camera button support
Add support for camera button
Based on commit http://review.cyanogenmod.org/#/c/52046/
This patch adds:
- Use camera button as wake key
- Use focus button as peek and wake key
- Use camera button to launch (secure) camera
Depends on
[1/2] Camera button support in frameworks/base
Change-Id: Idb959f24fec880d360afebf194a0bc573e011438
-rw-r--r-- | res/values/cm_strings.xml | 5 | ||||
-rw-r--r-- | res/xml/button_settings.xml | 24 | ||||
-rw-r--r-- | src/com/android/settings/ButtonSettings.java | 28 |
3 files changed, 57 insertions, 0 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 9cc9a66..218284e 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -333,6 +333,7 @@ <string name="hardware_keys_menu_key_title">Menu button</string> <string name="hardware_keys_assist_key_title">Search button</string> <string name="hardware_keys_appswitch_key_title">Recents button</string> + <string name="hardware_keys_camera_key_title">Camera button</string> <string name="hardware_keys_volume_keys_title">Volume buttons</string> <string name="hardware_keys_short_press_title">Short press action</string> <string name="hardware_keys_long_press_title">Long press action</string> @@ -346,6 +347,10 @@ <string name="hardware_keys_action_launch_camera">Launch camera</string> <string name="hardware_keys_action_sleep">Turn screen off</string> <string name="hardware_keys_action_last_app">Last app</string> + <string name="camera_sleep_on_release_title">Screen peek</string> + <string name="camera_sleep_on_release_summary">A half press will keep the screen on only while the button is held down</string> + <string name="camera_launch_title">Launch camera</string> + <string name="camera_launch_summary">A longpress and release will launch camera</string> <string name="volbtn_music_controls_title">Playback control</string> <string name="volbtn_music_controls_summary">When the screen is off, long pressing the volume keys will seek music tracks</string> <string name="volbtn_cursor_control_title">Keyboard cursor control</string> diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml index 773aebb..272bc22 100644 --- a/res/xml/button_settings.xml +++ b/res/xml/button_settings.xml @@ -215,6 +215,30 @@ </PreferenceCategory> <PreferenceCategory + android:key="camera_key" + android:title="@string/hardware_keys_camera_key_title" + settings:advanced="true"> + + <com.android.settings.cyanogenmod.SystemSettingSwitchPreference + android:key="camera_wake_screen" + android:title="@string/button_wake_title" + android:defaultValue="false" /> + + <com.android.settings.cyanogenmod.SystemSettingSwitchPreference + android:key="camera_sleep_on_release" + android:title="@string/camera_sleep_on_release_title" + android:summary="@string/camera_sleep_on_release_summary" + android:defaultValue="false" /> + + <com.android.settings.cyanogenmod.SystemSettingSwitchPreference + android:key="camera_launch" + android:title="@string/camera_launch_title" + android:summary="@string/camera_launch_summary" + android:defaultValue="false" /> + + </PreferenceCategory> + + <PreferenceCategory android:key="volume_keys" android:title="@string/hardware_keys_volume_keys_title" > diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index 73296d5..0c09601 100644 --- a/src/com/android/settings/ButtonSettings.java +++ b/src/com/android/settings/ButtonSettings.java @@ -121,6 +121,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private ListPreference mAssistLongPressAction; private ListPreference mAppSwitchPressAction; private ListPreference mAppSwitchLongPressAction; + private SwitchPreference mCameraWakeScreen; + private SwitchPreference mCameraSleepOnRelease; + private SwitchPreference mCameraLaunch; private ListPreference mVolumeKeyCursorControl; private SwitchPreference mVolumeWakeScreen; private SwitchPreference mVolumeMusicControls; @@ -157,6 +160,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements final boolean hasMenuKey = (deviceKeys & KEY_MASK_MENU) != 0; final boolean hasAssistKey = (deviceKeys & KEY_MASK_ASSIST) != 0; final boolean hasAppSwitchKey = (deviceKeys & KEY_MASK_APP_SWITCH) != 0; + final boolean hasCameraKey = (deviceKeys & KEY_MASK_CAMERA) != 0; final boolean hasVolumeKeys = (deviceKeys & KEY_MASK_VOLUME) != 0; final boolean showHomeWake = (deviceWakeKeys & KEY_MASK_HOME) != 0; @@ -164,6 +168,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements final boolean showMenuWake = (deviceWakeKeys & KEY_MASK_MENU) != 0; final boolean showAssistWake = (deviceWakeKeys & KEY_MASK_ASSIST) != 0; final boolean showAppSwitchWake = (deviceWakeKeys & KEY_MASK_APP_SWITCH) != 0; + final boolean showCameraWake = (deviceWakeKeys & KEY_MASK_CAMERA) != 0; final boolean showVolumeWake = (deviceWakeKeys & KEY_MASK_VOLUME) != 0; boolean hasAnyBindableKey = false; @@ -340,6 +345,18 @@ public class ButtonSettings extends SettingsPreferenceFragment implements prefScreen.removePreference(appSwitchCategory); } + if (hasCameraKey) { + if (!showCameraWake) { + prefScreen.removePreference(mCameraWakeScreen); + } + // Only show 'Camera sleep on release' if the device has a focus key + if (res.getBoolean(com.android.internal.R.bool.config_singleStageCameraKey)) { + prefScreen.removePreference(mCameraSleepOnRelease); + } + } else { + prefScreen.removePreference(mCameraLaunch); + } + if (Utils.hasVolumeRocker(getActivity())) { if (!showVolumeWake) { volumeCategory.removePreference(findPreference(Settings.System.VOLUME_WAKE_SCREEN)); @@ -389,6 +406,17 @@ public class ButtonSettings extends SettingsPreferenceFragment implements Utils.updatePreferenceToSpecificActivityFromMetaDataOrRemove(getActivity(), getPreferenceScreen(), KEY_BLUETOOTH_INPUT_SETTINGS); + mCameraWakeScreen = (SwitchPreference) findPreference(Settings.System.CAMERA_WAKE_SCREEN); + mCameraSleepOnRelease = + (SwitchPreference) findPreference(Settings.System.CAMERA_SLEEP_ON_RELEASE); + mCameraLaunch = (SwitchPreference) findPreference(Settings.System.CAMERA_LAUNCH); + + if (mCameraWakeScreen != null) { + if (mCameraSleepOnRelease != null && !getResources().getBoolean( + com.android.internal.R.bool.config_singleStageCameraKey)) { + mCameraSleepOnRelease.setDependency(Settings.System.CAMERA_WAKE_SCREEN); + } + } mVolumeWakeScreen = (SwitchPreference) findPreference(Settings.System.VOLUME_WAKE_SCREEN); mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS); |