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

Commit 03d78c22 authored by Arian's avatar Arian Committed by Bruno Martins
Browse files

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: default avatarJesse Chan <jc@lineageos.org>
parent d4ccd5db
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1177,7 +1177,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) {
@@ -1189,6 +1189,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
@@ -1233,7 +1234,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
@@ -1636,7 +1637,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;
    }
}