Skip to content

Commit 03d78c2

Browse files
ArianK16abgcngm
authored andcommitted
VolumeDialog: Fix muting streams with a minimal volume of 1
* Alarm and voice call streams report 1 as levelMin and hence ss.muted is never true, so that the muted icon never shows. After the first tap lastAudibleLevel is 1 so that the second tap only sets it back to 1, the minimal value for some streams. That leads to a bad UX when tapping on the icon because the first tap sets it to the minimal level and another tap just keeps it there. * With this patch we only set lastAudibleLevel if the current level is higher then levelMin instead of the hard-coded value of 0 so that the first tap sets the volume to its minimal value and the icon changes to the muted icon and the second tap restores the previous volume. * Also replace the check to show the muted icon with a check wether the current level is the minimal level. * Increase the default value of lastAudibleLevel to 2 so that it is never equal to the minimal value. Change-Id: I6d0d3960a42c949e2afd61eab86f5e3ffb8fa1b5 Signed-off-by: Jesse Chan <jc@lineageos.org>
1 parent d4ccd5d commit 03d78c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ private void updateVolumeRowH(VolumeRow row) {
11771177
final StreamState ss = mState.states.get(row.stream);
11781178
if (ss == null) return;
11791179
row.ss = ss;
1180-
if (ss.level > 0) {
1180+
if (ss.level > ss.levelMin) {
11811181
row.lastAudibleLevel = ss.level;
11821182
}
11831183
if (ss.level == row.requestedLevel) {
@@ -1189,6 +1189,7 @@ private void updateVolumeRowH(VolumeRow row) {
11891189
final boolean isAlarmStream = row.stream == STREAM_ALARM;
11901190
final boolean isMusicStream = row.stream == AudioManager.STREAM_MUSIC;
11911191
final boolean isNotificationStream = row.stream == AudioManager.STREAM_NOTIFICATION;
1192+
final boolean isMuted = row.ss.level == row.ss.levelMin;
11921193
final boolean isVibrate = mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE;
11931194
final boolean isRingVibrate = isRingStream && isVibrate;
11941195
final boolean isRingSilent = isRingStream
@@ -1233,7 +1234,7 @@ private void updateVolumeRowH(VolumeRow row) {
12331234
(ss.muted ? R.drawable.ic_volume_media_bt_mute
12341235
: R.drawable.ic_volume_media_bt)
12351236
: mAutomute && ss.level == 0 ? row.iconMuteRes
1236-
: (ss.muted ? row.iconMuteRes : row.iconRes);
1237+
: isMuted ? row.iconMuteRes : row.iconRes;
12371238
row.icon.setImageResource(iconRes);
12381239
row.iconState =
12391240
iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE
@@ -1636,7 +1637,7 @@ private static class VolumeRow {
16361637
private int iconState; // from Events
16371638
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
16381639
private int animTargetProgress;
1639-
private int lastAudibleLevel = 1;
1640+
private int lastAudibleLevel = 2;
16401641
private FrameLayout dndIcon;
16411642
}
16421643
}

0 commit comments

Comments
 (0)