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

Commit 48e093e6 authored by Jason Monk's avatar Jason Monk
Browse files

QS Detail: Don't animate switch before panel open

This will make it more obvious that wifi gets turned on by opening
the panel as the animation of the state change will be visible.

Change-Id: I6ceb0bef914a9ff368b1bdb750d19aeb43593e78
Fixes: 29057528
parent 3ed2a52b
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ public class QSDetail extends LinearLayout {
    private boolean mTriggeredExpand;
    private int mOpenX;
    private int mOpenY;
    private boolean mAnimating;
    private boolean mSwitchState;

    public QSDetail(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
@@ -158,7 +160,7 @@ public class QSDetail extends LinearLayout {
                mQsDetailHeader.setClickable(false);
            } else {
                mQsDetailHeaderSwitch.setVisibility(VISIBLE);
                mQsDetailHeaderSwitch.setChecked(toggleState);
                handleToggleStateChanged(toggleState);
                mQsDetailHeader.setClickable(true);
                mQsDetailHeader.setOnClickListener(new OnClickListener() {
                    @Override
@@ -228,6 +230,7 @@ public class QSDetail extends LinearLayout {
        }
        sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        if (visibleDiff) {
            mAnimating = true;
            if (mFullyExpanded || mDetailAdapter != null) {
                setAlpha(1);
                mClipper.animateCircularClip(x, y, mDetailAdapter != null, listener);
@@ -241,6 +244,10 @@ public class QSDetail extends LinearLayout {
    }

    private void handleToggleStateChanged(boolean state) {
        mSwitchState = state;
        if (mAnimating) {
            return;
        }
        mQsDetailHeaderSwitch.setChecked(state);
    }

@@ -257,6 +264,10 @@ public class QSDetail extends LinearLayout {
        }
    }

    private void checkPendingAnimations() {
        handleToggleStateChanged(mSwitchState);
    }

    private final QSPanel.Callback mQsPanelCallback = new QSPanel.Callback() {
        @Override
        public void onToggleStateChanged(final boolean state) {
@@ -294,6 +305,8 @@ public class QSDetail extends LinearLayout {
            // If we have been cancelled, remove the listener so that onAnimationEnd doesn't get
            // called, this will avoid accidentally turning off the grid when we don't want to.
            animation.removeListener(this);
            mAnimating = false;
            checkPendingAnimations();
        };

        @Override
@@ -303,6 +316,8 @@ public class QSDetail extends LinearLayout {
                mQsPanel.setGridContentVisibility(false);
                mHeader.setVisibility(View.INVISIBLE);
            }
            mAnimating = false;
            checkPendingAnimations();
        }
    };

+1 −1
Original line number Diff line number Diff line
@@ -90,11 +90,11 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
            mHost.startActivityDismissingKeyguard(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
            return;
        }
        showDetail(true);
        if (!mState.value) {
            mState.value = true;
            mController.setBluetoothEnabled(true);
        }
        showDetail(true);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -122,9 +122,9 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
        if (mState.value) {
            mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
        } else {
            showDetail(true);
            int zen = Prefs.getInt(mContext, Prefs.Key.DND_FAVORITE_ZEN, Global.ZEN_MODE_ALARMS);
            mController.setZen(zen, null, TAG);
            showDetail(true);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -113,11 +113,11 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
            mHost.startActivityDismissingKeyguard(new Intent(Settings.ACTION_WIFI_SETTINGS));
            return;
        }
        showDetail(true);
        if (!mState.value) {
            mController.setWifiEnabled(true);
            mState.value = true;
        }
        showDetail(true);
    }

    @Override