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 | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 21 | import android.content.res.Configuration; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 22 | import android.graphics.Bitmap; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 23 | import android.graphics.Rect; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 24 | import android.os.Debug; |
| 25 | import android.os.Handler; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 26 | import android.os.IBinder; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 27 | import android.os.IRemoteCallback; |
| 28 | import android.util.Slog; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 29 | import android.util.SparseArray; |
| 30 | import android.view.AppTransitionAnimationSpec; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 31 | import android.view.WindowManager; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 32 | import android.view.animation.AlphaAnimation; |
| 33 | import android.view.animation.Animation; |
| 34 | import android.view.animation.AnimationSet; |
| 35 | import android.view.animation.AnimationUtils; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 36 | import android.view.animation.ClipRectAnimation; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 37 | import android.view.animation.ClipRectLRAnimation; |
| 38 | import android.view.animation.ClipRectTBAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 39 | import android.view.animation.Interpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 40 | import android.view.animation.PathInterpolator; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 41 | import android.view.animation.ScaleAnimation; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 42 | import android.view.animation.TranslateAnimation; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 43 | import android.view.animation.TranslateYAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 44 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 45 | import com.android.internal.util.DumpUtils.Dump; |
| 46 | import com.android.server.AttributeCache; |
| 47 | import com.android.server.wm.WindowManagerService.H; |
| 48 | |
| 49 | import java.io.PrintWriter; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 50 | import java.util.ArrayList; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 51 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 52 | import static android.view.WindowManagerInternal.AppTransitionListener; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 53 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation; |
| 54 | import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 55 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation; |
| 56 | import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 57 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindSourceAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 58 | import static com.android.internal.R.styleable.WindowAnimation_launchTaskBehindTargetAnimation; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 59 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation; |
| 60 | import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 61 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation; |
| 62 | import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 63 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation; |
| 64 | import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 65 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation; |
| 66 | import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 67 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation; |
| 68 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 69 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation; |
| 70 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 71 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation; |
| 72 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation; |
| 73 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation; |
| 74 | import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 75 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 76 | // State management of app transitions. When we are preparing for a |
| 77 | // transition, mNextAppTransition will be the kind of transition to |
| 78 | // perform or TRANSIT_NONE if we are not waiting. If we are waiting, |
| 79 | // mOpeningApps and mClosingApps are the lists of tokens that will be |
| 80 | // made visible or hidden at the next transition. |
| 81 | public class AppTransition implements Dump { |
| 82 | private static final String TAG = "AppTransition"; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 83 | private static final boolean DEBUG_APP_TRANSITIONS = |
| 84 | WindowManagerService.DEBUG_APP_TRANSITIONS; |
| 85 | private static final boolean DEBUG_ANIM = WindowManagerService.DEBUG_ANIM; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 86 | private static final int CLIP_REVEAL_TRANSLATION_Y_DP = 8; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 87 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 88 | /** Not set up for a transition. */ |
| 89 | public static final int TRANSIT_UNSET = -1; |
| 90 | /** No animation for transition. */ |
| 91 | public static final int TRANSIT_NONE = 0; |
| 92 | /** 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] | 93 | public static final int TRANSIT_ACTIVITY_OPEN = 6; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 94 | /** The window in the top-most activity is being closed to reveal the |
| 95 | * previous activity in the same task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 96 | public static final int TRANSIT_ACTIVITY_CLOSE = 7; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 97 | /** A window in a new task is being opened on top of an existing one |
| 98 | * in another activity's task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 99 | public static final int TRANSIT_TASK_OPEN = 8; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 100 | /** A window in the top-most activity is being closed to reveal the |
| 101 | * previous activity in a different task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 102 | public static final int TRANSIT_TASK_CLOSE = 9; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 103 | /** A window in an existing task is being displayed on top of an existing one |
| 104 | * in another activity's task. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 105 | public static final int TRANSIT_TASK_TO_FRONT = 10; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 106 | /** 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] | 107 | public static final int TRANSIT_TASK_TO_BACK = 11; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 108 | /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that |
| 109 | * does, effectively closing the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 110 | public static final int TRANSIT_WALLPAPER_CLOSE = 12; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 111 | /** A window in a new activity that does have a wallpaper is being opened on one that didn't, |
| 112 | * effectively opening the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 113 | public static final int TRANSIT_WALLPAPER_OPEN = 13; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 114 | /** A window in a new activity is being opened on top of an existing one, and both are on top |
| 115 | * of the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 116 | public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 117 | /** The window in the top-most activity is being closed to reveal the previous activity, and |
| 118 | * both are on top of the wallpaper. */ |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 119 | public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15; |
| 120 | /** A window in a new task is being opened behind an existing one in another activity's task. |
| 121 | * The new window will show briefly and then be gone. */ |
| 122 | public static final int TRANSIT_TASK_OPEN_BEHIND = 16; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 123 | /** A window in a task is being animated in-place. */ |
| 124 | public static final int TRANSIT_TASK_IN_PLACE = 17; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 125 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 126 | /** Fraction of animation at which the recents thumbnail stays completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 127 | private static final float RECENTS_THUMBNAIL_FADEIN_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 128 | /** Fraction of animation at which the recents thumbnail becomes completely transparent */ |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 129 | private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.5f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 130 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 131 | private static final int DEFAULT_APP_TRANSITION_DURATION = 336; |
| 132 | private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336; |
| 133 | private static final int THUMBNAIL_APP_TRANSITION_ALPHA_DURATION = 336; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 134 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 135 | private final Context mContext; |
| 136 | private final Handler mH; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 137 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 138 | private int mNextAppTransition = TRANSIT_UNSET; |
| 139 | |
| 140 | private static final int NEXT_TRANSIT_TYPE_NONE = 0; |
| 141 | private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1; |
| 142 | private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2; |
| 143 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3; |
| 144 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 145 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP = 5; |
| 146 | private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN = 6; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 147 | private static final int NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE = 7; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 148 | private static final int NEXT_TRANSIT_TYPE_CLIP_REVEAL = 8; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 149 | private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
| 150 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 151 | // These are the possible states for the enter/exit activities during a thumbnail transition |
| 152 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0; |
| 153 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_UP = 1; |
| 154 | private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN = 2; |
| 155 | private static final int THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN = 3; |
| 156 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 157 | private String mNextAppTransitionPackage; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 158 | // 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] | 159 | private boolean mNextAppTransitionScaleUp; |
| 160 | private IRemoteCallback mNextAppTransitionCallback; |
| 161 | private int mNextAppTransitionEnter; |
| 162 | private int mNextAppTransitionExit; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 163 | private int mNextAppTransitionInPlace; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 164 | |
| 165 | // Keyed by task id. |
| 166 | private final SparseArray<AppTransitionAnimationSpec> mNextAppTransitionAnimationsSpecs |
| 167 | = new SparseArray<>(); |
| 168 | private AppTransitionAnimationSpec mDefaultNextAppTransitionAnimationSpec; |
| 169 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 170 | private Rect mNextAppTransitionInsets = new Rect(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 171 | |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 172 | private Rect mTmpFromClipRect = new Rect(); |
| 173 | private Rect mTmpToClipRect = new Rect(); |
| 174 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 175 | private final Rect mTmpStartRect = new Rect(); |
| 176 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 177 | private final static int APP_STATE_IDLE = 0; |
| 178 | private final static int APP_STATE_READY = 1; |
| 179 | private final static int APP_STATE_RUNNING = 2; |
| 180 | private final static int APP_STATE_TIMEOUT = 3; |
| 181 | private int mAppTransitionState = APP_STATE_IDLE; |
| 182 | |
| 183 | private final int mConfigShortAnimTime; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 184 | private final Interpolator mDecelerateInterpolator; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 185 | private final Interpolator mThumbnailFadeInInterpolator; |
| 186 | private final Interpolator mThumbnailFadeOutInterpolator; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 187 | private final Interpolator mLinearOutSlowInInterpolator; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 188 | private final Interpolator mFastOutLinearInInterpolator; |
| 189 | private final Interpolator mClipHorizontalInterpolator = new PathInterpolator(0, 0, 0.4f, 1f); |
| 190 | |
| 191 | /** Interpolator to be used for animations that respond directly to a touch */ |
| 192 | private final Interpolator mTouchResponseInterpolator = |
| 193 | new PathInterpolator(0.3f, 0f, 0.1f, 1f); |
| 194 | |
| 195 | private final int mClipRevealTranslationY; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 196 | |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 197 | private int mCurrentUserId = 0; |
| 198 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 199 | private final ArrayList<AppTransitionListener> mListeners = new ArrayList<>(); |
| 200 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 201 | AppTransition(Context context, Handler h) { |
| 202 | mContext = context; |
| 203 | mH = h; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 204 | mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, |
| 205 | com.android.internal.R.interpolator.linear_out_slow_in); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 206 | mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context, |
| 207 | com.android.internal.R.interpolator.fast_out_linear_in); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 208 | mConfigShortAnimTime = context.getResources().getInteger( |
| 209 | com.android.internal.R.integer.config_shortAnimTime); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 210 | mDecelerateInterpolator = AnimationUtils.loadInterpolator(context, |
| 211 | com.android.internal.R.interpolator.decelerate_cubic); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 212 | mThumbnailFadeInInterpolator = new Interpolator() { |
| 213 | @Override |
| 214 | public float getInterpolation(float input) { |
| 215 | // Linear response for first fraction, then complete after that. |
| 216 | if (input < RECENTS_THUMBNAIL_FADEIN_FRACTION) { |
| 217 | return 0f; |
| 218 | } |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 219 | float t = (input - RECENTS_THUMBNAIL_FADEIN_FRACTION) / |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 220 | (1f - RECENTS_THUMBNAIL_FADEIN_FRACTION); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 221 | return mFastOutLinearInInterpolator.getInterpolation(t); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 222 | } |
| 223 | }; |
| 224 | mThumbnailFadeOutInterpolator = new Interpolator() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 225 | @Override |
| 226 | public float getInterpolation(float input) { |
| 227 | // Linear response for first fraction, then complete after that. |
| 228 | if (input < RECENTS_THUMBNAIL_FADEOUT_FRACTION) { |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 229 | float t = input / RECENTS_THUMBNAIL_FADEOUT_FRACTION; |
| 230 | return mLinearOutSlowInInterpolator.getInterpolation(t); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 231 | } |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 232 | return 1f; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 233 | } |
| 234 | }; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 235 | mClipRevealTranslationY = (int) (CLIP_REVEAL_TRANSLATION_Y_DP |
| 236 | * mContext.getResources().getDisplayMetrics().density); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | boolean isTransitionSet() { |
| 240 | return mNextAppTransition != TRANSIT_UNSET; |
| 241 | } |
| 242 | |
| 243 | boolean isTransitionNone() { |
| 244 | return mNextAppTransition == TRANSIT_NONE; |
| 245 | } |
| 246 | |
| 247 | boolean isTransitionEqual(int transit) { |
| 248 | return mNextAppTransition == transit; |
| 249 | } |
| 250 | |
| 251 | int getAppTransition() { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 252 | return mNextAppTransition; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | void setAppTransition(int transit) { |
| 256 | mNextAppTransition = transit; |
| 257 | } |
| 258 | |
| 259 | boolean isReady() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 260 | return mAppTransitionState == APP_STATE_READY |
| 261 | || mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 264 | void setReady() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 265 | mAppTransitionState = APP_STATE_READY; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | boolean isRunning() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 269 | return mAppTransitionState == APP_STATE_RUNNING; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 272 | void setIdle() { |
| 273 | mAppTransitionState = APP_STATE_IDLE; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | boolean isTimeout() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 277 | return mAppTransitionState == APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 280 | void setTimeout() { |
| 281 | mAppTransitionState = APP_STATE_TIMEOUT; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 282 | } |
| 283 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 284 | Bitmap getAppTransitionThumbnailHeader(int taskId) { |
| 285 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
| 286 | return spec != null ? spec.bitmap : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 287 | } |
| 288 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 289 | /** Returns whether the next thumbnail transition is aspect scaled up. */ |
| 290 | boolean isNextThumbnailTransitionAspectScaled() { |
| 291 | return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 292 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 293 | } |
| 294 | |
| 295 | /** Returns whether the next thumbnail transition is scaling up. */ |
| 296 | boolean isNextThumbnailTransitionScaleUp() { |
| 297 | return mNextAppTransitionScaleUp; |
| 298 | } |
| 299 | |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 300 | boolean prepare() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 301 | if (!isRunning()) { |
| 302 | mAppTransitionState = APP_STATE_IDLE; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 303 | notifyAppTransitionPendingLocked(); |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 304 | return true; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 305 | } |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 306 | return false; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 309 | void goodToGo(AppWindowAnimator openingAppAnimator, AppWindowAnimator closingAppAnimator) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 310 | mNextAppTransition = TRANSIT_UNSET; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 311 | mAppTransitionState = APP_STATE_RUNNING; |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 312 | notifyAppTransitionStartingLocked( |
| 313 | openingAppAnimator != null ? openingAppAnimator.mAppToken.token : null, |
| 314 | closingAppAnimator != null ? closingAppAnimator.mAppToken.token : null, |
| 315 | openingAppAnimator != null ? openingAppAnimator.animation : null, |
| 316 | closingAppAnimator != null ? closingAppAnimator.animation : null); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | void clear() { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 320 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 321 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 322 | mNextAppTransitionAnimationsSpecs.clear(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 325 | void freeze() { |
| 326 | setAppTransition(AppTransition.TRANSIT_UNSET); |
| 327 | clear(); |
| 328 | setReady(); |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 329 | notifyAppTransitionCancelledLocked(); |
| 330 | } |
| 331 | |
| 332 | void registerListenerLocked(AppTransitionListener listener) { |
| 333 | mListeners.add(listener); |
| 334 | } |
| 335 | |
Wale Ogunwale | a48eadb | 2015-05-14 17:43:12 -0700 | [diff] [blame] | 336 | public void notifyAppTransitionFinishedLocked(IBinder token) { |
Jorim Jaggi | 77ba480 | 2015-02-18 13:57:50 +0100 | [diff] [blame] | 337 | for (int i = 0; i < mListeners.size(); i++) { |
| 338 | mListeners.get(i).onAppTransitionFinishedLocked(token); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | private void notifyAppTransitionPendingLocked() { |
| 343 | for (int i = 0; i < mListeners.size(); i++) { |
| 344 | mListeners.get(i).onAppTransitionPendingLocked(); |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | private void notifyAppTransitionCancelledLocked() { |
| 349 | for (int i = 0; i < mListeners.size(); i++) { |
| 350 | mListeners.get(i).onAppTransitionCancelledLocked(); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | private void notifyAppTransitionStartingLocked(IBinder openToken, |
| 355 | IBinder closeToken, Animation openAnimation, Animation closeAnimation) { |
| 356 | for (int i = 0; i < mListeners.size(); i++) { |
| 357 | mListeners.get(i).onAppTransitionStartingLocked(openToken, closeToken, openAnimation, |
| 358 | closeAnimation); |
| 359 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 362 | private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) { |
| 363 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg=" |
| 364 | + (lp != null ? lp.packageName : null) |
| 365 | + " resId=0x" + (lp != null ? Integer.toHexString(lp.windowAnimations) : null)); |
| 366 | if (lp != null && lp.windowAnimations != 0) { |
| 367 | // If this is a system resource, don't try to load it from the |
| 368 | // application resources. It is nice to avoid loading application |
| 369 | // resources if we can. |
| 370 | String packageName = lp.packageName != null ? lp.packageName : "android"; |
| 371 | int resId = lp.windowAnimations; |
| 372 | if ((resId&0xFF000000) == 0x01000000) { |
| 373 | packageName = "android"; |
| 374 | } |
| 375 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 376 | + packageName); |
| 377 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 378 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 379 | } |
| 380 | return null; |
| 381 | } |
| 382 | |
| 383 | private AttributeCache.Entry getCachedAnimations(String packageName, int resId) { |
| 384 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: package=" |
| 385 | + packageName + " resId=0x" + Integer.toHexString(resId)); |
| 386 | if (packageName != null) { |
| 387 | if ((resId&0xFF000000) == 0x01000000) { |
| 388 | packageName = "android"; |
| 389 | } |
| 390 | if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: picked package=" |
| 391 | + packageName); |
| 392 | return AttributeCache.instance().get(packageName, resId, |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 393 | com.android.internal.R.styleable.WindowAnimation, mCurrentUserId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 394 | } |
| 395 | return null; |
| 396 | } |
| 397 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 398 | Animation loadAnimationAttr(WindowManager.LayoutParams lp, int animAttr) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 399 | int anim = 0; |
| 400 | Context context = mContext; |
| 401 | if (animAttr >= 0) { |
| 402 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 403 | if (ent != null) { |
| 404 | context = ent.context; |
| 405 | anim = ent.array.getResourceId(animAttr, 0); |
| 406 | } |
| 407 | } |
| 408 | if (anim != 0) { |
| 409 | return AnimationUtils.loadAnimation(context, anim); |
| 410 | } |
| 411 | return null; |
| 412 | } |
| 413 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 414 | Animation loadAnimationRes(WindowManager.LayoutParams lp, int resId) { |
| 415 | Context context = mContext; |
| 416 | if (resId >= 0) { |
| 417 | AttributeCache.Entry ent = getCachedAnimations(lp); |
| 418 | if (ent != null) { |
| 419 | context = ent.context; |
| 420 | } |
| 421 | return AnimationUtils.loadAnimation(context, resId); |
| 422 | } |
| 423 | return null; |
| 424 | } |
| 425 | |
| 426 | private Animation loadAnimationRes(String packageName, int resId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 427 | int anim = 0; |
| 428 | Context context = mContext; |
| 429 | if (resId >= 0) { |
| 430 | AttributeCache.Entry ent = getCachedAnimations(packageName, resId); |
| 431 | if (ent != null) { |
| 432 | context = ent.context; |
| 433 | anim = resId; |
| 434 | } |
| 435 | } |
| 436 | if (anim != 0) { |
| 437 | return AnimationUtils.loadAnimation(context, anim); |
| 438 | } |
| 439 | return null; |
| 440 | } |
| 441 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 442 | /** |
| 443 | * Compute the pivot point for an animation that is scaling from a small |
| 444 | * rect on screen to a larger rect. The pivot point varies depending on |
| 445 | * the distance between the inner and outer edges on both sides. This |
| 446 | * function computes the pivot point for one dimension. |
| 447 | * @param startPos Offset from left/top edge of outer rectangle to |
| 448 | * left/top edge of inner rectangle. |
| 449 | * @param finalScale The scaling factor between the size of the outer |
| 450 | * and inner rectangles. |
| 451 | */ |
| 452 | private static float computePivot(int startPos, float finalScale) { |
| 453 | final float denom = finalScale-1; |
| 454 | if (Math.abs(denom) < .0001f) { |
| 455 | return startPos; |
| 456 | } |
| 457 | return -startPos / denom; |
| 458 | } |
| 459 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 460 | private Animation createScaleUpAnimationLocked( |
| 461 | int transit, boolean enter, int appWidth, int appHeight) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 462 | Animation a = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 463 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 464 | if (enter) { |
| 465 | // Entering app zooms out from the center of the initial rect. |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 466 | float scaleW = mTmpStartRect.width() / (float) appWidth; |
| 467 | float scaleH = mTmpStartRect.height() / (float) appHeight; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 468 | Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 469 | computePivot(mTmpStartRect.left, scaleW), |
| 470 | computePivot(mTmpStartRect.right, scaleH)); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 471 | scale.setInterpolator(mDecelerateInterpolator); |
| 472 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 473 | Animation alpha = new AlphaAnimation(0, 1); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 474 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 475 | |
| 476 | AnimationSet set = new AnimationSet(false); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 477 | set.addAnimation(scale); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 478 | set.addAnimation(alpha); |
| 479 | set.setDetachWallpaper(true); |
| 480 | a = set; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 481 | } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 482 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 483 | // If we are on top of the wallpaper, we need an animation that |
| 484 | // correctly handles the wallpaper staying static behind all of |
| 485 | // the animated elements. To do this, will just have the existing |
| 486 | // element fade out. |
| 487 | a = new AlphaAnimation(1, 0); |
| 488 | a.setDetachWallpaper(true); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 489 | } else { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 490 | // For normal animations, the exiting element just holds in place. |
| 491 | a = new AlphaAnimation(1, 1); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 492 | } |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 493 | |
| 494 | // Pick the desired duration. If this is an inter-activity transition, |
| 495 | // it is the standard duration for that. Otherwise we use the longer |
| 496 | // task transition duration. |
| 497 | final long duration; |
| 498 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 499 | case TRANSIT_ACTIVITY_OPEN: |
| 500 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 501 | duration = mConfigShortAnimTime; |
| 502 | break; |
| 503 | default: |
| 504 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 505 | break; |
| 506 | } |
| 507 | a.setDuration(duration); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 508 | a.setFillAfter(true); |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 509 | a.setInterpolator(mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 510 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 511 | return a; |
| 512 | } |
| 513 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 514 | private void getDefaultNextAppTransitionStartRect(Rect rect) { |
| 515 | if (mDefaultNextAppTransitionAnimationSpec == null || |
| 516 | mDefaultNextAppTransitionAnimationSpec.rect == null) { |
| 517 | Slog.wtf(TAG, "Starting rect for app requested, but none available", new Throwable()); |
| 518 | rect.setEmpty(); |
| 519 | } else { |
| 520 | rect.set(mDefaultNextAppTransitionAnimationSpec.rect); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | void getNextAppTransitionStartRect(int taskId, Rect rect) { |
| 525 | AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId); |
| 526 | if (spec == null || spec.rect == null) { |
| 527 | Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available", |
| 528 | new Throwable()); |
| 529 | rect.setEmpty(); |
| 530 | } else { |
| 531 | rect.set(spec.rect); |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | private void putDefaultNextAppTransitionCoordinates(int left, int top, int width, int height) { |
| 536 | mDefaultNextAppTransitionAnimationSpec = new AppTransitionAnimationSpec(-1 /* taskId */, |
| 537 | null /* bitmap */, new Rect(left, top, left + width, top + height)); |
| 538 | } |
| 539 | |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 540 | private Animation createClipRevealAnimationLocked(int transit, boolean enter, Rect appFrame) { |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 541 | final Animation anim; |
| 542 | if (enter) { |
| 543 | // Reveal will expand and move faster in horizontal direction |
| 544 | |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 545 | final int appWidth = appFrame.width(); |
| 546 | final int appHeight = appFrame.height(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 547 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 548 | |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 549 | float t = 0f; |
| 550 | if (appHeight > 0) { |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 551 | t = (float) mTmpStartRect.left / appHeight; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 552 | } |
| 553 | int translationY = mClipRevealTranslationY |
| 554 | + (int)(appHeight / 7f * t); |
| 555 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 556 | int centerX = mTmpStartRect.centerX(); |
| 557 | int centerY = mTmpStartRect.centerY(); |
| 558 | int halfWidth = mTmpStartRect.width() / 2; |
| 559 | int halfHeight = mTmpStartRect.height() / 2; |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 560 | |
| 561 | // 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] | 562 | Animation clipAnimLR = new ClipRectLRAnimation( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 563 | centerX - halfWidth, centerX + halfWidth, 0, appWidth); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 564 | clipAnimLR.setInterpolator(mClipHorizontalInterpolator); |
| 565 | clipAnimLR.setDuration((long) (DEFAULT_APP_TRANSITION_DURATION / 2.5f)); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 566 | Animation clipAnimTB = new ClipRectTBAnimation(centerY - halfHeight - translationY, |
| 567 | centerY + halfHeight/ 2 - translationY, 0, appHeight); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 568 | clipAnimTB.setInterpolator(mTouchResponseInterpolator); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 569 | clipAnimTB.setDuration(DEFAULT_APP_TRANSITION_DURATION); |
| 570 | |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 571 | TranslateYAnimation translateY = new TranslateYAnimation( |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 572 | Animation.ABSOLUTE, translationY, Animation.ABSOLUTE, 0); |
| 573 | translateY.setInterpolator(mLinearOutSlowInInterpolator); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 574 | translateY.setDuration(DEFAULT_APP_TRANSITION_DURATION); |
| 575 | |
| 576 | // Quick fade-in from icon to app window |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 577 | final int alphaDuration = DEFAULT_APP_TRANSITION_DURATION / 4; |
| 578 | AlphaAnimation alpha = new AlphaAnimation(0.5f, 1); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 579 | alpha.setDuration(alphaDuration); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 580 | alpha.setInterpolator(mLinearOutSlowInInterpolator); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 581 | |
| 582 | AnimationSet set = new AnimationSet(false); |
| 583 | set.addAnimation(clipAnimLR); |
| 584 | set.addAnimation(clipAnimTB); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 585 | set.addAnimation(translateY); |
| 586 | set.addAnimation(alpha); |
Filip Gruszczynski | 9e2cf5b | 2015-07-31 12:20:40 -0700 | [diff] [blame] | 587 | set.setZAdjustment(Animation.ZORDER_TOP); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 588 | set.initialize(appWidth, appHeight, appWidth, appHeight); |
| 589 | anim = set; |
| 590 | } else { |
| 591 | final long duration; |
| 592 | switch (transit) { |
| 593 | case TRANSIT_ACTIVITY_OPEN: |
| 594 | case TRANSIT_ACTIVITY_CLOSE: |
| 595 | duration = mConfigShortAnimTime; |
| 596 | break; |
| 597 | default: |
| 598 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 599 | break; |
| 600 | } |
| 601 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || |
| 602 | transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { |
| 603 | // If we are on top of the wallpaper, we need an animation that |
| 604 | // correctly handles the wallpaper staying static behind all of |
| 605 | // the animated elements. To do this, will just have the existing |
| 606 | // element fade out. |
| 607 | anim = new AlphaAnimation(1, 0); |
| 608 | anim.setDetachWallpaper(true); |
| 609 | } else { |
| 610 | // For normal animations, the exiting element just holds in place. |
| 611 | anim = new AlphaAnimation(1, 1); |
| 612 | } |
| 613 | anim.setInterpolator(mDecelerateInterpolator); |
| 614 | anim.setDuration(duration); |
| 615 | anim.setFillAfter(true); |
| 616 | } |
| 617 | return anim; |
| 618 | } |
| 619 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 620 | /** |
| 621 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 622 | */ |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 623 | Animation prepareThumbnailAnimationWithDuration(Animation a, int appWidth, int appHeight, |
| 624 | int duration, Interpolator interpolator) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 625 | if (duration > 0) { |
| 626 | a.setDuration(duration); |
| 627 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 628 | a.setFillAfter(true); |
| 629 | a.setInterpolator(interpolator); |
| 630 | a.initialize(appWidth, appHeight, appWidth, appHeight); |
| 631 | return a; |
| 632 | } |
| 633 | |
| 634 | /** |
| 635 | * Prepares the specified animation with a standard duration, interpolator, etc. |
| 636 | */ |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 637 | Animation prepareThumbnailAnimation(Animation a, int appWidth, int appHeight, int transit) { |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 638 | // Pick the desired duration. If this is an inter-activity transition, |
| 639 | // it is the standard duration for that. Otherwise we use the longer |
| 640 | // task transition duration. |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 641 | final int duration; |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 642 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 643 | case TRANSIT_ACTIVITY_OPEN: |
| 644 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 321bdf5 | 2012-12-18 09:53:24 -0800 | [diff] [blame] | 645 | duration = mConfigShortAnimTime; |
| 646 | break; |
| 647 | default: |
| 648 | duration = DEFAULT_APP_TRANSITION_DURATION; |
| 649 | break; |
| 650 | } |
Winson Chung | 5393dff | 2014-05-08 14:25:43 -0700 | [diff] [blame] | 651 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, |
| 652 | mDecelerateInterpolator); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 653 | } |
| 654 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 655 | /** |
| 656 | * Return the current thumbnail transition state. |
| 657 | */ |
| 658 | int getThumbnailTransitionState(boolean enter) { |
| 659 | if (enter) { |
| 660 | if (mNextAppTransitionScaleUp) { |
| 661 | return THUMBNAIL_TRANSITION_ENTER_SCALE_UP; |
| 662 | } else { |
| 663 | return THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN; |
| 664 | } |
| 665 | } else { |
| 666 | if (mNextAppTransitionScaleUp) { |
| 667 | return THUMBNAIL_TRANSITION_EXIT_SCALE_UP; |
| 668 | } else { |
| 669 | return THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN; |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /** |
| 675 | * 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^] | 676 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 677 | */ |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 678 | Animation createThumbnailAspectScaleAnimationLocked(Rect appRect, Bitmap thumbnailHeader, |
| 679 | final int taskId) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 680 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 681 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 682 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 683 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 684 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 685 | final int appWidth = appRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 686 | |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 687 | float scaleW = appWidth / thumbWidth; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 688 | float unscaledHeight = thumbHeight * scaleW; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 689 | getNextAppTransitionStartRect(taskId, mTmpStartRect); |
| 690 | float unscaledStartY = mTmpStartRect.top - (unscaledHeight - thumbHeight) / 2f; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 691 | if (mNextAppTransitionScaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 692 | // Animation up from the thumbnail to the full screen |
| 693 | Animation scale = new ScaleAnimation(1f, scaleW, 1f, scaleW, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 694 | mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f)); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 695 | scale.setInterpolator(mTouchResponseInterpolator); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 696 | scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 697 | Animation alpha = new AlphaAnimation(1, 0); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 698 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
| 699 | alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION); |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 700 | final float toX = appRect.left + appRect.width() / 2 - |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 701 | (mTmpStartRect.left + thumbWidth / 2); |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 702 | final float toY = appRect.top + mNextAppTransitionInsets.top + -unscaledStartY; |
| 703 | Animation translate = new TranslateAnimation(0, toX, 0, toY); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 704 | translate.setInterpolator(mTouchResponseInterpolator); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 705 | translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 706 | |
| 707 | // This AnimationSet uses the Interpolators assigned above. |
| 708 | AnimationSet set = new AnimationSet(false); |
| 709 | set.addAnimation(scale); |
| 710 | set.addAnimation(alpha); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 711 | set.addAnimation(translate); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 712 | a = set; |
| 713 | } else { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 714 | // Animation down from the full screen to the thumbnail |
| 715 | Animation scale = new ScaleAnimation(scaleW, 1f, scaleW, 1f, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 716 | mTmpStartRect.left + (thumbWidth / 2f), mTmpStartRect.top + (thumbHeight / 2f)); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 717 | scale.setInterpolator(mTouchResponseInterpolator); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 718 | scale.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); |
| 719 | Animation alpha = new AlphaAnimation(0f, 1f); |
| 720 | alpha.setInterpolator(mThumbnailFadeInInterpolator); |
| 721 | alpha.setDuration(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION); |
| 722 | Animation translate = new TranslateAnimation(0, 0, -unscaledStartY + |
| 723 | mNextAppTransitionInsets.top, 0); |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 724 | translate.setInterpolator(mTouchResponseInterpolator); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 725 | translate.setDuration(THUMBNAIL_APP_TRANSITION_DURATION); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 726 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 727 | // This AnimationSet uses the Interpolators assigned above. |
| 728 | AnimationSet set = new AnimationSet(false); |
| 729 | set.addAnimation(scale); |
| 730 | set.addAnimation(alpha); |
| 731 | set.addAnimation(translate); |
| 732 | a = set; |
| 733 | |
| 734 | } |
Filip Gruszczynski | dfb25d3 | 2015-08-14 11:06:18 -0700 | [diff] [blame] | 735 | return prepareThumbnailAnimationWithDuration(a, appWidth, appRect.height(), 0, |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 736 | mTouchResponseInterpolator); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | /** |
| 740 | * This alternate animation is created when we are doing a thumbnail transition, for the |
| 741 | * activity that is leaving, and the activity that is entering. |
| 742 | */ |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 743 | Animation createAspectScaledThumbnailEnterExitAnimationLocked(int thumbTransitState, |
| 744 | int appWidth, int appHeight, int orientation, int transit, Rect containingFrame, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 745 | Rect contentInsets, @Nullable Rect surfaceInsets, boolean resizedWindow, |
| 746 | int taskId) { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 747 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 748 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
| 749 | final int thumbWidthI = mTmpStartRect.width(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 750 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 751 | final int thumbHeightI = mTmpStartRect.height(); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 752 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 753 | |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 754 | // Used for the ENTER_SCALE_UP and EXIT_SCALE_DOWN transitions |
| 755 | float scale = 1f; |
| 756 | int scaledTopDecor = 0; |
| 757 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 758 | switch (thumbTransitState) { |
| 759 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: { |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 760 | if (resizedWindow) { |
| 761 | a = createAspectScaledThumbnailEnterNonFullscreenAnimationLocked( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 762 | containingFrame, surfaceInsets, taskId); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 763 | } else { |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 764 | // App window scaling up to become full screen |
| 765 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 766 | // In portrait, we scale the width and clip to the top/left square |
| 767 | scale = thumbWidth / appWidth; |
| 768 | scaledTopDecor = (int) (scale * contentInsets.top); |
| 769 | int unscaledThumbHeight = (int) (thumbHeight / scale); |
| 770 | mTmpFromClipRect.set(containingFrame); |
| 771 | mTmpFromClipRect.bottom = (mTmpFromClipRect.top + unscaledThumbHeight); |
| 772 | mTmpToClipRect.set(containingFrame); |
| 773 | } else { |
| 774 | // In landscape, we scale the height and clip to the top/left square |
| 775 | scale = thumbHeight / (appHeight - contentInsets.top); |
| 776 | scaledTopDecor = (int) (scale * contentInsets.top); |
| 777 | int unscaledThumbWidth = (int) (thumbWidth / scale); |
| 778 | mTmpFromClipRect.set(containingFrame); |
| 779 | mTmpFromClipRect.right = (mTmpFromClipRect.left + unscaledThumbWidth); |
| 780 | mTmpToClipRect.set(containingFrame); |
| 781 | } |
| 782 | // exclude top screen decor (status bar) region from the source clip. |
| 783 | mTmpFromClipRect.top = contentInsets.top; |
| 784 | |
| 785 | mNextAppTransitionInsets.set(contentInsets); |
| 786 | |
| 787 | Animation scaleAnim = new ScaleAnimation(scale, 1, scale, 1, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 788 | computePivot(mTmpStartRect.left, scale), |
| 789 | computePivot(mTmpStartRect.top, scale)); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 790 | Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect); |
| 791 | Animation translateAnim = new TranslateAnimation(0, 0, -scaledTopDecor, 0); |
| 792 | |
| 793 | AnimationSet set = new AnimationSet(true); |
| 794 | set.addAnimation(clipAnim); |
| 795 | set.addAnimation(scaleAnim); |
| 796 | set.addAnimation(translateAnim); |
| 797 | a = set; |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 798 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 799 | break; |
| 800 | } |
| 801 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 802 | // Previous app window during the scale up |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 803 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 804 | // Fade out the source activity if we are animating to a wallpaper |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 805 | // activity. |
| 806 | a = new AlphaAnimation(1, 0); |
| 807 | } else { |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 808 | a = new AlphaAnimation(1, 1); |
| 809 | } |
| 810 | break; |
| 811 | } |
| 812 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 813 | // Target app window during the scale down |
| 814 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 815 | // Fade in the destination activity if we are animating from a wallpaper |
| 816 | // activity. |
| 817 | a = new AlphaAnimation(0, 1); |
| 818 | } else { |
| 819 | a = new AlphaAnimation(1, 1); |
| 820 | } |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 821 | break; |
| 822 | } |
| 823 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 824 | // App window scaling down from full screen |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 825 | if (orientation == Configuration.ORIENTATION_PORTRAIT) { |
| 826 | // In portrait, we scale the width and clip to the top/left square |
| 827 | scale = thumbWidth / appWidth; |
| 828 | scaledTopDecor = (int) (scale * contentInsets.top); |
| 829 | int unscaledThumbHeight = (int) (thumbHeight / scale); |
| 830 | mTmpFromClipRect.set(containingFrame); |
| 831 | mTmpToClipRect.set(containingFrame); |
| 832 | mTmpToClipRect.bottom = (mTmpToClipRect.top + unscaledThumbHeight); |
| 833 | } else { |
| 834 | // In landscape, we scale the height and clip to the top/left square |
| 835 | scale = thumbHeight / (appHeight - contentInsets.top); |
| 836 | scaledTopDecor = (int) (scale * contentInsets.top); |
| 837 | int unscaledThumbWidth = (int) (thumbWidth / scale); |
| 838 | mTmpFromClipRect.set(containingFrame); |
| 839 | mTmpToClipRect.set(containingFrame); |
| 840 | mTmpToClipRect.right = (mTmpToClipRect.left + unscaledThumbWidth); |
| 841 | } |
Wale Ogunwale | 35a57f8 | 2015-07-01 15:07:36 -0700 | [diff] [blame] | 842 | // exclude top screen decor (status bar) region from the destination clip. |
| 843 | mTmpToClipRect.top = contentInsets.top; |
| 844 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 845 | mNextAppTransitionInsets.set(contentInsets); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 846 | |
| 847 | Animation scaleAnim = new ScaleAnimation(1, scale, 1, scale, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 848 | computePivot(mTmpStartRect.left, scale), |
| 849 | computePivot(mTmpStartRect.top, scale)); |
Winson Chung | 2820c45 | 2014-04-15 15:34:44 -0700 | [diff] [blame] | 850 | Animation clipAnim = new ClipRectAnimation(mTmpFromClipRect, mTmpToClipRect); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 851 | Animation translateAnim = new TranslateAnimation(0, 0, 0, -scaledTopDecor); |
| 852 | |
| 853 | AnimationSet set = new AnimationSet(true); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 854 | set.addAnimation(clipAnim); |
| 855 | set.addAnimation(scaleAnim); |
| 856 | set.addAnimation(translateAnim); |
| 857 | |
| 858 | a = set; |
| 859 | a.setZAdjustment(Animation.ZORDER_TOP); |
| 860 | break; |
| 861 | } |
| 862 | default: |
| 863 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 864 | } |
| 865 | |
Winson Chung | ab79fce | 2014-11-04 16:15:22 -0800 | [diff] [blame] | 866 | int duration = Math.max(THUMBNAIL_APP_TRANSITION_ALPHA_DURATION, |
| 867 | THUMBNAIL_APP_TRANSITION_DURATION); |
| 868 | return prepareThumbnailAnimationWithDuration(a, appWidth, appHeight, duration, |
Jorim Jaggi | 1d763a6 | 2015-06-02 17:07:39 -0700 | [diff] [blame] | 869 | mTouchResponseInterpolator); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 870 | } |
| 871 | |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 872 | private Animation createAspectScaledThumbnailEnterNonFullscreenAnimationLocked( |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 873 | Rect containingFrame, @Nullable Rect surfaceInsets, int taskId) { |
| 874 | getNextAppTransitionStartRect(taskId, mTmpStartRect); |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 875 | float width = containingFrame.width(); |
| 876 | float height = containingFrame.height(); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 877 | float scaleWidth = mTmpStartRect.width() / width; |
| 878 | float scaleHeight = mTmpStartRect.height() / height; |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 879 | AnimationSet set = new AnimationSet(true); |
| 880 | int surfaceInsetsHorizontal = surfaceInsets == null |
| 881 | ? 0 : surfaceInsets.left + surfaceInsets.right; |
| 882 | int surfaceInsetsVertical = surfaceInsets == null |
| 883 | ? 0 : surfaceInsets.top + surfaceInsets.bottom; |
| 884 | // We want the scaling to happen from the center of the surface. In order to achieve that, |
| 885 | // we need to account for surface insets that will be used to enlarge the surface. |
| 886 | ScaleAnimation scale = new ScaleAnimation(scaleWidth, 1, scaleHeight, 1, |
| 887 | (width + surfaceInsetsHorizontal) / 2, (height + surfaceInsetsVertical) / 2); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 888 | int fromX = mTmpStartRect.left + mTmpStartRect.width() / 2 |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 889 | - (containingFrame.left + containingFrame.width() / 2); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 890 | int fromY = mTmpStartRect.top + mTmpStartRect.height() / 2 |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 891 | - (containingFrame.top + containingFrame.height() / 2); |
| 892 | TranslateAnimation translation = new TranslateAnimation(fromX, 0, fromY, 0); |
| 893 | set.addAnimation(scale); |
| 894 | set.addAnimation(translation); |
| 895 | return set; |
| 896 | } |
| 897 | |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 898 | /** |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 899 | * 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^] | 900 | * when a thumbnail is specified with the pending animation override. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 901 | */ |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 902 | Animation createThumbnailScaleAnimationLocked(int appWidth, int appHeight, int transit, |
| 903 | Bitmap thumbnailHeader) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 904 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 905 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
| 906 | final int thumbWidthI = thumbnailHeader.getWidth(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 907 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 908 | final int thumbHeightI = thumbnailHeader.getHeight(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 909 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 910 | |
| 911 | if (mNextAppTransitionScaleUp) { |
| 912 | // Animation for the thumbnail zooming from its initial size to the full screen |
| 913 | float scaleW = appWidth / thumbWidth; |
| 914 | float scaleH = appHeight / thumbHeight; |
| 915 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 916 | computePivot(mTmpStartRect.left, 1 / scaleW), |
| 917 | computePivot(mTmpStartRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 918 | scale.setInterpolator(mDecelerateInterpolator); |
| 919 | |
| 920 | Animation alpha = new AlphaAnimation(1, 0); |
| 921 | alpha.setInterpolator(mThumbnailFadeOutInterpolator); |
| 922 | |
| 923 | // This AnimationSet uses the Interpolators assigned above. |
| 924 | AnimationSet set = new AnimationSet(false); |
| 925 | set.addAnimation(scale); |
| 926 | set.addAnimation(alpha); |
| 927 | a = set; |
| 928 | } else { |
| 929 | // Animation for the thumbnail zooming down from the full screen to its final size |
| 930 | float scaleW = appWidth / thumbWidth; |
| 931 | float scaleH = appHeight / thumbHeight; |
| 932 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 933 | computePivot(mTmpStartRect.left, 1 / scaleW), |
| 934 | computePivot(mTmpStartRect.top, 1 / scaleH)); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 935 | } |
| 936 | |
| 937 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 938 | } |
| 939 | |
| 940 | /** |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 941 | * This animation is created when we are doing a thumbnail transition, for the activity that is |
| 942 | * leaving, and the activity that is entering. |
| 943 | */ |
| 944 | Animation createThumbnailEnterExitAnimationLocked(int thumbTransitState, int appWidth, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 945 | int appHeight, int transit, int taskId) { |
| 946 | Bitmap thumbnailHeader = getAppTransitionThumbnailHeader(taskId); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 947 | Animation a; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 948 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
| 949 | final int thumbWidthI = thumbnailHeader != null ? thumbnailHeader.getWidth() : appWidth; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 950 | final float thumbWidth = thumbWidthI > 0 ? thumbWidthI : 1; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 951 | final int thumbHeightI = thumbnailHeader != null ? thumbnailHeader.getHeight() : appHeight; |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 952 | final float thumbHeight = thumbHeightI > 0 ? thumbHeightI : 1; |
| 953 | |
| 954 | switch (thumbTransitState) { |
| 955 | case THUMBNAIL_TRANSITION_ENTER_SCALE_UP: { |
| 956 | // Entering app scales up with the thumbnail |
| 957 | float scaleW = thumbWidth / appWidth; |
| 958 | float scaleH = thumbHeight / appHeight; |
| 959 | a = new ScaleAnimation(scaleW, 1, scaleH, 1, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 960 | computePivot(mTmpStartRect.left, scaleW), |
| 961 | computePivot(mTmpStartRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 962 | break; |
| 963 | } |
| 964 | case THUMBNAIL_TRANSITION_EXIT_SCALE_UP: { |
| 965 | // Exiting app while the thumbnail is scaling up should fade or stay in place |
| 966 | if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) { |
| 967 | // Fade out while bringing up selected activity. This keeps the |
| 968 | // current activity from showing through a launching wallpaper |
| 969 | // activity. |
| 970 | a = new AlphaAnimation(1, 0); |
| 971 | } else { |
| 972 | // noop animation |
| 973 | a = new AlphaAnimation(1, 1); |
| 974 | } |
| 975 | break; |
| 976 | } |
| 977 | case THUMBNAIL_TRANSITION_ENTER_SCALE_DOWN: { |
| 978 | // Entering the other app, it should just be visible while we scale the thumbnail |
| 979 | // down above it |
| 980 | a = new AlphaAnimation(1, 1); |
| 981 | break; |
| 982 | } |
| 983 | case THUMBNAIL_TRANSITION_EXIT_SCALE_DOWN: { |
| 984 | // Exiting the current app, the app should scale down with the thumbnail |
| 985 | float scaleW = thumbWidth / appWidth; |
| 986 | float scaleH = thumbHeight / appHeight; |
| 987 | Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 988 | computePivot(mTmpStartRect.left, scaleW), |
| 989 | computePivot(mTmpStartRect.top, scaleH)); |
Winson Chung | 399f620 | 2014-03-19 10:47:20 -0700 | [diff] [blame] | 990 | |
| 991 | Animation alpha = new AlphaAnimation(1, 0); |
| 992 | |
| 993 | AnimationSet set = new AnimationSet(true); |
| 994 | set.addAnimation(scale); |
| 995 | set.addAnimation(alpha); |
| 996 | set.setZAdjustment(Animation.ZORDER_TOP); |
| 997 | a = set; |
| 998 | break; |
| 999 | } |
| 1000 | default: |
| 1001 | throw new RuntimeException("Invalid thumbnail transition state"); |
| 1002 | } |
| 1003 | |
| 1004 | return prepareThumbnailAnimation(a, appWidth, appHeight, transit); |
| 1005 | } |
| 1006 | |
Jorim Jaggi | c554b77 | 2015-06-04 16:07:57 -0700 | [diff] [blame] | 1007 | /** |
| 1008 | * @return true if and only if the first frame of the transition can be skipped, i.e. the first |
| 1009 | * frame of the transition doesn't change the visuals on screen, so we can start |
| 1010 | * directly with the second one |
| 1011 | */ |
| 1012 | boolean canSkipFirstFrame() { |
| 1013 | return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM |
| 1014 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE |
| 1015 | && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
| 1016 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1017 | |
| 1018 | Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1019 | int appWidth, int appHeight, int orientation, Rect containingFrame, Rect contentInsets, |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1020 | @Nullable Rect surfaceInsets, Rect appFrame, boolean isVoiceInteraction, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1021 | boolean resizedWindow, int taskId) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1022 | Animation a; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1023 | if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_OPEN |
| 1024 | || transit == TRANSIT_TASK_OPEN |
| 1025 | || transit == TRANSIT_TASK_TO_FRONT)) { |
| 1026 | a = loadAnimationRes(lp, enter |
| 1027 | ? com.android.internal.R.anim.voice_activity_open_enter |
| 1028 | : com.android.internal.R.anim.voice_activity_open_exit); |
| 1029 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1030 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1031 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1032 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1033 | } else if (isVoiceInteraction && (transit == TRANSIT_ACTIVITY_CLOSE |
| 1034 | || transit == TRANSIT_TASK_CLOSE |
| 1035 | || transit == TRANSIT_TASK_TO_BACK)) { |
| 1036 | a = loadAnimationRes(lp, enter |
| 1037 | ? com.android.internal.R.anim.voice_activity_close_enter |
| 1038 | : com.android.internal.R.anim.voice_activity_close_exit); |
| 1039 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1040 | "applyAnimation voice:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1041 | + " anim=" + a + " transit=" + appTransitionToString(transit) |
| 1042 | + " isEntrance=" + enter + " Callers=" + Debug.getCallers(3)); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1043 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) { |
| 1044 | a = loadAnimationRes(mNextAppTransitionPackage, enter ? |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1045 | mNextAppTransitionEnter : mNextAppTransitionExit); |
| 1046 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1047 | "applyAnimation:" |
| 1048 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1049 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1050 | + " Callers=" + Debug.getCallers(3)); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1051 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) { |
| 1052 | a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace); |
| 1053 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1054 | "applyAnimation:" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1055 | + " anim=" + a + " nextAppTransition=ANIM_CUSTOM_IN_PLACE" |
| 1056 | + " transit=" + appTransitionToString(transit) |
| 1057 | + " Callers=" + Debug.getCallers(3)); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1058 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CLIP_REVEAL) { |
Craig Mautner | 80b1f64 | 2015-04-22 10:59:09 -0700 | [diff] [blame] | 1059 | a = createClipRevealAnimationLocked(transit, enter, appFrame); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1060 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1061 | "applyAnimation:" |
| 1062 | + " anim=" + a + " nextAppTransition=ANIM_CLIP_REVEAL" |
| 1063 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1064 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1065 | a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight); |
| 1066 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1067 | "applyAnimation:" |
| 1068 | + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP" |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1069 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1070 | + " Callers=" + Debug.getCallers(3)); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1071 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP || |
| 1072 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1073 | mNextAppTransitionScaleUp = |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1074 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1075 | a = createThumbnailEnterExitAnimationLocked(getThumbnailTransitionState(enter), |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1076 | appWidth, appHeight, transit, taskId); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1077 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1078 | String animName = mNextAppTransitionScaleUp ? |
| 1079 | "ANIM_THUMBNAIL_SCALE_UP" : "ANIM_THUMBNAIL_SCALE_DOWN"; |
| 1080 | Slog.v(TAG, "applyAnimation:" |
| 1081 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1082 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1083 | + " Callers=" + Debug.getCallers(3)); |
| 1084 | } |
| 1085 | } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP || |
| 1086 | mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN) { |
| 1087 | mNextAppTransitionScaleUp = |
| 1088 | (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP); |
| 1089 | a = createAspectScaledThumbnailEnterExitAnimationLocked( |
Filip Gruszczynski | 71b0d2d | 2015-08-12 18:52:26 -0700 | [diff] [blame] | 1090 | getThumbnailTransitionState(enter), appWidth, appHeight, orientation, transit, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1091 | containingFrame, contentInsets, surfaceInsets, resizedWindow, taskId); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1092 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) { |
| 1093 | String animName = mNextAppTransitionScaleUp ? |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1094 | "ANIM_THUMBNAIL_ASPECT_SCALE_UP" : "ANIM_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1095 | Slog.v(TAG, "applyAnimation:" |
| 1096 | + " anim=" + a + " nextAppTransition=" + animName |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1097 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1098 | + " Callers=" + Debug.getCallers(3)); |
| 1099 | } |
| 1100 | } else { |
| 1101 | int animAttr = 0; |
| 1102 | switch (transit) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1103 | case TRANSIT_ACTIVITY_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1104 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1105 | ? WindowAnimation_activityOpenEnterAnimation |
| 1106 | : WindowAnimation_activityOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1107 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1108 | case TRANSIT_ACTIVITY_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1109 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1110 | ? WindowAnimation_activityCloseEnterAnimation |
| 1111 | : WindowAnimation_activityCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1112 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1113 | case TRANSIT_TASK_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1114 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1115 | ? WindowAnimation_taskOpenEnterAnimation |
| 1116 | : WindowAnimation_taskOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1117 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1118 | case TRANSIT_TASK_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1119 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1120 | ? WindowAnimation_taskCloseEnterAnimation |
| 1121 | : WindowAnimation_taskCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1122 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1123 | case TRANSIT_TASK_TO_FRONT: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1124 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1125 | ? WindowAnimation_taskToFrontEnterAnimation |
| 1126 | : WindowAnimation_taskToFrontExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1127 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1128 | case TRANSIT_TASK_TO_BACK: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1129 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1130 | ? WindowAnimation_taskToBackEnterAnimation |
| 1131 | : WindowAnimation_taskToBackExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1132 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1133 | case TRANSIT_WALLPAPER_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1134 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1135 | ? WindowAnimation_wallpaperOpenEnterAnimation |
| 1136 | : WindowAnimation_wallpaperOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1137 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1138 | case TRANSIT_WALLPAPER_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1139 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1140 | ? WindowAnimation_wallpaperCloseEnterAnimation |
| 1141 | : WindowAnimation_wallpaperCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1142 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1143 | case TRANSIT_WALLPAPER_INTRA_OPEN: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1144 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1145 | ? WindowAnimation_wallpaperIntraOpenEnterAnimation |
| 1146 | : WindowAnimation_wallpaperIntraOpenExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1147 | break; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1148 | case TRANSIT_WALLPAPER_INTRA_CLOSE: |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1149 | animAttr = enter |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1150 | ? WindowAnimation_wallpaperIntraCloseEnterAnimation |
| 1151 | : WindowAnimation_wallpaperIntraCloseExitAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1152 | break; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1153 | case TRANSIT_TASK_OPEN_BEHIND: |
| 1154 | animAttr = enter |
| 1155 | ? WindowAnimation_launchTaskBehindSourceAnimation |
Craig Mautner | 3b2cd1d | 2014-08-25 14:25:54 -0700 | [diff] [blame] | 1156 | : WindowAnimation_launchTaskBehindTargetAnimation; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1157 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1158 | a = animAttr != 0 ? loadAnimationAttr(lp, animAttr) : null; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1159 | if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, |
| 1160 | "applyAnimation:" |
| 1161 | + " anim=" + a |
| 1162 | + " animAttr=0x" + Integer.toHexString(animAttr) |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1163 | + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1164 | + " Callers=" + Debug.getCallers(3)); |
| 1165 | } |
| 1166 | return a; |
| 1167 | } |
| 1168 | |
| 1169 | void postAnimationCallback() { |
| 1170 | if (mNextAppTransitionCallback != null) { |
| 1171 | mH.sendMessage(mH.obtainMessage(H.DO_ANIMATION_CALLBACK, mNextAppTransitionCallback)); |
| 1172 | mNextAppTransitionCallback = null; |
| 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, |
| 1177 | IRemoteCallback startedCallback) { |
| 1178 | if (isTransitionSet()) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1179 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1180 | mNextAppTransitionPackage = packageName; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1181 | mNextAppTransitionAnimationsSpecs.clear(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1182 | mNextAppTransitionEnter = enterAnim; |
| 1183 | mNextAppTransitionExit = exitAnim; |
| 1184 | postAnimationCallback(); |
| 1185 | mNextAppTransitionCallback = startedCallback; |
| 1186 | } else { |
| 1187 | postAnimationCallback(); |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1192 | int startHeight) { |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1193 | if (isTransitionSet()) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1194 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1195 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1196 | mNextAppTransitionAnimationsSpecs.clear(); |
| 1197 | putDefaultNextAppTransitionCoordinates(startX, startY, startX + startWidth, |
| 1198 | startY + startHeight); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1199 | postAnimationCallback(); |
| 1200 | mNextAppTransitionCallback = null; |
| 1201 | } |
| 1202 | } |
| 1203 | |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1204 | void overridePendingAppTransitionClipReveal(int startX, int startY, |
| 1205 | int startWidth, int startHeight) { |
| 1206 | if (isTransitionSet()) { |
| 1207 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CLIP_REVEAL; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1208 | putDefaultNextAppTransitionCoordinates(startX, startY, startWidth, startHeight); |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1209 | postAnimationCallback(); |
| 1210 | mNextAppTransitionCallback = null; |
| 1211 | } |
| 1212 | } |
| 1213 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1214 | void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, |
| 1215 | IRemoteCallback startedCallback, boolean scaleUp) { |
| 1216 | if (isTransitionSet()) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1217 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP |
| 1218 | : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN; |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1219 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1220 | mNextAppTransitionAnimationsSpecs.clear(); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1221 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1222 | putDefaultNextAppTransitionCoordinates(startX, startY, 0 ,0); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1223 | postAnimationCallback(); |
| 1224 | mNextAppTransitionCallback = startedCallback; |
| 1225 | } else { |
| 1226 | postAnimationCallback(); |
| 1227 | } |
| 1228 | } |
| 1229 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1230 | void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1231 | int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1232 | if (isTransitionSet()) { |
| 1233 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1234 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 1235 | mNextAppTransitionPackage = null; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1236 | mNextAppTransitionAnimationsSpecs.clear(); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1237 | mNextAppTransitionScaleUp = scaleUp; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1238 | putDefaultNextAppTransitionCoordinates(startX, startY, targetWidth, targetHeight); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1239 | postAnimationCallback(); |
| 1240 | mNextAppTransitionCallback = startedCallback; |
| 1241 | } else { |
| 1242 | postAnimationCallback(); |
| 1243 | } |
| 1244 | } |
| 1245 | |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1246 | public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs, |
| 1247 | IRemoteCallback callback, boolean scaleUp) { |
| 1248 | if (isTransitionSet()) { |
| 1249 | mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP |
| 1250 | : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 1251 | mNextAppTransitionPackage = null; |
| 1252 | mNextAppTransitionAnimationsSpecs.clear(); |
| 1253 | mNextAppTransitionScaleUp = scaleUp; |
| 1254 | for (int i = 0; i < specs.length; i++) { |
| 1255 | AppTransitionAnimationSpec spec = specs[i]; |
| 1256 | if (spec != null) { |
| 1257 | mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec); |
| 1258 | } |
| 1259 | } |
| 1260 | postAnimationCallback(); |
| 1261 | mNextAppTransitionCallback = callback; |
| 1262 | } else { |
| 1263 | postAnimationCallback(); |
| 1264 | } |
| 1265 | } |
| 1266 | |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1267 | void overrideInPlaceAppTransition(String packageName, int anim) { |
| 1268 | if (isTransitionSet()) { |
| 1269 | mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE; |
| 1270 | mNextAppTransitionPackage = packageName; |
| 1271 | mNextAppTransitionInPlace = anim; |
| 1272 | } else { |
| 1273 | postAnimationCallback(); |
| 1274 | } |
| 1275 | } |
| 1276 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1277 | @Override |
| 1278 | public String toString() { |
Wale Ogunwale | 8ebc82a | 2015-05-13 15:27:12 -0700 | [diff] [blame] | 1279 | return "mNextAppTransition=" + appTransitionToString(mNextAppTransition); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1280 | } |
| 1281 | |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1282 | /** |
| 1283 | * Returns the human readable name of a window transition. |
| 1284 | * |
| 1285 | * @param transition The window transition. |
| 1286 | * @return The transition symbolic name. |
| 1287 | */ |
| 1288 | public static String appTransitionToString(int transition) { |
| 1289 | switch (transition) { |
| 1290 | case TRANSIT_UNSET: { |
| 1291 | return "TRANSIT_UNSET"; |
| 1292 | } |
| 1293 | case TRANSIT_NONE: { |
| 1294 | return "TRANSIT_NONE"; |
| 1295 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1296 | case TRANSIT_ACTIVITY_OPEN: { |
| 1297 | return "TRANSIT_ACTIVITY_OPEN"; |
| 1298 | } |
| 1299 | case TRANSIT_ACTIVITY_CLOSE: { |
| 1300 | return "TRANSIT_ACTIVITY_CLOSE"; |
| 1301 | } |
| 1302 | case TRANSIT_TASK_OPEN: { |
| 1303 | return "TRANSIT_TASK_OPEN"; |
| 1304 | } |
| 1305 | case TRANSIT_TASK_CLOSE: { |
| 1306 | return "TRANSIT_TASK_CLOSE"; |
| 1307 | } |
| 1308 | case TRANSIT_TASK_TO_FRONT: { |
| 1309 | return "TRANSIT_TASK_TO_FRONT"; |
| 1310 | } |
| 1311 | case TRANSIT_TASK_TO_BACK: { |
| 1312 | return "TRANSIT_TASK_TO_BACK"; |
| 1313 | } |
| 1314 | case TRANSIT_WALLPAPER_CLOSE: { |
| 1315 | return "TRANSIT_WALLPAPER_CLOSE"; |
| 1316 | } |
| 1317 | case TRANSIT_WALLPAPER_OPEN: { |
| 1318 | return "TRANSIT_WALLPAPER_OPEN"; |
| 1319 | } |
| 1320 | case TRANSIT_WALLPAPER_INTRA_OPEN: { |
| 1321 | return "TRANSIT_WALLPAPER_INTRA_OPEN"; |
| 1322 | } |
| 1323 | case TRANSIT_WALLPAPER_INTRA_CLOSE: { |
| 1324 | return "TRANSIT_WALLPAPER_INTRA_CLOSE"; |
| 1325 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1326 | case TRANSIT_TASK_OPEN_BEHIND: { |
| 1327 | return "TRANSIT_TASK_OPEN_BEHIND"; |
| 1328 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1329 | default: { |
| 1330 | return "<UNKNOWN>"; |
| 1331 | } |
| 1332 | } |
| 1333 | } |
| 1334 | |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1335 | private String appStateToString() { |
| 1336 | switch (mAppTransitionState) { |
| 1337 | case APP_STATE_IDLE: |
| 1338 | return "APP_STATE_IDLE"; |
| 1339 | case APP_STATE_READY: |
| 1340 | return "APP_STATE_READY"; |
| 1341 | case APP_STATE_RUNNING: |
| 1342 | return "APP_STATE_RUNNING"; |
| 1343 | case APP_STATE_TIMEOUT: |
| 1344 | return "APP_STATE_TIMEOUT"; |
| 1345 | default: |
| 1346 | return "unknown state=" + mAppTransitionState; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | private String transitTypeToString() { |
| 1351 | switch (mNextAppTransitionType) { |
| 1352 | case NEXT_TRANSIT_TYPE_NONE: |
| 1353 | return "NEXT_TRANSIT_TYPE_NONE"; |
| 1354 | case NEXT_TRANSIT_TYPE_CUSTOM: |
| 1355 | return "NEXT_TRANSIT_TYPE_CUSTOM"; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1356 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
| 1357 | return "NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1358 | case NEXT_TRANSIT_TYPE_SCALE_UP: |
| 1359 | return "NEXT_TRANSIT_TYPE_SCALE_UP"; |
| 1360 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1361 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP"; |
| 1362 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
| 1363 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN"; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1364 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
| 1365 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP"; |
| 1366 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 1367 | return "NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN"; |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1368 | default: |
| 1369 | return "unknown type=" + mNextAppTransitionType; |
| 1370 | } |
| 1371 | } |
| 1372 | |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1373 | @Override |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1374 | public void dump(PrintWriter pw, String prefix) { |
| 1375 | pw.print(prefix); pw.println(this); |
| 1376 | pw.print(prefix); pw.print("mAppTransitionState="); pw.println(appStateToString()); |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1377 | if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1378 | pw.print(prefix); pw.print("mNextAppTransitionType="); |
| 1379 | pw.println(transitTypeToString()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1380 | } |
| 1381 | switch (mNextAppTransitionType) { |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1382 | case NEXT_TRANSIT_TYPE_CUSTOM: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1383 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1384 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1385 | pw.print(prefix); pw.print("mNextAppTransitionEnter=0x"); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1386 | pw.print(Integer.toHexString(mNextAppTransitionEnter)); |
| 1387 | pw.print(" mNextAppTransitionExit=0x"); |
| 1388 | pw.println(Integer.toHexString(mNextAppTransitionExit)); |
| 1389 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1390 | case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE: |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1391 | pw.print(prefix); pw.print("mNextAppTransitionPackage="); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1392 | pw.println(mNextAppTransitionPackage); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1393 | pw.print(prefix); pw.print("mNextAppTransitionInPlace=0x"); |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1394 | pw.print(Integer.toHexString(mNextAppTransitionInPlace)); |
| 1395 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1396 | case NEXT_TRANSIT_TYPE_SCALE_UP: { |
| 1397 | getDefaultNextAppTransitionStartRect(mTmpStartRect); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1398 | pw.print(prefix); pw.print("mNextAppTransitionStartX="); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1399 | pw.print(mTmpStartRect.left); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1400 | pw.print(" mNextAppTransitionStartY="); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1401 | pw.println(mTmpStartRect.top); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1402 | pw.print(prefix); pw.print("mNextAppTransitionStartWidth="); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1403 | pw.print(mTmpStartRect.width()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1404 | pw.print(" mNextAppTransitionStartHeight="); |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1405 | pw.println(mTmpStartRect.height()); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1406 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1407 | } |
Craig Mautner | 9a29a5d | 2012-12-27 19:03:40 -0800 | [diff] [blame] | 1408 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP: |
| 1409 | case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1410 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP: |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1411 | case NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN: { |
| 1412 | pw.print(prefix); pw.print("mDefaultNextAppTransitionAnimationSpec="); |
| 1413 | pw.println(mDefaultNextAppTransitionAnimationSpec); |
| 1414 | pw.print(prefix); pw.print("mNextAppTransitionAnimationsSpecs="); |
| 1415 | pw.println(mNextAppTransitionAnimationsSpecs); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1416 | pw.print(prefix); pw.print("mNextAppTransitionScaleUp="); |
| 1417 | pw.println(mNextAppTransitionScaleUp); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1418 | break; |
Filip Gruszczynski | 170192a | 2015-08-16 17:46:34 -0700 | [diff] [blame^] | 1419 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1420 | } |
| 1421 | if (mNextAppTransitionCallback != null) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 1422 | pw.print(prefix); pw.print("mNextAppTransitionCallback="); |
| 1423 | pw.println(mNextAppTransitionCallback); |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1424 | } |
| 1425 | } |
Amith Yamasani | 4befbec | 2013-07-10 16:18:01 -0700 | [diff] [blame] | 1426 | |
| 1427 | public void setCurrentUser(int newUserId) { |
| 1428 | mCurrentUserId = newUserId; |
| 1429 | } |
Craig Mautner | 164d4bb | 2012-11-26 13:51:23 -0800 | [diff] [blame] | 1430 | } |