summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/anim/overlay_task_fragment_change.xml20
-rw-r--r--core/res/res/anim/overlay_task_fragment_close_to_bottom.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_close_to_left.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_close_to_right.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_close_to_top.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_open_from_bottom.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_open_from_left.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_open_from_right.xml24
-rw-r--r--core/res/res/anim/overlay_task_fragment_open_from_top.xml24
-rw-r--r--core/res/res/values/symbols.xml9
-rw-r--r--libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java123
-rw-r--r--libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java66
12 files changed, 402 insertions, 8 deletions
diff --git a/core/res/res/anim/overlay_task_fragment_change.xml b/core/res/res/anim/overlay_task_fragment_change.xml
new file mode 100644
index 000000000000..eb02ba84d6c1
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_change.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:showBackdrop="false">
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_close_to_bottom.xml b/core/res/res/anim/overlay_task_fragment_close_to_bottom.xml
new file mode 100644
index 000000000000..d9487cba3265
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_close_to_bottom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="0"
+ android:toYDelta="100%"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_close_to_left.xml b/core/res/res/anim/overlay_task_fragment_close_to_left.xml
new file mode 100644
index 000000000000..3cdb77a307d4
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_close_to_left.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="0"
+ android:toXDelta="-100%"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_close_to_right.xml b/core/res/res/anim/overlay_task_fragment_close_to_right.xml
new file mode 100644
index 000000000000..37645610796e
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_close_to_right.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="0"
+ android:toXDelta="100%"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_close_to_top.xml b/core/res/res/anim/overlay_task_fragment_close_to_top.xml
new file mode 100644
index 000000000000..a8bfbbdd0e78
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_close_to_top.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="0"
+ android:toYDelta="-100%"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_open_from_bottom.xml b/core/res/res/anim/overlay_task_fragment_open_from_bottom.xml
new file mode 100644
index 000000000000..1d1223f8ead3
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_open_from_bottom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="100%"
+ android:toYDelta="0"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_open_from_left.xml b/core/res/res/anim/overlay_task_fragment_open_from_left.xml
new file mode 100644
index 000000000000..5e5e080c5fee
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_open_from_left.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="-100%"
+ android:toXDelta="0"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_open_from_right.xml b/core/res/res/anim/overlay_task_fragment_open_from_right.xml
new file mode 100644
index 000000000000..5674ff3199bc
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_open_from_right.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromXDelta="100%"
+ android:toXDelta="0"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/anim/overlay_task_fragment_open_from_top.xml b/core/res/res/anim/overlay_task_fragment_open_from_top.xml
new file mode 100644
index 000000000000..2e3dd0a61031
--- /dev/null
+++ b/core/res/res/anim/overlay_task_fragment_open_from_top.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+ <translate
+ android:fromYDelta="-100%"
+ android:toYDelta="0"
+ android:interpolator="@interpolator/fast_out_extra_slow_in"
+ android:duration="517" />
+</set> \ No newline at end of file
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8823894e18c8..bb615dcb90e6 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1753,6 +1753,15 @@
<java-symbol type="anim" name="task_fragment_clear_top_close_exit" />
<java-symbol type="anim" name="task_fragment_clear_top_open_enter" />
<java-symbol type="anim" name="task_fragment_clear_top_open_exit" />
+ <java-symbol type="anim" name="overlay_task_fragment_open_from_left" />
+ <java-symbol type="anim" name="overlay_task_fragment_open_from_top" />
+ <java-symbol type="anim" name="overlay_task_fragment_open_from_right" />
+ <java-symbol type="anim" name="overlay_task_fragment_open_from_bottom" />
+ <java-symbol type="anim" name="overlay_task_fragment_change" />
+ <java-symbol type="anim" name="overlay_task_fragment_close_to_left" />
+ <java-symbol type="anim" name="overlay_task_fragment_close_to_top" />
+ <java-symbol type="anim" name="overlay_task_fragment_close_to_right" />
+ <java-symbol type="anim" name="overlay_task_fragment_close_to_bottom" />
<java-symbol type="array" name="config_autoRotationTiltTolerance" />
<java-symbol type="array" name="config_longPressVibePattern" />
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
index d0e49d8c403f..eb1fc23d6b00 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitPresenter.java
@@ -20,8 +20,10 @@ import static android.content.pm.PackageManager.MATCH_ALL;
import static androidx.window.extensions.embedding.DividerPresenter.getBoundsOffsetForDivider;
import static androidx.window.extensions.embedding.SplitAttributesHelper.isReversedLayout;
+import static androidx.window.extensions.embedding.SplitController.TAG;
import static androidx.window.extensions.embedding.WindowAttributes.DIM_AREA_ON_TASK;
+import android.annotation.AnimRes;
import android.app.Activity;
import android.app.ActivityThread;
import android.app.WindowConfiguration;
@@ -31,9 +33,11 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
+import android.util.Log;
import android.util.Pair;
import android.util.Size;
import android.view.View;
@@ -56,6 +60,7 @@ import androidx.window.extensions.layout.FoldingFeature;
import androidx.window.extensions.layout.WindowLayoutComponentImpl;
import androidx.window.extensions.layout.WindowLayoutInfo;
+import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.window.flags.Flags;
@@ -125,6 +130,16 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
static final int RESULT_EXPAND_FAILED_NO_TF_INFO = 2;
/**
+ * The key of {@link ActivityStack} alignment relative to its parent container.
+ * <p>
+ * See {@link ContainerPosition} for possible values.
+ * <p>
+ * Note that this constants must align with the definition in WM Jetpack library.
+ */
+ private static final String KEY_ACTIVITY_STACK_ALIGNMENT =
+ "androidx.window.embedding.ActivityStackAlignment";
+
+ /**
* Result of {@link #expandSplitContainerIfNeeded(WindowContainerTransaction, SplitContainer,
* Activity, Activity, Intent)}
*/
@@ -649,14 +664,114 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
// TODO(b/243518738): Update to resizeTaskFragment after we migrate WCT#setRelativeBounds
// and WCT#setWindowingMode to take fragmentToken.
resizeTaskFragmentIfRegistered(wct, container, relativeBounds);
- int windowingMode = container.getTaskContainer().getWindowingModeForTaskFragment(
- relativeBounds);
+ final TaskContainer taskContainer = container.getTaskContainer();
+ final int windowingMode = taskContainer.getWindowingModeForTaskFragment(relativeBounds);
updateTaskFragmentWindowingModeIfRegistered(wct, container, windowingMode);
- // Always use default animation for standalone ActivityStack.
- updateAnimationParams(wct, fragmentToken, TaskFragmentAnimationParams.DEFAULT);
+ if (container.isOverlay() && isOverlayTransitionSupported()) {
+ // Use the overlay transition for the overlay container if it's supported.
+ final TaskFragmentAnimationParams params = createOverlayAnimationParams(relativeBounds,
+ taskContainer.getBounds(), container);
+ updateAnimationParams(wct, fragmentToken, params);
+ } else {
+ // Otherwise, fallabck to use the default animation params.
+ updateAnimationParams(wct, fragmentToken, TaskFragmentAnimationParams.DEFAULT);
+ }
setTaskFragmentDimOnTask(wct, fragmentToken, dimOnTask);
}
+ private static boolean isOverlayTransitionSupported() {
+ return Flags.moveAnimationOptionsToChange()
+ && Flags.activityEmbeddingOverlayPresentationFlag();
+ }
+
+ @NonNull
+ private static TaskFragmentAnimationParams createOverlayAnimationParams(
+ @NonNull Rect relativeBounds, @NonNull Rect parentContainerBounds,
+ @NonNull TaskFragmentContainer container) {
+ if (relativeBounds.isEmpty()) {
+ return TaskFragmentAnimationParams.DEFAULT;
+ }
+
+ final int positionFromOptions = container.getLaunchOptions()
+ .getInt(KEY_ACTIVITY_STACK_ALIGNMENT , -1);
+ final int position = positionFromOptions != -1 ? positionFromOptions
+ // Fallback to calculate from bounds if the info can't be retrieved from options.
+ : getOverlayPosition(relativeBounds, parentContainerBounds);
+
+ return new TaskFragmentAnimationParams.Builder()
+ .setOpenAnimationResId(getOpenAnimationResourcesId(position))
+ .setChangeAnimationResId(R.anim.overlay_task_fragment_change)
+ .setCloseAnimationResId(getCloseAnimationResourcesId(position))
+ .build();
+ }
+
+ @VisibleForTesting
+ @ContainerPosition
+ static int getOverlayPosition(
+ @NonNull Rect relativeBounds, @NonNull Rect parentContainerBounds) {
+ final Rect relativeParentBounds = new Rect(parentContainerBounds);
+ relativeParentBounds.offsetTo(0, 0);
+ final int leftMatch = (relativeParentBounds.left == relativeBounds.left) ? 1 : 0;
+ final int topMatch = (relativeParentBounds.top == relativeBounds.top) ? 1 : 0;
+ final int rightMatch = (relativeParentBounds.right == relativeBounds.right) ? 1 : 0;
+ final int bottomMatch = (relativeParentBounds.bottom == relativeBounds.bottom) ? 1 : 0;
+
+ // Flag format: {left|top|right|bottom}. Note that overlay container could be shrunk and
+ // centered, which makes only one of overlay container edge matches the parent container.
+ final int directionFlag = (leftMatch << 3) + (topMatch << 2) + (rightMatch << 1)
+ + bottomMatch;
+
+ final int position = switch (directionFlag) {
+ // Only the left edge match or only the right edge not match: should be on the left of
+ // the parent container.
+ case 0b1000, 0b1101 -> CONTAINER_POSITION_LEFT;
+ // Only the top edge match or only the bottom edge not match: should be on the top of
+ // the parent container.
+ case 0b0100, 0b1110 -> CONTAINER_POSITION_TOP;
+ // Only the right edge match or only the left edge not match: should be on the right of
+ // the parent container.
+ case 0b0010, 0b0111 -> CONTAINER_POSITION_RIGHT;
+ // Only the bottom edge match or only the top edge not match: should be on the bottom of
+ // the parent container.
+ case 0b0001, 0b1011 -> CONTAINER_POSITION_BOTTOM;
+ default -> {
+ Log.w(TAG, "Unsupported position:" + Integer.toBinaryString(directionFlag)
+ + " fallback to treat it as right. Relative parent bounds: "
+ + relativeParentBounds + ", relative overlay bounds:" + relativeBounds);
+ yield CONTAINER_POSITION_RIGHT;
+ }
+ };
+ return position;
+ }
+
+ @AnimRes
+ private static int getOpenAnimationResourcesId(@ContainerPosition int position) {
+ return switch (position) {
+ case CONTAINER_POSITION_LEFT -> R.anim.overlay_task_fragment_open_from_left;
+ case CONTAINER_POSITION_TOP -> R.anim.overlay_task_fragment_open_from_top;
+ case CONTAINER_POSITION_RIGHT -> R.anim.overlay_task_fragment_open_from_right;
+ case CONTAINER_POSITION_BOTTOM -> R.anim.overlay_task_fragment_open_from_bottom;
+ default -> {
+ Log.w(TAG, "Unknown position:" + position);
+ yield Resources.ID_NULL;
+ }
+ };
+ }
+
+ @AnimRes
+ private static int getCloseAnimationResourcesId(@ContainerPosition int position) {
+ return switch (position) {
+ case CONTAINER_POSITION_LEFT -> R.anim.overlay_task_fragment_close_to_left;
+ case CONTAINER_POSITION_TOP -> R.anim.overlay_task_fragment_close_to_top;
+ case CONTAINER_POSITION_RIGHT -> R.anim.overlay_task_fragment_close_to_right;
+ case CONTAINER_POSITION_BOTTOM -> R.anim.overlay_task_fragment_close_to_bottom;
+ default -> {
+ Log.w(TAG, "Unknown position:" + position);
+ yield Resources.ID_NULL;
+ }
+ };
+ }
+
/**
* Returns the expanded bounds if the {@code relBounds} violate minimum dimension or are not
* fully covered by the task bounds. Otherwise, returns {@code relBounds}.
diff --git a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
index 7a0b9a0ece6b..325750243744 100644
--- a/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
+++ b/libs/WindowManager/Jetpack/tests/unittest/src/androidx/window/extensions/embedding/OverlayPresentationTest.java
@@ -30,6 +30,11 @@ import static androidx.window.extensions.embedding.EmbeddingTestUtils.createSpli
import static androidx.window.extensions.embedding.EmbeddingTestUtils.createSplitPlaceholderRuleBuilder;
import static androidx.window.extensions.embedding.EmbeddingTestUtils.createSplitRule;
import static androidx.window.extensions.embedding.EmbeddingTestUtils.createTfContainer;
+import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_BOTTOM;
+import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_LEFT;
+import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_RIGHT;
+import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSITION_TOP;
+import static androidx.window.extensions.embedding.SplitPresenter.getOverlayPosition;
import static androidx.window.extensions.embedding.SplitPresenter.sanitizeBounds;
import static androidx.window.extensions.embedding.WindowAttributes.DIM_AREA_ON_TASK;
@@ -666,8 +671,8 @@ public class OverlayPresentationTest {
attributes.getRelativeBounds());
verify(mSplitPresenter).updateTaskFragmentWindowingModeIfRegistered(mTransaction, container,
WINDOWING_MODE_MULTI_WINDOW);
- verify(mSplitPresenter).updateAnimationParams(mTransaction, token,
- TaskFragmentAnimationParams.DEFAULT);
+ verify(mSplitPresenter).updateAnimationParams(eq(mTransaction), eq(token),
+ any(TaskFragmentAnimationParams.class));
verify(mSplitPresenter).setTaskFragmentIsolatedNavigation(mTransaction, container, true);
verify(mSplitPresenter, never()).setTaskFragmentPinned(any(),
any(TaskFragmentContainer.class), anyBoolean());
@@ -691,8 +696,8 @@ public class OverlayPresentationTest {
attributes.getRelativeBounds());
verify(mSplitPresenter).updateTaskFragmentWindowingModeIfRegistered(mTransaction,
container, WINDOWING_MODE_MULTI_WINDOW);
- verify(mSplitPresenter).updateAnimationParams(mTransaction, token,
- TaskFragmentAnimationParams.DEFAULT);
+ verify(mSplitPresenter).updateAnimationParams(eq(mTransaction), eq(token),
+ any(TaskFragmentAnimationParams.class));
verify(mSplitPresenter, never()).setTaskFragmentIsolatedNavigation(any(),
any(TaskFragmentContainer.class), anyBoolean());
verify(mSplitPresenter).setTaskFragmentPinned(mTransaction, container, true);
@@ -870,6 +875,59 @@ public class OverlayPresentationTest {
eq(overlayContainer.getTaskFragmentToken()), eq(activityToken));
}
+ // TODO(b/243518738): Rewrite with TestParameter.
+ @Test
+ public void testGetOverlayPosition() {
+ assertWithMessage("It must be position left for left overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left,
+ TASK_BOUNDS.top,
+ TASK_BOUNDS.right / 2,
+ TASK_BOUNDS.bottom), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_LEFT);
+ assertWithMessage("It must be position left for shrunk left overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left,
+ TASK_BOUNDS.top + 20,
+ TASK_BOUNDS.right / 2,
+ TASK_BOUNDS.bottom - 20), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_LEFT);
+ assertWithMessage("It must be position left for top overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left,
+ TASK_BOUNDS.top,
+ TASK_BOUNDS.right,
+ TASK_BOUNDS.bottom / 2), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_TOP);
+ assertWithMessage("It must be position left for shrunk top overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left + 20,
+ TASK_BOUNDS.top,
+ TASK_BOUNDS.right - 20,
+ TASK_BOUNDS.bottom / 2), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_TOP);
+ assertWithMessage("It must be position left for right overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.right / 2,
+ TASK_BOUNDS.top,
+ TASK_BOUNDS.right,
+ TASK_BOUNDS.bottom), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_RIGHT);
+ assertWithMessage("It must be position left for shrunk right overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.right / 2,
+ TASK_BOUNDS.top + 20,
+ TASK_BOUNDS.right,
+ TASK_BOUNDS.bottom - 20), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_RIGHT);
+ assertWithMessage("It must be position left for bottom overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left,
+ TASK_BOUNDS.bottom / 2,
+ TASK_BOUNDS.right,
+ TASK_BOUNDS.bottom), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_BOTTOM);
+ assertWithMessage("It must be position left for shrunk bottom overlay.")
+ .that(getOverlayPosition(new Rect(
+ TASK_BOUNDS.left + 20,
+ TASK_BOUNDS.bottom / 20,
+ TASK_BOUNDS.right - 20,
+ TASK_BOUNDS.bottom), TASK_BOUNDS)).isEqualTo(CONTAINER_POSITION_BOTTOM);
+ }
+
/**
* A simplified version of {@link SplitController#createOrUpdateOverlayTaskFragmentIfNeeded}
*/