Merge changes I2099ed36,I38f6c4d4,I6f8c54bb
* changes: 11/N Remove UIEventLogger from QSPanel. 10/N Remove MetricsLogger from QSPanel 9/N Remove MediaHost from QSPanel
This commit is contained in:
@@ -25,8 +25,7 @@ import com.android.systemui.R
|
||||
import com.android.systemui.qs.TileLayout.exactly
|
||||
|
||||
class DoubleLineTileLayout(
|
||||
context: Context,
|
||||
private val uiEventLogger: UiEventLogger
|
||||
context: Context
|
||||
) : ViewGroup(context), QSPanel.QSTileLayout {
|
||||
|
||||
companion object {
|
||||
@@ -84,7 +83,7 @@ class DoubleLineTileLayout(
|
||||
return false
|
||||
}
|
||||
|
||||
override fun setListening(listening: Boolean) {
|
||||
override fun setListening(listening: Boolean, uiEventLogger: UiEventLogger) {
|
||||
if (_listening == listening) return
|
||||
_listening = listening
|
||||
for (record in mRecords) {
|
||||
|
||||
@@ -142,7 +142,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
public void setListening(boolean listening, UiEventLogger uiEventLogger) {
|
||||
if (mListening == listening) return;
|
||||
mListening = listening;
|
||||
updateListening();
|
||||
@@ -150,7 +150,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
|
||||
private void updateListening() {
|
||||
for (TilePage tilePage : mPages) {
|
||||
tilePage.setListening(tilePage.getParent() == null ? false : mListening);
|
||||
tilePage.setListening(tilePage.getParent() != null && mListening);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
|
||||
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
@@ -184,7 +183,8 @@ public class QSContainerImpl extends FrameLayout {
|
||||
mBackground.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
void updateResources(QSPanelController qsPanelController) {
|
||||
void updateResources(QSPanelController qsPanelController,
|
||||
QuickStatusBarHeaderController quickStatusBarHeaderController) {
|
||||
LayoutParams layoutParams = (LayoutParams) mQSPanelContainer.getLayoutParams();
|
||||
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.quick_qs_offset_height);
|
||||
@@ -196,7 +196,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
boolean marginsChanged = padding != mContentPadding;
|
||||
mContentPadding = padding;
|
||||
if (marginsChanged) {
|
||||
updatePaddingsAndMargins(qsPanelController);
|
||||
updatePaddingsAndMargins(qsPanelController, quickStatusBarHeaderController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,8 @@ public class QSContainerImpl extends FrameLayout {
|
||||
updateExpansion();
|
||||
}
|
||||
|
||||
private void updatePaddingsAndMargins(QSPanelController qsPanelController) {
|
||||
private void updatePaddingsAndMargins(QSPanelController qsPanelController,
|
||||
QuickStatusBarHeaderController quickStatusBarHeaderController) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View view = getChildAt(i);
|
||||
if (view == mQSCustomizer) {
|
||||
@@ -271,7 +272,7 @@ public class QSContainerImpl extends FrameLayout {
|
||||
} else if (view == mHeader) {
|
||||
// The header contains the QQS panel which needs to have special padding, to
|
||||
// visually align them.
|
||||
mHeader.setContentMargins(mContentPadding, mContentPadding);
|
||||
quickStatusBarHeaderController.setContentMargins(mContentPadding, mContentPadding);
|
||||
} else {
|
||||
view.setPaddingRelative(
|
||||
mContentPadding,
|
||||
|
||||
@@ -35,7 +35,7 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
|
||||
new ConfigurationController.ConfigurationListener() {
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
mView.updateResources(mQsPanelController);
|
||||
mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ public class QSContainerImplController extends ViewController<QSContainerImpl> {
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
mView.updateResources(mQsPanelController);
|
||||
mView.updateResources(mQsPanelController, mQuickStatusBarHeaderController);
|
||||
mQsPanelController.setMediaVisibilityChangedListener((visible) -> {
|
||||
if (mQsPanelController.isShown()) {
|
||||
mView.onMediaVisibilityChanged(true);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.media.dagger.MediaModule.QS_PANEL;
|
||||
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
|
||||
import static com.android.systemui.util.Utils.useQsMediaPlayer;
|
||||
|
||||
@@ -36,13 +35,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.widget.RemeasuringLinearLayout;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.DetailAdapter;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
@@ -50,7 +45,6 @@ import com.android.systemui.settings.brightness.BrightnessSlider;
|
||||
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
import com.android.systemui.util.animation.DisappearParameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -68,7 +62,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
private static final String TAG = "QSPanel";
|
||||
|
||||
protected final Context mContext;
|
||||
private final MediaHost mMediaHost;
|
||||
|
||||
/**
|
||||
* The index where the content starts that needs to be moved between parents
|
||||
@@ -81,7 +74,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
protected BrightnessSlider mToggleSliderController;
|
||||
|
||||
private final H mHandler = new H();
|
||||
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
|
||||
/** Whether or not the QS media player feature is enabled. */
|
||||
protected boolean mUsingMediaPlayer;
|
||||
private int mVisualMarginStart;
|
||||
@@ -92,7 +84,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
|
||||
private QSDetail.Callback mCallback;
|
||||
private final QSLogger mQSLogger;
|
||||
protected final UiEventLogger mUiEventLogger;
|
||||
protected QSTileHost mHost;
|
||||
private final List<OnConfigurationChangedListener> mOnConfigurationChangedListeners =
|
||||
new ArrayList<>();
|
||||
@@ -108,7 +99,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
@Nullable
|
||||
private ViewGroup mHeaderContainer;
|
||||
private PageIndicator mFooterPageIndicator;
|
||||
private boolean mGridContentVisible = true;
|
||||
private int mContentMarginStart;
|
||||
private int mContentMarginEnd;
|
||||
private int mVisualTilePadding;
|
||||
@@ -134,18 +124,14 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
public QSPanel(
|
||||
@Named(VIEW_CONTEXT) Context context,
|
||||
AttributeSet attrs,
|
||||
QSLogger qsLogger,
|
||||
@Named(QS_PANEL) MediaHost mediaHost,
|
||||
UiEventLogger uiEventLogger
|
||||
QSLogger qsLogger
|
||||
) {
|
||||
super(context, attrs);
|
||||
mUsingMediaPlayer = useQsMediaPlayer(context);
|
||||
mMediaTotalBottomMargin = getResources().getDimensionPixelSize(
|
||||
R.dimen.quick_settings_bottom_margin_media);
|
||||
mMediaHost = mediaHost;
|
||||
mContext = context;
|
||||
mQSLogger = qsLogger;
|
||||
mUiEventLogger = uiEventLogger;
|
||||
|
||||
setOrientation(VERTICAL);
|
||||
|
||||
@@ -213,36 +199,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
return createRegularTileLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the way the media disappears based on if we're using the horizontal layout
|
||||
*/
|
||||
void updateMediaDisappearParameters() {
|
||||
if (!mUsingMediaPlayer) {
|
||||
return;
|
||||
}
|
||||
DisappearParameters parameters = mMediaHost.getDisappearParameters();
|
||||
if (mUsingHorizontalLayout) {
|
||||
// Only height remaining
|
||||
parameters.getDisappearSize().set(0.0f, 0.4f);
|
||||
// Disappearing on the right side on the bottom
|
||||
parameters.getGonePivot().set(1.0f, 1.0f);
|
||||
// translating a bit horizontal
|
||||
parameters.getContentTranslationFraction().set(0.25f, 1.0f);
|
||||
parameters.setDisappearEnd(0.6f);
|
||||
} else {
|
||||
// Only width remaining
|
||||
parameters.getDisappearSize().set(1.0f, 0.0f);
|
||||
// Disappearing on the bottom
|
||||
parameters.getGonePivot().set(0.0f, 1.0f);
|
||||
// translating a bit vertical
|
||||
parameters.getContentTranslationFraction().set(0.0f, 1.05f);
|
||||
parameters.setDisappearEnd(0.95f);
|
||||
}
|
||||
parameters.setFadeStartPosition(0.95f);
|
||||
parameters.setDisappearStart(0.0f);
|
||||
mMediaHost.setDisappearParameters(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (mTileLayout instanceof PagedTileLayout) {
|
||||
@@ -284,14 +240,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
setMeasuredDimension(getMeasuredWidth(), height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
if (mTileLayout != null) {
|
||||
mTileLayout.setListening(false);
|
||||
}
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
protected String getDumpableTag() {
|
||||
return TAG;
|
||||
}
|
||||
@@ -403,65 +351,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
mDivider = findViewById(R.id.divider);
|
||||
}
|
||||
|
||||
boolean switchTileLayout(boolean force, List<QSPanelControllerBase.TileRecord> records) {
|
||||
/** Whether or not the QuickQSPanel currently contains a media player. */
|
||||
boolean horizontal = shouldUseHorizontalLayout();
|
||||
if (mDivider != null) {
|
||||
if (!horizontal && mUsingMediaPlayer && mMediaHost.getVisible()) {
|
||||
mDivider.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mDivider.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (horizontal != mUsingHorizontalLayout || force) {
|
||||
mUsingHorizontalLayout = horizontal;
|
||||
View visibleView = horizontal ? mHorizontalLinearLayout : (View) mRegularTileLayout;
|
||||
View hiddenView = horizontal ? (View) mRegularTileLayout : mHorizontalLinearLayout;
|
||||
ViewGroup newParent = horizontal ? mHorizontalContentContainer : this;
|
||||
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);
|
||||
reAttachMediaHost();
|
||||
if (mTileLayout != null) {
|
||||
mTileLayout.setListening(false);
|
||||
for (QSPanelControllerBase.TileRecord record : records) {
|
||||
mTileLayout.removeTile(record);
|
||||
record.tile.removeCallback(record.callback);
|
||||
}
|
||||
}
|
||||
mTileLayout = newLayout;
|
||||
if (needsDynamicRowsAndColumns()) {
|
||||
newLayout.setMinRows(horizontal ? 2 : 1);
|
||||
// Let's use 3 columns to match the current layout
|
||||
newLayout.setMaxColumns(horizontal ? 3 : TileLayout.NO_MAX_COLUMNS);
|
||||
}
|
||||
updateTileLayoutMargins();
|
||||
updateFooterMargin();
|
||||
updateDividerMargin();
|
||||
updateMediaDisappearParameters();
|
||||
updateMediaHostContentMargins();
|
||||
updateHorizontalLinearLayoutMargins();
|
||||
updatePadding();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the listening state of the current layout to the state of the view. Used after
|
||||
* switching layouts.
|
||||
*/
|
||||
public void reSetLayoutListening() {
|
||||
mTileLayout.setListening(mListening);
|
||||
}
|
||||
|
||||
private void updateHorizontalLinearLayoutMargins() {
|
||||
if (mHorizontalLinearLayout != null && !displayMediaMarginsOnMedia()) {
|
||||
LayoutParams lp = (LayoutParams) mHorizontalLinearLayout.getLayoutParams();
|
||||
@@ -524,27 +413,19 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldUseHorizontalLayout() {
|
||||
return mUsingMediaPlayer && mMediaHost.getVisible()
|
||||
&& getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
protected void reAttachMediaHost() {
|
||||
/** Call when orientation has changed and MediaHost needs to be adjusted. */
|
||||
private void reAttachMediaHost(ViewGroup hostView, boolean horizontal) {
|
||||
if (!mUsingMediaPlayer) {
|
||||
return;
|
||||
}
|
||||
boolean horizontal = shouldUseHorizontalLayout();
|
||||
ViewGroup host = mMediaHost.getHostView();
|
||||
|
||||
ViewGroup newParent = horizontal ? mHorizontalLinearLayout : this;
|
||||
ViewGroup currentParent = (ViewGroup) host.getParent();
|
||||
ViewGroup currentParent = (ViewGroup) hostView.getParent();
|
||||
if (currentParent != newParent) {
|
||||
if (currentParent != null) {
|
||||
currentParent.removeView(host);
|
||||
currentParent.removeView(hostView);
|
||||
}
|
||||
newParent.addView(host);
|
||||
LinearLayout.LayoutParams layoutParams = (LayoutParams) host.getLayoutParams();
|
||||
newParent.addView(hostView);
|
||||
LinearLayout.LayoutParams layoutParams = (LayoutParams) hostView.getLayoutParams();
|
||||
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.width = horizontal ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.weight = horizontal ? 1.2f : 0;
|
||||
@@ -576,16 +457,10 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setListening(boolean listening, String cachedSpecs) {
|
||||
if (mListening == listening) return;
|
||||
public void setListening(boolean listening) {
|
||||
mListening = listening;
|
||||
if (mTileLayout != null) {
|
||||
mQSLogger.logAllTilesChangeListening(listening, getDumpableTag(), cachedSpecs);
|
||||
mTileLayout.setListening(listening);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void showDetailAdapter(boolean show, DetailAdapter adapter, int[] locationInWindow) {
|
||||
int xInWindow = locationInWindow[0];
|
||||
int yInWindow = locationInWindow[1];
|
||||
@@ -728,14 +603,6 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
fireScanStateChanged(scanState);
|
||||
}
|
||||
|
||||
void setGridContentVisibility(boolean visible) {
|
||||
int newVis = visible ? VISIBLE : INVISIBLE;
|
||||
setVisibility(newVis);
|
||||
if (mGridContentVisible != visible) {
|
||||
mMetricsLogger.visibility(MetricsEvent.QS_PANEL, newVis);
|
||||
}
|
||||
mGridContentVisible = visible;
|
||||
}
|
||||
private void fireShowingDetail(DetailAdapter detail, int x, int y) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onShowingDetail(detail, x, y);
|
||||
@@ -763,14 +630,15 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
return mDivider;
|
||||
}
|
||||
|
||||
public void setContentMargins(int startMargin, int endMargin) {
|
||||
/** */
|
||||
public void setContentMargins(int startMargin, int endMargin, ViewGroup mediaHostView) {
|
||||
// Only some views actually want this content padding, others want to go all the way
|
||||
// to the edge like the brightness slider
|
||||
mContentMarginStart = startMargin;
|
||||
mContentMarginEnd = endMargin;
|
||||
updateTileLayoutMargins(mContentMarginStart - mVisualTilePadding,
|
||||
mContentMarginEnd - mVisualTilePadding);
|
||||
updateMediaHostContentMargins();
|
||||
updateMediaHostContentMargins(mediaHostView);
|
||||
updateFooterMargin();
|
||||
updateDividerMargin();
|
||||
}
|
||||
@@ -826,13 +694,13 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
/**
|
||||
* Update the margins of the media hosts
|
||||
*/
|
||||
protected void updateMediaHostContentMargins() {
|
||||
protected void updateMediaHostContentMargins(ViewGroup mediaHostView) {
|
||||
if (mUsingMediaPlayer) {
|
||||
int marginStart = mContentMarginStart;
|
||||
if (mUsingHorizontalLayout) {
|
||||
marginStart = 0;
|
||||
}
|
||||
updateMargins(mMediaHost.getHostView(), marginStart, mContentMarginEnd);
|
||||
updateMargins(mediaHostView, marginStart, mContentMarginEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,6 +739,45 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
mSecurityFooter = view;
|
||||
}
|
||||
|
||||
void setUsingHorizontalLayout(boolean horizontal, ViewGroup mediaHostView, boolean force,
|
||||
UiEventLogger uiEventLogger) {
|
||||
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);
|
||||
reAttachMediaHost(mediaHostView, horizontal);
|
||||
mTileLayout = newLayout;
|
||||
newLayout.setListening(mListening, uiEventLogger);
|
||||
if (needsDynamicRowsAndColumns()) {
|
||||
newLayout.setMinRows(horizontal ? 2 : 1);
|
||||
// Let's use 3 columns to match the current layout
|
||||
newLayout.setMaxColumns(horizontal ? 3 : TileLayout.NO_MAX_COLUMNS);
|
||||
}
|
||||
updateMargins(mediaHostView);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMargins(ViewGroup mediaHostView) {
|
||||
updateTileLayoutMargins();
|
||||
updateFooterMargin();
|
||||
updateDividerMargin();
|
||||
updateMediaHostContentMargins(mediaHostView);
|
||||
updateHorizontalLinearLayoutMargins();
|
||||
updatePadding();
|
||||
}
|
||||
|
||||
private class H extends Handler {
|
||||
private static final int SHOW_DETAIL = 1;
|
||||
private static final int SET_TILE_VISIBILITY = 2;
|
||||
@@ -912,7 +819,7 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
boolean updateResources();
|
||||
|
||||
/** */
|
||||
void setListening(boolean listening);
|
||||
void setListening(boolean listening, UiEventLogger uiEventLogger);
|
||||
|
||||
/**
|
||||
* Set the minimum number of rows to show
|
||||
@@ -924,7 +831,7 @@ public class QSPanel extends LinearLayout implements Tunable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the max number of collums to show
|
||||
* Set the max number of columns to show
|
||||
*
|
||||
* @param maxColumns the maximum
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.media.dagger.MediaModule.QS_PANEL;
|
||||
import static com.android.systemui.qs.QSPanel.QS_SHOW_BRIGHTNESS;
|
||||
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.res.Configuration;
|
||||
@@ -27,6 +28,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.media.MediaHierarchyManager;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
@@ -34,6 +36,7 @@ import com.android.systemui.plugins.qs.DetailAdapter;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.settings.brightness.BrightnessController;
|
||||
import com.android.systemui.settings.brightness.BrightnessSlider;
|
||||
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
|
||||
@@ -57,6 +60,9 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
private final BrightnessSlider.Factory mBrightnessSliderFactory;
|
||||
private final BrightnessSlider mBrightnessSlider;
|
||||
|
||||
private BrightnessMirrorController mBrightnessMirrorController;
|
||||
private boolean mGridContentVisible = true;
|
||||
|
||||
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
|
||||
new QSPanel.OnConfigurationChangedListener() {
|
||||
@Override
|
||||
@@ -69,7 +75,6 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
updateBrightnessMirror();
|
||||
}
|
||||
};
|
||||
private BrightnessMirrorController mBrightnessMirrorController;
|
||||
|
||||
private final BrightnessMirrorController.BrightnessMirrorListener mBrightnessMirrorListener =
|
||||
mirror -> updateBrightnessMirror();
|
||||
@@ -77,13 +82,14 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
@Inject
|
||||
QSPanelController(QSPanel view, QSSecurityFooter qsSecurityFooter, TunerService tunerService,
|
||||
QSTileHost qstileHost, QSCustomizerController qsCustomizerController,
|
||||
@Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer,
|
||||
@Named(QS_PANEL) MediaHost mediaHost,
|
||||
QSTileRevealController.Factory qsTileRevealControllerFactory,
|
||||
DumpManager dumpManager, MetricsLogger metricsLogger, UiEventLogger uiEventLogger,
|
||||
BrightnessController.Factory brightnessControllerFactory,
|
||||
QSLogger qsLogger, BrightnessController.Factory brightnessControllerFactory,
|
||||
BrightnessSlider.Factory brightnessSliderFactory) {
|
||||
super(view, qstileHost, qsCustomizerController, mediaHost, metricsLogger, uiEventLogger,
|
||||
dumpManager);
|
||||
super(view, qstileHost, qsCustomizerController, usingMediaPlayer, mediaHost,
|
||||
metricsLogger, uiEventLogger, qsLogger, dumpManager);
|
||||
mQsSecurityFooter = qsSecurityFooter;
|
||||
mTunerService = tunerService;
|
||||
mQsCustomizerController = qsCustomizerController;
|
||||
@@ -111,7 +117,7 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
protected void onViewAttached() {
|
||||
super.onViewAttached();
|
||||
|
||||
mView.updateMediaDisappearParameters();
|
||||
updateMediaDisappearParameters();
|
||||
|
||||
mTunerService.addTunable(mView, QS_SHOW_BRIGHTNESS);
|
||||
mView.updateResources();
|
||||
@@ -142,11 +148,6 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
super.onViewDetached();
|
||||
}
|
||||
|
||||
/** TODO(b/168904199): Remove this method once view is controllerized. */
|
||||
QSPanel getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the header container of quick settings.
|
||||
*/
|
||||
@@ -246,7 +247,12 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
|
||||
/** */
|
||||
public void setGridContentVisibility(boolean visible) {
|
||||
mView.setGridContentVisibility(visible);
|
||||
int newVis = visible ? View.VISIBLE : View.INVISIBLE;
|
||||
setVisibility(newVis);
|
||||
if (mGridContentVisible != visible) {
|
||||
mMetricsLogger.visibility(MetricsEvent.QS_PANEL, newVis);
|
||||
}
|
||||
mGridContentVisible = visible;
|
||||
}
|
||||
|
||||
public boolean isLayoutRtl() {
|
||||
@@ -277,7 +283,7 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
|
||||
|
||||
/** */
|
||||
public void setContentMargins(int startMargin, int endMargin) {
|
||||
mView.setContentMargins(startMargin, endMargin);
|
||||
mView.setContentMargins(startMargin, endMargin, mMediaHost.getHostView());
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.res.Configuration;
|
||||
import android.metrics.LogMaker;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
@@ -31,7 +33,9 @@ import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.plugins.qs.QSTileView;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.external.CustomTile;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.util.ViewController;
|
||||
import com.android.systemui.util.animation.DisappearParameters;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -39,6 +43,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
@@ -51,9 +57,11 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
implements Dumpable{
|
||||
protected final QSTileHost mHost;
|
||||
private final QSCustomizerController mQsCustomizerController;
|
||||
private final boolean mUsingMediaPlayer;
|
||||
protected final MediaHost mMediaHost;
|
||||
private final MetricsLogger mMetricsLogger;
|
||||
protected final MetricsLogger mMetricsLogger;
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
private final QSLogger mQSLogger;
|
||||
private final DumpManager mDumpManager;
|
||||
protected final ArrayList<TileRecord> mRecords = new ArrayList<>();
|
||||
|
||||
@@ -81,15 +89,21 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
return null;
|
||||
};
|
||||
|
||||
private boolean mUsingHorizontalLayout;
|
||||
|
||||
protected QSPanelControllerBase(T view, QSTileHost host,
|
||||
QSCustomizerController qsCustomizerController, MediaHost mediaHost,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, DumpManager dumpManager) {
|
||||
QSCustomizerController qsCustomizerController,
|
||||
@Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer, MediaHost mediaHost,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger,
|
||||
DumpManager dumpManager) {
|
||||
super(view);
|
||||
mHost = host;
|
||||
mQsCustomizerController = qsCustomizerController;
|
||||
mUsingMediaPlayer = usingMediaPlayer;
|
||||
mMediaHost = mediaHost;
|
||||
mMetricsLogger = metricsLogger;
|
||||
mUiEventLogger = uiEventLogger;
|
||||
mQSLogger = qsLogger;
|
||||
mDumpManager = dumpManager;
|
||||
}
|
||||
|
||||
@@ -115,6 +129,8 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener);
|
||||
mHost.removeCallback(mQSHostCallback);
|
||||
|
||||
mView.getTileLayout().setListening(false, mUiEventLogger);
|
||||
|
||||
mMediaHost.removeVisibilityChangeListener(mMediaHostVisibilityListener);
|
||||
|
||||
for (TileRecord record : mRecords) {
|
||||
@@ -238,17 +254,77 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
|
||||
|
||||
|
||||
void setListening(boolean listening) {
|
||||
mView.setListening(listening, mCachedSpecs);
|
||||
mView.setListening(listening);
|
||||
|
||||
if (mView.getTileLayout() != null) {
|
||||
mQSLogger.logAllTilesChangeListening(listening, mView.getDumpableTag(), mCachedSpecs);
|
||||
mView.getTileLayout().setListening(listening, mUiEventLogger);
|
||||
}
|
||||
}
|
||||
|
||||
boolean switchTileLayout(boolean force) {
|
||||
if (mView.switchTileLayout(force, mRecords)) {
|
||||
/** Whether or not the QuickQSPanel currently contains a media player. */
|
||||
boolean horizontal = shouldUseHorizontalLayout();
|
||||
if (mView.getDivider() != null) {
|
||||
if (!horizontal && mUsingMediaPlayer && mMediaHost.getVisible()) {
|
||||
mView.getDivider().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mView.getDivider().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
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);
|
||||
updateMediaDisappearParameters();
|
||||
|
||||
setTiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the way the media disappears based on if we're using the horizontal layout
|
||||
*/
|
||||
void updateMediaDisappearParameters() {
|
||||
if (!mUsingMediaPlayer) {
|
||||
return;
|
||||
}
|
||||
DisappearParameters parameters = mMediaHost.getDisappearParameters();
|
||||
if (mUsingHorizontalLayout) {
|
||||
// Only height remaining
|
||||
parameters.getDisappearSize().set(0.0f, 0.4f);
|
||||
// Disappearing on the right side on the bottom
|
||||
parameters.getGonePivot().set(1.0f, 1.0f);
|
||||
// translating a bit horizontal
|
||||
parameters.getContentTranslationFraction().set(0.25f, 1.0f);
|
||||
parameters.setDisappearEnd(0.6f);
|
||||
} else {
|
||||
// Only width remaining
|
||||
parameters.getDisappearSize().set(1.0f, 0.0f);
|
||||
// Disappearing on the bottom
|
||||
parameters.getGonePivot().set(0.0f, 1.0f);
|
||||
// translating a bit vertical
|
||||
parameters.getContentTranslationFraction().set(0.0f, 1.05f);
|
||||
parameters.setDisappearEnd(0.95f);
|
||||
}
|
||||
parameters.setFadeStartPosition(0.95f);
|
||||
parameters.setDisappearStart(0.0f);
|
||||
mMediaHost.setDisappearParameters(parameters);
|
||||
}
|
||||
|
||||
boolean shouldUseHorizontalLayout() {
|
||||
return mUsingMediaPlayer && mMediaHost.getVisible()
|
||||
&& getResources().getConfiguration().orientation
|
||||
== Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
private void logTiles() {
|
||||
for (int i = 0; i < mRecords.size(); i++) {
|
||||
QSTile tile = mRecords.get(i).tile;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.media.dagger.MediaModule.QUICK_QS_PANEL;
|
||||
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -29,7 +28,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.plugins.qs.QSTile.SignalState;
|
||||
import com.android.systemui.plugins.qs.QSTile.State;
|
||||
@@ -57,9 +55,8 @@ public class QuickQSPanel extends QSPanel {
|
||||
@Named(VIEW_CONTEXT) Context context,
|
||||
AttributeSet attrs,
|
||||
QSLogger qsLogger,
|
||||
@Named(QUICK_QS_PANEL) MediaHost mediaHost,
|
||||
UiEventLogger uiEventLogger) {
|
||||
super(context, attrs, qsLogger, mediaHost, uiEventLogger);
|
||||
super(context, attrs, qsLogger);
|
||||
mMaxTiles = Math.min(DEFAULT_MAX_TILES,
|
||||
getResources().getInteger(R.integer.quick_qs_panel_max_columns));
|
||||
applyBottomMargin((View) mRegularTileLayout);
|
||||
@@ -79,12 +76,12 @@ public class QuickQSPanel extends QSPanel {
|
||||
|
||||
@Override
|
||||
public TileLayout createRegularTileLayout() {
|
||||
return new QuickQSPanel.HeaderTileLayout(mContext, mUiEventLogger);
|
||||
return new QuickQSPanel.HeaderTileLayout(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QSTileLayout createHorizontalTileLayout() {
|
||||
return new DoubleLineTileLayout(mContext, mUiEventLogger);
|
||||
return new DoubleLineTileLayout(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,13 +195,10 @@ public class QuickQSPanel extends QSPanel {
|
||||
|
||||
private static class HeaderTileLayout extends TileLayout {
|
||||
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
|
||||
private Rect mClippingBounds = new Rect();
|
||||
|
||||
public HeaderTileLayout(Context context, UiEventLogger uiEventLogger) {
|
||||
HeaderTileLayout(Context context) {
|
||||
super(context);
|
||||
mUiEventLogger = uiEventLogger;
|
||||
setClipChildren(false);
|
||||
setClipToPadding(false);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
||||
@@ -332,14 +326,14 @@ public class QuickQSPanel extends QSPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
public void setListening(boolean listening, UiEventLogger uiEventLogger) {
|
||||
boolean startedListening = !mListening && listening;
|
||||
super.setListening(listening);
|
||||
super.setListening(listening, uiEventLogger);
|
||||
if (startedListening) {
|
||||
// getNumVisibleTiles() <= mRecords.size()
|
||||
for (int i = 0; i < getNumVisibleTiles(); i++) {
|
||||
QSTile tile = mRecords.get(i).tile;
|
||||
mUiEventLogger.logWithInstanceId(QSEvent.QQS_TILE_VISIBLE, 0,
|
||||
uiEventLogger.logWithInstanceId(QSEvent.QQS_TILE_VISIBLE, 0,
|
||||
tile.getMetricsSpec(), tile.getInstanceId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.media.dagger.MediaModule.QUICK_QS_PANEL;
|
||||
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
@@ -27,6 +28,7 @@ import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -51,11 +53,12 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
@Inject
|
||||
QuickQSPanelController(QuickQSPanel view, QSTileHost qsTileHost,
|
||||
QSCustomizerController qsCustomizerController,
|
||||
@Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer,
|
||||
@Named(QUICK_QS_PANEL) MediaHost mediaHost,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger,
|
||||
DumpManager dumpManager) {
|
||||
super(view, qsTileHost, qsCustomizerController, mediaHost, metricsLogger, uiEventLogger,
|
||||
dumpManager);
|
||||
super(view, qsTileHost, qsCustomizerController, usingMediaPlayer, mediaHost, metricsLogger,
|
||||
uiEventLogger, qsLogger, dumpManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,6 +102,11 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
super.setTiles(mAllTiles.subList(0, mView.getNumQuickTiles()), true);
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setContentMargins(int marginStart, int marginEnd) {
|
||||
mView.setContentMargins(marginStart, marginEnd, mMediaHost.getHostView());
|
||||
}
|
||||
|
||||
public int getNumQuickTiles() {
|
||||
return mView.getNumQuickTiles();
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ import com.android.systemui.BatteryMeterView;
|
||||
import com.android.systemui.DualToneHandler;
|
||||
import com.android.systemui.Interpolators;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.privacy.OngoingPrivacyChip;
|
||||
import com.android.systemui.qs.QSDetail.Callback;
|
||||
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
|
||||
@@ -466,14 +464,15 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
|
||||
}
|
||||
|
||||
/** */
|
||||
public void setContentMargins(int marginStart, int marginEnd) {
|
||||
public void setContentMargins(int marginStart, int marginEnd,
|
||||
QuickQSPanelController quickQSPanelController) {
|
||||
mContentMarginStart = marginStart;
|
||||
mContentMarginEnd = marginEnd;
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View view = getChildAt(i);
|
||||
if (view == mHeaderQsPanel) {
|
||||
// QS panel doesn't lays out some of its content full width
|
||||
mHeaderQsPanel.setContentMargins(marginStart, marginEnd);
|
||||
quickQSPanelController.setContentMargins(marginStart, marginEnd);
|
||||
} else {
|
||||
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
|
||||
lp.setMarginStart(marginStart);
|
||||
|
||||
@@ -379,6 +379,11 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
|
||||
mZenModeController.getConsolidatedPolicy());
|
||||
}
|
||||
|
||||
public void setContentMargins(int contentPaddingStart, int contentPaddingEnd) {
|
||||
mView.setContentMargins(contentPaddingStart, contentPaddingEnd, mHeaderQsPanelController);
|
||||
}
|
||||
|
||||
|
||||
private static class ClockDemoModeReceiver implements DemoMode {
|
||||
private Clock mClockView;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSPanel.QSTileLayout;
|
||||
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;
|
||||
@@ -59,8 +60,12 @@ public class TileLayout extends ViewGroup implements QSTileLayout {
|
||||
return getTop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
setListening(listening, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListening(boolean listening, UiEventLogger uiEventLogger) {
|
||||
if (mListening == listening) return;
|
||||
mListening = listening;
|
||||
for (TileRecord record : mRecords) {
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.systemui.qs.dagger;
|
||||
|
||||
import static com.android.systemui.util.Utils.useQsMediaPlayer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@@ -44,6 +47,7 @@ import dagger.Provides;
|
||||
@Module
|
||||
public interface QSFragmentModule {
|
||||
String QS_SECURITY_FOOTER_VIEW = "qs_security_footer";
|
||||
String QS_USING_MEDIA_PLAYER = "qs_using_media_player";
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@@ -108,4 +112,12 @@ public interface QSFragmentModule {
|
||||
static View providesQSSecurityFooterView(LayoutInflater layoutInflater, QSPanel qsPanel) {
|
||||
return layoutInflater.inflate(R.layout.quick_settings_footer, qsPanel, false);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@Named(QS_USING_MEDIA_PLAYER)
|
||||
static boolean providesQSUsingMediaPlayer(Context context) {
|
||||
return useQsMediaPlayer(context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +42,9 @@ import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.QSTileView;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
import com.android.systemui.util.animation.DisappearParameters;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -75,6 +77,8 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private MetricsLogger mMetricsLogger;
|
||||
private UiEventLoggerFake mUiEventLogger = new UiEventLoggerFake();
|
||||
@Mock
|
||||
private QSLogger mQSLogger;
|
||||
private DumpManager mDumpManager = new DumpManager();
|
||||
@Mock
|
||||
QSTileImpl mQSTile;
|
||||
@@ -89,9 +93,10 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
private class TestableQSPanelControllerBase extends QSPanelControllerBase<QSPanel> {
|
||||
protected TestableQSPanelControllerBase(QSPanel view, QSTileHost host,
|
||||
QSCustomizerController qsCustomizerController, MediaHost mediaHost,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, DumpManager dumpManager) {
|
||||
super(view, host, qsCustomizerController, mediaHost,
|
||||
metricsLogger, uiEventLogger, dumpManager);
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger,
|
||||
DumpManager dumpManager) {
|
||||
super(view, host, qsCustomizerController, true, mediaHost, metricsLogger, uiEventLogger,
|
||||
qsLogger, dumpManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,13 +114,17 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
when(mQSPanel.openPanelEvent()).thenReturn(QSEvent.QS_PANEL_EXPANDED);
|
||||
when(mQSPanel.closePanelEvent()).thenReturn(QSEvent.QS_PANEL_COLLAPSED);
|
||||
when(mQSPanel.createRegularTileLayout()).thenReturn(mPagedTileLayout);
|
||||
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(mQSTileRevealControllerFactory.create(any(), any()))
|
||||
.thenReturn(mQSTileRevealController);
|
||||
when(mMediaHost.getDisappearParameters()).thenReturn(new DisappearParameters());
|
||||
|
||||
mController = new TestableQSPanelControllerBase(mQSPanel, mQSTileHost,
|
||||
mQSCustomizerController, mMediaHost, mMetricsLogger, mUiEventLogger, mDumpManager);
|
||||
mQSCustomizerController, mMediaHost,
|
||||
mMetricsLogger, mUiEventLogger, mQSLogger, mDumpManager);
|
||||
|
||||
mController.init();
|
||||
reset(mQSTileRevealController);
|
||||
@@ -125,9 +134,9 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
public void testSetRevealExpansion_preAttach() {
|
||||
mController.onViewDetached();
|
||||
|
||||
QSPanelControllerBase<QSPanel> controller = new QSPanelControllerBase<QSPanel>(
|
||||
mQSPanel, mQSTileHost, mQSCustomizerController, mMediaHost, mMetricsLogger,
|
||||
mUiEventLogger, mDumpManager) {
|
||||
QSPanelControllerBase<QSPanel> controller = new TestableQSPanelControllerBase(mQSPanel,
|
||||
mQSTileHost, mQSCustomizerController, mMediaHost,
|
||||
mMetricsLogger, mUiEventLogger, mQSLogger, mDumpManager) {
|
||||
@Override
|
||||
protected QSTileRevealController createTileRevealController() {
|
||||
return mQSTileRevealController;
|
||||
@@ -195,4 +204,14 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
|
||||
assertEquals(expected, w.getBuffer().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setListening() {
|
||||
mController.setListening(true);
|
||||
verify(mQSLogger).logAllTilesChangeListening(true, "QSPanel", "dnd");
|
||||
verify(mPagedTileLayout).setListening(true, mUiEventLogger);
|
||||
|
||||
mController.setListening(false);
|
||||
verify(mQSLogger).logAllTilesChangeListening(false, "QSPanel", "dnd");
|
||||
verify(mPagedTileLayout).setListening(false, mUiEventLogger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.QSTileView;
|
||||
import com.android.systemui.qs.customize.QSCustomizerController;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
import com.android.systemui.settings.brightness.BrightnessController;
|
||||
import com.android.systemui.settings.brightness.BrightnessSlider;
|
||||
@@ -77,6 +78,8 @@ public class QSPanelControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private QSSecurityFooter mQSSecurityFooter;
|
||||
@Mock
|
||||
private QSLogger mQSLogger;
|
||||
@Mock
|
||||
private BrightnessController.Factory mBrightnessControllerFactory;
|
||||
@Mock
|
||||
private BrightnessController mBrightnessController;
|
||||
@@ -91,7 +94,6 @@ public class QSPanelControllerTest extends SysuiTestCase {
|
||||
@Mock
|
||||
PagedTileLayout mPagedTileLayout;
|
||||
|
||||
|
||||
private QSPanelController mController;
|
||||
|
||||
@Before
|
||||
@@ -112,9 +114,9 @@ public class QSPanelControllerTest extends SysuiTestCase {
|
||||
when(mMediaHost.getDisappearParameters()).thenReturn(new DisappearParameters());
|
||||
|
||||
mController = new QSPanelController(mQSPanel, mQSSecurityFooter, mTunerService,
|
||||
mQSTileHost, mQSCustomizerController, mMediaHost, mQSTileRevealControllerFactory,
|
||||
mDumpManager, mMetricsLogger, mUiEventLogger, mBrightnessControllerFactory,
|
||||
mToggleSliderViewControllerFactory);
|
||||
mQSTileHost, mQSCustomizerController, true, mMediaHost,
|
||||
mQSTileRevealControllerFactory, mDumpManager, mMetricsLogger, mUiEventLogger,
|
||||
mQSLogger, mBrightnessControllerFactory, mToggleSliderViewControllerFactory);
|
||||
|
||||
mController.init();
|
||||
}
|
||||
|
||||
@@ -32,18 +32,13 @@ import android.widget.FrameLayout;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.testing.UiEventLoggerFake;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.qs.QSTileView;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.qs.tileimpl.QSTileImpl;
|
||||
import com.android.systemui.statusbar.policy.SecurityController;
|
||||
import com.android.systemui.util.animation.DisappearParameters;
|
||||
import com.android.systemui.util.animation.UniqueObjectHostView;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -58,7 +53,6 @@ import java.util.Collections;
|
||||
@SmallTest
|
||||
public class QSPanelTest extends SysuiTestCase {
|
||||
|
||||
private MetricsLogger mMetricsLogger;
|
||||
private TestableLooper mTestableLooper;
|
||||
private QSPanel mQsPanel;
|
||||
@Mock
|
||||
@@ -75,10 +69,7 @@ public class QSPanelTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private QSTileView mQSTileView;
|
||||
@Mock
|
||||
private MediaHost mMediaHost;
|
||||
@Mock
|
||||
private ActivityStarter mActivityStarter;
|
||||
private UiEventLoggerFake mUiEventLogger;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -90,15 +81,11 @@ public class QSPanelTest extends SysuiTestCase {
|
||||
mDependency.injectMockDependency(SecurityController.class);
|
||||
mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper());
|
||||
mContext.addMockSystemService(Context.USER_SERVICE, mock(UserManager.class));
|
||||
when(mMediaHost.getHostView()).thenReturn(new UniqueObjectHostView(getContext()));
|
||||
when(mMediaHost.getDisappearParameters()).thenReturn(new DisappearParameters());
|
||||
mDndTileRecord.tile = dndTile;
|
||||
mDndTileRecord.tileView = mQSTileView;
|
||||
|
||||
mUiEventLogger = new UiEventLoggerFake();
|
||||
mTestableLooper.runWithLooper(() -> {
|
||||
mMetricsLogger = mDependency.injectMockDependency(MetricsLogger.class);
|
||||
mQsPanel = new QSPanel(mContext, null, mQSLogger, mMediaHost, mUiEventLogger);
|
||||
mQsPanel = new QSPanel(mContext, null, mQSLogger);
|
||||
mQsPanel.onFinishInflate();
|
||||
// Provides a parent with non-zero size for QSPanel
|
||||
mParentView = new FrameLayout(mContext);
|
||||
@@ -130,15 +117,6 @@ public class QSPanelTest extends SysuiTestCase {
|
||||
verify(mCallback).onShowingDetail(any(), anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setListening() {
|
||||
mQsPanel.setListening(true, "dnd");
|
||||
verify(mQSLogger).logAllTilesChangeListening(true, mQsPanel.getDumpableTag(), "dnd");
|
||||
|
||||
mQsPanel.setListening(false, "dnd");
|
||||
verify(mQSLogger).logAllTilesChangeListening(false, mQsPanel.getDumpableTag(), "dnd");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenDetailsWithNullParameter_NoException() {
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TileLayoutTest extends SysuiTestCase {
|
||||
public void testSetListening_CallsSetListeningOnTile() {
|
||||
QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
|
||||
mTileLayout.addTile(tileRecord);
|
||||
mTileLayout.setListening(true);
|
||||
mTileLayout.setListening(true, null);
|
||||
verify(tileRecord.tile, times(1)).setListening(mTileLayout, true);
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ public class TileLayoutTest extends SysuiTestCase {
|
||||
public void testSetListening_SameValueIsNoOp() {
|
||||
QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
|
||||
mTileLayout.addTile(tileRecord);
|
||||
mTileLayout.setListening(false);
|
||||
mTileLayout.setListening(false, null);
|
||||
verify(tileRecord.tile, times(1)).setListening(any(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetListening_ChangesValueForAddingFutureTiles() {
|
||||
QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
|
||||
mTileLayout.setListening(true);
|
||||
mTileLayout.setListening(true, null);
|
||||
mTileLayout.addTile(tileRecord);
|
||||
verify(tileRecord.tile, times(1)).setListening(mTileLayout, true);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class TileLayoutTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testRemoveTile_CallsSetListeningFalseOnTile() {
|
||||
QSPanelControllerBase.TileRecord tileRecord = createTileRecord();
|
||||
mTileLayout.setListening(true);
|
||||
mTileLayout.setListening(true, null);
|
||||
mTileLayout.addTile(tileRecord);
|
||||
mTileLayout.removeTile(tileRecord);
|
||||
verify(tileRecord.tile, times(1)).setListening(mTileLayout, false);
|
||||
@@ -108,7 +108,7 @@ public class TileLayoutTest extends SysuiTestCase {
|
||||
public void testRemoveAllViews_CallsSetListeningFalseOnAllTiles() {
|
||||
QSPanelControllerBase.TileRecord tileRecord1 = createTileRecord();
|
||||
QSPanelControllerBase.TileRecord tileRecord2 = createTileRecord();
|
||||
mTileLayout.setListening(true);
|
||||
mTileLayout.setListening(true, null);
|
||||
mTileLayout.addTile(tileRecord1);
|
||||
mTileLayout.addTile(tileRecord2);
|
||||
mTileLayout.removeAllViews();
|
||||
|
||||
@@ -231,6 +231,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
||||
when(mView.findViewById(R.id.qs_frame)).thenReturn(mQsFrame);
|
||||
when(mView.findViewById(R.id.keyguard_status_view))
|
||||
.thenReturn(mock(KeyguardStatusView.class));
|
||||
when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar);
|
||||
FlingAnimationUtils.Builder flingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(
|
||||
mDisplayMetrics);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user