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

Commit 3e241345 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Android (Google) Code Review
Browse files

Merge "Use only a single TileLayout in QSPanel" into sc-dev

parents e54680b3 464e4ad2
Loading
Loading
Loading
Loading
+15 −45
Original line number Diff line number Diff line
@@ -98,11 +98,7 @@ public class QSPanel extends LinearLayout implements Tunable {
    private LinearLayout mHorizontalLinearLayout;
    protected LinearLayout mHorizontalContentContainer;

    // Only used with media
    private QSTileLayout mHorizontalTileLayout;
    protected QSTileLayout mRegularTileLayout;
    protected QSTileLayout mTileLayout;
    private int mLastOrientation = -1;
    private int mMediaTotalBottomMargin;

    public QSPanel(Context context, AttributeSet attrs) {
@@ -119,8 +115,7 @@ public class QSPanel extends LinearLayout implements Tunable {
    }

    void initialize() {
        mRegularTileLayout = createRegularTileLayout();
        mTileLayout = mRegularTileLayout;
        mTileLayout = getOrCreateTileLayout();

        if (mUsingMediaPlayer) {
            mHorizontalLinearLayout = new RemeasuringLinearLayout(mContext);
@@ -133,7 +128,6 @@ public class QSPanel extends LinearLayout implements Tunable {
            mHorizontalContentContainer.setClipChildren(true);
            mHorizontalContentContainer.setClipToPadding(false);

            mHorizontalTileLayout = createHorizontalTileLayout();
            LayoutParams lp = new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
            int marginSize = (int) mContext.getResources().getDimension(R.dimen.qs_media_padding);
            lp.setMarginStart(0);
@@ -176,17 +170,12 @@ public class QSPanel extends LinearLayout implements Tunable {
    }

    /** */
    public QSTileLayout createRegularTileLayout() {
        if (mRegularTileLayout == null) {
            mRegularTileLayout = (QSTileLayout) LayoutInflater.from(mContext)
    public QSTileLayout getOrCreateTileLayout() {
        if (mTileLayout == null) {
            mTileLayout = (QSTileLayout) LayoutInflater.from(mContext)
                    .inflate(R.layout.qs_paged_tile_layout, this, false);
        }
        return mRegularTileLayout;
    }


    protected QSTileLayout createHorizontalTileLayout() {
        return createRegularTileLayout();
        return mTileLayout;
    }

    @Override
@@ -273,18 +262,18 @@ public class QSPanel extends LinearLayout implements Tunable {
     * @param pageIndicator indicator to use for page scrolling
     */
    public void setFooterPageIndicator(PageIndicator pageIndicator) {
        if (mRegularTileLayout instanceof PagedTileLayout) {
        if (mTileLayout instanceof PagedTileLayout) {
            mFooterPageIndicator = pageIndicator;
            updatePageIndicator();
        }
    }

    private void updatePageIndicator() {
        if (mRegularTileLayout instanceof PagedTileLayout) {
        if (mTileLayout instanceof PagedTileLayout) {
            if (mFooterPageIndicator != null) {
                mFooterPageIndicator.setVisibility(View.GONE);

                ((PagedTileLayout) mRegularTileLayout).setPageIndicator(mFooterPageIndicator);
                ((PagedTileLayout) mTileLayout).setPageIndicator(mFooterPageIndicator);
            }
        }
    }
@@ -354,7 +343,7 @@ public class QSPanel extends LinearLayout implements Tunable {
        return true;
    }

    protected boolean needsDynamicRowsAndColumns() {
    private boolean needsDynamicRowsAndColumns() {
        return true;
    }

@@ -669,39 +658,20 @@ public class QSPanel extends LinearLayout implements Tunable {
    }

    protected void setPageMargin(int pageMargin) {
        if (mRegularTileLayout instanceof PagedTileLayout) {
            ((PagedTileLayout) mRegularTileLayout).setPageMargin(pageMargin);
        }
        if (mHorizontalTileLayout != mRegularTileLayout
                && mHorizontalTileLayout instanceof PagedTileLayout) {
            ((PagedTileLayout) mHorizontalTileLayout).setPageMargin(pageMargin);
        if (mTileLayout instanceof PagedTileLayout) {
            ((PagedTileLayout) mTileLayout).setPageMargin(pageMargin);
        }
    }

    void setUsingHorizontalLayout(boolean horizontal, ViewGroup mediaHostView, boolean force,
            UiEventLogger uiEventLogger) {
    void setUsingHorizontalLayout(boolean horizontal, ViewGroup mediaHostView, boolean force) {
        if (horizontal != mUsingHorizontalLayout || force) {
            mUsingHorizontalLayout = horizontal;
            View visibleView = horizontal ? mHorizontalLinearLayout : (View) mRegularTileLayout;
            View hiddenView = horizontal ? (View) mRegularTileLayout : mHorizontalLinearLayout;
            ViewGroup newParent = horizontal ? mHorizontalContentContainer : this;
            QSPanel.QSTileLayout newLayout = horizontal
                    ? mHorizontalTileLayout : mRegularTileLayout;
            if (hiddenView != null
                    && (mRegularTileLayout != mHorizontalTileLayout
                    || hiddenView != mRegularTileLayout)) {
                // Only hide the view if the horizontal and the regular view are different,
                // otherwise its reattached.
                hiddenView.setVisibility(View.GONE);
            }
            visibleView.setVisibility(View.VISIBLE);
            switchAllContentToParent(newParent, newLayout);
            switchAllContentToParent(newParent, mTileLayout);
            reAttachMediaHost(mediaHostView, horizontal);
            mTileLayout = newLayout;
            newLayout.setListening(mListening, uiEventLogger);
            if (needsDynamicRowsAndColumns()) {
                newLayout.setMinRows(horizontal ? 2 : 1);
                newLayout.setMaxColumns(horizontal ? 2 : 4);
                mTileLayout.setMinRows(horizontal ? 2 : 1);
                mTileLayout.setMaxColumns(horizontal ? 2 : 4);
            }
            updateMargins(mediaHostView);
        }
+2 −2
Original line number Diff line number Diff line
@@ -147,14 +147,14 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
            mBrightnessMirrorController.addCallback(mBrightnessMirrorListener);
        }

        ((PagedTileLayout) mView.createRegularTileLayout())
        ((PagedTileLayout) mView.getOrCreateTileLayout())
                .setOnTouchListener(mTileLayoutTouchListener);
    }

    @Override
    protected QSTileRevealController createTileRevealController() {
        return mQsTileRevealControllerFactory.create(
                this, (PagedTileLayout) mView.createRegularTileLayout());
                this, (PagedTileLayout) mView.getOrCreateTileLayout());
    }

    @Override
+2 −10
Original line number Diff line number Diff line
@@ -297,20 +297,12 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
    }

    boolean switchTileLayout(boolean force) {
        /** Whether or not the QuickQSPanel currently contains a media player. */
        /* Whether or not the panel currently contains a media player. */
        boolean horizontal = shouldUseHorizontalLayout();
        if (horizontal != mUsingHorizontalLayout || force) {
            mUsingHorizontalLayout = horizontal;
            for (QSPanelControllerBase.TileRecord record : mRecords) {
                mView.removeTile(record);
                record.tile.removeCallback(record.callback);
            }
            mView.setUsingHorizontalLayout(mUsingHorizontalLayout, mMediaHost.getHostView(), force,
                    mUiEventLogger);
            mView.setUsingHorizontalLayout(mUsingHorizontalLayout, mMediaHost.getHostView(), force);
            updateMediaDisappearParameters();

            setTiles();

            return true;
        }
        return false;
+1 −12
Original line number Diff line number Diff line
@@ -61,21 +61,10 @@ public class QuickQSPanel extends QSPanel {
    }

    @Override
    public TileLayout createRegularTileLayout() {
    public TileLayout getOrCreateTileLayout() {
        return new QQSSideLabelTileLayout(mContext);
    }

    @Override
    protected QSTileLayout createHorizontalTileLayout() {
        TileLayout t = createRegularTileLayout();
        t.setMaxColumns(2);
        return t;
    }

    @Override
    protected boolean needsDynamicRowsAndColumns() {
        return false; // QQS always have the same layout
    }

    @Override
    protected boolean displayMediaMarginsOnMedia() {
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
        when(mQSPanel.getDumpableTag()).thenReturn("QSPanel");
        when(mQSPanel.openPanelEvent()).thenReturn(QSEvent.QS_PANEL_EXPANDED);
        when(mQSPanel.closePanelEvent()).thenReturn(QSEvent.QS_PANEL_COLLAPSED);
        when(mQSPanel.createRegularTileLayout()).thenReturn(mPagedTileLayout);
        when(mQSPanel.getOrCreateTileLayout()).thenReturn(mPagedTileLayout);
        when(mQSPanel.getTileLayout()).thenReturn(mPagedTileLayout);
        when(mQSTile.getTileSpec()).thenReturn("dnd");
        when(mQSTileHost.getTiles()).thenReturn(Collections.singleton(mQSTile));
Loading