Merge changes from topic "new-size-spec" into tm-qpr-dev am: 3ef8a24aa1

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

Change-Id: I79840bbfc974db8cb3e4a7a57750849f35931fd5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ikram Gabiyev
2023-02-03 06:12:35 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 12 deletions

View File

@@ -45,8 +45,9 @@ public class PipSizeSpecHandler {
@VisibleForTesting @VisibleForTesting
final SizeSpecSource mSizeSpecSourceImpl; final SizeSpecSource mSizeSpecSourceImpl;
/** The preferred minimum (and default) size specified by apps. */ /** The preferred minimum (and default minimum) size specified by apps. */
@Nullable private Size mOverrideMinSize; @Nullable private Size mOverrideMinSize;
private int mOverridableMinSize;
/** Used to store values obtained from resource files. */ /** Used to store values obtained from resource files. */
private Point mScreenEdgeInsets; private Point mScreenEdgeInsets;
@@ -386,6 +387,8 @@ public class PipSizeSpecHandler {
mDefaultMinSize = res.getDimensionPixelSize( mDefaultMinSize = res.getDimensionPixelSize(
R.dimen.default_minimal_size_pip_resizable_task); R.dimen.default_minimal_size_pip_resizable_task);
mOverridableMinSize = res.getDimensionPixelSize(
R.dimen.overridable_minimal_size_pip_resizable_task);
final String screenEdgeInsetsDpString = res.getString( final String screenEdgeInsetsDpString = res.getString(
R.string.config_defaultPictureInPictureScreenEdgeInsets); R.string.config_defaultPictureInPictureScreenEdgeInsets);
@@ -443,13 +446,19 @@ public class PipSizeSpecHandler {
/** Returns the preferred minimal size specified by the activity in PIP. */ /** Returns the preferred minimal size specified by the activity in PIP. */
@Nullable @Nullable
public Size getOverrideMinSize() { public Size getOverrideMinSize() {
if (mOverrideMinSize != null
&& (mOverrideMinSize.getWidth() < mOverridableMinSize
|| mOverrideMinSize.getHeight() < mOverridableMinSize)) {
return new Size(mOverridableMinSize, mOverridableMinSize);
}
return mOverrideMinSize; return mOverrideMinSize;
} }
/** Returns the minimum edge size of the override minimum size, or 0 if not set. */ /** Returns the minimum edge size of the override minimum size, or 0 if not set. */
public int getOverrideMinEdgeSize() { public int getOverrideMinEdgeSize() {
if (mOverrideMinSize == null) return 0; if (mOverrideMinSize == null) return 0;
return Math.min(mOverrideMinSize.getWidth(), mOverrideMinSize.getHeight()); return Math.min(getOverrideMinSize().getWidth(), getOverrideMinSize().getHeight());
} }
public int getMinEdgeSize() { public int getMinEdgeSize() {
@@ -505,7 +514,7 @@ public class PipSizeSpecHandler {
if (mOverrideMinSize == null) { if (mOverrideMinSize == null) {
return null; return null;
} }
final Size size = mOverrideMinSize; final Size size = getOverrideMinSize();
final float sizeAspectRatio = size.getWidth() / (float) size.getHeight(); final float sizeAspectRatio = size.getWidth() / (float) size.getHeight();
if (sizeAspectRatio > aspectRatio) { if (sizeAspectRatio > aspectRatio) {
// Size is wider, fix the width and increase the height // Size is wider, fix the width and increase the height

View File

@@ -300,9 +300,9 @@ public class PipBoundsAlgorithmTest extends ShellTestCase {
(MAX_ASPECT_RATIO + DEFAULT_ASPECT_RATIO) / 2 (MAX_ASPECT_RATIO + DEFAULT_ASPECT_RATIO) / 2
}; };
final Size[] minimalSizes = new Size[] { final Size[] minimalSizes = new Size[] {
new Size((int) (100 * aspectRatios[0]), 100), new Size((int) (200 * aspectRatios[0]), 200),
new Size((int) (100 * aspectRatios[1]), 100), new Size((int) (200 * aspectRatios[1]), 200),
new Size((int) (100 * aspectRatios[2]), 100) new Size((int) (200 * aspectRatios[2]), 200)
}; };
for (int i = 0; i < aspectRatios.length; i++) { for (int i = 0; i < aspectRatios.length; i++) {
final float aspectRatio = aspectRatios[i]; final float aspectRatio = aspectRatios[i];

View File

@@ -162,10 +162,10 @@ public class PipBoundsStateTest extends ShellTestCase {
@Test @Test
public void testSetOverrideMinSize_notChanged_callbackNotInvoked() { public void testSetOverrideMinSize_notChanged_callbackNotInvoked() {
final Runnable callback = mock(Runnable.class); final Runnable callback = mock(Runnable.class);
mPipBoundsState.setOverrideMinSize(new Size(5, 5)); mPipBoundsState.setOverrideMinSize(new Size(100, 150));
mPipBoundsState.setOnMinimalSizeChangeCallback(callback); mPipBoundsState.setOnMinimalSizeChangeCallback(callback);
mPipBoundsState.setOverrideMinSize(new Size(5, 5)); mPipBoundsState.setOverrideMinSize(new Size(100, 150));
verify(callback, never()).run(); verify(callback, never()).run();
} }
@@ -175,11 +175,11 @@ public class PipBoundsStateTest extends ShellTestCase {
mPipBoundsState.setOverrideMinSize(null); mPipBoundsState.setOverrideMinSize(null);
assertEquals(0, mPipBoundsState.getOverrideMinEdgeSize()); assertEquals(0, mPipBoundsState.getOverrideMinEdgeSize());
mPipBoundsState.setOverrideMinSize(new Size(5, 10)); mPipBoundsState.setOverrideMinSize(new Size(100, 110));
assertEquals(5, mPipBoundsState.getOverrideMinEdgeSize()); assertEquals(100, mPipBoundsState.getOverrideMinEdgeSize());
mPipBoundsState.setOverrideMinSize(new Size(15, 10)); mPipBoundsState.setOverrideMinSize(new Size(150, 200));
assertEquals(10, mPipBoundsState.getOverrideMinEdgeSize()); assertEquals(150, mPipBoundsState.getOverrideMinEdgeSize());
} }
@Test @Test