Merge changes I037517d9,Ic603b271,I47fe530f into sc-qpr1-dev

* changes:
  Update task transition animations
  Show color layer in task animations when requested
  Add color layer to TaskDisplayArea for animations
This commit is contained in:
Pablo Gamito
2021-09-21 22:30:21 +00:00
committed by Android (Google) Code Review
18 changed files with 262 additions and 483 deletions

View File

@@ -18,19 +18,10 @@
-->
<!-- This should be kept in sync with task_open_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:hasRoundedCorners="true"
android:shareInterpolator="false"
android:zAdjustment="top">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="-105%"
@@ -38,36 +29,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- To keep the thumbnail around longer and fade out the thumbnail -->
<alpha android:fromAlpha="1.0" android:toAlpha="0"

View File

@@ -14,20 +14,10 @@
~ limitations under the License
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="105%"
@@ -35,34 +25,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
</set>

View File

@@ -15,19 +15,9 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="283"/>
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="0"
@@ -35,22 +25,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0"
android:toXScale="0.95"
android:fromYScale="1.0"
android:toYScale="0.95"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- This is needed to keep the animation running while task_open_enter completes -->
<alpha

View File

@@ -16,20 +16,10 @@
<!-- This should in sync with task_open_enter_cross_profile_apps.xml -->
<!-- This should in sync with cross_profile_apps_thumbnail_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="-105%"
@@ -37,34 +27,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
</set>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
</set>

View File

@@ -16,20 +16,10 @@
-->
<!-- This should in sync with task_open_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="-105%"
@@ -37,36 +27,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- To keep the transition around longer for the thumbnail, should be kept in sync with
cross_profile_apps_thumbmail.xml -->
@@ -75,4 +38,4 @@
android:toAlpha="1.0"
android:startOffset="717"
android:duration="200"/>
</set>
</set>

View File

@@ -15,19 +15,9 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="283"/>
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="0"
@@ -35,22 +25,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0"
android:toXScale="0.95"
android:fromYScale="1.0"
android:toYScale="0.95"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- This is needed to keep the animation running while task_open_enter completes -->
<alpha

View File

@@ -19,18 +19,9 @@
<!-- This should be kept in sync with task_open_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:zAdjustment="top">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:background="@color/overview_background">
<translate
android:fromXDelta="105%"
@@ -38,36 +29,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- To keep the thumbnail around longer and fade out the thumbnail -->
<alpha android:fromAlpha="1.0" android:toAlpha="0"

View File

@@ -16,20 +16,10 @@
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="-105%"
@@ -37,34 +27,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
</set>

View File

@@ -17,19 +17,9 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="283"/>
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="0"
@@ -37,22 +27,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0"
android:toXScale="0.95"
android:fromYScale="1.0"
android:toYScale="0.95"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- This is needed to keep the animation running while task_open_enter completes -->
<alpha

View File

@@ -15,23 +15,13 @@
** limitations under the License.
*/
-->
<!-- This should in sync with task_open_enter_cross_profile_apps.xml -->
<!-- This should in sync with cross_profile_apps_thumbnail_enter.xml -->
<!-- This should be kept in sync with task_open_enter_cross_profile_apps.xml -->
<!-- This should be kept in sync with cross_profile_apps_thumbnail_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="105%"
@@ -39,34 +29,7 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
</set>

View File

@@ -18,20 +18,10 @@
-->
<!-- This should in sync with task_open_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1"
android:toAlpha="1.0"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="217"/>
android:shareInterpolator="false"
android:zAdjustment="top"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="105%"
@@ -39,36 +29,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0526"
android:toXScale="1"
android:fromYScale="1.0526"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
<scale
android:fromXScale="0.95"
android:toXScale="1"
android:fromYScale="0.95"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/fast_out_slow_in"
android:startOffset="283"
android:duration="317"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- To keep the transition around longer for the thumbnail, should be kept in sync with
cross_profile_apps_thumbmail.xml -->

View File

@@ -17,19 +17,9 @@
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:showWallpaper="true">
<alpha
android:fromAlpha="1.0"
android:toAlpha="1"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/linear"
android:startOffset="67"
android:duration="283"/>
android:shareInterpolator="false"
android:hasRoundedCorners="true"
android:background="@color/overview_background">
<translate
android:fromXDelta="0"
@@ -37,22 +27,9 @@
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:interpolator="@interpolator/aggressive_ease"
android:startOffset="50"
android:duration="383"/>
<scale
android:fromXScale="1.0"
android:toXScale="0.95"
android:fromYScale="1.0"
android:toYScale="0.95"
android:fillEnabled="true"
android:fillBefore="true"
android:fillAfter="true"
android:pivotX="50%"
android:pivotY="50%"
android:interpolator="@interpolator/fast_out_slow_in"
android:duration="283"/>
android:interpolator="@interpolator/fast_out_extra_slow_in"
android:startOffset="0"
android:duration="500"/>
<!-- This is needed to keep the animation running while task_open_enter completes -->
<alpha

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral2_500" android:lStar="87" />
</selector>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2021 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/system_neutral2_500" android:lStar="35" />
</selector>

View File

@@ -33,4 +33,6 @@
<color name="call_notification_answer_color">#5DBA80</color>
<color name="personal_apps_suspension_notification_color">#8AB4F8</color>
<color name="overview_background">@color/overview_background_dark</color>
</resources>

View File

@@ -59,11 +59,30 @@ class SurfaceAnimator {
@VisibleForTesting
final Animatable mAnimatable;
private final OnAnimationFinishedCallback mInnerAnimationFinishedCallback;
/**
* Static callback to run on all animations started through this SurfaceAnimator
* when an animation on a Surface is finished or cancelled without restart.
*/
@VisibleForTesting
@Nullable
final OnAnimationFinishedCallback mStaticAnimationFinishedCallback;
/**
* Callback unique to each animation (i.e. AnimationAdapter). To be run when an animation on a
* Surface is finished or cancelled without restart.
*/
@Nullable
private OnAnimationFinishedCallback mAnimationFinishedCallback;
private OnAnimationFinishedCallback mSurfaceAnimationFinishedCallback;
/**
* The callback is triggered after the SurfaceAnimator sends a cancel call to the underlying
* AnimationAdapter.
* NOTE: Must be called wherever we call onAnimationCancelled on mAnimation.
*/
@Nullable
private Runnable mAnimationCancelledCallback;
private boolean mAnimationStartDelayed;
/**
@@ -100,7 +119,7 @@ class SurfaceAnimator {
return;
}
final OnAnimationFinishedCallback animationFinishCallback =
mAnimationFinishedCallback;
mSurfaceAnimationFinishedCallback;
reset(mAnimatable.getPendingTransaction(), true /* destroyLeash */);
if (staticAnimationFinishedCallback != null) {
staticAnimationFinishedCallback.onAnimationFinished(type, anim);
@@ -130,15 +149,19 @@ class SurfaceAnimator {
* This is important as it will start with the leash hidden or visible before
* handing it to the component that is responsible to run the animation.
* @param animationFinishedCallback The callback being triggered when the animation finishes.
* @param animationCancelledCallback The callback is triggered after the SurfaceAnimator sends a
* cancel call to the underlying AnimationAdapter.
*/
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type,
@Nullable OnAnimationFinishedCallback animationFinishedCallback,
@Nullable Runnable animationCancelledCallback,
@Nullable SurfaceFreezer freezer) {
cancelAnimation(t, true /* restarting */, true /* forwardCancel */);
mAnimation = anim;
mAnimationType = type;
mAnimationFinishedCallback = animationFinishedCallback;
mSurfaceAnimationFinishedCallback = animationFinishedCallback;
mAnimationCancelledCallback = animationCancelledCallback;
final SurfaceControl surface = mAnimatable.getSurfaceControl();
if (surface == null) {
Slog.w(TAG, "Unable to start animation, surface is null or no children.");
@@ -160,15 +183,10 @@ class SurfaceAnimator {
mAnimation.startAnimation(mLeash, t, type, mInnerAnimationFinishedCallback);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type,
@Nullable OnAnimationFinishedCallback animationFinishedCallback) {
startAnimation(t, anim, hidden, type, animationFinishedCallback, null /* freezer */);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type) {
startAnimation(t, anim, hidden, type, null /* animationFinishedCallback */);
startAnimation(t, anim, hidden, type, null /* animationFinishedCallback */,
null /* animationCancelledCallback */, null /* freezer */);
}
/**
@@ -278,7 +296,8 @@ class SurfaceAnimator {
mLeash = from.mLeash;
mAnimation = from.mAnimation;
mAnimationType = from.mAnimationType;
mAnimationFinishedCallback = from.mAnimationFinishedCallback;
mSurfaceAnimationFinishedCallback = from.mSurfaceAnimationFinishedCallback;
mAnimationCancelledCallback = from.mAnimationCancelledCallback;
// Cancel source animation, but don't let animation runner cancel the animation.
from.cancelAnimation(t, false /* restarting */, false /* forwardCancel */);
@@ -306,11 +325,16 @@ class SurfaceAnimator {
final SurfaceControl leash = mLeash;
final AnimationAdapter animation = mAnimation;
final @AnimationType int animationType = mAnimationType;
final OnAnimationFinishedCallback animationFinishedCallback = mAnimationFinishedCallback;
final OnAnimationFinishedCallback animationFinishedCallback =
mSurfaceAnimationFinishedCallback;
final Runnable animationCancelledCallback = mAnimationCancelledCallback;
reset(t, false);
if (animation != null) {
if (!mAnimationStartDelayed && forwardCancel) {
animation.onAnimationCancelled(leash);
if (animationCancelledCallback != null) {
animationCancelledCallback.run();
}
}
if (!restarting) {
if (mStaticAnimationFinishedCallback != null) {
@@ -335,7 +359,7 @@ class SurfaceAnimator {
private void reset(Transaction t, boolean destroyLeash) {
mService.mAnimationTransferMap.remove(mAnimation);
mAnimation = null;
mAnimationFinishedCallback = null;
mSurfaceAnimationFinishedCallback = null;
mAnimationType = ANIMATION_TYPE_NONE;
if (mLeash == null) {
return;

View File

@@ -42,6 +42,9 @@ import static com.android.server.wm.Task.TASK_VISIBILITY_VISIBLE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ROOT_TASK;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static java.lang.Integer.MIN_VALUE;
import android.annotation.ColorInt;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
@@ -79,6 +82,22 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
DisplayContent mDisplayContent;
/**
* A color layer that serves as a solid color background to certain animations.
*/
private SurfaceControl mColorBackgroundLayer;
/**
* This counter is used to make sure we don't prematurely clear the background color in the
* case that background color animations are interleaved.
* NOTE: The last set color will remain until the counter is reset to 0, which means that an
* animation background color may sometime remain after the animation has finished through an
* animation with a different background color if an animation starts after and ends before
* another where both set different background colors. However, this is not a concern as
* currently all task animation backgrounds are the same color.
*/
private int mColorLayerCounter = 0;
/**
* A control placed at the appropriate level for transitions to occur.
*/
@@ -961,6 +980,11 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
void onParentChanged(ConfigurationContainer newParent, ConfigurationContainer oldParent) {
if (getParent() != null) {
super.onParentChanged(newParent, oldParent, () -> {
mColorBackgroundLayer = makeChildSurface(null)
.setColorLayer()
.setName("colorBackgroundLayer")
.setCallsite("TaskDisplayArea.onParentChanged")
.build();
mAppAnimationLayer = makeChildSurface(null)
.setName("animationLayer")
.setCallsite("TaskDisplayArea.onParentChanged")
@@ -977,6 +1001,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
.setName("splitScreenDividerAnchor")
.setCallsite("TaskDisplayArea.onParentChanged")
.build();
getSyncTransaction()
.show(mAppAnimationLayer)
.show(mBoostedAppAnimationLayer)
@@ -986,11 +1011,13 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
} else {
super.onParentChanged(newParent, oldParent);
mWmService.mTransactionFactory.get()
.remove(mColorBackgroundLayer)
.remove(mAppAnimationLayer)
.remove(mBoostedAppAnimationLayer)
.remove(mHomeAppAnimationLayer)
.remove(mSplitScreenDividerAnchor)
.apply();
mColorBackgroundLayer = null;
mAppAnimationLayer = null;
mBoostedAppAnimationLayer = null;
mHomeAppAnimationLayer = null;
@@ -998,6 +1025,39 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
}
}
void setBackgroundColor(@ColorInt int color) {
if (mColorBackgroundLayer == null) {
return;
}
float r = ((color >> 16) & 0xff) / 255.0f;
float g = ((color >> 8) & 0xff) / 255.0f;
float b = ((color >> 0) & 0xff) / 255.0f;
float a = ((color >> 24) & 0xff) / 255.0f;
mColorLayerCounter++;
getPendingTransaction().setLayer(mColorBackgroundLayer, MIN_VALUE)
.setColor(mColorBackgroundLayer, new float[]{r, g, b})
.setAlpha(mColorBackgroundLayer, a)
.setWindowCrop(mColorBackgroundLayer, getSurfaceWidth(), getSurfaceHeight())
.setPosition(mColorBackgroundLayer, 0, 0)
.show(mColorBackgroundLayer);
scheduleAnimation();
}
void clearBackgroundColor() {
mColorLayerCounter--;
// Only clear the color layer if we have received the same amounts of clear as set
// requests.
if (mColorLayerCounter == 0) {
getPendingTransaction().hide(mColorBackgroundLayer);
scheduleAnimation();
}
}
@Override
void migrateToNewSurfaceControl(SurfaceControl.Transaction t) {
super.migrateToNewSurfaceControl(t);
@@ -1006,6 +1066,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
}
// As TaskDisplayArea is getting a new surface, reparent and reorder the child surfaces.
t.reparent(mColorBackgroundLayer, mSurfaceControl);
t.reparent(mAppAnimationLayer, mSurfaceControl);
t.reparent(mBoostedAppAnimationLayer, mSurfaceControl);
t.reparent(mHomeAppAnimationLayer, mSurfaceControl);
@@ -2148,6 +2209,11 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
mPreferredTopFocusableRootTask = null;
}
@Override
TaskDisplayArea getTaskDisplayArea() {
return this;
}
@Override
boolean isTaskDisplayArea() {
return true;

View File

@@ -850,6 +850,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return parent != null ? parent.getRootDisplayArea() : null;
}
@Nullable
TaskDisplayArea getTaskDisplayArea() {
WindowContainer parent = getParent();
return parent != null ? parent.getTaskDisplayArea() : null;
}
boolean isAttached() {
return getDisplayArea() != null;
}
@@ -2495,10 +2501,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
* some point but the meaning is too weird to work for all containers.
* @param type The type of animation defined as {@link AnimationType}.
* @param animationFinishedCallback The callback being triggered when the animation finishes.
* @param animationCancelledCallback The callback is triggered after the SurfaceAnimator sends a
* cancel call to the underlying AnimationAdapter.
*/
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type,
@Nullable OnAnimationFinishedCallback animationFinishedCallback) {
@Nullable OnAnimationFinishedCallback animationFinishedCallback,
@Nullable Runnable animationCancelledCallback) {
if (DEBUG_ANIM) {
Slog.v(TAG, "Starting animation on " + this + ": type=" + type + ", anim=" + anim);
}
@@ -2506,7 +2515,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
// TODO: This should use isVisible() but because isVisible has a really weird meaning at
// the moment this doesn't work for all animatable window containers.
mSurfaceAnimator.startAnimation(t, anim, hidden, type, animationFinishedCallback,
mSurfaceFreezer);
animationCancelledCallback, mSurfaceFreezer);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@AnimationType int type,
@Nullable OnAnimationFinishedCallback animationFinishedCallback) {
startAnimation(t, anim, hidden, type, animationFinishedCallback,
null /* adapterAnimationCancelledCallback */);
}
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden,
@@ -2714,8 +2730,27 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
if (sources != null) {
mSurfaceAnimationSources.addAll(sources);
}
TaskDisplayArea taskDisplayArea = getTaskDisplayArea();
int backgroundColor = adapter.getBackgroundColor();
boolean shouldSetBackgroundColor = taskDisplayArea != null && backgroundColor != 0;
if (shouldSetBackgroundColor) {
taskDisplayArea.setBackgroundColor(backgroundColor);
}
Runnable clearColorBackground = () -> {
if (shouldSetBackgroundColor) {
taskDisplayArea.clearBackgroundColor();
}
};
startAnimation(getPendingTransaction(), adapter, !isVisible(),
ANIMATION_TYPE_APP_TRANSITION);
ANIMATION_TYPE_APP_TRANSITION,
(type, anim) -> clearColorBackground.run(),
clearColorBackground);
if (adapter.getShowWallpaper()) {
getDisplayContent().pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
}