From 7152dd4b22b7234b5cb63e6038e472dcc0997503 Mon Sep 17 00:00:00 2001 From: Pawit Pornkitprasan Date: Sun, 21 Apr 2013 22:52:33 +0700 Subject: 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 --- src/com/android/settings/ButtonSettings.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.1