Skip to content

Commit

Permalink
Keyhandler: Add a silent option
Browse files Browse the repository at this point in the history
-The total silence mode disables media volume too.
-Add silent option which mutes all notifications but allows media volume.
-Adapted to KeyHandler by AshwinRC | POSP

Signed-off-by: Ashwin R C <ashwin2001achu@gmail.com>
  • Loading branch information
mTresk authored and Ashwin4RC committed May 15, 2020
1 parent e3fa66e commit 43bd3a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions KeyHandler/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<string-array name="notification_slider_action_entries" translatable="false">
<item>@string/notification_slider_mode_total_silence</item>
<item>@string/notification_slider_mode_silent</item>
<item>@string/notification_slider_mode_alarms_only</item>
<item>@string/notification_slider_mode_priority_only</item>
<item>@string/notification_slider_mode_vibrate</item>
Expand All @@ -30,6 +31,7 @@
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public class KeyHandler implements DeviceKeyHandler {
private static final SparseIntArray sSupportedSliderRingModes = new SparseIntArray();
static {
sSupportedSliderZenModes.put(Constants.KEY_VALUE_TOTAL_SILENCE, Settings.Global.ZEN_MODE_NO_INTERRUPTIONS);
sSupportedSliderZenModes.put(Constants.KEY_VALUE_SILENT, Settings.Global.ZEN_MODE_OFF);
sSupportedSliderZenModes.put(Constants.KEY_VALUE_ALARMS_ONLY, Settings.Global.ZEN_MODE_ALARMS);
sSupportedSliderZenModes.put(Constants.KEY_VALUE_PRIORTY_ONLY, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
sSupportedSliderZenModes.put(Constants.KEY_VALUE_VIBRATE, Settings.Global.ZEN_MODE_OFF);
sSupportedSliderZenModes.put(Constants.KEY_VALUE_NORMAL, Settings.Global.ZEN_MODE_OFF);

sSupportedSliderRingModes.put(Constants.KEY_VALUE_TOTAL_SILENCE, AudioManager.RINGER_MODE_NORMAL);
sSupportedSliderRingModes.put(Constants.KEY_VALUE_SILENT, AudioManager.RINGER_MODE_SILENT);
sSupportedSliderRingModes.put(Constants.KEY_VALUE_ALARMS_ONLY, AudioManager.RINGER_MODE_NORMAL);
sSupportedSliderRingModes.put(Constants.KEY_VALUE_PRIORTY_ONLY, AudioManager.RINGER_MODE_NORMAL);
sSupportedSliderRingModes.put(Constants.KEY_VALUE_VIBRATE, AudioManager.RINGER_MODE_VIBRATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ public class Constants {

// Default values
public static final int KEY_VALUE_TOTAL_SILENCE = 0;
public static final int KEY_VALUE_ALARMS_ONLY = 1;
public static final int KEY_VALUE_PRIORTY_ONLY = 2;
public static final int KEY_VALUE_VIBRATE = 3;
public static final int KEY_VALUE_NORMAL = 4;
public static final int KEY_VALUE_SILENT = 1;
public static final int KEY_VALUE_ALARMS_ONLY = 2;
public static final int KEY_VALUE_PRIORTY_ONLY = 3;
public static final int KEY_VALUE_VIBRATE = 4;
public static final int KEY_VALUE_NORMAL = 5;

public static final Map<String, String> sStringKeyPreferenceMap = new HashMap<>();
public static final Map<Integer, String> sKeyMap = new HashMap<>();
Expand Down

0 comments on commit 43bd3a8

Please sign in to comment.