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

Commit 1e732fff 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 257868c9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -182,6 +182,14 @@
                    android:text="@string/link_volume_mutes"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                />
            <CheckBox
                    android:id="@+id/volume_keys_control_ring_stream"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="start"
                    android:text="@string/volume_keys_control_ring_stream"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                />
        </LinearLayout>

        <TextView
+1 −0
Original line number Diff line number Diff line
@@ -453,6 +453,7 @@

    <string name="link_volume_ringtones">Link ringtone &amp; notifications volumes</string>
    <string name="link_volume_mutes">Silent mode affects notifications</string>
    <string name="volume_keys_control_ring_stream">Volume keys control ringtone volume</string>

    <!-- Display settings screen, notification light settings -->
    <string name="notification_pulse_title">Notification light</string>
+19 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ public class RingerVolumePreference extends VolumePreference {

        final CheckBox linkCheckBox = (CheckBox) view.findViewById(R.id.link_ring_and_volume);
        final CheckBox linkMuteStates = (CheckBox) view.findViewById(R.id.link_mutes);
        final CheckBox volumeKeysControlRingStream = (CheckBox) view.findViewById(R.id.volume_keys_control_ring_stream);

        final View ringerSection = view.findViewById(R.id.ringer_section);
        final View notificationSection = view.findViewById(R.id.notification_section);
@@ -256,6 +257,24 @@ public class RingerVolumePreference extends VolumePreference {
                }

            });

            if (System.getInt(getContext().getContentResolver(),
                    System.VOLUME_KEYS_CONTROL_RING_STREAM, 1) == 1) {
                volumeKeysControlRingStream.setChecked(true);
            } else {
                volumeKeysControlRingStream.setChecked(false);
            }

            volumeKeysControlRingStream.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    Settings.System.putInt(buttonView.getContext().getContentResolver(),
                            Settings.System.VOLUME_KEYS_CONTROL_RING_STREAM, isChecked ? 1 : 0);
                }

            });

        } else {
            ringerSection.setVisibility(View.GONE);
            linkVolumesSection.setVisibility(View.GONE);