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

Commit ca37559e authored by Eran's avatar Eran Committed by Steve Kondik
Browse files

Add selection of silent mode with volume control. Settings part.

Allows volume buttons to control "silent <-> vibrate <-> volume",
when the appropriate setting is enabled.

Patch by Alex Hofbauer.
Original patch and small fix by Eran Mizrahi.

Change-Id: I58e7f01697b5d2008fb939b0ba0a2965e97a24ce
parent 083c8410
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -322,6 +322,8 @@
    <string name="sound_summary">Sound and audio focus settings</string>
    <string name="sound_notifications_focus_title">Notification focus</string>
    <string name="sound_notifications_focus_summary">Audio focus requests causes compatible apps to lower the volume while notifications play.</string>
    <string name="sound_volume_control_silent_title">Silent state</string>
    <string name="sound_volume_control_silent_summary">Add a state for complete silence to volume control</string>
    <string name="sound_to_speaker_title">Always play on speaker</string>
    <string name="sound_notifications_title">Notifications</string>
    <string name="sound_rings_title">Ring tones</string>
+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,12 @@
        android:summary="@string/sound_notifications_focus_summary"
        android:persistent="false" />

    <!-- Silent state -->
    <CheckBoxPreference android:key="vol-ctrl-silent"
        android:title="@string/sound_volume_control_silent_title"
        android:summary="@string/sound_volume_control_silent_summary"
        android:persistent="false" />

    <!-- Some spacing -->
    <PreferenceCategory />

+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ public class SoundActivity extends PreferenceActivity implements
    private static final String NOTIFICATIONS_SPEAKER = "notif-speaker";
    private static final String NOTIFICATIONS_ATTENUATION = "notif-attn";
    private static final String NOTIFICATIONS_LIMITVOL = "notif-limitvol";
    private static final String VOLUME_CONTROL_SILENT = "vol-ctrl-silent";
    private static final String RINGS_SPEAKER = "ring-speaker";
    private static final String RINGS_ATTENUATION = "ring-attn";
    private static final String RINGS_LIMITVOL = "ring-limitvol";
@@ -87,6 +88,11 @@ public class SoundActivity extends PreferenceActivity implements
        p.setChecked(SystemProperties.getBoolean(getKey(NOTIFICATIONS_SPEAKER), false));
        p.setOnPreferenceChangeListener(this);

        p = (CheckBoxPreference) prefSet.findPreference(VOLUME_CONTROL_SILENT);
        p.setChecked(Settings.System.getInt(getContentResolver(),
                                            Settings.System.VOLUME_CONTROL_SILENT, 0) != 0);
        p.setOnPreferenceChangeListener(this);

        p = (CheckBoxPreference) prefSet.findPreference(RINGS_SPEAKER);
        p.setChecked(SystemProperties.getBoolean(getKey(RINGS_SPEAKER), false));
        p.setOnPreferenceChangeListener(this);
@@ -175,6 +181,9 @@ public class SoundActivity extends PreferenceActivity implements
        if (key.equals(NOTIFICATIONS_FOCUS)) {
            Settings.System.putInt(getContentResolver(), Settings.System.NOTIFICATIONS_AUDIO_FOCUS,
                    getBoolean(newValue) ? 1 : 0);
        } else if (key.equals (VOLUME_CONTROL_SILENT)) {
            Settings.System.putInt(getContentResolver(), Settings.System.VOLUME_CONTROL_SILENT,
                    getBoolean(newValue) ? 1 : 0);
        } else if (key.equals(NOTIFICATIONS_SPEAKER) || key.equals(RINGS_SPEAKER)
                || key.equals(ALARMS_SPEAKER)) {
            SystemProperties.set(getKey(key), getBoolean(newValue) ? "1" : "0");