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

This commit is contained in:
An An Yu
2022-05-12 16:00:51 +00:00
committed by Android (Google) Code Review
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" <set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"> android:shareInterpolator="false">
<scale <alpha
android:fromXScale="1.1" android:fromAlpha="1.0"
android:toXScale="1" android:toAlpha="1.0"
android:fromYScale="1.1" android:fillEnabled="true"
android:toYScale="1" android:fillBefore="true"
android:pivotX="50%" android:fillAfter="true"
android:pivotY="50%" android:interpolator="@interpolator/linear"
android:startOffset="0"
android:duration="200" />
<translate
android:fillEnabled="true" android:fillEnabled="true"
android:fillBefore="true" android:fillBefore="true"
android:fillAfter="true" android:fillAfter="true"
android:interpolator="@interpolator/fast_out_extra_slow_in" android:interpolator="@interpolator/fast_out_extra_slow_in"
android:duration="400"/> android:startOffset="0"
android:duration="200" />
</set> </set>

View File

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

View File

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

View File

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

View File

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