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, |
| 884 | Bitmap thumbnailHeader, final int taskId) { |
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 | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 893 | final float toY = mTmpRect.height() / 2 * (scaleW - 1f) + appRect.top; |
| 894 | final float fromY = mTmpRect.top; |
| 895 | final float toX = mTmpRect.width() / 2 * (scaleW - 1f) + appRect.left; |
| 896 | final float fromX = mTmpRect.left; |
| 897 | final float pivotX = mTmpRect.width() / 2; |
| 898 | final float pivotY = mTmpRect.height() / 2; |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 899 | final long duration = getAspectScaleDuration(); |
| 900 | final Interpolator interpolator = getAspectScaleInterpolator(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 901 | if (mNextAppTransitionScaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 902 | // Animation up from the thumbnail to the full screen |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 903 | Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 904 | scale.setInterpolator(interpolator); |
| 905 | scale.setDuration(duration); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 906 | Animation alpha = new AlphaAnimation(1f, 0f); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 907 | alpha.setInterpolator(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 908 | ? THUMBNAIL_DOCK_INTERPOLATOR : mThumbnailFadeOutInterpolator); |
| 909 | alpha.setDuration(mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
| 910 | ? duration / 2 |
| 911 | : duration); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 912 | Animation translate = createCurvedMotion(fromX, toX, fromY, toY); |
| 913 | translate.setInterpolator(interpolator); |
| 914 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 915 | |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 916 | mTmpFromClipRect.set(0, 0, thumbWidthI, thumbHeightI); |
| 917 | mTmpToClipRect.set(appRect); |
| 918 | |
| 919 | // Containing frame is in screen space, but we need the clip rect in the |
| 920 | // app space. |
| 921 | mTmpToClipRect.offsetTo(0, 0); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 922 | mTmpToClipRect.right = (int) (mTmpToClipRect.right / scaleW); |
| 923 | mTmpToClipRect.bottom = (int) (mTmpToClipRect.bottom / scaleW); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 924 | |
| 925 | if (contentInsets != null) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 926 | mTmpToClipRect.inset((int) (-contentInsets.left * scaleW), |
| 927 | (int) (-contentInsets.top * scaleW), |
| 928 | (int) (-contentInsets.right * scaleW), |
| 929 | (int) (-contentInsets.bottom * scaleW)); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 933 | clipAnim.setInterpolator(interpolator); |
| 934 | clipAnim.setDuration(duration); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 935 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 936 | // This AnimationSet uses the Interpolators assigned above. |
| 937 | AnimationSet set = new AnimationSet(false); |
| 938 | set.addAnimation(scale); |
| 939 | set.addAnimation(alpha); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 940 | set.addAnimation(translate); |
Jorim Jaggi | de63d44 | 2016-03-14 14:56:56 +0100 | [diff] [blame] | 941 | set.addAnimation(clipAnim); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 942 | a = set; |
| 943 | } else { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 944 | // Animation down from the full screen to the thumbnail |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 945 | Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, pivotX, pivotY); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 946 | scale.setInterpolator(interpolator); |
| 947 | scale.setDuration(duration); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 948 | Animation alpha = new AlphaAnimation(0f, 1f); |
| 949 | alpha.setInterpolator(mThumbnailFadeInInterpolator); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 950 | alpha.setDuration(duration); |
| 951 | Animation translate = createCurvedMotion(toX, fromX, toY, fromY); |
| 952 | translate.setInterpolator(interpolator); |
| 953 | translate.setDuration(duration); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 954 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 955 | // This AnimationSet uses the Interpolators assigned above. |
| 956 | AnimationSet set = new AnimationSet(false); |
| 957 | set.addAnimation(scale); |
| 958 | set.addAnimation(alpha); |
| 959 | set.addAnimation(translate); |
| 960 | a = set; |
| 961 | |
| 962 | } |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 963 | return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 964 | null); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 965 | } |
| 966 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 967 | private Animation createCurvedMotion(float fromX, float toX, float fromY, float toY) { |
| 968 | |
| 969 | // Almost no x-change - use linear animation |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 970 | if (Math.abs(toX - fromX) < 1f || mNextAppTransition != TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 971 | return new TranslateAnimation(fromX, toX, fromY, toY); |
| 972 | } else { |
| 973 | final Path path = createCurvedPath(fromX, toX, fromY, toY); |
| 974 | return new CurvedTranslateAnimation(path); |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | private Path createCurvedPath(float fromX, float toX, float fromY, float toY) { |
| 979 | final Path path = new Path(); |
| 980 | path.moveTo(fromX, fromY); |
| 981 | path.cubicTo(fromX, fromY, toX, 0.9f * fromY + 0.1f * toY, toX, toY); |
| 982 | return path; |
| 983 | } |
| 984 | |
| 985 | private long getAspectScaleDuration() { |
| 986 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 987 | return (long) (THUMBNAIL_APP_TRANSITION_DURATION * 1.35f); |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 988 | } else { |
| 989 | return THUMBNAIL_APP_TRANSITION_DURATION; |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | private Interpolator getAspectScaleInterpolator() { |
| 994 | if (mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS) { |
| 995 | return mFastOutSlowInInterpolator; |
| 996 | } else { |
| 997 | return TOUCH_RESPONSE_INTERPOLATOR; |
| 998 | } |
| 999 | } |
| 1000 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1001 | /** |
| 1002 | * This alternate animation is created when we are doing a thumbnail transition, for the |
| 1003 | * activity that is leaving, and the activity that is entering. |
| 1004 | */ |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1005 | Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState, |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1006 | int orientation, int transit, Rect containingFrame, Rect contentInsets, |
| 1007 | @Nullable Rect surfaceInsets, boolean freeform, int taskId) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1008 | Animation a; |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1009 | final int appWidth = containingFrame.width(); |
| 1010 | final int appHeight = containingFrame.height(); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1011 | getDefaultNextAppTransitionStartRect(mTmpRect); |
| 1012 | final int thumbWidthI = mTmpRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1013 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1014 | final int thumbHeightI = mTmpRect.height(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1015 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1016 | final int thumbStartX = mTmpRect.left - containingFrame.left; |
| 1017 | final int thumbStartY = mTmpRect.top - containingFrame.top; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1018 | |
| 1019 | switch (thumbTransitState) { |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1020 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: |
| 1021 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1022 | final boolean scaleUp = thumbTransitState == THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 1023 | if (freeform && scaleUp) { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1024 | a = createAspectScaledThumbnailEnterFreeformAnimationLocked( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1025 | containingFrame, surfaceInsets, taskId); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1026 | } else if (freeform) { |
| 1027 | a = createAspectScaledThumbnailExitFreeformAnimationLocked( |
| 1028 | containingFrame, surfaceInsets, taskId); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1029 | } else { |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1030 | AnimationSet set = new AnimationSet(true); |
| 1031 | |
| 1032 | // In portrait, we scale to fit the width |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1033 | mTmpFromClipRect.set(containingFrame); |
Filip Gruszczynski | efd3d1b | 2015-10-14 13:57:55 -0700 | [diff] [blame] | 1034 | mTmpToClipRect.set(containingFrame); |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 1035 | |
| 1036 | // Containing frame is in screen space, but we need the clip rect in the |
| 1037 | // app space. |
| 1038 | mTmpFromClipRect.offsetTo(0, 0); |
| 1039 | mTmpToClipRect.offsetTo(0, 0); |
| 1040 | |
| 1041 | // Exclude insets region from the source clip. |
| 1042 | mTmpFromClipRect.inset(contentInsets); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1043 | mNextAppTransitionInsets.set(contentInsets); |
| 1044 | |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1045 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 1046 | // We scale the width and clip to the top/left square |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1047 | // We scale the width and clip to the top/left square |
| 1048 | float scale = thumbWidth / |
| 1049 | (appWidth - contentInsets.left - contentInsets.right); |
| 1050 | int unscaledThumbHeight = (int) (thumbHeight / scale); |
| 1051 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + unscaledThumbHeight; |
| 1052 | |
| 1053 | mNextAppTransitionInsets.set(contentInsets); |
| 1054 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1055 | Animation scaleAnim = new ScaleAnimation( |
| 1056 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
| 1057 | scaleUp ? scale : 1, scaleUp ? 1 : scale, |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1058 | containingFrame.width() / 2f, |
| 1059 | containingFrame.height() / 2f + contentInsets.top); |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1060 | final float targetX = (mTmpRect.left - containingFrame.left); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1061 | final float x = containingFrame.width() / 2f |
| 1062 | - containingFrame.width() / 2f * scale; |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1063 | final float targetY = (mTmpRect.top - containingFrame.top); |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1064 | final float y = containingFrame.height() / 2f |
| 1065 | - containingFrame.height() / 2f * scale; |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1066 | final float startX = targetX - x; |
| 1067 | final float startY = targetY - y; |
| 1068 | Animation clipAnim = scaleUp |
| 1069 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1070 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1071 | Animation translateAnim = scaleUp |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1072 | ? createCurvedMotion(startX, 0, startY - contentInsets.top, 0) |
| 1073 | : createCurvedMotion(0, startX, 0, startY - contentInsets.top); |
| 1074 | |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1075 | set.addAnimation(clipAnim); |
| 1076 | set.addAnimation(scaleAnim); |
| 1077 | set.addAnimation(translateAnim); |
| 1078 | |
| 1079 | } else { |
| 1080 | // In landscape, we don't scale at all and only crop |
| 1081 | mTmpFromClipRect.bottom = mTmpFromClipRect.top + thumbHeightI; |
| 1082 | mTmpFromClipRect.right = mTmpFromClipRect.left + thumbWidthI; |
| 1083 | |
Jorim Jaggi | 8448f33 | 2016-03-14 17:50:37 +0100 | [diff] [blame] | 1084 | Animation clipAnim = scaleUp |
| 1085 | ? new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect) |
| 1086 | : new ClipRectAnimation(mTmpToClipRect, mTmpFromClipRect); |
| 1087 | Animation translateAnim = scaleUp |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1088 | ? createCurvedMotion(thumbStartX, 0, |
| 1089 | thumbStartY - contentInsets.top, 0) |
| 1090 | : createCurvedMotion(0, thumbStartX, 0, |
| 1091 | thumbStartY - contentInsets.top); |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1092 | |
| 1093 | set.addAnimation(clipAnim); |
| 1094 | set.addAnimation(translateAnim); |
| 1095 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1096 | a = set; |
Winson | 2170093 | 2016-03-24 17:26:23 -0700 | [diff] [blame] | 1097 | a.setZAdjustment(Animation.ZORDER_TOP); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 1098 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1099 | break; |
| 1100 | } |
| 1101 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1102 | // Previous app window during the scale up |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1103 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1104 | // Fade out the source activity if we are animating to a wallpaper |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1105 | // activity. |
| 1106 | a = new AlphaAnimation(1, 0); |
| 1107 | } else { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1108 | a = new AlphaAnimation(1, 1); |
| 1109 | } |
| 1110 | break; |
| 1111 | } |
| 1112 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1113 | // Target app window during the scale down |
| 1114 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1115 | // Fade in the destination activity if we are animating from a wallpaper |
| 1116 | // activity. |
| 1117 | a = new AlphaAnimation(0, 1); |
| 1118 | } else { |
| 1119 | a = new AlphaAnimation(1, 1); |
| 1120 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1121 | break; |
| 1122 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1123 | default: |
| 1124 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1125 | } |
| 1126 | |
Jorim Jaggi | 787e9dd | 2016-03-15 10:52:40 +0100 | [diff] [blame] | 1127 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, |
| 1128 | getAspectScaleDuration(), getAspectScaleInterpolator()); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1131 | private Animation createAspectScaledThumbnailEnterFreeformAnimationLocked(Rect frame, |
| 1132 | @Nullable Rect surfaceInsets, int taskId) { |
| 1133 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1134 | return createAspectScaledThumbnailFreeformAnimationLocked(mTmpRect, frame, surfaceInsets, |
| 1135 | true); |
| 1136 | } |
| 1137 | |
| 1138 | private Animation createAspectScaledThumbnailExitFreeformAnimationLocked(Rect frame, |
| 1139 | @Nullable Rect surfaceInsets, int taskId) { |
| 1140 | getNextAppTransitionStartRect(taskId, mTmpRect); |
| 1141 | return createAspectScaledThumbnailFreeformAnimationLocked(frame, mTmpRect, surfaceInsets, |
| 1142 | false); |
| 1143 | } |
| 1144 | |
| 1145 | private AnimationSet createAspectScaledThumbnailFreeformAnimationLocked(Rect sourceFrame, |
| 1146 | Rect destFrame, @Nullable Rect surfaceInsets, boolean enter) { |
| 1147 | final float sourceWidth = sourceFrame.width(); |
| 1148 | final float sourceHeight = sourceFrame.height(); |
| 1149 | final float destWidth = destFrame.width(); |
| 1150 | final float destHeight = destFrame.height(); |
| 1151 | final float scaleH = enter ? sourceWidth / destWidth : destWidth / sourceWidth; |
| 1152 | final float scaleV = enter ? sourceHeight / destHeight : destHeight / sourceHeight; |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1153 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1154 | final int surfaceInsetsH = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1155 | ? 0 : surfaceInsets.left + surfaceInsets.right; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1156 | final int surfaceInsetsV = surfaceInsets == null |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1157 | ? 0 : surfaceInsets.top + surfaceInsets.bottom; |
| 1158 | // We want the scaling to happen from the center of the surface. In order to achieve that, |
| 1159 | // 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] | 1160 | final float scaleHCenter = ((enter ? destWidth : sourceWidth) + surfaceInsetsH) / 2; |
| 1161 | final float scaleVCenter = ((enter ? destHeight : sourceHeight) + surfaceInsetsV) / 2; |
| 1162 | final ScaleAnimation scale = enter ? |
| 1163 | new ScaleAnimation(scaleH, 1, scaleV, 1, scaleHCenter, scaleVCenter) |
| 1164 | : new ScaleAnimation(1, scaleH, 1, scaleV, scaleHCenter, scaleVCenter); |
| 1165 | final int sourceHCenter = sourceFrame.left + sourceFrame.width() / 2; |
| 1166 | final int sourceVCenter = sourceFrame.top + sourceFrame.height() / 2; |
| 1167 | final int destHCenter = destFrame.left + destFrame.width() / 2; |
| 1168 | final int destVCenter = destFrame.top + destFrame.height() / 2; |
| 1169 | final int fromX = enter ? sourceHCenter - destHCenter : destHCenter - sourceHCenter; |
| 1170 | final int fromY = enter ? sourceVCenter - destVCenter : destVCenter - sourceVCenter; |
| 1171 | final TranslateAnimation translation = enter ? new TranslateAnimation(fromX, 0, fromY, 0) |
| 1172 | : new TranslateAnimation(0, fromX, 0, fromY); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1173 | set.addAnimation(scale); |
| 1174 | set.addAnimation(translation); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1175 | |
| 1176 | final IRemoteCallback callback = mAnimationFinishedCallback; |
| 1177 | if (callback != null) { |
| 1178 | set.setAnimationListener(new Animation.AnimationListener() { |
| 1179 | @Override |
| 1180 | public void onAnimationStart(Animation animation) { } |
| 1181 | |
| 1182 | @Override |
| 1183 | public void onAnimationEnd(Animation animation) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1184 | mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, callback).sendToTarget(); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | @Override |
| 1188 | public void onAnimationRepeat(Animation animation) { } |
| 1189 | }); |
| 1190 | } |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1191 | return set; |
| 1192 | } |
| 1193 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1194 | /** |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1195 | * 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] | 1196 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1197 | */ |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1198 | Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, |
| 1199 | Bitmap thumbnailHeader) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1200 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1201 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1202 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1203 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1204 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1205 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1206 | |
| 1207 | if (mNextAppTransitionScaleUp) { |
| 1208 | // Animation for the thumbnail zooming from its initial size to the full screen |
| 1209 | float scaleW = appWidth / thumbWidth; |
| 1210 | float scaleH = appHeight / thumbHeight; |
| 1211 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1212 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1213 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1214 | scale.setInterpolator(mDecelerateInterpolator); |
| 1215 | |
| 1216 | Animation alpha = new AlphaAnimation(1, 0); |
| 1217 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
| 1218 | |
| 1219 | // This AnimationSet uses the Interpolators assigned above. |
| 1220 | AnimationSet set = new AnimationSet(false); |
| 1221 | set.addAnimation(scale); |
| 1222 | set.addAnimation(alpha); |
| 1223 | a = set; |
| 1224 | } else { |
| 1225 | // Animation for the thumbnail zooming down from the full screen to its final size |
| 1226 | float scaleW = appWidth / thumbWidth; |
| 1227 | float scaleH = appHeight / thumbHeight; |
| 1228 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1229 | computePivot(mTmpRect.left, 1 / scaleW), |
| 1230 | computePivot(mTmpRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1231 | } |
| 1232 | |
| 1233 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1234 | } |
| 1235 | |
| 1236 | /** |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1237 | * This animation is created when we are doing a thumbnail transition, for the activity that is |
| 1238 | * leaving, and the activity that is entering. |
| 1239 | */ |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1240 | Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, Rect containingFrame, |
| 1241 | int transit, int taskId) { |
| 1242 | final int appWidth = containingFrame.width(); |
| 1243 | final int appHeight = containingFrame.height(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1244 | Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1245 | Animation a; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1246 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1247 | final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1248 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1249 | final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1250 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 1251 | |
| 1252 | switch (thumbTransitState) { |
| 1253 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: { |
| 1254 | // Entering app scales up with the thumbnail |
| 1255 | float scaleW = thumbWidth / appWidth; |
| 1256 | float scaleH = thumbHeight / appHeight; |
| 1257 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1258 | computePivot(mTmpRect.left, scaleW), |
| 1259 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1260 | break; |
| 1261 | } |
| 1262 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
| 1263 | // Exiting app while the thumbnail is scaling up should fade or stay in place |
| 1264 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 1265 | // Fade out while bringing up selected activity. This keeps the |
| 1266 | // current activity from showing through a launching wallpaper |
| 1267 | // activity. |
| 1268 | a = new AlphaAnimation(1, 0); |
| 1269 | } else { |
| 1270 | // noop animation |
| 1271 | a = new AlphaAnimation(1, 1); |
| 1272 | } |
| 1273 | break; |
| 1274 | } |
| 1275 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
| 1276 | // Entering the other app, it should just be visible while we scale the thumbnail |
| 1277 | // down above it |
| 1278 | a = new AlphaAnimation(1, 1); |
| 1279 | break; |
| 1280 | } |
| 1281 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 1282 | // Exiting the current app, the app should scale down with the thumbnail |
| 1283 | float scaleW = thumbWidth / appWidth; |
| 1284 | float scaleH = thumbHeight / appHeight; |
| 1285 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1286 | computePivot(mTmpRect.left, scaleW), |
| 1287 | computePivot(mTmpRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 1288 | |
| 1289 | Animation alpha = new AlphaAnimation(1, 0); |
| 1290 | |
| 1291 | AnimationSet set = new AnimationSet(true); |
| 1292 | set.addAnimation(scale); |
| 1293 | set.addAnimation(alpha); |
| 1294 | set.setZAdjustment(Animation.ZORDER_TOP); |
| 1295 | a = set; |
| 1296 | break; |
| 1297 | } |
| 1298 | default: |
| 1299 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1300 | } |
| 1301 | |
| 1302 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1303 | } |
| 1304 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1305 | private Animation createRelaunchAnimation(Rect containingFrame, Rect contentInsets) { |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1306 | getDefaultNextAppTransitionStartRect(mTmpFromClipRect); |
| 1307 | final int left = mTmpFromClipRect.left; |
| 1308 | final int top = mTmpFromClipRect.top; |
| 1309 | mTmpFromClipRect.offset(-left, -top); |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1310 | // TODO: Isn't that strange that we ignore exact position of the containingFrame? |
| 1311 | mTmpToClipRect.set(0, 0, containingFrame.width(), containingFrame.height()); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1312 | AnimationSet set = new AnimationSet(true); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1313 | float fromWidth = mTmpFromClipRect.width(); |
| 1314 | float toWidth = mTmpToClipRect.width(); |
| 1315 | float fromHeight = mTmpFromClipRect.height(); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1316 | // While the window might span the whole display, the actual content will be cropped to the |
| 1317 | // system decoration frame, for example when the window is docked. We need to take into |
| 1318 | // account the visible height when constructing the animation. |
| 1319 | float toHeight = mTmpToClipRect.height() - contentInsets.top - contentInsets.bottom; |
| 1320 | int translateAdjustment = 0; |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1321 | if (fromWidth <= toWidth && fromHeight <= toHeight) { |
| 1322 | // The final window is larger in both dimensions than current window (e.g. we are |
| 1323 | // maximizing), so we can simply unclip the new window and there will be no disappearing |
| 1324 | // frame. |
| 1325 | set.addAnimation(new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect)); |
| 1326 | } else { |
| 1327 | // The disappearing window has one larger dimension. We need to apply scaling, so the |
| 1328 | // first frame of the entry animation matches the old window. |
| 1329 | set.addAnimation(new ScaleAnimation(fromWidth / toWidth, 1, fromHeight / toHeight, 1)); |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1330 | // We might not be going exactly full screen, but instead be aligned under the status |
| 1331 | // bar using cropping. We still need to account for the cropped part, which will also |
| 1332 | // be scaled. |
| 1333 | translateAdjustment = (int) (contentInsets.top * fromHeight / toHeight); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1334 | } |
| 1335 | |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1336 | // We animate the translation from the old position of the removed window, to the new |
| 1337 | // position of the added window. The latter might not be full screen, for example docked for |
| 1338 | // docked windows. |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1339 | TranslateAnimation translate = new TranslateAnimation(left - containingFrame.left, |
Filip Gruszczynski | 2dfcf84 | 2015-10-25 13:40:47 -0700 | [diff] [blame] | 1340 | 0, top - containingFrame.top - translateAdjustment, 0); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1341 | set.addAnimation(translate); |
| 1342 | set.setDuration(DEFAULT_APP_TRANSITION_DURATION); |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 1343 | set.setZAdjustment(Animation.ZORDER_TOP); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1344 | return set; |
| 1345 | } |
| 1346 | |
Jorim Jaggi | c554b77 | 2015-06-04 16:07:57 -0700 | [diff] [blame] | 1347 | /** |
| 1348 | * @return true if and only if the first frame of the transition can be skipped, i.e. the first |
| 1349 | * frame of the transition doesn't change the visuals on screen, so we can start |
| 1350 | * directly with the second one |
| 1351 | */ |
| 1352 | boolean canSkipFirstFrame() { |
| 1353 | return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM |
| 1354 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE |
| 1355 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
| 1356 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1357 | |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1358 | /** |
| 1359 | * |
| 1360 | * @param frame These are the bounds of the window when it finishes the animation. This is where |
| 1361 | * the animation must usually finish in entrance animation, as the next frame will |
| 1362 | * display the window at these coordinates. In case of exit animation, this is |
| 1363 | * where the animation must start, as the frame before the animation is displaying |
| 1364 | * the window at these bounds. |
| 1365 | * @param insets Knowing where the window will be positioned is not enough. Some parts of the |
| 1366 | * window might be obscured, usually by the system windows (status bar and |
| 1367 | * navigation bar) and we use content insets to convey that information. This |
| 1368 | * usually affects the animation aspects vertically, as the system decoration is |
| 1369 | * at the top and the bottom. For example when we animate from full screen to |
| 1370 | * recents, we want to exclude the covered parts, because they won't match the |
| 1371 | * thumbnail after the last frame is executed. |
| 1372 | * @param surfaceInsets In rare situation the surface is larger than the content and we need to |
| 1373 | * know about this to make the animation frames match. We currently use |
| 1374 | * this for freeform windows, which have larger surfaces to display |
| 1375 | * shadows. When we animate them from recents, we want to match the content |
| 1376 | * to the recents thumbnail and hence need to account for the surface being |
| 1377 | * bigger. |
| 1378 | */ |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1379 | Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1380 | int orientation, Rect frame, Rect displayFrame, Rect insets, |
| 1381 | @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform, |
| 1382 | int taskId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1383 | Animation a; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1384 | if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN |
| 1385 | || transit == TRANSIT_TASK_OPEN |
| 1386 | || transit == TRANSIT_TASK_TO_FRONT)) { |
| 1387 | a = loadAnimationRes(lp, enter |
| 1388 | ? com.android.internal.R.anim.voice_activity_open_enter |
| 1389 | : com.android.internal.R.anim.voice_activity_open_exit); |
| 1390 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1391 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1392 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1393 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1394 | } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE |
| 1395 | || transit == TRANSIT_TASK_CLOSE |
| 1396 | || transit == TRANSIT_TASK_TO_BACK)) { |
| 1397 | a = loadAnimationRes(lp, enter |
| 1398 | ? com.android.internal.R.anim.voice_activity_close_enter |
| 1399 | : com.android.internal.R.anim.voice_activity_close_exit); |
| 1400 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1401 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1402 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1403 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1404 | } else if (transit == TRANSIT_ACTIVITY_RELAUNCH) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1405 | a = createRelaunchAnimation(frame, insets); |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1406 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1407 | "applyAnimation:" |
| 1408 | + " anim=" + a + " nextAppTransition=" + mNextAppTransition |
| 1409 | + " transit=" + appTransitionToString(transit) |
| 1410 | + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1411 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) { |
| 1412 | a = loadAnimationRes(mNextAppTransitionPackage, enter ? |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1413 | mNextAppTransitionEnter : mNextAppTransitionExit); |
| 1414 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1415 | "applyAnimation:" |
| 1416 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1417 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1418 | + " Callers=" + Debug.getCallers(3)); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1419 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) { |
| 1420 | a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace); |
| 1421 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1422 | "applyAnimation:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1423 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" |
| 1424 | + " transit=" + appTransitionToString(transit) |
| 1425 | + " Callers=" + Debug.getCallers(3)); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1426 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) { |
Jorim Jaggi | 8fe7e0a | 2016-02-12 19:43:39 -0800 | [diff] [blame] | 1427 | a = createClipRevealAnimationLocked(transit, enter, frame, displayFrame); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1428 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1429 | "applyAnimation:" |
| 1430 | + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" |
Filip Gruszczynski | 49b80af | 2015-09-24 09:04:26 -0700 | [diff] [blame] | 1431 | + " transit=" + appTransitionToString(transit) |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1432 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1433 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) { |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1434 | a = createScaleUpAnimationLocked(transit, enter, frame); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1435 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1436 | "applyAnimation:" |
| 1437 | + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1438 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1439 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1440 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 1441 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1442 | mNextAppTransitionScaleUp = |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1443 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1444 | a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1445 | frame, transit, taskId); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1446 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1447 | String animName = mNextAppTransitionScaleUp ? |
| 1448 | "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN"; |
| 1449 | Slog.v(TAG, "applyAnimation:" |
| 1450 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1451 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1452 | + " Callers=" + Debug.getCallers(3)); |
| 1453 | } |
| 1454 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 1455 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) { |
| 1456 | mNextAppTransitionScaleUp = |
| 1457 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP); |
| 1458 | a = createAspectScaledThumbnailEnterExitAnimationLocked( |
Filip Gruszczynski | 541f92c | 2015-10-25 17:15:06 -0700 | [diff] [blame] | 1459 | getThumbnailTransitionState(enter), orientation, transit, frame, |
| 1460 | insets, surfaceInsets, freeform, taskId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1461 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1462 | String animName = mNextAppTransitionScaleUp ? |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1463 | "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1464 | Slog.v(TAG, "applyAnimation:" |
| 1465 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1466 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1467 | + " Callers=" + Debug.getCallers(3)); |
| 1468 | } |
| 1469 | } else { |
| 1470 | int animAttr = 0; |
| 1471 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1472 | case TRANSIT_ACTIVITY_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1473 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1474 | ? WindowAnimation_activityOpenEnterAnimation |
| 1475 | : WindowAnimation_activityOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1476 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1477 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1478 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1479 | ? WindowAnimation_activityCloseEnterAnimation |
| 1480 | : WindowAnimation_activityCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1481 | break; |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1482 | case TRANSIT_DOCK_TASK_FROM_RECENTS: |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1483 | case TRANSIT_TASK_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1484 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1485 | ? WindowAnimation_taskOpenEnterAnimation |
| 1486 | : WindowAnimation_taskOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1487 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1488 | case TRANSIT_TASK_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1489 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1490 | ? WindowAnimation_taskCloseEnterAnimation |
| 1491 | : WindowAnimation_taskCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1492 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1493 | case TRANSIT_TASK_TO_FRONT: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1494 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1495 | ? WindowAnimation_taskToFrontEnterAnimation |
| 1496 | : WindowAnimation_taskToFrontExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1497 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1498 | case TRANSIT_TASK_TO_BACK: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1499 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1500 | ? WindowAnimation_taskToBackEnterAnimation |
| 1501 | : WindowAnimation_taskToBackExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1502 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1503 | case TRANSIT_WALLPAPER_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1504 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1505 | ? WindowAnimation_wallpaperOpenEnterAnimation |
| 1506 | : WindowAnimation_wallpaperOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1507 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1508 | case TRANSIT_WALLPAPER_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1509 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1510 | ? WindowAnimation_wallpaperCloseEnterAnimation |
| 1511 | : WindowAnimation_wallpaperCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1512 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1513 | case TRANSIT_WALLPAPER_INTRA_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1514 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1515 | ? WindowAnimation_wallpaperIntraOpenEnterAnimation |
| 1516 | : WindowAnimation_wallpaperIntraOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1517 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1518 | case TRANSIT_WALLPAPER_INTRA_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1519 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1520 | ? WindowAnimation_wallpaperIntraCloseEnterAnimation |
| 1521 | : WindowAnimation_wallpaperIntraCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1522 | break; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1523 | case TRANSIT_TASK_OPEN_BEHIND: |
| 1524 | animAttr = enter |
| 1525 | ? WindowAnimation_launchTaskBehindSourceAnimation |
Craig Mautner | 3b2cd1d | 2014-08-25 14:25:54 -0700 | [diff] [blame] | 1526 | : WindowAnimation_launchTaskBehindTargetAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1527 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1528 | a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1529 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1530 | "applyAnimation:" |
| 1531 | + " anim=" + a |
| 1532 | + " animAttr=0x" + Integer.toHexString(animAttr) |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1533 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1534 | + " Callers=" + Debug.getCallers(3)); |
| 1535 | } |
| 1536 | return a; |
| 1537 | } |
| 1538 | |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1539 | int getAppStackClipMode() { |
| 1540 | return mNextAppTransition == TRANSIT_ACTIVITY_RELAUNCH |
Jorim Jaggi | c69bd22 | 2016-03-15 14:38:37 +0100 | [diff] [blame] | 1541 | || mNextAppTransition == TRANSIT_DOCK_TASK_FROM_RECENTS |
Jorim Jaggi | 6a7c90a | 2016-03-11 15:04:59 +0100 | [diff] [blame] | 1542 | ? STACK_CLIP_NONE |
| 1543 | : STACK_CLIP_AFTER_ANIM; |
| 1544 | } |
| 1545 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1546 | void postAnimationCallback() { |
| 1547 | if (mNextAppTransitionCallback != null) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1548 | mService.mH.sendMessage(mService.mH.obtainMessage(H.DO_ANIMATION_CALLBACK, |
| 1549 | mNextAppTransitionCallback)); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1550 | mNextAppTransitionCallback = null; |
| 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1555 | IRemoteCallback startedCallback) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1556 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1557 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1558 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1559 | mNextAppTransitionPackage = packageName; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1560 | mNextAppTransitionEnter = enterAnim; |
| 1561 | mNextAppTransitionExit = exitAnim; |
| 1562 | postAnimationCallback(); |
| 1563 | mNextAppTransitionCallback = startedCallback; |
| 1564 | } else { |
| 1565 | postAnimationCallback(); |
| 1566 | } |
| 1567 | } |
| 1568 | |
| 1569 | void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1570 | int startHeight) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1571 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1572 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1573 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1574 | putDefaultNextAppTransitionCoordinates(startX, startY, startX + startWidth, |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1575 | startY + startHeight, null); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1576 | postAnimationCallback(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1577 | } |
| 1578 | } |
| 1579 | |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1580 | void overridePendingAppTransitionClipReveal(int startX, int startY, |
| 1581 | int startWidth, int startHeight) { |
| 1582 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1583 | clear(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1584 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1585 | putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight, null); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1586 | postAnimationCallback(); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1587 | } |
| 1588 | } |
| 1589 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1590 | void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, |
| 1591 | IRemoteCallback startedCallback, boolean scaleUp) { |
| 1592 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1593 | clear(); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1594 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP |
| 1595 | : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1596 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1597 | putDefaultNextAppTransitionCoordinates(startX, startY, 0, 0, srcThumb); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1598 | postAnimationCallback(); |
| 1599 | mNextAppTransitionCallback = startedCallback; |
| 1600 | } else { |
| 1601 | postAnimationCallback(); |
| 1602 | } |
| 1603 | } |
| 1604 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1605 | void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1606 | int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1607 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1608 | clear(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1609 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1610 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1611 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 7248c56 | 2015-11-09 13:05:40 -0800 | [diff] [blame] | 1612 | putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight, |
| 1613 | srcThumb); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1614 | postAnimationCallback(); |
| 1615 | mNextAppTransitionCallback = startedCallback; |
| 1616 | } else { |
| 1617 | postAnimationCallback(); |
| 1618 | } |
| 1619 | } |
| 1620 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1621 | public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs, |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1622 | IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback, |
| 1623 | boolean scaleUp) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1624 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1625 | clear(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1626 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1627 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1628 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1629 | if (specs != null) { |
| 1630 | for (int i = 0; i < specs.length; i++) { |
| 1631 | AppTransitionAnimationSpec spec = specs[i]; |
| 1632 | if (spec != null) { |
| 1633 | mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec); |
| 1634 | if (i == 0) { |
| 1635 | // In full screen mode, the transition code depends on the default spec |
| 1636 | // to be set. |
| 1637 | Rect rect = spec.rect; |
| 1638 | putDefaultNextAppTransitionCoordinates(rect.left, rect.top, |
Filip Gruszczynski | e3264d8 | 2015-11-20 17:10:04 -0800 | [diff] [blame] | 1639 | rect.width(), rect.height(), spec.bitmap); |
Jorim Jaggi | 4310241 | 2015-11-11 16:28:37 +0100 | [diff] [blame] | 1640 | } |
Filip Gruszczynski | d143142 | 2015-09-08 11:18:54 -0700 | [diff] [blame] | 1641 | } |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1642 | } |
| 1643 | } |
| 1644 | postAnimationCallback(); |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1645 | mNextAppTransitionCallback = onAnimationStartedCallback; |
| 1646 | mAnimationFinishedCallback = onAnimationFinishedCallback; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1647 | } else { |
| 1648 | postAnimationCallback(); |
| 1649 | } |
| 1650 | } |
| 1651 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1652 | void overridePendingAppTransitionMultiThumbFuture( |
| 1653 | IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback callback, |
| 1654 | boolean scaleUp) { |
| 1655 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1656 | clear(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1657 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1658 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1659 | mNextAppTransitionAnimationsSpecsFuture = specsFuture; |
| 1660 | mNextAppTransitionScaleUp = scaleUp; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 1661 | mNextAppTransitionFutureCallback = callback; |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1662 | } |
| 1663 | } |
| 1664 | |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1665 | void overrideInPlaceAppTransition(String packageName, int anim) { |
| 1666 | if (isTransitionSet()) { |
Jorim Jaggi | 6519399 | 2015-11-23 16:49:59 -0800 | [diff] [blame] | 1667 | clear(); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1668 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE; |
| 1669 | mNextAppTransitionPackage = packageName; |
| 1670 | mNextAppTransitionInPlace = anim; |
| 1671 | } else { |
| 1672 | postAnimationCallback(); |
| 1673 | } |
| 1674 | } |
| 1675 | |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1676 | /** |
| 1677 | * If a future is set for the app transition specs, fetch it in another thread. |
| 1678 | */ |
| 1679 | private void fetchAppTransitionSpecsFromFuture() { |
| 1680 | if (mNextAppTransitionAnimationsSpecsFuture != null) { |
| 1681 | mNextAppTransitionAnimationsSpecsPending = true; |
| 1682 | final IAppTransitionAnimationSpecsFuture future |
| 1683 | = mNextAppTransitionAnimationsSpecsFuture; |
| 1684 | mNextAppTransitionAnimationsSpecsFuture = null; |
| 1685 | mDefaultExecutor.execute(new Runnable() { |
| 1686 | @Override |
| 1687 | public void run() { |
| 1688 | AppTransitionAnimationSpec[] specs = null; |
| 1689 | try { |
| 1690 | specs = future.get(); |
| 1691 | } catch (RemoteException e) { |
| 1692 | Slog.w(TAG, "Failed to fetch app transition specs: " + e); |
| 1693 | } |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1694 | synchronized (mService.mWindowMap) { |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1695 | mNextAppTransitionAnimationsSpecsPending = false; |
Jorim Jaggi | 7cc7b08 | 2015-11-10 16:06:54 +0100 | [diff] [blame] | 1696 | overridePendingAppTransitionMultiThumb(specs, |
| 1697 | mNextAppTransitionFutureCallback, null /* finishedCallback */, |
| 1698 | mNextAppTransitionScaleUp); |
| 1699 | mNextAppTransitionFutureCallback = null; |
Filip Gruszczynski | 96daf32 | 2015-11-18 18:01:27 -0800 | [diff] [blame] | 1700 | if (specs != null) { |
| 1701 | mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp); |
| 1702 | } |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1703 | } |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1704 | mService.requestTraversal(); |
Jorim Jaggi | 2f7d292 | 2015-10-29 13:08:29 +0100 | [diff] [blame] | 1705 | } |
| 1706 | }); |
| 1707 | } |
| 1708 | } |
| 1709 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1710 | @Override |
| 1711 | public String toString() { |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1712 | return "mNextAppTransition=" + appTransitionToString(mNextAppTransition); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1713 | } |
| 1714 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1715 | /** |
| 1716 | * Returns the human readable name of a window transition. |
| 1717 | * |
| 1718 | * @param transition The window transition. |
| 1719 | * @return The transition symbolic name. |
| 1720 | */ |
| 1721 | public static String appTransitionToString(int transition) { |
| 1722 | switch (transition) { |
| 1723 | case TRANSIT_UNSET: { |
| 1724 | return "TRANSIT_UNSET"; |
| 1725 | } |
| 1726 | case TRANSIT_NONE: { |
| 1727 | return "TRANSIT_NONE"; |
| 1728 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1729 | case TRANSIT_ACTIVITY_OPEN: { |
| 1730 | return "TRANSIT_ACTIVITY_OPEN"; |
| 1731 | } |
| 1732 | case TRANSIT_ACTIVITY_CLOSE: { |
| 1733 | return "TRANSIT_ACTIVITY_CLOSE"; |
| 1734 | } |
| 1735 | case TRANSIT_TASK_OPEN: { |
| 1736 | return "TRANSIT_TASK_OPEN"; |
| 1737 | } |
| 1738 | case TRANSIT_TASK_CLOSE: { |
| 1739 | return "TRANSIT_TASK_CLOSE"; |
| 1740 | } |
| 1741 | case TRANSIT_TASK_TO_FRONT: { |
| 1742 | return "TRANSIT_TASK_TO_FRONT"; |
| 1743 | } |
| 1744 | case TRANSIT_TASK_TO_BACK: { |
| 1745 | return "TRANSIT_TASK_TO_BACK"; |
| 1746 | } |
| 1747 | case TRANSIT_WALLPAPER_CLOSE: { |
| 1748 | return "TRANSIT_WALLPAPER_CLOSE"; |
| 1749 | } |
| 1750 | case TRANSIT_WALLPAPER_OPEN: { |
| 1751 | return "TRANSIT_WALLPAPER_OPEN"; |
| 1752 | } |
| 1753 | case TRANSIT_WALLPAPER_INTRA_OPEN: { |
| 1754 | return "TRANSIT_WALLPAPER_INTRA_OPEN"; |
| 1755 | } |
| 1756 | case TRANSIT_WALLPAPER_INTRA_CLOSE: { |
| 1757 | return "TRANSIT_WALLPAPER_INTRA_CLOSE"; |
| 1758 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1759 | case TRANSIT_TASK_OPEN_BEHIND: { |
| 1760 | return "TRANSIT_TASK_OPEN_BEHIND"; |
| 1761 | } |
Filip Gruszczynski | 55a309f | 2015-09-04 17:15:01 -0700 | [diff] [blame] | 1762 | case TRANSIT_ACTIVITY_RELAUNCH: { |
| 1763 | return "TRANSIT_ACTIVITY_RELAUNCH"; |
| 1764 | } |
Jorim Jaggi | 192086e | 2016-03-11 17:17:03 +0100 | [diff] [blame] | 1765 | case TRANSIT_DOCK_TASK_FROM_RECENTS: { |
| 1766 | return "TRANSIT_DOCK_TASK_FROM_RECENTS"; |
| 1767 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1768 | default: { |
| 1769 | return "<UNKNOWN>"; |
| 1770 | } |
| 1771 | } |
| 1772 | } |
| 1773 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1774 | private String appStateToString() { |
| 1775 | switch (mAppTransitionState) { |
| 1776 | case APP_STATE_IDLE: |
| 1777 | return "APP_STATE_IDLE"; |
| 1778 | case APP_STATE_READY: |
| 1779 | return "APP_STATE_READY"; |
| 1780 | case APP_STATE_RUNNING: |
| 1781 | return "APP_STATE_RUNNING"; |
| 1782 | case APP_STATE_TIMEOUT: |
| 1783 | return "APP_STATE_TIMEOUT"; |
| 1784 | default: |
| 1785 | return "unknown state=" + mAppTransitionState; |
| 1786 | } |
| 1787 | } |
| 1788 | |
| 1789 | private String transitTypeToString() { |
| 1790 | switch (mNextAppTransitionType) { |
| 1791 | case NEXT_TRANSIT_TYPE_NONE: |
| 1792 | return "NEXT_TRANSIT_TYPE_NONE"; |
| 1793 | case NEXT_TRANSIT_TYPE_CUSTOM: |
| 1794 | return "NEXT_TRANSIT_TYPE_CUSTOM"; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1795 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
| 1796 | return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1797 | case NEXT_TRANSIT_TYPE_SCALE_UP: |
| 1798 | return "NEXT_TRANSIT_TYPE_SCALE_UP"; |
| 1799 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1800 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP"; |
| 1801 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
| 1802 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN"; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1803 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
| 1804 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP"; |
| 1805 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 1806 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1807 | default: |
| 1808 | return "unknown type=" + mNextAppTransitionType; |
| 1809 | } |
| 1810 | } |
| 1811 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1812 | @Override |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1813 | public void dump(PrintWriter pw, String prefix) { |
| 1814 | pw.print(prefix); pw.println(this); |
| 1815 | pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString()); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1816 | if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1817 | pw.print(prefix); pw.print("mNextAppTransitionType="); |
| 1818 | pw.println(transitTypeToString()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1819 | } |
| 1820 | switch (mNextAppTransitionType) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1821 | case NEXT_TRANSIT_TYPE_CUSTOM: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1822 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1823 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1824 | pw.print(prefix); pw.print("mNextAppTransitionEnter=0x"); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1825 | pw.print(Integer.toHexString(mNextAppTransitionEnter)); |
| 1826 | pw.print(" mNextAppTransitionExit=0x"); |
| 1827 | pw.println(Integer.toHexString(mNextAppTransitionExit)); |
| 1828 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1829 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1830 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1831 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1832 | pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x"); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1833 | pw.print(Integer.toHexString(mNextAppTransitionInPlace)); |
| 1834 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1835 | case NEXT_TRANSIT_TYPE_SCALE_UP: { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1836 | getDefaultNextAppTransitionStartRect(mTmpRect); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1837 | pw.print(prefix); pw.print("mNextAppTransitionStartX="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1838 | pw.print(mTmpRect.left); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1839 | pw.print(" mNextAppTransitionStartY="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1840 | pw.println(mTmpRect.top); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1841 | pw.print(prefix); pw.print("mNextAppTransitionStartWidth="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1842 | pw.print(mTmpRect.width()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1843 | pw.print(" mNextAppTransitionStartHeight="); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1844 | pw.println(mTmpRect.height()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1845 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1846 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1847 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1848 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1849 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1850 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: { |
| 1851 | pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec="); |
| 1852 | pw.println(mDefaultNextAppTransitionAnimationSpec); |
| 1853 | pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs="); |
| 1854 | pw.println(mNextAppTransitionAnimationsSpecs); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1855 | pw.print(prefix); pw.print("mNextAppTransitionScaleUp="); |
| 1856 | pw.println(mNextAppTransitionScaleUp); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1857 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame] | 1858 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1859 | } |
| 1860 | if (mNextAppTransitionCallback != null) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1861 | pw.print(prefix); pw.print("mNextAppTransitionCallback="); |
| 1862 | pw.println(mNextAppTransitionCallback); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1863 | } |
| 1864 | } |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 1865 | |
| 1866 | public void setCurrentUser(int newUserId) { |
| 1867 | mCurrentUserId = newUserId; |
| 1868 | } |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1869 | |
| 1870 | /** |
| 1871 | * @return true if transition is not running and should not be skipped, false if transition is |
| 1872 | * already running |
| 1873 | */ |
| 1874 | boolean prepareAppTransitionLocked(int transit, boolean alwaysKeepCurrent) { |
| 1875 | if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:" |
| 1876 | + " transit=" + appTransitionToString(transit) |
| 1877 | + " " + this |
| 1878 | + " alwaysKeepCurrent=" + alwaysKeepCurrent |
| 1879 | + " Callers=" + Debug.getCallers(3)); |
| 1880 | if (!isTransitionSet() || mNextAppTransition == TRANSIT_NONE) { |
| 1881 | setAppTransition(transit); |
| 1882 | } else if (!alwaysKeepCurrent) { |
| 1883 | if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) { |
| 1884 | // Opening a new task always supersedes a close for the anim. |
| 1885 | setAppTransition(transit); |
| 1886 | } else if (transit == TRANSIT_ACTIVITY_OPEN |
| 1887 | && isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) { |
| 1888 | // Opening a new activity always supersedes a close for the anim. |
| 1889 | setAppTransition(transit); |
| 1890 | } |
| 1891 | } |
| 1892 | boolean prepared = prepare(); |
| 1893 | if (isTransitionSet()) { |
Filip Gruszczynski | 1a4dfe5 | 2015-11-15 10:58:57 -0800 | [diff] [blame] | 1894 | mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT); |
| 1895 | mService.mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, APP_TRANSITION_TIMEOUT_MS); |
Filip Gruszczynski | 24966d4 | 2015-09-05 15:00:00 -0700 | [diff] [blame] | 1896 | } |
| 1897 | return prepared; |
| 1898 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1899 | } |