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

Commit a72faf94 authored by Michael Wright's avatar Michael Wright
Browse files

Re-initialize the brightness slider when out of sync.

Whenever the brightness controller stops listening to brightness events,
it could get out of sync and so will animate when next opened and it
re-registers. We want to avoid this animation since it looks odd to the
user so we always re-initialize whenever we might get out of sync.

Bug: 72635553
Test: manual
Change-Id: I3a7e05e18652af33511a5de5a8ebeee01d2f0349
parent 88ca395b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public class BrightnessController implements ToggleSlider.Listener {
    private volatile boolean mIsVrModeEnabled;
    private boolean mListening;
    private boolean mExternalChange;
    private boolean mControlInitialized;
    private boolean mControlValueInitialized;

    private ValueAnimator mSliderAnimator;

@@ -337,6 +337,7 @@ public class BrightnessController implements ToggleSlider.Listener {

        mBackgroundHandler.post(mStopListeningRunnable);
        mListening = false;
        mControlValueInitialized = false;
    }

    @Override
@@ -428,10 +429,10 @@ public class BrightnessController implements ToggleSlider.Listener {
    }

    private void animateSliderTo(int target) {
        if (!mControlInitialized) {
        if (!mControlValueInitialized) {
            // Don't animate the first value since it's default state isn't meaningful to users.
            mControl.setValue(target);
            mControlInitialized = true;
            mControlValueInitialized = true;
        }
        if (mSliderAnimator != null && mSliderAnimator.isStarted()) {
            mSliderAnimator.cancel();