Browse Source

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>
ten
Arian 1 year ago
parent
commit
c37ba3c876
No account linked to committer's email address

+ 4
- 3
packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java View File

@@ -1178,7 +1178,7 @@ public class VolumeDialogImpl implements VolumeDialog,
final StreamState ss = mState.states.get(row.stream);
if (ss == null) return;
row.ss = ss;
if (ss.level > 0) {
if (ss.level > ss.levelMin) {
row.lastAudibleLevel = ss.level;
}
if (ss.level == row.requestedLevel) {
@@ -1190,6 +1190,7 @@ public class VolumeDialogImpl implements VolumeDialog,
final boolean isAlarmStream = row.stream == STREAM_ALARM;
final boolean isMusicStream = row.stream == AudioManager.STREAM_MUSIC;
final boolean isNotificationStream = row.stream == AudioManager.STREAM_NOTIFICATION;
final boolean isMuted = row.ss.level == row.ss.levelMin;
final boolean isVibrate = mState.ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE;
final boolean isRingVibrate = isRingStream && isVibrate;
final boolean isRingSilent = isRingStream
@@ -1236,7 +1237,7 @@ public class VolumeDialogImpl implements VolumeDialog,
(ss.muted ? R.drawable.ic_volume_media_bt_mute
: R.drawable.ic_volume_media_bt)
: mAutomute && ss.level == 0 ? row.iconMuteRes
: (ss.muted ? row.iconMuteRes : row.iconRes);
: isMuted ? row.iconMuteRes : row.iconRes;
row.icon.setImageResource(iconRes);
row.iconState =
iconRes == R.drawable.ic_volume_ringer_vibrate ? Events.ICON_STATE_VIBRATE
@@ -1693,7 +1694,7 @@ public class VolumeDialogImpl implements VolumeDialog,
private int iconState; // from Events
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
private int animTargetProgress;
private int lastAudibleLevel = 1;
private int lastAudibleLevel = 2;
private FrameLayout dndIcon;
}
}

Loading…
Cancel
Save