diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2013-04-21 22:52:33 +0700 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:31 -0700 |
commit | 7152dd4b22b7234b5cb63e6038e472dcc0997503 (patch) | |
tree | cc8aad13536b6285ce2b5e2a80714d2fb6c1ee02 | |
parent | 14c91238695b94d3bdff6404e3b791fb00a4375f (diff) | |
download | packages_apps_Settings-7152dd4b22b7234b5cb63e6038e472dcc0997503.zip packages_apps_Settings-7152dd4b22b7234b5cb63e6038e472dcc0997503.tar.gz packages_apps_Settings-7152dd4b22b7234b5cb63e6038e472dcc0997503.tar.bz2 |
Option to use volume keys to control media volume anytime (1/2)
Some users don't adjust ringtone volume often (e.g. only use toggle to
switch between silent and non-silent) mode. Having an option to
use the volume keys to control media volume anytime allows media
volume to be controllled/muted before entering a game or other apps
with sound in an undesirable location.
Change-Id: I6dbd25d1a14bcf5b1bf0b0468b96f4b4f8efdb14
-rw-r--r-- | res/values/cm_strings.xml | 4 | ||||
-rw-r--r-- | res/xml/button_settings.xml | 6 | ||||
-rw-r--r-- | src/com/android/settings/ButtonSettings.java | 16 |
3 files changed, 24 insertions, 2 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 104ec13..9cc9a66 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -202,7 +202,6 @@ <!-- Profiles --> <string name="profile_menu_delete_title">Delete</string> <string name="profile_menu_triggers_title">Modify triggers</string> - <string name="profile_action_none">Leave unchanged</string> <string name="profile_action_system">System default</string> <string name="profile_action_disable">Turn off</string> @@ -553,4 +552,7 @@ <string name="lto_download_data_wifi_only">GPS assisted data download</string> <string name="lto_download_data_wifi_only_on">Over any networks</string> <string name="lto_download_data_wifi_only_off">Only over Wi\u2011Fi networks</string> + + <string name="volume_keys_control_ring_stream_title">Volume keys control ringtone volume</string> + <string name="volume_keys_control_ring_stream_summary">If on, volume keys control ringtone volume. If off, volume keys control media volume.</string> </resources> diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml index b232cc2..773aebb 100644 --- a/res/xml/button_settings.xml +++ b/res/xml/button_settings.xml @@ -229,6 +229,12 @@ android:summary="@string/volbtn_music_controls_summary" android:defaultValue="true" /> + <com.android.settings.cyanogenmod.SecureSettingSwitchPreference + android:key="volume_keys_control_ring_stream" + android:title="@string/volume_keys_control_ring_stream_title" + android:summary="@string/volume_keys_control_ring_stream_summary" + settings:advanced="true" /> + <ListPreference android:key="volume_key_cursor_control" android:dialogTitle="@string/volbtn_cursor_control_title" diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index f9d29e2..d200679 100644 --- a/src/com/android/settings/ButtonSettings.java +++ b/src/com/android/settings/ButtonSettings.java @@ -77,6 +77,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private static final String KEY_HOME_ANSWER_CALL = "home_answer_call"; private static final String KEY_BLUETOOTH_INPUT_SETTINGS = "bluetooth_input_settings"; private static final String KEY_VOLUME_MUSIC_CONTROLS = "volbtn_music_controls"; + private static final String KEY_VOLUME_CONTROL_RING_STREAM = "volume_keys_control_ring_stream"; private static final String CATEGORY_POWER = "power_key"; private static final String CATEGORY_HOME = "home_key"; @@ -123,6 +124,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private ListPreference mVolumeKeyCursorControl; private SwitchPreference mVolumeWakeScreen; private SwitchPreference mVolumeMusicControls; + private SwitchPreference mVolumeControlRingStream; private SwitchPreference mSwapVolumeButtons; private SwitchPreference mDisableNavigationKeys; private SwitchPreference mNavigationBarLeftPref; @@ -201,7 +203,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements initRecentsLongPressAction(KEY_NAVIGATION_RECENTS_LONG_PRESS); final CmHardwareManager cmHardwareManager = - (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE); + (CmHardwareManager) getActivity().getSystemService(Context.CMHW_SERVICE); // Only visible on devices that does not have a navigation bar already, // and don't even try unless the existing keys can be disabled @@ -390,6 +392,14 @@ public class ButtonSettings extends SettingsPreferenceFragment implements mVolumeWakeScreen = (SwitchPreference) findPreference(Settings.System.VOLUME_WAKE_SCREEN); mVolumeMusicControls = (SwitchPreference) findPreference(KEY_VOLUME_MUSIC_CONTROLS); + mVolumeControlRingStream = (SwitchPreference) + findPreference(KEY_VOLUME_CONTROL_RING_STREAM); + int volumeControlRingtone = Settings.System.getInt(getContentResolver(), + Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, 1); + if (mVolumeControlRingStream != null) { + mVolumeControlRingStream.setChecked(volumeControlRingtone > 0); + } + if (mVolumeWakeScreen != null) { if (mVolumeMusicControls != null) { mVolumeMusicControls.setDependency(Settings.System.VOLUME_WAKE_SCREEN); @@ -666,6 +676,10 @@ public class ButtonSettings extends SettingsPreferenceFragment implements ? (Utils.isTablet(getActivity()) ? 2 : 1) : 0; Settings.System.putInt(getActivity().getContentResolver(), Settings.System.SWAP_VOLUME_KEYS_ON_ROTATION, value); + } else if (preference == mVolumeControlRingStream) { + int value = mVolumeControlRingStream.isChecked() ? 1 : 0; + Settings.System.putInt(getActivity().getContentResolver(), + Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, value); } else if (preference == mDisableNavigationKeys) { mDisableNavigationKeys.setEnabled(false); mNavigationPreferencesCat.setEnabled(false); |