Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f302629c authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Gerrit Code Review
Browse files

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
parent f84af763
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@
    <string name="volbtn_cursor_control_on_reverse">Volume up/down moves cursor right/left</string>
    <string name="swap_volume_buttons_title">Reorient</string>
    <string name="swap_volume_buttons_summary">Swap volume buttons when the screen is rotated</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>
    <string name="power_end_call_title">End call</string>
    <string name="power_end_call_summary">Pressing the power button will end the current call</string>
    <string name="button_wake_title">Wake up device</string>
+6 −0
Original line number Diff line number Diff line
@@ -232,6 +232,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"
+14 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
    private static final String KEY_POWER_END_CALL = "power_end_call";
    private static final String KEY_HOME_ANSWER_CALL = "home_answer_call";
    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;
@@ -204,6 +206,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);
@@ -692,6 +702,10 @@ public class ButtonSettings extends SettingsPreferenceFragment implements
                    ? (ScreenType.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);