Simplify config changes and request media host layout updates am: 73bf6685f6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20553227

Change-Id: I8048ee00e978d16c15a9b27d0d9ab2575915d2b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Beth Thibodeau
2022-11-29 01:17:10 +00:00
committed by Automerger Merge Worker
6 changed files with 21 additions and 28 deletions

View File

@@ -465,6 +465,8 @@ public class QSPanel extends LinearLayout implements Tunable {
? Math.max(mMediaTotalBottomMargin - getPaddingBottom(), 0) : 0;
layoutParams.topMargin = mediaNeedsTopMargin() && !horizontal
? mMediaTopMargin : 0;
// Call setLayoutParams explicitly to ensure that requestLayout happens
hostView.setLayoutParams(layoutParams);
}
}

View File

@@ -21,7 +21,6 @@ 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.content.res.Configuration;
import android.view.MotionEvent;
import android.view.View;
@@ -63,17 +62,6 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
private boolean mGridContentVisible = true;
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
new QSPanel.OnConfigurationChangedListener() {
@Override
public void onConfigurationChange(Configuration newConfig) {
mView.updateResources();
if (mView.isListening()) {
refreshAllTiles();
}
}
};
private View.OnTouchListener mTileLayoutTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -131,7 +119,6 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
if (mView.isListening()) {
refreshAllTiles();
}
mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener);
switchTileLayout(true);
mBrightnessMirrorHandler.onQsPanelAttached();
@@ -148,11 +135,18 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {
@Override
protected void onViewDetached() {
mTunerService.removeTunable(mView);
mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener);
mBrightnessMirrorHandler.onQsPanelDettached();
super.onViewDetached();
}
@Override
protected void onConfigurationChanged() {
mView.updateResources();
if (mView.isListening()) {
refreshAllTiles();
}
}
/** */
public void setVisibility(int visibility) {
mView.setVisibility(visibility);

View File

@@ -90,11 +90,11 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
LargeScreenUtils.shouldUseSplitNotificationShade(getResources());
mQSLogger.logOnConfigurationChanged(mLastOrientation, newConfig.orientation,
mView.getDumpableTag());
onConfigurationChanged();
if (newConfig.orientation != mLastOrientation) {
mLastOrientation = newConfig.orientation;
switchTileLayout(false);
}
onConfigurationChanged();
}
};
@@ -408,6 +408,8 @@ public abstract class QSPanelControllerBase<T extends QSPanel> extends ViewContr
}
if (mMediaHost != null) {
pw.println(" media bounds: " + mMediaHost.getCurrentBounds());
pw.println(" horizontal layout: " + mUsingHorizontalLayout);
pw.println(" last orientation: " + mLastOrientation);
}
}

View File

@@ -44,14 +44,6 @@ import javax.inject.Named;
@QSScope
public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel> {
private final QSPanel.OnConfigurationChangedListener mOnConfigurationChangedListener =
newConfig -> {
int newMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_tiles);
if (newMaxTiles != mView.getNumQuickTiles()) {
setMaxTiles(newMaxTiles);
}
};
private final boolean mUsingCollapsedLandscapeMedia;
@Inject
@@ -95,13 +87,11 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
@Override
protected void onViewAttached() {
super.onViewAttached();
mView.addOnConfigurationChangedListener(mOnConfigurationChangedListener);
}
@Override
protected void onViewDetached() {
super.onViewDetached();
mView.removeOnConfigurationChangedListener(mOnConfigurationChangedListener);
}
private void setMaxTiles(int parseNumTiles) {
@@ -111,6 +101,10 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
@Override
protected void onConfigurationChanged() {
int newMaxTiles = getResources().getInteger(R.integer.quick_qs_panel_max_tiles);
if (newMaxTiles != mView.getNumQuickTiles()) {
setMaxTiles(newMaxTiles);
}
updateMediaExpansion();
}

View File

@@ -224,7 +224,9 @@ public class QSPanelControllerBaseTest extends SysuiTestCase {
+ " Tile records:\n"
+ " " + mockTileString + "\n"
+ " " + mockTileViewString + "\n"
+ " media bounds: null\n";
+ " media bounds: null\n"
+ " horizontal layout: false\n"
+ " last orientation: 0\n";
assertEquals(expected, w.getBuffer().toString());
}

View File

@@ -126,8 +126,7 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
@Test
fun testMediaExpansionUpdatedWhenConfigurationChanged() {
// times(2) because both controller and base controller are registering their listeners
verify(quickQSPanel, times(2)).addOnConfigurationChangedListener(captor.capture())
verify(quickQSPanel).addOnConfigurationChangedListener(captor.capture())
// verify that media starts in the expanded state by default
verify(mediaHost).expansion = MediaHostState.EXPANDED