diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index db8efd5301952..7c7f566589199 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -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); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java index 9810e96ed199c..ae0f5104d20fe 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelController.java @@ -147,14 +147,14 @@ public class QSPanelController extends QSPanelControllerBase { 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 diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java index 77591b50c1038..7a0982688b498 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanelControllerBase.java @@ -297,20 +297,12 @@ public abstract class QSPanelControllerBase 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; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java index 659475d192779..68962b0cd17ad 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java @@ -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() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java index 1f066d81793a3..65e5f9703d847 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerBaseTest.java @@ -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)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.java index 53eae8c46d2fe..bf6c981bf05c4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelControllerTest.java @@ -107,7 +107,7 @@ public class QSPanelControllerTest extends SysuiTestCase { when(mQSPanel.isAttachedToWindow()).thenReturn(true); when(mQSPanel.getDumpableTag()).thenReturn("QSPanel"); - when(mQSPanel.createRegularTileLayout()).thenReturn(mPagedTileLayout); + when(mQSPanel.getOrCreateTileLayout()).thenReturn(mPagedTileLayout); when(mQSPanel.getTileLayout()).thenReturn(mPagedTileLayout); when(mQSTileHost.getTiles()).thenReturn(Collections.singleton(mQSTile)); when(mQSTileHost.createTileView(any(), eq(mQSTile), anyBoolean())).thenReturn(mQSTileView);