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

Commit ac2e2918 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "QS Detail: Fix up open/close animations" into nyc-dev

parents 972b9021 66448936
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ public class QSContainer extends FrameLayout {
    private void updateQsState() {
        boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling || mHeaderAnimating;
        mQSPanel.setExpanded(mQsExpanded);
        mQSDetail.setExpanded(mQsExpanded);
        mHeader.setVisibility((mQsExpanded || !mKeyguardShowing || mHeaderAnimating)
                ? View.VISIBLE
                : View.INVISIBLE);
+27 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;

import com.android.internal.logging.MetricsLogger;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
@@ -64,6 +65,9 @@ public class QSDetail extends LinearLayout {
    private boolean mFullyExpanded;
    private View mQsDetailHeaderBack;
    private BaseStatusBarHeader mHeader;
    private boolean mTriggeredExpand;
    private int mOpenX;
    private int mOpenY;

    public QSDetail(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
@@ -112,6 +116,7 @@ public class QSDetail extends LinearLayout {
    public void setQsPanel(QSPanel panel, BaseStatusBarHeader header) {
        mQsPanel = panel;
        mHeader = header;
        mHeader.setCallback(mQsPanelCallback);
        mQsPanel.setCallback(mQsPanelCallback);
    }

@@ -126,6 +131,12 @@ public class QSDetail extends LinearLayout {
        mFullyExpanded = fullyExpanded;
    }

    public void setExpanded(boolean qsExpanded) {
        if (!qsExpanded) {
            mTriggeredExpand = false;
        }
    }

    private void updateDetailText() {
        mDetailDoneButton.setText(R.string.quick_settings_done);
        mDetailSettingsButton.setText(R.string.quick_settings_more_settings);
@@ -161,6 +172,22 @@ public class QSDetail extends LinearLayout {
                    }
                });
            }
            if (!mFullyExpanded) {
                mTriggeredExpand = true;
                mHost.animateToggleQSExpansion();
            } else {
                mTriggeredExpand = false;
            }
            mOpenX = x;
            mOpenY = y;
        } else {
            // Ensure we collapse into the same point we opened from.
            x = mOpenX;
            y = mOpenY;
            if (mTriggeredExpand) {
                mHost.animateToggleQSExpansion();
                mTriggeredExpand = false;
            }
        }

        boolean visibleDiff = (mDetailAdapter != null) != (adapter != null);
+14 −15
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.res.Resources;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -56,7 +57,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {

    private int mPanelPaddingBottom;
    private int mBrightnessPaddingTop;
    private boolean mExpanded;
    protected boolean mExpanded;
    protected boolean mListening;

    private Callback mCallback;
@@ -70,7 +71,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {

    private QSCustomizer mCustomizePanel;
    private Record mDetailRecord;
    private boolean mTriggeredExpand;

    public QSPanel(Context context) {
        this(context, null);
@@ -221,7 +221,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
        }
        MetricsLogger.visibility(mContext, MetricsEvent.QS_PANEL, mExpanded);
        if (!mExpanded) {
            mTriggeredExpand = false;
            closeDetail();
        } else {
            logTiles();
@@ -279,6 +278,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
    public void setTiles(Collection<QSTile<?>> tiles, boolean collapsedView) {
        for (TileRecord record : mRecords) {
            mTileLayout.removeTile(record);
            record.tile.removeCallback(record.callback);
        }
        mRecords.clear();
        for (QSTile<?> tile : tiles) {
@@ -294,6 +294,10 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
        return new QSTileView(mContext, tile.createTileView(mContext), collapsedView);
    }

    protected boolean shouldShowDetail() {
        return mExpanded;
    }

    protected void addTile(final QSTile<?> tile, boolean collapsedView) {
        final TileRecord r = new TileRecord();
        r.tile = tile;
@@ -306,8 +310,12 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {

            @Override
            public void onShowDetail(boolean show) {
                // Both the collapsed and full QS panels get this callback, this check determines
                // which one should handle showing the detail.
                if (shouldShowDetail()) {
                    QSPanel.this.showDetail(show, r);
                }
            }

            @Override
            public void onToggleStateChanged(boolean state) {
@@ -330,6 +338,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
            }
        };
        r.tile.addCallback(callback);
        r.callback = callback;
        final View.OnClickListener click = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
@@ -390,17 +399,6 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
    }

    protected void handleShowDetail(Record r, boolean show) {
        if (show) {
            if (!mExpanded) {
                mTriggeredExpand = true;
                mHost.animateToggleQSExpansion();
            } else {
                mTriggeredExpand = false;
            }
        } else if (mTriggeredExpand) {
            mHost.animateToggleQSExpansion();
            mTriggeredExpand = false;
        }
        if (r instanceof TileRecord) {
            handleShowDetailTile((TileRecord) r, show);
        } else {
@@ -520,6 +518,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback {
        public QSTile<?> tile;
        public QSTileBaseView tileView;
        public boolean scanState;
        public QSTile.Callback callback;
    }

    public interface Callback {
+13 −1
Original line number Diff line number Diff line
@@ -161,6 +161,10 @@ public abstract class QSTile<TState extends State> {
        mHandler.obtainMessage(H.ADD_CALLBACK, callback).sendToTarget();
    }

    public void removeCallback(Callback callback) {
        mHandler.obtainMessage(H.REMOVE_CALLBACK, callback).sendToTarget();
    }

    public void removeCallbacks() {
        mHandler.sendEmptyMessage(H.REMOVE_CALLBACKS);
    }
@@ -224,6 +228,10 @@ public abstract class QSTile<TState extends State> {
        handleRefreshState(null);
    }

    private void handleRemoveCallback(Callback callback) {
        mCallbacks.remove(callback);
    }

    private void handleRemoveCallbacks() {
        mCallbacks.clear();
    }
@@ -334,7 +342,8 @@ public abstract class QSTile<TState extends State> {
        private static final int DESTROY = 10;
        private static final int CLEAR_STATE = 11;
        private static final int REMOVE_CALLBACKS = 12;
        private static final int SET_LISTENING = 13;
        private static final int REMOVE_CALLBACK = 13;
        private static final int SET_LISTENING = 14;

        private H(Looper looper) {
            super(looper);
@@ -350,6 +359,9 @@ public abstract class QSTile<TState extends State> {
                } else if (msg.what == REMOVE_CALLBACKS) {
                    name = "handleRemoveCallbacks";
                    handleRemoveCallbacks();
                } else if (msg.what == REMOVE_CALLBACK) {
                    name = "handleRemoveCallback";
                    handleRemoveCallback((QSTile.Callback) msg.obj);
                } else if (msg.what == CLICK) {
                    name = "handleClick";
                    if (mState.disabledByPolicy) {
+5 −5
Original line number Diff line number Diff line
@@ -76,6 +76,11 @@ public class QuickQSPanel extends QSPanel {
        mHeader = header;
    }

    @Override
    protected boolean shouldShowDetail() {
        return !mExpanded;
    }

    @Override
    protected void drawTile(TileRecord r, State state) {
        if (state instanceof SignalState) {
@@ -89,11 +94,6 @@ public class QuickQSPanel extends QSPanel {
        super.drawTile(r, state);
    }

    @Override
    protected void showDetail(boolean show, Record r) {
        // Do nothing, will be handled by the QSPanel.
    }

    @Override
    protected QSTileBaseView createTileView(QSTile<?> tile, boolean collapsedView) {
        return new QSTileBaseView(mContext, tile.createTileView(mContext), collapsedView);
Loading