Merge "Update ActivityEmbedding default TaskFragment animations to crossfade." into tm-dev am: ca2a3e01da

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

Change-Id: Ica54f254e90fe515ce21d14f202b86379d24dda1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
An An Yu
2022-05-12 17:08:58 +00:00
committed by Automerger Merge Worker
9 changed files with 210 additions and 52 deletions

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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:shareInterpolator="false">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="0"
android:duration="200" />
<translate
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="200" />
</set>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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:shareInterpolator="false">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="35"
android:duration="83" />
<translate
android:fromXDelta="0"
android:toXDelta="-10%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="200" />
</set>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?><!--
/*
** Copyright 2022, 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:shareInterpolator="false">
<alpha
android:fromAlpha="0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="50"
android:duration="83" />
<translate
android:fromXDelta="-10%"
android:toXDelta="0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="450" />
</set>

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?><!--
/*
** Copyright 2022, 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:shareInterpolator="false">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/standard_accelerate"
android:startOffset="0"
android:duration="450" />
<translate
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="450" />
</set>

View File

@@ -17,16 +17,21 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:fromXScale="1.1"
android:toXScale="1"
android:fromYScale="1.1"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="0"
android:duration="200" />
<translate
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="400"/>
android:startOffset="0"
android:duration="200" />
</set>

View File

@@ -19,24 +19,21 @@
android:shareInterpolator="false"
android:zAdjustment="top">
<alpha
android:fromAlpha="1"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="33"
android:duration="50"/>
<scale
android:fromXScale="1"
android:toXScale="0.9"
android:fromYScale="1"
android:toYScale="0.9"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="0"
android:duration="83" />
<translate
android:fromXDelta="0"
android:toXDelta="10%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="400"/>
android:duration="200" />
</set>

View File

@@ -25,17 +25,13 @@
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="50"
android:duration="50"/>
<scale
android:fromXScale="0.85"
android:toXScale="1"
android:fromYScale="0.85"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:duration="83" />
<translate
android:fromXDelta="10%"
android:toXDelta="0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="400"/>
android:duration="400" />
</set>

View File

@@ -17,16 +17,20 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<scale
android:fromXScale="1"
android:toXScale="1.05"
android:fromYScale="1"
android:toYScale="1.05"
android:pivotX="50%"
android:pivotY="50%"
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/standard_accelerate"
android:startOffset="0"
android:duration="400" />
<translate
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="400"/>
android:duration="400" />
</set>

View File

@@ -17,6 +17,8 @@
package androidx.window.extensions.embedding;
import static android.graphics.Matrix.MSCALE_X;
import static android.graphics.Matrix.MTRANS_X;
import static android.graphics.Matrix.MTRANS_Y;
import android.graphics.Rect;
import android.view.Choreographer;
@@ -96,22 +98,20 @@ class TaskFragmentAnimationAdapter {
mTarget.localBounds.left, mTarget.localBounds.top);
t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
t.setAlpha(mLeash, mTransformation.getAlpha());
// Open/close animation may scale up the surface. Apply an inverse scale to the window crop
// so that it will not be covering other windows.
mVecs[1] = mVecs[2] = 0;
mVecs[0] = mVecs[3] = 1;
mTransformation.getMatrix().mapVectors(mVecs);
mVecs[0] = 1.f / mVecs[0];
mVecs[3] = 1.f / mVecs[3];
final Rect clipRect = mTarget.localBounds;
mRect.left = (int) (clipRect.left * mVecs[0] + 0.5f);
mRect.right = (int) (clipRect.right * mVecs[0] + 0.5f);
mRect.top = (int) (clipRect.top * mVecs[3] + 0.5f);
mRect.bottom = (int) (clipRect.bottom * mVecs[3] + 0.5f);
mRect.offsetTo(Math.round(mTarget.localBounds.width() * (1 - mVecs[0]) / 2.f),
Math.round(mTarget.localBounds.height() * (1 - mVecs[3]) / 2.f));
t.setWindowCrop(mLeash, mRect);
// Get current animation position.
final int positionX = Math.round(mMatrix[MTRANS_X]);
final int positionY = Math.round(mMatrix[MTRANS_Y]);
// The exiting surface starts at position: mTarget.localBounds and moves with
// positionX varying. Offset our crop region by the amount we have slided so crop
// regions stays exactly on the original container in split.
final int cropOffsetX = mTarget.localBounds.left - positionX;
final int cropOffsetY = mTarget.localBounds.top - positionY;
final Rect cropRect = new Rect();
cropRect.set(mTarget.localBounds);
// Because window crop uses absolute position.
cropRect.offsetTo(0, 0);
cropRect.offset(cropOffsetX, cropOffsetY);
t.setCrop(mLeash, cropRect);
}
/** Called after animation finished. */