Pass the context from QS into QSFactory#createTileView
This way, we guarantee that the theme is the same in all of QS Test: manual Bug: 183953523 Change-Id: Ia03171194d8c90358730fcacb9ea7dcf61d4dbed
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.systemui.plugins.Plugin;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
@@ -28,9 +30,18 @@ import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
public interface QSFactory extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_QS_FACTORY";
|
||||
int VERSION = 1;
|
||||
int VERSION = 2;
|
||||
|
||||
QSTile createTile(String tileSpec);
|
||||
QSTileView createTileView(QSTile tile, boolean collapsedView);
|
||||
|
||||
/**
|
||||
* Create a view for a tile.
|
||||
*
|
||||
* @param context a themed context for inflating the view
|
||||
* @param tile the tile for which the view is created
|
||||
* @param collapsedView {@code true} if the view will live in QQS and {@code false} otherwise.
|
||||
* @return a view for the tile
|
||||
*/
|
||||
QSTileView createTileView(Context context, QSTile tile, boolean collapsedView);
|
||||
|
||||
}
|
||||
|
||||
@@ -202,11 +202,10 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
private void addTile(final QSTile tile, boolean collapsedView) {
|
||||
final TileRecord r = new TileRecord();
|
||||
r.tile = tile;
|
||||
r.tileView = mHost.createTileView(tile, collapsedView);
|
||||
r.tileView = mHost.createTileView(getContext(), tile, collapsedView);
|
||||
mView.addTile(r);
|
||||
mRecords.add(r);
|
||||
mCachedSpecs = getTilesSpecs();
|
||||
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -423,9 +423,15 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
||||
return null;
|
||||
}
|
||||
|
||||
public QSTileView createTileView(QSTile tile, boolean collapsedView) {
|
||||
/**
|
||||
* Create a view for a tile, iterating over all possible {@link QSFactory}.
|
||||
*
|
||||
* @see QSFactory#createTileView
|
||||
*/
|
||||
public QSTileView createTileView(Context themedContext, QSTile tile, boolean collapsedView) {
|
||||
for (int i = 0; i < mQsFactories.size(); i++) {
|
||||
QSTileView view = mQsFactories.get(i).createTileView(tile, collapsedView);
|
||||
QSTileView view = mQsFactories.get(i)
|
||||
.createTileView(themedContext, tile, collapsedView);
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@ import static com.android.systemui.qs.dagger.QSFlagsModule.QS_LABELS_FLAG;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.plugins.qs.QSFactory;
|
||||
import com.android.systemui.plugins.qs.QSIconView;
|
||||
@@ -251,8 +249,7 @@ public class QSFactoryImpl implements QSFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QSTileView createTileView(QSTile tile, boolean collapsedView) {
|
||||
Context context = new ContextThemeWrapper(mQsHostLazy.get().getContext(), R.style.qs_theme);
|
||||
public QSTileView createTileView(Context context, QSTile tile, boolean collapsedView) {
|
||||
QSIconView icon = tile.createTileView(context);
|
||||
if (mSideLabels) {
|
||||
return new QSTileViewHorizontal(context, icon, collapsedView);
|
||||
|
||||
@@ -131,7 +131,7 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
when(mQSPanel.getTileLayout()).thenReturn(mPagedTileLayout);
|
||||
when(mQSTile.getTileSpec()).thenReturn("dnd");
|
||||
when(mQSTileHost.getTiles()).thenReturn(Collections.singleton(mQSTile));
|
||||
when(mQSTileHost.createTileView(eq(mQSTile), anyBoolean())).thenReturn(mQSTileView);
|
||||
when(mQSTileHost.createTileView(any(), eq(mQSTile), anyBoolean())).thenReturn(mQSTileView);
|
||||
when(mQSTileRevealControllerFactory.create(any(), any()))
|
||||
.thenReturn(mQSTileRevealController);
|
||||
when(mMediaHost.getDisappearParameters()).thenReturn(new DisappearParameters());
|
||||
|
||||
@@ -108,7 +108,7 @@ public class QSPanelControllerTest extends SysuiTestCase {
|
||||
when(mQSPanel.createRegularTileLayout()).thenReturn(mPagedTileLayout);
|
||||
when(mQSPanel.getTileLayout()).thenReturn(mPagedTileLayout);
|
||||
when(mQSTileHost.getTiles()).thenReturn(Collections.singleton(mQSTile));
|
||||
when(mQSTileHost.createTileView(eq(mQSTile), anyBoolean())).thenReturn(mQSTileView);
|
||||
when(mQSTileHost.createTileView(any(), eq(mQSTile), anyBoolean())).thenReturn(mQSTileView);
|
||||
when(mToggleSliderViewControllerFactory.create(any(), any()))
|
||||
.thenReturn(mBrightnessSlider);
|
||||
when(mBrightnessControllerFactory.create(any(ToggleSlider.class)))
|
||||
|
||||
@@ -89,7 +89,7 @@ public class QSPanelTest extends SysuiTestCase {
|
||||
|
||||
when(dndTile.getTileSpec()).thenReturn("dnd");
|
||||
when(mHost.getTiles()).thenReturn(Collections.emptyList());
|
||||
when(mHost.createTileView(any(), anyBoolean())).thenReturn(mQSTileView);
|
||||
when(mHost.createTileView(any(), any(), anyBoolean())).thenReturn(mQSTileView);
|
||||
mQsPanel.addTile(mDndTileRecord);
|
||||
mQsPanel.setCallback(mCallback);
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
|
||||
|
||||
`when`(quickQSPanel.tileLayout).thenReturn(tileLayout)
|
||||
`when`(quickQSPanel.dumpableTag).thenReturn("")
|
||||
`when`(qsTileHost.createTileView(any(), anyBoolean())).thenReturn(tileView)
|
||||
`when`(qsTileHost.createTileView(any(), any(), anyBoolean())).thenReturn(tileView)
|
||||
|
||||
controller = QuickQSPanelController(
|
||||
quickQSPanel,
|
||||
|
||||
Reference in New Issue
Block a user