Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 19 | import static android.view.WindowManagerInternal.AppTransitionListener; |
| 20 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation; |
| 21 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation; |
| 22 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation; |
| 23 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation; |
| 24 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation; |
| 25 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation; |
| 26 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation; |
| 27 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation; |
| 28 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation; |
| 29 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation; |
| 30 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation; |
| 31 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation; |
| 32 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation; |
| 33 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation; |
| 34 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation; |
| 35 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation; |
| 36 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation; |
| 37 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation; |
| 38 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation; |
| 39 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation; |
| 40 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation; |
| 41 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation; |
Filip Gruszczynski | 198dcbf | 2016-01-18 10:02:00 -0800 | [diff] [blame] | 42 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; |
| 43 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 44 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 45 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 46 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_NONE; |
| 47 | import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM; |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 48 | |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 49 | import android.annotation.Nullable; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 50 | import android.content.Context; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 51 | import android.content.res.Configuration; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 52 | import android.graphics.Bitmap; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 53 | import android.graphics.Path; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 54 | import android.graphics.Rect; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 55 | import android.os.Debug; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 56 | import android.os.IBinder; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 57 | import android.os.IRemoteCallback; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 58 | import android.os.RemoteException; |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 59 | import android.util.ArraySet; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 60 | import android.util.Slog; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 61 | import android.util.SparseArray; |
| 62 | import android.view.AppTransitionAnimationSpec; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 63 | import android.view.IAppTransitionAnimationSpecsFuture; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 64 | import android.view.WindowManager; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 65 | import android.view.animation.AlphaAnimation; |
| 66 | import android.view.animation.Animation; |
| 67 | import android.view.animation.AnimationSet; |
| 68 | import android.view.animation.AnimationUtils; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 69 | import android.view.animation.ClipRectAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 70 | import android.view.animation.Interpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 71 | import android.view.animation.PathInterpolator; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 72 | import android.view.animation.ScaleAnimation; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 73 | import android.view.animation.TranslateAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 74 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 75 | import com.android.internal.util.DumpUtils.Dump; |
| 76 | import com.android.server.AttributeCache; |
| 77 | import com.android.server.wm.WindowManagerService.H; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 78 | import com.android.server.wm.animation.ClipRectLRAnimation; |
| 79 | import com.android.server.wm.animation.ClipRectTBAnimation; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 80 | import com.android.server.wm.animation.CurvedTranslateAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 81 | |
| 82 | import java.io.PrintWriter; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 83 | import java.util.ArrayList; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 84 | import java.util.concurrent.ExecutorService; |
| 85 | import java.util.concurrent.Executors; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 86 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 87 | // State management of app transitions. When we are preparing for a |
| 88 | // transition, mNextAppTransition will be the kind of transition to |
| 89 | // perform or TRANSIT_NONE if we are not waiting. If we are waiting, |
| 90 | // mOpeningApps and mClosingApps are the lists of tokens that will be |
| 91 | // made visible or hidden at the next transition. |
| 92 | public class AppTransition implements Dump { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 93 | private static final String TAG = TAG_WITH_CLASS_NAME ? "AppTransition" : TAG_WM; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 94 | private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 95 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 96 | /** Not set up for a transition. */ |
| 97 | public static final int TRANSIT_UNSET = -1; |
| 98 | /** No animation for transition. */ |
| 99 | public static final int TRANSIT_NONE = 0; |
| 100 | /** A window in a new activity is being opened on top of an existing one in the same task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 101 | public static final int TRANSIT_ACTIVITY_OPEN = 6; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 102 | /** The window in the top-most activity is being closed to reveal the |
| 103 | * previous activity in the same task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 104 | public static final int TRANSIT_ACTIVITY_CLOSE = 7; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 105 | /** A window in a new task is being opened on top of an existing one |
| 106 | * in another activity's task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 107 | public static final int TRANSIT_TASK_OPEN = 8; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 108 | /** A window in the top-most activity is being closed to reveal the |
| 109 | * previous activity in a different task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 110 | public static final int TRANSIT_TASK_CLOSE = 9; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 111 | /** A window in an existing task is being displayed on top of an existing one |
| 112 | * in another activity's task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 113 | public static final int TRANSIT_TASK_TO_FRONT = 10; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 114 | /** A window in an existing task is being put below all other tasks. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 115 | public static final int TRANSIT_TASK_TO_BACK = 11; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 116 | /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that |
| 117 | * does, effectively closing the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 118 | public static final int TRANSIT_WALLPAPER_CLOSE = 12; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 119 | /** A window in a new activity that does have a wallpaper is being opened on one that didn't, |
| 120 | * effectively opening the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 121 | public static final int TRANSIT_WALLPAPER_OPEN = 13; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 122 | /** A window in a new activity is being opened on top of an existing one, and both are on top |
| 123 | * of the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 124 | public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 125 | /** The window in the top-most activity is being closed to reveal the previous activity, and |
| 126 | * both are on top of the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 127 | public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15; |
| 128 | /** A window in a new task is being opened behind an existing one in another activity's task. |
| 129 | * The new window will show briefly and then be gone. */ |
| 130 | public static final int TRANSIT_TASK_OPEN_BEHIND = 16; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 131 | /** A window in a task is being animated in-place. */ |
| 132 | public static final int TRANSIT_TASK_IN_PLACE = 17; |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 133 | /** An activity is being relaunched (e.g. due to configuration change). */ |
| 134 | public static final int TRANSIT_ACTIVITY_RELAUNCH = 18; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 135 | /** A task is being docked from recents. */ |
| 136 | public static final int TRANSIT_DOCK_TASK_FROM_RECENTS = 19; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 137 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 138 | /** Fraction of animation at which the recents thumbnail stays completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 139 | private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 140 | /** Fraction of animation at which the recents thumbnail becomes completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 141 | private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 142 | |
Filip Gruszczynski | 84fa335 | 2016-01-25 16:28:49 -0800 | [diff] [blame] | 143 | static final int DEFAULT_APP_TRANSITION_DURATION = 336; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 144 | |
| 145 | /** Interpolator to be used for animations that respond directly to a touch */ |
| 146 | static final Interpolator TOUCH_RESPONSE_INTERPOLATOR = |
| 147 | new PathInterpolator(0.3f, 0f, 0.1f, 1f); |
| 148 | |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 149 | private static final Interpolator THUMBNAIL_DOCK_INTERPOLATOR = |
| 150 | new PathInterpolator(0.85f, 0f, 1f, 1f); |
| 151 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 152 | /** |
| 153 | * Maximum duration for the clip reveal animation. This is used when there is a lot of movement |
| 154 | * involved, to make it more understandable. |
| 155 | */ |
| 156 | private static final int MAX_CLIP_REVEAL_TRANSITION_DURATION = 420; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 157 | private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336; |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 158 | private static final long APP_TRANSITION_TIMEOUT_MS = 5000; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 159 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 160 | private final Context mContext; |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 161 | private final WindowManagerService mService; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 162 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 163 | private int mNextAppTransition = TRANSIT_UNSET; |
| 164 | |
| 165 | private static final int NEXT_TRANSIT_TYPE_NONE = 0; |
| 166 | private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1; |
| 167 | private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2; |
| 168 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3; |
| 169 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 170 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5; |
| 171 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 172 | private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 173 | private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 174 | private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
| 175 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 176 | // These are the possible states for the enter/exit activities during a thumbnail transition |
| 177 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0; |
| 178 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1; |
| 179 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2; |
| 180 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3; |
| 181 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 182 | private String mNextAppTransitionPackage; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 183 | // Used for thumbnail transitions. True if we're scaling up, false if scaling down |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 184 | private boolean mNextAppTransitionScaleUp; |
| 185 | private IRemoteCallback mNextAppTransitionCallback; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 186 | private IRemoteCallback mNextAppTransitionFutureCallback; |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 187 | private IRemoteCallback mAnimationFinishedCallback; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 188 | private int mNextAppTransitionEnter; |
| 189 | private int mNextAppTransitionExit; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 190 | private int mNextAppTransitionInPlace; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 191 | |
| 192 | // Keyed by task id. |
| 193 | private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs |
| 194 | = new SparseArray<>(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 195 | private IAppTransitionAnimationSpecsFuture mNextAppTransitionAnimationsSpecsFuture; |
| 196 | private boolean mNextAppTransitionAnimationsSpecsPending; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 197 | private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec; |
| 198 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 199 | private Rect mNextAppTransitionInsets = new Rect(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 200 | |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 201 | private Rect mTmpFromClipRect = new Rect(); |
| 202 | private Rect mTmpToClipRect = new Rect(); |
| 203 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 204 | private final Rect mTmpRect = new Rect(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 205 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 206 | private final static int APP_STATE_IDLE = 0; |
| 207 | private final static int APP_STATE_READY = 1; |
| 208 | private final static int APP_STATE_RUNNING = 2; |
| 209 | private final static int APP_STATE_TIMEOUT = 3; |
| 210 | private int mAppTransitionState = APP_STATE_IDLE; |
| 211 | |
| 212 | private final int mConfigShortAnimTime; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 213 | private final Interpolator mDecelerateInterpolator; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 214 | private final Interpolator mThumbnailFadeInInterpolator; |
| 215 | private final Interpolator mThumbnailFadeOutInterpolator; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 216 | private final Interpolator mLinearOutSlowInInterpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 217 | private final Interpolator mFastOutLinearInInterpolator; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 218 | private final Interpolator mFastOutSlowInInterpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 219 | private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f); |
| 220 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 221 | private final int mClipRevealTranslationY; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 222 | |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 223 | private int mCurrentUserId = 0; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 224 | private long mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION; |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 225 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 226 | private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 227 | private final ExecutorService mDefaultExecutor = Executors.newSingleThreadExecutor(); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 228 | |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 229 | private int mLastClipRevealMaxTranslation; |
| 230 | private boolean mLastHadClipReveal; |
| 231 | |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 232 | AppTransition(Context context, WindowManagerService service) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 233 | mContext = context; |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 234 | mService = service; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 235 | mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 236 | com.android.internal.R.interpolator.linear_out_slow_in); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 237 | mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context, |
| 238 | com.android.internal.R.interpolator.fast_out_linear_in); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 239 | mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 240 | com.android.internal.R.interpolator.fast_out_slow_in); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 241 | mConfigShortAnimTime = context.getResources().getInteger( |
| 242 | com.android.internal.R.integer.config_shortAnimTime); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 243 | mDecelerateInterpolator = AnimationUtils.loadInterpolator(context, |
| 244 | com.android.internal.R.interpolator.decelerate_cubic); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 245 | mThumbnailFadeInInterpolator = new Interpolator() { |
| 246 | @Override |
| 247 | public float getInterpolation(float input) { |
| 248 | // Linear response for first fraction, then complete after that. |
| 249 | if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) { |
| 250 | return 0f; |
| 251 | } |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 252 | float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) / |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 253 | (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 254 | return mFastOutLinearInInterpolator.getInterpolation(t); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 255 | } |
| 256 | }; |
| 257 | mThumbnailFadeOutInterpolator = new Interpolator() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 258 | @Override |
| 259 | public float getInterpolation(float input) { |
| 260 | // Linear response for first fraction, then complete after that. |
| 261 | if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) { |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 262 | float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION; |
| 263 | return mLinearOutSlowInInterpolator.getInterpolation(t); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 264 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 265 | return 1f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 266 | } |
| 267 | }; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 268 | mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP |
| 269 | * mContext.getResources().getDisplayMetrics().density); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | boolean isTransitionSet() { |
| 273 | return mNextAppTransition != TRANSIT_UNSET; |
| 274 | } |
| 275 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 276 | boolean isTransitionEqual(int transit) { |
| 277 | return mNextAppTransition == transit; |
| 278 | } |
| 279 | |
| 280 | int getAppTransition() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 281 | return mNextAppTransition; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 282 | } |
| 283 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 284 | private void setAppTransition(int transit) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 285 | mNextAppTransition = transit; |
| 286 | } |
| 287 | |
| 288 | boolean isReady() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 289 | return mAppTransitionState == APP_STATE_READY |
| 290 | || mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 293 | void setReady() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 294 | mAppTransitionState = APP_STATE_READY; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 295 | fetchAppTransitionSpecsFromFuture(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | boolean isRunning() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 299 | return mAppTransitionState == APP_STATE_RUNNING; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 300 | } |
| 301 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 302 | void setIdle() { |
| 303 | mAppTransitionState = APP_STATE_IDLE; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | boolean isTimeout() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 307 | return mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 310 | void setTimeout() { |
| 311 | mAppTransitionState = APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 312 | } |
| 313 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 314 | Bitmap getAppTransitionThumbnailHeader(int taskId) { |
| 315 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 316 | if (spec == null) { |
| 317 | spec = mDefaultNextAppTransitionAnimationSpec; |
| 318 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 319 | return spec != null ? spec.bitmap : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 320 | } |
| 321 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 322 | /** Returns whether the next thumbnail transition is aspect scaled up. */ |
| 323 | boolean isNextThumbnailTransitionAspectScaled() { |
| 324 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 325 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 326 | } |
| 327 | |
| 328 | /** Returns whether the next thumbnail transition is scaling up. */ |
| 329 | boolean isNextThumbnailTransitionScaleUp() { |
| 330 | return mNextAppTransitionScaleUp; |
| 331 | } |
| 332 | |
Filip Gruszczynski | 4cbc315 | 2015-12-07 11:50:57 -0800 | [diff] [blame] | 333 | boolean isNextAppTransitionThumbnailUp() { |
| 334 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 335 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP; |
| 336 | } |
| 337 | |
| 338 | boolean isNextAppTransitionThumbnailDown() { |
| 339 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN || |
| 340 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 341 | } |
| 342 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 343 | /** |
| 344 | * @return true if and only if we are currently fetching app transition specs from the future |
| 345 | * passed into {@link #overridePendingAppTransitionMultiThumbFuture} |
| 346 | */ |
| 347 | boolean isFetchingAppTransitionsSpecs() { |
| 348 | return mNextAppTransitionAnimationsSpecsPending; |
| 349 | } |
| 350 | |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 351 | private boolean prepare() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 352 | if (!isRunning()) { |
| 353 | mAppTransitionState = APP_STATE_IDLE; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 354 | notifyAppTransitionPendingLocked(); |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 355 | mLastHadClipReveal = false; |
| 356 | mLastClipRevealMaxTranslation = 0; |
| 357 | mLastClipRevealTransitionDuration = DEFAULT_APP_TRANSITION_DURATION; |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 358 | return true; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 359 | } |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 360 | return false; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 361 | } |
| 362 | |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 363 | void goodToGo(AppWindowAnimator topOpeningAppAnimator, AppWindowAnimator topClosingAppAnimator, |
| 364 | ArraySet<AppWindowToken> openingApps, ArraySet<AppWindowToken> closingApps) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 365 | mNextAppTransition = TRANSIT_UNSET; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 366 | mAppTransitionState = APP_STATE_RUNNING; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 367 | notifyAppTransitionStartingLocked( |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 368 | topOpeningAppAnimator != null ? topOpeningAppAnimator.mAppToken.token : null, |
| 369 | topClosingAppAnimator != null ? topClosingAppAnimator.mAppToken.token : null, |
| 370 | topOpeningAppAnimator != null ? topOpeningAppAnimator.animation : null, |
| 371 | topClosingAppAnimator != null ? topClosingAppAnimator.animation : null); |
| 372 | mService.getDefaultDisplayContentLocked().getDockedDividerController() |
| 373 | .notifyAppTransitionStarting(openingApps, closingApps); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | void clear() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 377 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 378 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 379 | mNextAppTransitionAnimationsSpecs.clear(); |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 380 | mNextAppTransitionAnimationsSpecsFuture = null; |
| 381 | mDefaultNextAppTransitionAnimationSpec = null; |
| 382 | mAnimationFinishedCallback = null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 383 | } |
| 384 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 385 | void freeze() { |
| 386 | setAppTransition(AppTransition.TRANSIT_UNSET); |
| 387 | clear(); |
| 388 | setReady(); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 389 | notifyAppTransitionCancelledLocked(); |
| 390 | } |
| 391 | |
| 392 | void registerListenerLocked(AppTransitionListener listener) { |
| 393 | mListeners.add(listener); |
| 394 | } |
| 395 | |
Wale Ogunwale | a48eadb | 2015-05-14 17:43:12 -0700 | [diff] [blame] | 396 | public void notifyAppTransitionFinishedLocked(IBinder token) { |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 397 | for (int i = 0; i < mListeners.size(); i++) { |
| 398 | mListeners.get(i).onAppTransitionFinishedLocked(token); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | private void notifyAppTransitionPendingLocked() { |
| 403 | for (int i = 0; i < mListeners.size(); i++) { |
| 404 | mListeners.get(i).onAppTransitionPendingLocked(); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | private void notifyAppTransitionCancelledLocked() { |
| 409 | for (int i = 0; i < mListeners.size(); i++) { |
| 410 | mListeners.get(i).onAppTransitionCancelledLocked(); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | private void notifyAppTransitionStartingLocked(IBinder openToken, |
| 415 | IBinder closeToken, Animation openAnimation, Animation closeAnimation) { |
| 416 | for (int i = 0; i < mListeners.size(); i++) { |
| 417 | mListeners.get(i).onAppTransitionStartingLocked(openToken, closeToken, openAnimation, |
| 418 | closeAnimation); |
| 419 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 420 | } |
| 421 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 422 | private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) { |
| 423 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg=" |
| 424 | + (lp != null ? lp.packageName : null) |
| 425 | + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null)); |
| 426 | if (lp != null && lp.windowAnimations != 0) { |
| 427 | // If this is a system resource, don't try to load it from the |
| 428 | // application resources. It is nice to avoid loading application |
| 429 | // resources if we can. |
| 430 | String packageName = lp.packageName != null ? lp.packageName : "android"; |
| 431 | int resId = lp.windowAnimations; |
| 432 | if ((resId&0xFF000000) == 0x01000000) { |
| 433 | packageName = "android"; |
| 434 | } |
| 435 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 436 | + packageName); |
| 437 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 438 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 439 | } |
| 440 | return null; |
| 441 | } |
| 442 | |
| 443 | private AttributeCache.Entry getCachedAnimations(String packageName, int resId) { |
| 444 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package=" |
| 445 | + packageName + " resId=0x" + Integer.toHexString(resId)); |
| 446 | if (packageName != null) { |
| 447 | if ((resId&0xFF000000) == 0x01000000) { |
| 448 | packageName = "android"; |
| 449 | } |
| 450 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 451 | + packageName); |
| 452 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 453 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 454 | } |
| 455 | return null; |
| 456 | } |
| 457 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 458 | Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 459 | int anim = 0; |
| 460 | Context context = mContext; |
| 461 | if (animAttr >= 0) { |
| 462 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 463 | if (ent != null) { |
| 464 | context = ent.context; |
| 465 | anim = ent.array.getResourceId(animAttr, 0); |
| 466 | } |
| 467 | } |
| 468 | if (anim != 0) { |
| 469 | return AnimationUtils.loadAnimation(context, anim); |
| 470 | } |
| 471 | return null; |
| 472 | } |
| 473 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 474 | Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) { |
| 475 | Context context = mContext; |
| 476 | if (resId >= 0) { |
| 477 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 478 | if (ent != null) { |
| 479 | context = ent.context; |
| 480 | } |
| 481 | return AnimationUtils.loadAnimation(context, resId); |
| 482 | } |
| 483 | return null; |
| 484 | } |
| 485 | |
| 486 | private Animation loadAnimationRes(String packageName, int resId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 487 | int anim = 0; |
| 488 | Context context = mContext; |
| 489 | if (resId >= 0) { |
| 490 | AttributeCache.Entry ent = getCachedAnimations(packageName, resId); |
| 491 | if (ent != null) { |
| 492 | context = ent.context; |
| 493 | anim = resId; |
| 494 | } |
| 495 | } |
| 496 | if (anim != 0) { |
| 497 | return AnimationUtils.loadAnimation(context, anim); |
| 498 | } |
| 499 | return null; |
| 500 | } |
| 501 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 502 | /** |
| 503 | * Compute the pivot point for an animation that is scaling from a small |
| 504 | * rect on screen to a larger rect. The pivot point varies depending on |
| 505 | * the distance between the inner and outer edges on both sides. This |
| 506 | * function computes the pivot point for one dimension. |
| 507 | * @param startPos Offset from left/top edge of outer rectangle to |
| 508 | * left/top edge of inner rectangle. |
| 509 | * @param finalScale The scaling factor between the size of the outer |
| 510 | * and inner rectangles. |
| 511 | */ |
| 512 | private static float computePivot(int startPos, float finalScale) { |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 513 | |
| 514 | /* |
| 515 | Theorem of intercepting lines: |
| 516 | |
| 517 | + + +-----------------------------------------------+ |
| 518 | | | | | |
| 519 | | | | | |
| 520 | | | | | |
| 521 | | | | | |
| 522 | x | y | | | |
| 523 | | | | | |
| 524 | | | | | |
| 525 | | | | | |
| 526 | | | | | |
| 527 | | + | +--------------------+ | |
| 528 | | | | | | |
| 529 | | | | | | |
| 530 | | | | | | |
| 531 | | | | | | |
| 532 | | | | | | |
| 533 | | | | | | |
| 534 | | | | | | |
| 535 | | | | | | |
| 536 | | | | | | |
| 537 | | | | | | |
| 538 | | | | | | |
| 539 | | | | | | |
| 540 | | | | | | |
| 541 | | | | | | |
| 542 | | | | | | |
| 543 | | | | | | |
| 544 | | | | | | |
| 545 | | | +--------------------+ | |
| 546 | | | | |
| 547 | | | | |
| 548 | | | | |
| 549 | | | | |
| 550 | | | | |
| 551 | | | | |
| 552 | | | | |
| 553 | | +-----------------------------------------------+ |
| 554 | | |
| 555 | | |
| 556 | | |
| 557 | | |
| 558 | | |
| 559 | | |
| 560 | | |
| 561 | | |
| 562 | | |
| 563 | + ++ |
| 564 | p ++ |
| 565 | |
| 566 | scale = (x - y) / x |
| 567 | <=> x = -y / (scale - 1) |
| 568 | */ |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 569 | final float denom = finalScale-1; |
| 570 | if (Math.abs(denom) < .0001f) { |
| 571 | return startPos; |
| 572 | } |
| 573 | return -startPos / denom; |
| 574 | } |
| 575 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 576 | private Animation createScaleUpAnimationLocked(int transit, boolean enter, |
| 577 | Rect containingFrame) { |
| 578 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 579 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 580 | final int appWidth = containingFrame.width(); |
| 581 | final int appHeight = containingFrame.height(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 582 | if (enter) { |
| 583 | // Entering app zooms out from the center of the initial rect. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 584 | float scaleW = mTmpRect.width() / (float) appWidth; |
| 585 | float scaleH = mTmpRect.height() / (float) appHeight; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 586 | Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 587 | computePivot(mTmpRect.left, scaleW), |
| 588 | computePivot(mTmpRect.right, scaleH)); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 589 | scale.setInterpolator(mDecelerateInterpolator); |
| 590 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 591 | Animation alpha = new AlphaAnimation(0, 1); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 592 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 593 | |
| 594 | AnimationSet set = new AnimationSet(false); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 595 | set.addAnimation(scale); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 596 | set.addAnimation(alpha); |
| 597 | set.setDetachWallpaper(true); |
| 598 | a = set; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 599 | } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 600 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 601 | // If we are on top of the wallpaper, we need an animation that |
| 602 | // correctly handles the wallpaper staying static behind all of |
| 603 | // the animated elements. To do this, will just have the existing |
| 604 | // element fade out. |
| 605 | a = new AlphaAnimation(1, 0); |
| 606 | a.setDetachWallpaper(true); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 607 | } else { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 608 | // For normal animations, the exiting element just holds in place. |
| 609 | a = new AlphaAnimation(1, 1); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 610 | } |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 611 | |
| 612 | // Pick the desired duration. If this is an inter-activity transition, |
| 613 | // it is the standard duration for that. Otherwise we use the longer |
| 614 | // task transition duration. |
| 615 | final long duration; |
| 616 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 617 | case TRANSIT_ACTIVITY_OPEN: |
| 618 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 619 | duration = mConfigShortAnimTime; |
| 620 | break; |
| 621 | default: |
| 622 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 623 | break; |
| 624 | } |
| 625 | a.setDuration(duration); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 626 | a.setFillAfter(true); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 627 | a.setInterpolator(mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 628 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 629 | return a; |
| 630 | } |
| 631 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 632 | private void getDefaultNextAppTransitionStartRect(Rect rect) { |
| 633 | if (mDefaultNextAppTransitionAnimationSpec == null || |
| 634 | mDefaultNextAppTransitionAnimationSpec.rect == null) { |
| 635 | Slog.wtf(TAG, "Starting rect for app requested, but none available", new Throwable()); |
| 636 | rect.setEmpty(); |
| 637 | } else { |
| 638 | rect.set(mDefaultNextAppTransitionAnimationSpec.rect); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | void getNextAppTransitionStartRect(int taskId, Rect rect) { |
| 643 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 644 | if (spec == null) { |
| 645 | spec = mDefaultNextAppTransitionAnimationSpec; |
| 646 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 647 | if (spec == null || spec.rect == null) { |
| 648 | Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available", |
| 649 | new Throwable()); |
| 650 | rect.setEmpty(); |
| 651 | } else { |
| 652 | rect.set(spec.rect); |
| 653 | } |
| 654 | } |
| 655 | |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 656 | private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height, |
| 657 | Bitmap bitmap) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 658 | mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */, |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 659 | bitmap, new Rect(left, top, left + width, top + height)); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 662 | /** |
| 663 | * @return the duration of the last clip reveal animation |
| 664 | */ |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 665 | long getLastClipRevealTransitionDuration() { |
| 666 | return mLastClipRevealTransitionDuration; |
| 667 | } |
| 668 | |
| 669 | /** |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 670 | * @return the maximum distance the app surface is traveling of the last clip reveal animation |
| 671 | */ |
| 672 | int getLastClipRevealMaxTranslation() { |
| 673 | return mLastClipRevealMaxTranslation; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * @return true if in the last app transition had a clip reveal animation, false otherwise |
| 678 | */ |
| 679 | boolean hadClipRevealAnimation() { |
| 680 | return mLastHadClipReveal; |
| 681 | } |
| 682 | |
| 683 | /** |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 684 | * Calculates the duration for the clip reveal animation. If the clip is "cut off", meaning that |
| 685 | * the start rect is outside of the target rect, and there is a lot of movement going on. |
| 686 | * |
| 687 | * @param cutOff whether the start rect was not fully contained by the end rect |
| 688 | * @param translationX the total translation the surface moves in x direction |
| 689 | * @param translationY the total translation the surfaces moves in y direction |
| 690 | * @param displayFrame our display frame |
| 691 | * |
| 692 | * @return the duration of the clip reveal animation, in milliseconds |
| 693 | */ |
| 694 | private long calculateClipRevealTransitionDuration(boolean cutOff, float translationX, |
| 695 | float translationY, Rect displayFrame) { |
| 696 | if (!cutOff) { |
| 697 | return DEFAULT_APP_TRANSITION_DURATION; |
| 698 | } |
| 699 | final float fraction = Math.max(Math.abs(translationX) / displayFrame.width(), |
| 700 | Math.abs(translationY) / displayFrame.height()); |
| 701 | return (long) (DEFAULT_APP_TRANSITION_DURATION + fraction * |
| 702 | (MAX_CLIP_REVEAL_TRANSITION_DURATION - DEFAULT_APP_TRANSITION_DURATION)); |
| 703 | } |
| 704 | |
| 705 | private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame, |
| 706 | Rect displayFrame) { |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 707 | final Animation anim; |
| 708 | if (enter) { |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 709 | final int appWidth = appFrame.width(); |
| 710 | final int appHeight = appFrame.height(); |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 711 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 712 | // mTmpRect will contain an area around the launcher icon that was pressed. We will |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 713 | // clip reveal from that area in the final area of the app. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 714 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 715 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 716 | float t = 0f; |
| 717 | if (appHeight > 0) { |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 718 | t = (float) mTmpRect.top / displayFrame.height(); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 719 | } |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 720 | int translationY = mClipRevealTranslationY + (int)(displayFrame.height() / 7f * t); |
| 721 | int translationX = 0; |
| 722 | int translationYCorrection = translationY; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 723 | int centerX = mTmpRect.centerX(); |
| 724 | int centerY = mTmpRect.centerY(); |
| 725 | int halfWidth = mTmpRect.width() / 2; |
| 726 | int halfHeight = mTmpRect.height() / 2; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 727 | int clipStartX = centerX - halfWidth - appFrame.left; |
| 728 | int clipStartY = centerY - halfHeight - appFrame.top; |
| 729 | boolean cutOff = false; |
| 730 | |
| 731 | // If the starting rectangle is fully or partially outside of the target rectangle, we |
| 732 | // need to start the clipping at the edge and then achieve the rest with translation |
| 733 | // and extending the clip rect from that edge. |
| 734 | if (appFrame.top > centerY - halfHeight) { |
| 735 | translationY = (centerY - halfHeight) - appFrame.top; |
| 736 | translationYCorrection = 0; |
| 737 | clipStartY = 0; |
| 738 | cutOff = true; |
| 739 | } |
| 740 | if (appFrame.left > centerX - halfWidth) { |
| 741 | translationX = (centerX - halfWidth) - appFrame.left; |
| 742 | clipStartX = 0; |
| 743 | cutOff = true; |
| 744 | } |
| 745 | if (appFrame.right < centerX + halfWidth) { |
| 746 | translationX = (centerX + halfWidth) - appFrame.right; |
| 747 | clipStartX = appWidth - mTmpRect.width(); |
| 748 | cutOff = true; |
| 749 | } |
| 750 | final long duration = calculateClipRevealTransitionDuration(cutOff, translationX, |
| 751 | translationY, displayFrame); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 752 | |
| 753 | // Clip third of the from size of launch icon, expand to full width/height |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 754 | Animation clipAnimLR = new ClipRectLRAnimation( |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 755 | clipStartX, clipStartX + mTmpRect.width(), 0, appWidth); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 756 | clipAnimLR.setInterpolator(mClipHorizontalInterpolator); |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 757 | clipAnimLR.setDuration((long) (duration / 2.5f)); |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 758 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 759 | TranslateAnimation translate = new TranslateAnimation(translationX, 0, translationY, 0); |
| 760 | translate.setInterpolator(cutOff ? TOUCH_RESPONSE_INTERPOLATOR |
| 761 | : mLinearOutSlowInInterpolator); |
| 762 | translate.setDuration(duration); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 763 | |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 764 | Animation clipAnimTB = new ClipRectTBAnimation( |
| 765 | clipStartY, clipStartY + mTmpRect.height(), |
| 766 | 0, appHeight, |
| 767 | translationYCorrection, 0, |
| 768 | mLinearOutSlowInInterpolator); |
| 769 | clipAnimTB.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR); |
| 770 | clipAnimTB.setDuration(duration); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 771 | |
| 772 | // Quick fade-in from icon to app window |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 773 | final long alphaDuration = duration / 4; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 774 | AlphaAnimation alpha = new AlphaAnimation(0.5f, 1); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 775 | alpha.setDuration(alphaDuration); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 776 | alpha.setInterpolator(mLinearOutSlowInInterpolator); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 777 | |
| 778 | AnimationSet set = new AnimationSet(false); |
| 779 | set.addAnimation(clipAnimLR); |
| 780 | set.addAnimation(clipAnimTB); |
Filip Gruszczynski | 8286136 | 2015-10-16 14:21:09 -0700 | [diff] [blame] | 781 | set.addAnimation(translate); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 782 | set.addAnimation(alpha); |
Filip Gruszczynski | 9e2cf5b | 2015-07-31 12:20:40 -0700 | [diff] [blame] | 783 | set.setZAdjustment(Animation.ZORDER_TOP); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 784 | set.initialize(appWidth, appHeight, appWidth, appHeight); |
| 785 | anim = set; |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 786 | mLastHadClipReveal = true; |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 787 | mLastClipRevealTransitionDuration = duration; |
Jorim Jaggi | f97ed92 | 2016-02-18 18:57:07 -0800 | [diff] [blame] | 788 | |
| 789 | // If the start rect was full inside the target rect (cutOff == false), we don't need |
| 790 | // to store the translation, because it's only used if cutOff == true. |
| 791 | mLastClipRevealMaxTranslation = cutOff |
| 792 | ? Math.max(Math.abs(translationY), Math.abs(translationX)) : 0; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 793 | } else { |
| 794 | final long duration; |
| 795 | switch (transit) { |
| 796 | case TRANSIT_ACTIVITY_OPEN: |
| 797 | case TRANSIT_ACTIVITY_CLOSE: |
| 798 | duration = mConfigShortAnimTime; |
| 799 | break; |
| 800 | default: |
| 801 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 802 | break; |
| 803 | } |
| 804 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 805 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
| 806 | // If we are on top of the wallpaper, we need an animation that |
| 807 | // correctly handles the wallpaper staying static behind all of |
| 808 | // the animated elements. To do this, will just have the existing |
| 809 | // element fade out. |
| 810 | anim = new AlphaAnimation(1, 0); |
| 811 | anim.setDetachWallpaper(true); |
| 812 | } else { |
| 813 | // For normal animations, the exiting element just holds in place. |
| 814 | anim = new AlphaAnimation(1, 1); |
| 815 | } |
| 816 | anim.setInterpolator(mDecelerateInterpolator); |
| 817 | anim.setDuration(duration); |
| 818 | anim.setFillAfter(true); |
| 819 | } |
| 820 | return anim; |
| 821 | } |
| 822 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 823 | /** |
| 824 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 825 | */ |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 826 | Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight, |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 827 | long duration, Interpolator interpolator) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 828 | if (duration > 0) { |
| 829 | a.setDuration(duration); |
| 830 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 831 | a.setFillAfter(true); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 832 | if (interpolator != null) { |
| 833 | a.setInterpolator(interpolator); |
| 834 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 835 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 836 | return a; |
| 837 | } |
| 838 | |
| 839 | /** |
| 840 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 841 | */ |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 842 | Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 843 | // Pick the desired duration. If this is an inter-activity transition, |
| 844 | // it is the standard duration for that. Otherwise we use the longer |
| 845 | // task transition duration. |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 846 | final int duration; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 847 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 848 | case TRANSIT_ACTIVITY_OPEN: |
| 849 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 850 | duration = mConfigShortAnimTime; |
| 851 | break; |
| 852 | default: |
| 853 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 854 | break; |
| 855 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 856 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, |
| 857 | mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 858 | } |
| 859 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 860 | /** |
| 861 | * Return the current thumbnail transition state. |
| 862 | */ |
| 863 | int getThumbnailTransitionState(boolean enter) { |
| 864 | if (enter) { |
| 865 | if (mNextAppTransitionScaleUp) { |
| 866 | return THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 867 | } else { |
| 868 | return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN; |
| 869 | } |
| 870 | } else { |
| 871 | if (mNextAppTransitionScaleUp) { |
| 872 | return THUMBNAIL_TRANSITION_EXIT_SCALE_UP; |
| 873 | } else { |
| 874 | return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN; |
| 875 | } |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | /** |
| 880 | * This animation runs for the thumbnail that gets cross faded with the enter/exit activity |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 881 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 882 | */ |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 883 | Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, @Nullable Rect contentInsets, |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame^] | 884 | Bitmap thumbnailHeader, final int taskId, int orientation) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 885 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 886 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 887 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 888 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 889 | final int appWidth = appRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 890 | |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 891 | float scaleW = appWidth / thumbWidth; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 892 | getNextAppTransitionStartRect(taskId, mTmpRect); |
Jorim Jaggi | 0907200 | 2016-03-25 16:48:42 -0700 | [diff] [blame^] | 893 | final float fromX; |
| 894 | final float fromY; |
| 895 | final float toX; |
| 896 | final float toY; |
| 897 | final float pivotX; |
| 898 | final float pivotY; |
| 899 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 900 | fromX = mTmpRect.left; |
| 901 | fromY = mTmpRect.top; |
| 902 | |
| 903 | // For the curved translate animation to work, the pivot points needs to be at the |
| 904 | // same absolute position as the one from the real surface. |
| 905 | toX = mTmpRect.width() / 2 * (scaleW - 1f) + appRect.left; |
| 906 | toY = appRect.height() / 2 * (1 - 1 / scaleW) + appRect.top; |
| 907 | pivotX = mTmpRect.width() / 2; |
| 908 | pivotY = appRect.height() / 2 / scaleW; |
| 909 | } else { |
| 910 | pivotX = 0; |
| 911 | pivotY = 0; |
| 912 | fromX = mTmpRect.left; |
| 913 | fromY = mTmpRect.top; |
| 914 | toX = appRect.left; |
| 915 | toY = appRect.top; |
| 916 | } |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 917 | final long duration = getAspectScaleDuration(); |
| 918 | final Interpolator interpolator = getAspectScaleInterpolator(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 919 | if (mNextAppTransitionScaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 920 | // Animation up from the thumbnail to the full screen |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 921 | Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 922 | scale.setInterpolator(interpolator); |
| 923 | scale.setDuration(duration); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 924 | Animation alpha = new AlphaAnimation(1f, 0f); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 925 | alpha.setInterpolator(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 926 | ? THUMBNAIL_DOCK_INTERPOLATOR : mThumbnailFadeOutInterpolator); |
| 927 | alpha.setDuration(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 928 | ? duration / 2 |
| 929 | : duration); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 930 | Animation translate = createCurvedMotion(fromX, toX, fromY, toY); |
| 931 | translate.setInterpolator(interpolator); |
| 932 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 933 | |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 934 | mTmpFromClipRect.set(0, 0, thumbWidthI, thumbHeightI); |
| 935 | mTmpToClipRect.set(appRect); |
| 936 | |
| 937 | // Containing frame is in screen space, but we need the clip rect in the |
| 938 | // app space. |
| 939 | mTmpToClipRect.offsetTo(0, 0); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 940 | mTmpToClipRect.right = (int) (mTmpToClipRect.right / scaleW); |
| 941 | mTmpToClipRect.bottom = (int) (mTmpToClipRect.bottom / scaleW); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 942 | |
| 943 | if (contentInsets != null) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 944 | mTmpToClipRect.inset((int) (-contentInsets.left * scaleW), |
| 945 | (int) (-contentInsets.top * scaleW), |
| 946 | (int) (-contentInsets.right * scaleW), |
| 947 | (int) (-contentInsets.bottom * scaleW)); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 951 | clipAnim.setInterpolator(interpolator); |
| 952 | clipAnim.setDuration(duration); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 953 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 954 | // This AnimationSet uses the Interpolators assigned above. |
| 955 | AnimationSet set = new AnimationSet(false); |
| 956 | set.addAnimation(scale); |
| 957 | set.addAnimation(alpha); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 958 | set.addAnimation(translate); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 959 | set.addAnimation(clipAnim); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 960 | a = set; |
| 961 | } else { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 962 | // Animation down from the full screen to the thumbnail |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 963 | Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 964 | scale.setInterpolator(interpolator); |
| 965 | scale.setDuration(duration); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 966 | Animation alpha = new AlphaAnimation(0f, 1f); |
| 967 | alpha.setInterpolator(mThumbnailFadeInInterpolator); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 968 | alpha.setDuration(duration); |
| 969 | Animation translate = createCurvedMotion(toX, fromX, toY, fromY); |
| 970 | translate.setInterpolator(interpolator); |
| 971 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 972 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 973 | // This AnimationSet uses the Interpolators assigned above. |
| 974 | AnimationSet set = new AnimationSet(false); |
| 975 | set.addAnimation(scale); |
| 976 | set.addAnimation(alpha); |
| 977 | set.addAnimation(translate); |
| 978 | a = set; |
| 979 | |
| 980 | } |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 981 | return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 982 | null); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 983 | } |
| 984 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 985 | private Animation createCurvedMotion(float fromX, float toX, float fromY, float toY) { |
| 986 | |
| 987 | // Almost no x-change - use linear animation |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 988 | if (Math.abs(toX - fromX) < 1f || mNextAppTransition != TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 989 | return new TranslateAnimation(fromX, toX, fromY, toY); |
| 990 | } else { |
| 991 | final Path path = createCurvedPath(fromX, toX, fromY, toY); |
| 992 | return new CurvedTranslateAnimation(path); |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | private Path createCurvedPath(float fromX, float toX, float fromY, float toY) { |
| 997 | final Path path = new Path(); |
| 998 | path.moveTo(fromX, fromY); |
| 999 | path.cubicTo(fromX, fromY, toX, 0.9f * fromY + 0.1f * toY, toX, toY); |
| 1000 | return path; |
| 1001 | } |
| 1002 | |
| 1003 | private long getAspectScaleDuration() { |
| 1004 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1005 | return (long) (THUMBNAIL_APP_TRANSITION_DURATION * 1.35f); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1006 | } else { |
| 1007 | return THUMBNAIL_APP_TRANSITION_DURATION; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | private Interpolator getAspectScaleInterpolator() { |
| 1012 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
| 1013 | return mFastOutSlowInInterpolator; |
| 1014 | } else { |
| 1015 | return TOUCH_RESPONSE_INTERPOLATOR; |
| 1016 | } |
| 1017 | } |
| 1018 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1019 | /** |
| 1020 | * This alternate animation is created when we are doing a thumbnail transition, for the |
| 1021 | * activity that is leaving, and the activity that is entering. |
| 1022 | */ |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1023 | Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState, |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1024 | int orientation, int transit, Rect containingFrame, Rect contentInsets, |
| 1025 | @Nullable Rect surfaceInsets, boolean freeform, int taskId) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1026 | Animation a; |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1027 | final int appWidth = containingFrame.width(); |
| 1028 | final int appHeight = containingFrame.height(); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1029 | getDefaultNextAppTransitionStartRect(mTmpRect); |
| 1030 | final int thumbWidthI = mTmpRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1031 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1032 | final int thumbHeightI = mTmpRect.height(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1033 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1034 | final int thumbStartX = mTmpRect.left - containingFrame.left; |
| 1035 | final int thumbStartY = mTmpRect.top - containingFrame.top; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1036 | |
| 1037 | switch (thumbTransitState) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1038 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: |
| 1039 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1040 | final boolean scaleUp = thumbTransitState == THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 1041 | if (freeform && scaleUp) { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1042 | a = createAspectScaledThumbnailEnterFreeformAnimationLocked( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1043 | containingFrame, surfaceInsets, taskId); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1044 | } else if (freeform) { |
| 1045 | a = createAspectScaledThumbnailExitFreeformAnimationLocked( |
| 1046 | containingFrame, surfaceInsets, taskId); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1047 | } else { |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1048 | AnimationSet set = new AnimationSet(true); |
| 1049 | |
| 1050 | // In portrait, we scale to fit the width |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1051 | mTmpFromClipRect.set(containingFrame); |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1052 | mTmpToClipRect.set(containingFrame); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 1053 | |
| 1054 | // Containing frame is in screen space, but we need the clip rect in the |
| 1055 | // app space. |
| 1056 | mTmpFromClipRect.offsetTo(0, 0); |
| 1057 | mTmpToClipRect.offsetTo(0, 0); |
| 1058 | |
| 1059 | // Exclude insets region from the source clip. |
| 1060 | mTmpFromClipRect.inset(contentInsets); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1061 | mNextAppTransitionInsets.set(contentInsets); |
| 1062 | |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1063 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 1064 | // We scale the width and clip to the top/left square |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1065 | // We scale the width and clip to the top/left square |
| 1066 | float scale = thumbWidth / |
| 1067 | (appWidth - contentInsets.left - contentInsets.right); |
| 1068 | int unscaledThumbHeight = (int) (thumbHeight / scale); |
| 1069 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + unscaledThumbHeight; |
| 1070 | |
| 1071 | mNextAppTransitionInsets.set(contentInsets); |
| 1072 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1073 | Animation scaleAnim = new ScaleAnimation( |
| 1074 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
| 1075 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1076 | containingFrame.width() / 2f, |
| 1077 | containingFrame.height() / 2f + contentInsets.top); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1078 | final float targetX = (mTmpRect.left - containingFrame.left); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1079 | final float x = containingFrame.width() / 2f |
| 1080 | - containingFrame.width() / 2f * scale; |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1081 | final float targetY = (mTmpRect.top - containingFrame.top); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1082 | final float y = containingFrame.height() / 2f |
| 1083 | - containingFrame.height() / 2f * scale; |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1084 | final float startX = targetX - x; |
| 1085 | final float startY = targetY - y; |
| 1086 | Animation clipAnim = scaleUp |
| 1087 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1088 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1089 | Animation translateAnim = scaleUp |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1090 | ? createCurvedMotion(startX, 0, startY - contentInsets.top, 0) |
| 1091 | : createCurvedMotion(0, startX, 0, startY - contentInsets.top); |
| 1092 | |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1093 | set.addAnimation(clipAnim); |
| 1094 | set.addAnimation(scaleAnim); |
| 1095 | set.addAnimation(translateAnim); |
| 1096 | |
| 1097 | } else { |
| 1098 | // In landscape, we don't scale at all and only crop |
| 1099 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + thumbHeightI; |
| 1100 | mTmpFromClipRect.right = mTmpFromClipRect.left + thumbWidthI; |
| 1101 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1102 | Animation clipAnim = scaleUp |
| 1103 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1104 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1105 | Animation translateAnim = scaleUp |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1106 | ? createCurvedMotion(thumbStartX, 0, |
| 1107 | thumbStartY - contentInsets.top, 0) |
| 1108 | : createCurvedMotion(0, thumbStartX, 0, |
| 1109 | thumbStartY - contentInsets.top); |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1110 | |
| 1111 | set.addAnimation(clipAnim); |
| 1112 | set.addAnimation(translateAnim); |
| 1113 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1114 | a = set; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1115 | a.setZAdjustment(Animation.ZORDER_TOP); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1116 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1117 | break; |
| 1118 | } |
| 1119 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1120 | // Previous app window during the scale up |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1121 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1122 | // Fade out the source activity if we are animating to a wallpaper |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1123 | // activity. |
| 1124 | a = new AlphaAnimation(1, 0); |
| 1125 | } else { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1126 | a = new AlphaAnimation(1, 1); |
| 1127 | } |
| 1128 | break; |
| 1129 | } |
| 1130 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1131 | // Target app window during the scale down |
| 1132 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1133 | // Fade in the destination activity if we are animating from a wallpaper |
| 1134 | // activity. |
| 1135 | a = new AlphaAnimation(0, 1); |
| 1136 | } else { |
| 1137 | a = new AlphaAnimation(1, 1); |
| 1138 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1139 | break; |
| 1140 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1141 | default: |
| 1142 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1143 | } |
| 1144 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1145 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, |
| 1146 | getAspectScaleDuration(), getAspectScaleInterpolator()); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1147 | } |
| 1148 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1149 | private Animation createAspectScaledThumbnailEnterFreeformAnimationLocked(Rect frame, |
| 1150 | @Nullable Rect surfaceInsets, int taskId) { |
| 1151 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1152 | return createAspectScaledThumbnailFreeformAnimationLocked(mTmpRect, frame, surfaceInsets, |
| 1153 | true); |
| 1154 | } |
| 1155 | |
| 1156 | private Animation createAspectScaledThumbnailExitFreeformAnimationLocked(Rect frame, |
| 1157 | @Nullable Rect surfaceInsets, int taskId) { |
| 1158 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1159 | return createAspectScaledThumbnailFreeformAnimationLocked(frame, mTmpRect, surfaceInsets, |
| 1160 | false); |
| 1161 | } |
| 1162 | |
| 1163 | private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, |
| 1164 | Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) { |
| 1165 | final float sourceWidth = sourceFrame.width(); |
| 1166 | final float sourceHeight = sourceFrame.height(); |
| 1167 | final float destWidth = destFrame.width(); |
| 1168 | final float destHeight = destFrame.height(); |
| 1169 | final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth; |
| 1170 | final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight; |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1171 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1172 | final int surfaceInsetsH = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1173 | ? 0 : surfaceInsets.left + surfaceInsets.right; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1174 | final int surfaceInsetsV = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1175 | ? 0 : surfaceInsets.top + surfaceInsets.bottom; |
| 1176 | // We want the scaling to happen from the center of the surface. In order to achieve that, |
| 1177 | // we need to account for surface insets that will be used to enlarge the surface. |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1178 | final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2; |
| 1179 | final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2; |
| 1180 | final ScaleAnimation scale = enter ? |
| 1181 | new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) |
| 1182 | : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter); |
| 1183 | final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2; |
| 1184 | final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2; |
| 1185 | final int destHCenter = destFrame.left + destFrame.width() / 2; |
| 1186 | final int destVCenter = destFrame.top + destFrame.height() / 2; |
| 1187 | final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter; |
| 1188 | final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter; |
| 1189 | final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) |
| 1190 | : new TranslateAnimation(0, fromX, 0, fromY); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1191 | set.addAnimation(scale); |
| 1192 | set.addAnimation(translation); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1193 | |
| 1194 | final IRemoteCallback callback = mAnimationFinishedCallback; |
| 1195 | if (callback != null) { |
| 1196 | set.setAnimationListener(new Animation.AnimationListener() { |
| 1197 | @Override |
| 1198 | public void onAnimationStart(Animation animation) { } |
| 1199 | |
| 1200 | @Override |
| 1201 | public void onAnimationEnd(Animation animation) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1202 | mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget(); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | @Override |
| 1206 | public void onAnimationRepeat(Animation animation) { } |
| 1207 | }); |
| 1208 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1209 | return set; |
| 1210 | } |
| 1211 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1212 | /** |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1213 | * This animation runs for the thumbnail that gets cross faded with the enter/exit activity |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1214 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1215 | */ |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1216 | Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, |
| 1217 | Bitmap thumbnailHeader) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1218 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1219 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1220 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1221 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1222 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1223 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1224 | |
| 1225 | if (mNextAppTransitionScaleUp) { |
| 1226 | // Animation for the thumbnail zooming from its initial size to the full screen |
| 1227 | float scaleW = appWidth / thumbWidth; |
| 1228 | float scaleH = appHeight / thumbHeight; |
| 1229 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1230 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1231 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1232 | scale.setInterpolator(mDecelerateInterpolator); |
| 1233 | |
| 1234 | Animation alpha = new AlphaAnimation(1, 0); |
| 1235 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
| 1236 | |
| 1237 | // This AnimationSet uses the Interpolators assigned above. |
| 1238 | AnimationSet set = new AnimationSet(false); |
| 1239 | set.addAnimation(scale); |
| 1240 | set.addAnimation(alpha); |
| 1241 | a = set; |
| 1242 | } else { |
| 1243 | // Animation for the thumbnail zooming down from the full screen to its final size |
| 1244 | float scaleW = appWidth / thumbWidth; |
| 1245 | float scaleH = appHeight / thumbHeight; |
| 1246 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1247 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1248 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1252 | } |
| 1253 | |
| 1254 | /** |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1255 | * This animation is created when we are doing a thumbnail transition, for the activity that is |
| 1256 | * leaving, and the activity that is entering. |
| 1257 | */ |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1258 | Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, |
| 1259 | int transit, int taskId) { |
| 1260 | final int appWidth = containingFrame.width(); |
| 1261 | final int appHeight = containingFrame.height(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1262 | Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1263 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1264 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1265 | final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1266 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1267 | final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1268 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1269 | |
| 1270 | switch (thumbTransitState) { |
| 1271 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: { |
| 1272 | // Entering app scales up with the thumbnail |
| 1273 | float scaleW = thumbWidth / appWidth; |
| 1274 | float scaleH = thumbHeight / appHeight; |
| 1275 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1276 | computePivot(mTmpRect.left, scaleW), |
| 1277 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1278 | break; |
| 1279 | } |
| 1280 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
| 1281 | // Exiting app while the thumbnail is scaling up should fade or stay in place |
| 1282 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1283 | // Fade out while bringing up selected activity. This keeps the |
| 1284 | // current activity from showing through a launching wallpaper |
| 1285 | // activity. |
| 1286 | a = new AlphaAnimation(1, 0); |
| 1287 | } else { |
| 1288 | // noop animation |
| 1289 | a = new AlphaAnimation(1, 1); |
| 1290 | } |
| 1291 | break; |
| 1292 | } |
| 1293 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
| 1294 | // Entering the other app, it should just be visible while we scale the thumbnail |
| 1295 | // down above it |
| 1296 | a = new AlphaAnimation(1, 1); |
| 1297 | break; |
| 1298 | } |
| 1299 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1300 | // Exiting the current app, the app should scale down with the thumbnail |
| 1301 | float scaleW = thumbWidth / appWidth; |
| 1302 | float scaleH = thumbHeight / appHeight; |
| 1303 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1304 | computePivot(mTmpRect.left, scaleW), |
| 1305 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1306 | |
| 1307 | Animation alpha = new AlphaAnimation(1, 0); |
| 1308 | |
| 1309 | AnimationSet set = new AnimationSet(true); |
| 1310 | set.addAnimation(scale); |
| 1311 | set.addAnimation(alpha); |
| 1312 | set.setZAdjustment(Animation.ZORDER_TOP); |
| 1313 | a = set; |
| 1314 | break; |
| 1315 | } |
| 1316 | default: |
| 1317 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1318 | } |
| 1319 | |
| 1320 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1321 | } |
| 1322 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1323 | private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1324 | getDefaultNextAppTransitionStartRect(mTmpFromClipRect); |
| 1325 | final int left = mTmpFromClipRect.left; |
| 1326 | final int top = mTmpFromClipRect.top; |
| 1327 | mTmpFromClipRect.offset(-left, -top); |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1328 | // TODO: Isn't that strange that we ignore exact position of the containingFrame? |
| 1329 | mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height()); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1330 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1331 | float fromWidth = mTmpFromClipRect.width(); |
| 1332 | float toWidth = mTmpToClipRect.width(); |
| 1333 | float fromHeight = mTmpFromClipRect.height(); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1334 | // While the window might span the whole display, the actual content will be cropped to the |
| 1335 | // system decoration frame, for example when the window is docked. We need to take into |
| 1336 | // account the visible height when constructing the animation. |
| 1337 | float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom; |
| 1338 | int translateAdjustment = 0; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1339 | if (fromWidth <= toWidth && fromHeight <= toHeight) { |
| 1340 | // The final window is larger in both dimensions than current window (e.g. we are |
| 1341 | // maximizing), so we can simply unclip the new window and there will be no disappearing |
| 1342 | // frame. |
| 1343 | set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)); |
| 1344 | } else { |
| 1345 | // The disappearing window has one larger dimension. We need to apply scaling, so the |
| 1346 | // first frame of the entry animation matches the old window. |
| 1347 | set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1)); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1348 | // We might not be going exactly full screen, but instead be aligned under the status |
| 1349 | // bar using cropping. We still need to account for the cropped part, which will also |
| 1350 | // be scaled. |
| 1351 | translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1354 | // We animate the translation from the old position of the removed window, to the new |
| 1355 | // position of the added window. The latter might not be full screen, for example docked for |
| 1356 | // docked windows. |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1357 | TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left, |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1358 | 0, top - containingFrame.top - translateAdjustment, 0); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1359 | set.addAnimation(translate); |
| 1360 | set.setDuration(DEFAULT_APP_TRANSITION_DURATION); |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 1361 | set.setZAdjustment(Animation.ZORDER_TOP); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1362 | return set; |
| 1363 | } |
| 1364 | |
Jorim Jaggi | c554b77 | 2015-06-04 16:07:57 -0700 | [diff] [blame] | 1365 | /** |
| 1366 | * @return true if and only if the first frame of the transition can be skipped, i.e. the first |
| 1367 | * frame of the transition doesn't change the visuals on screen, so we can start |
| 1368 | * directly with the second one |
| 1369 | */ |
| 1370 | boolean canSkipFirstFrame() { |
| 1371 | return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM |
| 1372 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE |
| 1373 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
| 1374 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1375 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1376 | /** |
| 1377 | * |
| 1378 | * @param frame These are the bounds of the window when it finishes the animation. This is where |
| 1379 | * the animation must usually finish in entrance animation, as the next frame will |
| 1380 | * display the window at these coordinates. In case of exit animation, this is |
| 1381 | * where the animation must start, as the frame before the animation is displaying |
| 1382 | * the window at these bounds. |
| 1383 | * @param insets Knowing where the window will be positioned is not enough. Some parts of the |
| 1384 | * window might be obscured, usually by the system windows (status bar and |
| 1385 | * navigation bar) and we use content insets to convey that information. This |
| 1386 | * usually affects the animation aspects vertically, as the system decoration is |
| 1387 | * at the top and the bottom. For example when we animate from full screen to |
| 1388 | * recents, we want to exclude the covered parts, because they won't match the |
| 1389 | * thumbnail after the last frame is executed. |
| 1390 | * @param surfaceInsets In rare situation the surface is larger than the content and we need to |
| 1391 | * know about this to make the animation frames match. We currently use |
| 1392 | * this for freeform windows, which have larger surfaces to display |
| 1393 | * shadows. When we animate them from recents, we want to match the content |
| 1394 | * to the recents thumbnail and hence need to account for the surface being |
| 1395 | * bigger. |
| 1396 | */ |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1397 | Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1398 | int orientation, Rect frame, Rect displayFrame, Rect insets, |
| 1399 | @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform, |
| 1400 | int taskId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1401 | Animation a; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1402 | if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN |
| 1403 | || transit == TRANSIT_TASK_OPEN |
| 1404 | || transit == TRANSIT_TASK_TO_FRONT)) { |
| 1405 | a = loadAnimationRes(lp, enter |
| 1406 | ? com.android.internal.R.anim.voice_activity_open_enter |
| 1407 | : com.android.internal.R.anim.voice_activity_open_exit); |
| 1408 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1409 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1410 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1411 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1412 | } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE |
| 1413 | || transit == TRANSIT_TASK_CLOSE |
| 1414 | || transit == TRANSIT_TASK_TO_BACK)) { |
| 1415 | a = loadAnimationRes(lp, enter |
| 1416 | ? com.android.internal.R.anim.voice_activity_close_enter |
| 1417 | : com.android.internal.R.anim.voice_activity_close_exit); |
| 1418 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1419 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1420 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1421 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1422 | } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1423 | a = createRelaunchAnimation(frame, insets); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1424 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1425 | "applyAnimation:" |
| 1426 | + " anim=" + a + " nextAppTransition=" + mNextAppTransition |
| 1427 | + " transit=" + appTransitionToString(transit) |
| 1428 | + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1429 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) { |
| 1430 | a = loadAnimationRes(mNextAppTransitionPackage, enter ? |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1431 | mNextAppTransitionEnter : mNextAppTransitionExit); |
| 1432 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1433 | "applyAnimation:" |
| 1434 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1435 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1436 | + " Callers=" + Debug.getCallers(3)); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1437 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) { |
| 1438 | a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace); |
| 1439 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1440 | "applyAnimation:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1441 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" |
| 1442 | + " transit=" + appTransitionToString(transit) |
| 1443 | + " Callers=" + Debug.getCallers(3)); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1444 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) { |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1445 | a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1446 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1447 | "applyAnimation:" |
| 1448 | + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1449 | + " transit=" + appTransitionToString(transit) |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1450 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1451 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1452 | a = createScaleUpAnimationLocked(transit, enter, frame); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1453 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1454 | "applyAnimation:" |
| 1455 | + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1456 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1457 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1458 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 1459 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1460 | mNextAppTransitionScaleUp = |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1461 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1462 | a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1463 | frame, transit, taskId); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1464 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1465 | String animName = mNextAppTransitionScaleUp ? |
| 1466 | "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN"; |
| 1467 | Slog.v(TAG, "applyAnimation:" |
| 1468 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1469 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1470 | + " Callers=" + Debug.getCallers(3)); |
| 1471 | } |
| 1472 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 1473 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) { |
| 1474 | mNextAppTransitionScaleUp = |
| 1475 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP); |
| 1476 | a = createAspectScaledThumbnailEnterExitAnimationLocked( |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1477 | getThumbnailTransitionState(enter), orientation, transit, frame, |
| 1478 | insets, surfaceInsets, freeform, taskId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1479 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1480 | String animName = mNextAppTransitionScaleUp ? |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1481 | "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1482 | Slog.v(TAG, "applyAnimation:" |
| 1483 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1484 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1485 | + " Callers=" + Debug.getCallers(3)); |
| 1486 | } |
| 1487 | } else { |
| 1488 | int animAttr = 0; |
| 1489 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1490 | case TRANSIT_ACTIVITY_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1491 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1492 | ? WindowAnimation_activityOpenEnterAnimation |
| 1493 | : WindowAnimation_activityOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1494 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1495 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1496 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1497 | ? WindowAnimation_activityCloseEnterAnimation |
| 1498 | : WindowAnimation_activityCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1499 | break; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1500 | case TRANSIT_DOCK_TASK_FROM_RECENTS: |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1501 | case TRANSIT_TASK_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1502 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1503 | ? WindowAnimation_taskOpenEnterAnimation |
| 1504 | : WindowAnimation_taskOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1505 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1506 | case TRANSIT_TASK_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1507 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1508 | ? WindowAnimation_taskCloseEnterAnimation |
| 1509 | : WindowAnimation_taskCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1510 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1511 | case TRANSIT_TASK_TO_FRONT: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1512 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1513 | ? WindowAnimation_taskToFrontEnterAnimation |
| 1514 | : WindowAnimation_taskToFrontExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1515 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1516 | case TRANSIT_TASK_TO_BACK: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1517 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1518 | ? WindowAnimation_taskToBackEnterAnimation |
| 1519 | : WindowAnimation_taskToBackExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1520 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1521 | case TRANSIT_WALLPAPER_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1522 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1523 | ? WindowAnimation_wallpaperOpenEnterAnimation |
| 1524 | : WindowAnimation_wallpaperOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1525 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1526 | case TRANSIT_WALLPAPER_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1527 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1528 | ? WindowAnimation_wallpaperCloseEnterAnimation |
| 1529 | : WindowAnimation_wallpaperCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1530 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1531 | case TRANSIT_WALLPAPER_INTRA_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1532 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1533 | ? WindowAnimation_wallpaperIntraOpenEnterAnimation |
| 1534 | : WindowAnimation_wallpaperIntraOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1535 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1536 | case TRANSIT_WALLPAPER_INTRA_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1537 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1538 | ? WindowAnimation_wallpaperIntraCloseEnterAnimation |
| 1539 | : WindowAnimation_wallpaperIntraCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1540 | break; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1541 | case TRANSIT_TASK_OPEN_BEHIND: |
| 1542 | animAttr = enter |
| 1543 | ? WindowAnimation_launchTaskBehindSourceAnimation |
Craig Mautner | 3b2cd1d | 2014-08-25 14:25:54 -0700 | [diff] [blame] | 1544 | : WindowAnimation_launchTaskBehindTargetAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1545 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1546 | a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1547 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1548 | "applyAnimation:" |
| 1549 | + " anim=" + a |
| 1550 | + " animAttr=0x" + Integer.toHexString(animAttr) |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1551 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1552 | + " Callers=" + Debug.getCallers(3)); |
| 1553 | } |
| 1554 | return a; |
| 1555 | } |
| 1556 | |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1557 | int getAppStackClipMode() { |
| 1558 | return mNextAppTransition == TRANSIT_ACTIVITY_RELAUNCH |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1559 | || mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1560 | ? STACK_CLIP_NONE |
| 1561 | : STACK_CLIP_AFTER_ANIM; |
| 1562 | } |
| 1563 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1564 | void postAnimationCallback() { |
| 1565 | if (mNextAppTransitionCallback != null) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1566 | mService.mH.sendMessage(mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, |
| 1567 | mNextAppTransitionCallback)); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1568 | mNextAppTransitionCallback = null; |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1573 | IRemoteCallback startedCallback) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1574 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1575 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1576 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1577 | mNextAppTransitionPackage = packageName; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1578 | mNextAppTransitionEnter = enterAnim; |
| 1579 | mNextAppTransitionExit = exitAnim; |
| 1580 | postAnimationCallback(); |
| 1581 | mNextAppTransitionCallback = startedCallback; |
| 1582 | } else { |
| 1583 | postAnimationCallback(); |
| 1584 | } |
| 1585 | } |
| 1586 | |
| 1587 | void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1588 | int startHeight) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1589 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1590 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1591 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1592 | putDefaultNextAppTransitionCoordinates(startX, startY, startX + startWidth, |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1593 | startY + startHeight, null); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1594 | postAnimationCallback(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1595 | } |
| 1596 | } |
| 1597 | |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1598 | void overridePendingAppTransitionClipReveal(int startX, int startY, |
| 1599 | int startWidth, int startHeight) { |
| 1600 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1601 | clear(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1602 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1603 | putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1604 | postAnimationCallback(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1605 | } |
| 1606 | } |
| 1607 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1608 | void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, |
| 1609 | IRemoteCallback startedCallback, boolean scaleUp) { |
| 1610 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1611 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1612 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP |
| 1613 | : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1614 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1615 | putDefaultNextAppTransitionCoordinates(startX, startY, 0, 0, srcThumb); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1616 | postAnimationCallback(); |
| 1617 | mNextAppTransitionCallback = startedCallback; |
| 1618 | } else { |
| 1619 | postAnimationCallback(); |
| 1620 | } |
| 1621 | } |
| 1622 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1623 | void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1624 | int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1625 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1626 | clear(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1627 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1628 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1629 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1630 | putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight, |
| 1631 | srcThumb); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1632 | postAnimationCallback(); |
| 1633 | mNextAppTransitionCallback = startedCallback; |
| 1634 | } else { |
| 1635 | postAnimationCallback(); |
| 1636 | } |
| 1637 | } |
| 1638 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1639 | public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs, |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1640 | IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback, |
| 1641 | boolean scaleUp) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1642 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1643 | clear(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1644 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1645 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1646 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1647 | if (specs != null) { |
| 1648 | for (int i = 0; i < specs.length; i++) { |
| 1649 | AppTransitionAnimationSpec spec = specs[i]; |
| 1650 | if (spec != null) { |
| 1651 | mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec); |
| 1652 | if (i == 0) { |
| 1653 | // In full screen mode, the transition code depends on the default spec |
| 1654 | // to be set. |
| 1655 | Rect rect = spec.rect; |
| 1656 | putDefaultNextAppTransitionCoordinates(rect.left, rect.top, |
Filip Gruszczynski | e3264d8 | 2015-11-20 17:10:04 -0800 | [diff] [blame] | 1657 | rect.width(), rect.height(), spec.bitmap); |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1658 | } |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1659 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1660 | } |
| 1661 | } |
| 1662 | postAnimationCallback(); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1663 | mNextAppTransitionCallback = onAnimationStartedCallback; |
| 1664 | mAnimationFinishedCallback = onAnimationFinishedCallback; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1665 | } else { |
| 1666 | postAnimationCallback(); |
| 1667 | } |
| 1668 | } |
| 1669 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1670 | void overridePendingAppTransitionMultiThumbFuture( |
| 1671 | IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback callback, |
| 1672 | boolean scaleUp) { |
| 1673 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1674 | clear(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1675 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1676 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1677 | mNextAppTransitionAnimationsSpecsFuture = specsFuture; |
| 1678 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 1679 | mNextAppTransitionFutureCallback = callback; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1680 | } |
| 1681 | } |
| 1682 | |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1683 | void overrideInPlaceAppTransition(String packageName, int anim) { |
| 1684 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1685 | clear(); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1686 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE; |
| 1687 | mNextAppTransitionPackage = packageName; |
| 1688 | mNextAppTransitionInPlace = anim; |
| 1689 | } else { |
| 1690 | postAnimationCallback(); |
| 1691 | } |
| 1692 | } |
| 1693 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1694 | /** |
| 1695 | * If a future is set for the app transition specs, fetch it in another thread. |
| 1696 | */ |
| 1697 | private void fetchAppTransitionSpecsFromFuture() { |
| 1698 | if (mNextAppTransitionAnimationsSpecsFuture != null) { |
| 1699 | mNextAppTransitionAnimationsSpecsPending = true; |
| 1700 | final IAppTransitionAnimationSpecsFuture future |
| 1701 | = mNextAppTransitionAnimationsSpecsFuture; |
| 1702 | mNextAppTransitionAnimationsSpecsFuture = null; |
| 1703 | mDefaultExecutor.execute(new Runnable() { |
| 1704 | @Override |
| 1705 | public void run() { |
| 1706 | AppTransitionAnimationSpec[] specs = null; |
| 1707 | try { |
| 1708 | specs = future.get(); |
| 1709 | } catch (RemoteException e) { |
| 1710 | Slog.w(TAG, "Failed to fetch app transition specs: " + e); |
| 1711 | } |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1712 | synchronized (mService.mWindowMap) { |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1713 | mNextAppTransitionAnimationsSpecsPending = false; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 1714 | overridePendingAppTransitionMultiThumb(specs, |
| 1715 | mNextAppTransitionFutureCallback, null /* finishedCallback */, |
| 1716 | mNextAppTransitionScaleUp); |
| 1717 | mNextAppTransitionFutureCallback = null; |
Filip Gruszczynski | 96daf32 | 2015-11-18 18:01:27 -0800 | [diff] [blame] | 1718 | if (specs != null) { |
| 1719 | mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp); |
| 1720 | } |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1721 | } |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1722 | mService.requestTraversal(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1723 | } |
| 1724 | }); |
| 1725 | } |
| 1726 | } |
| 1727 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1728 | @Override |
| 1729 | public String toString() { |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1730 | return "mNextAppTransition=" + appTransitionToString(mNextAppTransition); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1731 | } |
| 1732 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1733 | /** |
| 1734 | * Returns the human readable name of a window transition. |
| 1735 | * |
| 1736 | * @param transition The window transition. |
| 1737 | * @return The transition symbolic name. |
| 1738 | */ |
| 1739 | public static String appTransitionToString(int transition) { |
| 1740 | switch (transition) { |
| 1741 | case TRANSIT_UNSET: { |
| 1742 | return "TRANSIT_UNSET"; |
| 1743 | } |
| 1744 | case TRANSIT_NONE: { |
| 1745 | return "TRANSIT_NONE"; |
| 1746 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1747 | case TRANSIT_ACTIVITY_OPEN: { |
| 1748 | return "TRANSIT_ACTIVITY_OPEN"; |
| 1749 | } |
| 1750 | case TRANSIT_ACTIVITY_CLOSE: { |
| 1751 | return "TRANSIT_ACTIVITY_CLOSE"; |
| 1752 | } |
| 1753 | case TRANSIT_TASK_OPEN: { |
| 1754 | return "TRANSIT_TASK_OPEN"; |
| 1755 | } |
| 1756 | case TRANSIT_TASK_CLOSE: { |
| 1757 | return "TRANSIT_TASK_CLOSE"; |
| 1758 | } |
| 1759 | case TRANSIT_TASK_TO_FRONT: { |
| 1760 | return "TRANSIT_TASK_TO_FRONT"; |
| 1761 | } |
| 1762 | case TRANSIT_TASK_TO_BACK: { |
| 1763 | return "TRANSIT_TASK_TO_BACK"; |
| 1764 | } |
| 1765 | case TRANSIT_WALLPAPER_CLOSE: { |
| 1766 | return "TRANSIT_WALLPAPER_CLOSE"; |
| 1767 | } |
| 1768 | case TRANSIT_WALLPAPER_OPEN: { |
| 1769 | return "TRANSIT_WALLPAPER_OPEN"; |
| 1770 | } |
| 1771 | case TRANSIT_WALLPAPER_INTRA_OPEN: { |
| 1772 | return "TRANSIT_WALLPAPER_INTRA_OPEN"; |
| 1773 | } |
| 1774 | case TRANSIT_WALLPAPER_INTRA_CLOSE: { |
| 1775 | return "TRANSIT_WALLPAPER_INTRA_CLOSE"; |
| 1776 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1777 | case TRANSIT_TASK_OPEN_BEHIND: { |
| 1778 | return "TRANSIT_TASK_OPEN_BEHIND"; |
| 1779 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1780 | case TRANSIT_ACTIVITY_RELAUNCH: { |
| 1781 | return "TRANSIT_ACTIVITY_RELAUNCH"; |
| 1782 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1783 | case TRANSIT_DOCK_TASK_FROM_RECENTS: { |
| 1784 | return "TRANSIT_DOCK_TASK_FROM_RECENTS"; |
| 1785 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1786 | default: { |
| 1787 | return "<UNKNOWN>"; |
| 1788 | } |
| 1789 | } |
| 1790 | } |
| 1791 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1792 | private String appStateToString() { |
| 1793 | switch (mAppTransitionState) { |
| 1794 | case APP_STATE_IDLE: |
| 1795 | return "APP_STATE_IDLE"; |
| 1796 | case APP_STATE_READY: |
| 1797 | return "APP_STATE_READY"; |
| 1798 | case APP_STATE_RUNNING: |
| 1799 | return "APP_STATE_RUNNING"; |
| 1800 | case APP_STATE_TIMEOUT: |
| 1801 | return "APP_STATE_TIMEOUT"; |
| 1802 | default: |
| 1803 | return "unknown state=" + mAppTransitionState; |
| 1804 | } |
| 1805 | } |
| 1806 | |
| 1807 | private String transitTypeToString() { |
| 1808 | switch (mNextAppTransitionType) { |
| 1809 | case NEXT_TRANSIT_TYPE_NONE: |
| 1810 | return "NEXT_TRANSIT_TYPE_NONE"; |
| 1811 | case NEXT_TRANSIT_TYPE_CUSTOM: |
| 1812 | return "NEXT_TRANSIT_TYPE_CUSTOM"; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1813 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
| 1814 | return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1815 | case NEXT_TRANSIT_TYPE_SCALE_UP: |
| 1816 | return "NEXT_TRANSIT_TYPE_SCALE_UP"; |
| 1817 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1818 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP"; |
| 1819 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
| 1820 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN"; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1821 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
| 1822 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP"; |
| 1823 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 1824 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1825 | default: |
| 1826 | return "unknown type=" + mNextAppTransitionType; |
| 1827 | } |
| 1828 | } |
| 1829 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1830 | @Override |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1831 | public void dump(PrintWriter pw, String prefix) { |
| 1832 | pw.print(prefix); pw.println(this); |
| 1833 | pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString()); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1834 | if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1835 | pw.print(prefix); pw.print("mNextAppTransitionType="); |
| 1836 | pw.println(transitTypeToString()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1837 | } |
| 1838 | switch (mNextAppTransitionType) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1839 | case NEXT_TRANSIT_TYPE_CUSTOM: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1840 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1841 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1842 | pw.print(prefix); pw.print("mNextAppTransitionEnter=0x"); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1843 | pw.print(Integer.toHexString(mNextAppTransitionEnter)); |
| 1844 | pw.print(" mNextAppTransitionExit=0x"); |
| 1845 | pw.println(Integer.toHexString(mNextAppTransitionExit)); |
| 1846 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1847 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1848 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1849 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1850 | pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x"); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1851 | pw.print(Integer.toHexString(mNextAppTransitionInPlace)); |
| 1852 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1853 | case NEXT_TRANSIT_TYPE_SCALE_UP: { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1854 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1855 | pw.print(prefix); pw.print("mNextAppTransitionStartX="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1856 | pw.print(mTmpRect.left); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1857 | pw.print(" mNextAppTransitionStartY="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1858 | pw.println(mTmpRect.top); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1859 | pw.print(prefix); pw.print("mNextAppTransitionStartWidth="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1860 | pw.print(mTmpRect.width()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1861 | pw.print(" mNextAppTransitionStartHeight="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1862 | pw.println(mTmpRect.height()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1863 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1864 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1865 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1866 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1867 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1868 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: { |
| 1869 | pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec="); |
| 1870 | pw.println(mDefaultNextAppTransitionAnimationSpec); |
| 1871 | pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs="); |
| 1872 | pw.println(mNextAppTransitionAnimationsSpecs); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1873 | pw.print(prefix); pw.print("mNextAppTransitionScaleUp="); |
| 1874 | pw.println(mNextAppTransitionScaleUp); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1875 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1876 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1877 | } |
| 1878 | if (mNextAppTransitionCallback != null) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1879 | pw.print(prefix); pw.print("mNextAppTransitionCallback="); |
| 1880 | pw.println(mNextAppTransitionCallback); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1881 | } |
| 1882 | } |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 1883 | |
| 1884 | public void setCurrentUser(int newUserId) { |
| 1885 | mCurrentUserId = newUserId; |
| 1886 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1887 | |
| 1888 | /** |
| 1889 | * @return true if transition is not running and should not be skipped, false if transition is |
| 1890 | * already running |
| 1891 | */ |
| 1892 | boolean prepareAppTransitionLocked(int transit, boolean alwaysKeepCurrent) { |
| 1893 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:" |
| 1894 | + " transit=" + appTransitionToString(transit) |
| 1895 | + " " + this |
| 1896 | + " alwaysKeepCurrent=" + alwaysKeepCurrent |
| 1897 | + " Callers=" + Debug.getCallers(3)); |
| 1898 | if (!isTransitionSet() || mNextAppTransition == TRANSIT_NONE) { |
| 1899 | setAppTransition(transit); |
| 1900 | } else if (!alwaysKeepCurrent) { |
| 1901 | if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) { |
| 1902 | // Opening a new task always supersedes a close for the anim. |
| 1903 | setAppTransition(transit); |
| 1904 | } else if (transit == TRANSIT_ACTIVITY_OPEN |
| 1905 | && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) { |
| 1906 | // Opening a new activity always supersedes a close for the anim. |
| 1907 | setAppTransition(transit); |
| 1908 | } |
| 1909 | } |
| 1910 | boolean prepared = prepare(); |
| 1911 | if (isTransitionSet()) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1912 | mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT); |
| 1913 | mService.mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, APP_TRANSITION_TIMEOUT_MS); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1914 | } |
| 1915 | return prepared; |
| 1916 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1917 | } |