Merge "ScreenDecorations: Update corner radius when configuration changes" into pi-dev
This commit is contained in:
@@ -89,9 +89,9 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
private DisplayManager mDisplayManager;
|
||||
private DisplayManager.DisplayListener mDisplayListener;
|
||||
|
||||
private int mRoundedDefault;
|
||||
private int mRoundedDefaultTop;
|
||||
private int mRoundedDefaultBottom;
|
||||
@VisibleForTesting protected int mRoundedDefault;
|
||||
@VisibleForTesting protected int mRoundedDefaultTop;
|
||||
@VisibleForTesting protected int mRoundedDefaultBottom;
|
||||
private View mOverlay;
|
||||
private View mBottomOverlay;
|
||||
private float mDensity;
|
||||
@@ -119,12 +119,7 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
private void startOnScreenDecorationsThread() {
|
||||
mRotation = RotationUtils.getExactRotation(mContext);
|
||||
mWindowManager = mContext.getSystemService(WindowManager.class);
|
||||
mRoundedDefault = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius);
|
||||
mRoundedDefaultTop = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_top);
|
||||
mRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_bottom);
|
||||
updateRoundedCornerRadii();
|
||||
if (hasRoundedCorners() || shouldDrawCutout()) {
|
||||
setupDecorations();
|
||||
}
|
||||
@@ -249,6 +244,7 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
int oldRotation = mRotation;
|
||||
mPendingRotationChange = false;
|
||||
updateOrientation();
|
||||
updateRoundedCornerRadii();
|
||||
if (DEBUG) Log.i(TAG, "onConfigChanged from rot " + oldRotation + " to " + mRotation);
|
||||
if (shouldDrawCutout() && mOverlay == null) {
|
||||
setupDecorations();
|
||||
@@ -281,6 +277,26 @@ public class ScreenDecorations extends SystemUI implements Tunable {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRoundedCornerRadii() {
|
||||
final int newRoundedDefault = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius);
|
||||
final int newRoundedDefaultTop = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_top);
|
||||
final int newRoundedDefaultBottom = mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.rounded_corner_radius_bottom);
|
||||
|
||||
final boolean roundedCornersChanged = mRoundedDefault != newRoundedDefault
|
||||
|| mRoundedDefaultBottom != newRoundedDefaultBottom
|
||||
|| mRoundedDefaultTop != newRoundedDefaultTop;
|
||||
|
||||
if (roundedCornersChanged) {
|
||||
mRoundedDefault = newRoundedDefault;
|
||||
mRoundedDefaultTop = newRoundedDefaultTop;
|
||||
mRoundedDefaultBottom = newRoundedDefaultBottom;
|
||||
onTuningChanged(SIZE, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateViews() {
|
||||
View topLeft = mOverlay.findViewById(R.id.left);
|
||||
View topRight = mOverlay.findViewById(R.id.right);
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.systemui.tuner.TunablePadding.FLAG_START;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -226,4 +227,17 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
||||
verify(padding).destroy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateRoundedCorners() {
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
com.android.internal.R.bool.config_fillMainBuiltInDisplayCutout, false);
|
||||
mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 20);
|
||||
|
||||
mScreenDecorations.start();
|
||||
assertEquals(mScreenDecorations.mRoundedDefault, 20);
|
||||
|
||||
mContext.getOrCreateTestableResources().addOverride(dimen.rounded_corner_radius, 5);
|
||||
mScreenDecorations.onConfigurationChanged(null);
|
||||
assertEquals(mScreenDecorations.mRoundedDefault, 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user