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

Commit 5a3899b2 authored by Umang96's avatar Umang96 Committed by Michael W
Browse files

SystemUI: Fix alignment glitch with brightness mirror

Alignment of brightness mirror dialog was not exatly same as the
QS brightness dialog, which produced a visual glitch of slider
thumb shifting whenever we change brightness.
This is solved by dynamically handling the visibility of
mirror brightness icon, gone when brightness icon is off and
invisible when brightness icon is on, so that both mirror and
QS slider are equally aligned.

[BadDaemon]
Updated code to reflect the code style (using more methods) and trying to
reduce the footprint of the code impact

Change-Id: Ifb85643db669ee8d7473d3c48e7e4733428a77d6
parent 955996a0
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    private Record mDetailRecord;

    private BrightnessMirrorController mBrightnessMirrorController;
    private ImageView mMirrorAutoBrightnessView;
    private View mDivider;

    public QSPanel(Context context) {
@@ -232,6 +233,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
            updateViewVisibilityForTuningValue(mAutoBrightnessView, newValue);
        } else if (QS_SHOW_BRIGHTNESS_SLIDER.equals(key)) {
            updateViewVisibilityForTuningValue(mBrightnessView, newValue);
            updateViewVisibilityForBrightnessMirrorIcon(newValue);
        }
    }

@@ -239,6 +241,18 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        view.setVisibility(TunerService.parseIntegerSwitch(newValue, true) ? VISIBLE : GONE);
    }

    private void updateViewVisibilityForBrightnessMirrorIcon(@Nullable String newValue) {
        if (mMirrorAutoBrightnessView != null) {
            mMirrorAutoBrightnessView.setVisibility(
                    TunerService.parseIntegerSwitch(newValue, true) ? INVISIBLE : GONE);
        } else if (mBrightnessMirrorController != null) {
            mMirrorAutoBrightnessView = mBrightnessMirrorController.getMirror()
                    .findViewById(R.id.brightness_icon);
            mMirrorAutoBrightnessView.setVisibility(mAutoBrightnessView.getVisibility()
                    == VISIBLE ? INVISIBLE : GONE);
        }
    }

    public void openDetails(String subPanel) {
        QSTile tile = getTile(subPanel);
        // If there's no tile with that name (as defined in QSFactoryImpl or other QSFactory),
@@ -266,6 +280,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
            mBrightnessMirrorController.addCallback(this);
        }
        updateBrightnessMirror();
        updateViewVisibilityForBrightnessMirrorIcon(null);
    }

    @Override