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

Commit aab323ea authored by William C. Garrison III's avatar William C. Garrison III Committed by Adnan Begovic
Browse files

VolumePanel: better handling of updating sliders in expanded view

Don't update all sliders willy-nilly, just the ones that need updated

This fixes the wonky animation when expanding the zen mode panel

Change-Id: Id93ff0c319f9ef15e694ea02f6ce8a35ed52976a
parent faa430be
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -717,7 +717,6 @@ public class VolumePanel extends Handler implements DemoMode {
                        public void onClick(View v) {
                            resetTimeout();
                            toggleRinger(sc);
                            updateStates();
                        }
                    });
                }
@@ -924,6 +923,25 @@ public class VolumePanel extends Handler implements DemoMode {
        updateSliderSuppressor(sc);
    }

    private void updateNotificationSlider(boolean forceReloadIcon) {
        final StreamControl notification = mStreamControls.get(AudioManager.STREAM_NOTIFICATION);
        if (notification != null) {
            updateSlider(notification, forceReloadIcon);
        }
    }

    private void updateRingerSlider(boolean forceReloadIcon) {
        // If no ringer, we should update notification slider instead
        if (!mVoiceCapable) {
            updateNotificationSlider(forceReloadIcon);
            return;
        }
        final StreamControl ringer = mStreamControls.get(AudioManager.STREAM_RING);
        if (ringer != null) {
            updateSlider(ringer, forceReloadIcon);
        }
    }

    private void updateSliderEnabled(final StreamControl sc, boolean muted, boolean fixedVolume) {
        final boolean wasEnabled = sc.seekbarView.isEnabled();
        final boolean isRinger = isNotificationOrRing(sc.streamType);
@@ -1312,6 +1330,10 @@ public class VolumePanel extends Handler implements DemoMode {
            updateSliderEnabled(sc, muted, (flags & AudioManager.FLAG_FIXED_VOLUME) != 0);
            if (isNotificationOrRing(streamType)) {
                updateSliderIcon(sc, muted);
                // If an unlinked notification slider is visible, update it as well
                if (mVoiceCapable && !mVolumeLinkNotification && mExtendedPanelExpanded) {
                    updateNotificationSlider(false);
                }
            }
        }

@@ -1605,7 +1627,10 @@ public class VolumePanel extends Handler implements DemoMode {
            case MSG_NOTIFICATION_EFFECTS_SUPPRESSOR_CHANGED: {
                if (isShowing()) {
                    if (mExtendedPanelExpanded) {
                        updateStates();
                        updateRingerSlider(false);
                        if (mVoiceCapable && !mVolumeLinkNotification) {
                            updateNotificationSlider(false);
                        }
                    } else {
                        updateActiveSlider();
                    }
@@ -1693,7 +1718,6 @@ public class VolumePanel extends Handler implements DemoMode {
                StreamControl sc = (StreamControl) tag;
                setStreamVolume(sc, progress,
                        AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
                updateStates();
            }
            resetTimeout();
        }