Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 android.app; |
| 18 | |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 20 | import static android.app.ActivityManager.StackId.INVALID_STACK_ID; |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 21 | |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 22 | import android.annotation.Nullable; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 23 | import android.content.Context; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 24 | import android.content.Intent; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 25 | import android.graphics.Bitmap; |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 26 | import android.graphics.Rect; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 27 | import android.os.Bundle; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 28 | import android.os.Handler; |
| 29 | import android.os.IRemoteCallback; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 30 | import android.os.Parcelable; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 31 | import android.os.RemoteException; |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 32 | import android.os.ResultReceiver; |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 33 | import android.util.Pair; |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 34 | import android.util.Slog; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 35 | import android.view.AppTransitionAnimationSpec; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 36 | import android.view.View; |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 37 | import android.view.Window; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 38 | |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 39 | import java.util.ArrayList; |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 40 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 41 | /** |
| 42 | * Helper class for building an options Bundle that can be used with |
| 43 | * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) |
| 44 | * Context.startActivity(Intent, Bundle)} and related methods. |
| 45 | */ |
| 46 | public class ActivityOptions { |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 47 | private static final String TAG = "ActivityOptions"; |
| 48 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 49 | /** |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 50 | * A long in the extras delivered by {@link #requestUsageTimeReport} that contains |
Dianne Hackborn | 67ba2c7 | 2015-06-05 14:23:38 -0700 | [diff] [blame] | 51 | * the total time (in ms) the user spent in the app flow. |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 52 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 53 | public static final String EXTRA_USAGE_TIME_REPORT = "android.activity.usage_time"; |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * A Bundle in the extras delivered by {@link #requestUsageTimeReport} that contains |
| 57 | * detailed information about the time spent in each package associated with the app; |
| 58 | * each key is a package name, whose value is a long containing the time (in ms). |
| 59 | */ |
Dianne Hackborn | 67ba2c7 | 2015-06-05 14:23:38 -0700 | [diff] [blame] | 60 | public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages"; |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 63 | * The package name that created the options. |
| 64 | * @hide |
| 65 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 66 | public static final String KEY_PACKAGE_NAME = "android:activity.packageName"; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 69 | * The bounds (window size) that the activity should be launched in. Set to null explicitly for |
| 70 | * full screen. If the key is not found, previous bounds will be preserved. |
| 71 | * NOTE: This value is ignored on devices that don't have |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 72 | * {@link android.content.pm.PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT} or |
| 73 | * {@link android.content.pm.PackageManager#FEATURE_PICTURE_IN_PICTURE} enabled. |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 74 | * @hide |
| 75 | */ |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 76 | public static final String KEY_LAUNCH_BOUNDS = "android:activity.launchBounds"; |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 79 | * Type of animation that arguments specify. |
| 80 | * @hide |
| 81 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 82 | public static final String KEY_ANIM_TYPE = "android:activity.animType"; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 85 | * Custom enter animation resource ID. |
| 86 | * @hide |
| 87 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 88 | public static final String KEY_ANIM_ENTER_RES_ID = "android:activity.animEnterRes"; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Custom exit animation resource ID. |
| 92 | * @hide |
| 93 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 94 | public static final String KEY_ANIM_EXIT_RES_ID = "android:activity.animExitRes"; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 95 | |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 96 | /** |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 97 | * Custom in-place animation resource ID. |
| 98 | * @hide |
| 99 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 100 | public static final String KEY_ANIM_IN_PLACE_RES_ID = "android:activity.animInPlaceRes"; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 103 | * Bitmap for thumbnail animation. |
| 104 | * @hide |
| 105 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 106 | public static final String KEY_ANIM_THUMBNAIL = "android:activity.animThumbnail"; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Start X position of thumbnail animation. |
| 110 | * @hide |
| 111 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 112 | public static final String KEY_ANIM_START_X = "android:activity.animStartX"; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Start Y position of thumbnail animation. |
| 116 | * @hide |
| 117 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 118 | public static final String KEY_ANIM_START_Y = "android:activity.animStartY"; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 119 | |
| 120 | /** |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 121 | * Initial width of the animation. |
| 122 | * @hide |
| 123 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 124 | public static final String KEY_ANIM_WIDTH = "android:activity.animWidth"; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Initial height of the animation. |
| 128 | * @hide |
| 129 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 130 | public static final String KEY_ANIM_HEIGHT = "android:activity.animHeight"; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 133 | * Callback for when animation is started. |
| 134 | * @hide |
| 135 | */ |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 136 | public static final String KEY_ANIM_START_LISTENER = "android:activity.animStartListener"; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 137 | |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 138 | /** |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 139 | * Callback for when the last frame of the animation is played. |
| 140 | * @hide |
| 141 | */ |
| 142 | private static final String KEY_ANIMATION_FINISHED_LISTENER = |
| 143 | "android:activity.animationFinishedListener"; |
| 144 | |
| 145 | /** |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 146 | * Descriptions of app transition animations to be played during the activity launch. |
| 147 | */ |
| 148 | private static final String KEY_ANIM_SPECS = "android:activity.animSpecs"; |
| 149 | |
| 150 | /** |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 151 | * The stack id the activity should be launched into. |
| 152 | * @hide |
| 153 | */ |
| 154 | private static final String KEY_LAUNCH_STACK_ID = "android.activity.launchStackId"; |
| 155 | |
| 156 | /** |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 157 | * Where the docked stack should be positioned. |
| 158 | * @hide |
| 159 | */ |
| 160 | private static final String KEY_DOCK_CREATE_MODE = "android:activity.dockCreateMode"; |
| 161 | |
| 162 | /** |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 163 | * For Activity transitions, the calling Activity's TransitionListener used to |
| 164 | * notify the called Activity when the shared element and the exit transitions |
| 165 | * complete. |
| 166 | */ |
| 167 | private static final String KEY_TRANSITION_COMPLETE_LISTENER |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 168 | = "android:activity.transitionCompleteListener"; |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 169 | |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 170 | private static final String KEY_TRANSITION_IS_RETURNING |
| 171 | = "android:activity.transitionIsReturning"; |
| 172 | private static final String KEY_TRANSITION_SHARED_ELEMENTS |
| 173 | = "android:activity.sharedElementNames"; |
| 174 | private static final String KEY_RESULT_DATA = "android:activity.resultData"; |
| 175 | private static final String KEY_RESULT_CODE = "android:activity.resultCode"; |
| 176 | private static final String KEY_EXIT_COORDINATOR_INDEX |
| 177 | = "android:activity.exitCoordinatorIndex"; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 178 | |
Dianne Hackborn | a750a63 | 2015-06-16 17:18:23 -0700 | [diff] [blame] | 179 | private static final String KEY_USAGE_TIME_REPORT = "android:activity.usageTimeReport"; |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 180 | |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 181 | /** @hide */ |
| 182 | public static final int ANIM_NONE = 0; |
| 183 | /** @hide */ |
| 184 | public static final int ANIM_CUSTOM = 1; |
| 185 | /** @hide */ |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 186 | public static final int ANIM_SCALE_UP = 2; |
| 187 | /** @hide */ |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 188 | public static final int ANIM_THUMBNAIL_SCALE_UP = 3; |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 189 | /** @hide */ |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 190 | public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 191 | /** @hide */ |
| 192 | public static final int ANIM_SCENE_TRANSITION = 5; |
George Mount | 0b6f3e1 | 2014-06-20 07:35:23 -0700 | [diff] [blame] | 193 | /** @hide */ |
| 194 | public static final int ANIM_DEFAULT = 6; |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 195 | /** @hide */ |
| 196 | public static final int ANIM_LAUNCH_TASK_BEHIND = 7; |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 197 | /** @hide */ |
| 198 | public static final int ANIM_THUMBNAIL_ASPECT_SCALE_UP = 8; |
| 199 | /** @hide */ |
| 200 | public static final int ANIM_THUMBNAIL_ASPECT_SCALE_DOWN = 9; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 201 | /** @hide */ |
| 202 | public static final int ANIM_CUSTOM_IN_PLACE = 10; |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 203 | /** @hide */ |
| 204 | public static final int ANIM_CLIP_REVEAL = 11; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 205 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 206 | private String mPackageName; |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 207 | private Rect mLaunchBounds; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 208 | private int mAnimationType = ANIM_NONE; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 209 | private int mCustomEnterResId; |
| 210 | private int mCustomExitResId; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 211 | private int mCustomInPlaceResId; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 212 | private Bitmap mThumbnail; |
| 213 | private int mStartX; |
| 214 | private int mStartY; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 215 | private int mWidth; |
| 216 | private int mHeight; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 217 | private IRemoteCallback mAnimationStartedListener; |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 218 | private IRemoteCallback mAnimationFinishedListener; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 219 | private ResultReceiver mTransitionReceiver; |
| 220 | private boolean mIsReturning; |
| 221 | private ArrayList<String> mSharedElementNames; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 222 | private Intent mResultData; |
| 223 | private int mResultCode; |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 224 | private int mExitCoordinatorIndex; |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 225 | private PendingIntent mUsageTimeReport; |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 226 | private int mLaunchStackId = INVALID_STACK_ID; |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 227 | private int mDockCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 228 | private AppTransitionAnimationSpec mAnimSpecs[]; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 229 | |
| 230 | /** |
| 231 | * Create an ActivityOptions specifying a custom animation to run when |
| 232 | * the activity is displayed. |
| 233 | * |
| 234 | * @param context Who is defining this. This is the application that the |
| 235 | * animation resources will be loaded from. |
| 236 | * @param enterResId A resource ID of the animation resource to use for |
| 237 | * the incoming activity. Use 0 for no animation. |
| 238 | * @param exitResId A resource ID of the animation resource to use for |
| 239 | * the outgoing activity. Use 0 for no animation. |
| 240 | * @return Returns a new ActivityOptions object that you can use to |
| 241 | * supply these options as the options Bundle when starting an activity. |
| 242 | */ |
| 243 | public static ActivityOptions makeCustomAnimation(Context context, |
| 244 | int enterResId, int exitResId) { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 245 | return makeCustomAnimation(context, enterResId, exitResId, null, null); |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Create an ActivityOptions specifying a custom animation to run when |
| 250 | * the activity is displayed. |
| 251 | * |
| 252 | * @param context Who is defining this. This is the application that the |
| 253 | * animation resources will be loaded from. |
| 254 | * @param enterResId A resource ID of the animation resource to use for |
| 255 | * the incoming activity. Use 0 for no animation. |
| 256 | * @param exitResId A resource ID of the animation resource to use for |
| 257 | * the outgoing activity. Use 0 for no animation. |
| 258 | * @param handler If <var>listener</var> is non-null this must be a valid |
| 259 | * Handler on which to dispatch the callback; otherwise it should be null. |
| 260 | * @param listener Optional OnAnimationStartedListener to find out when the |
| 261 | * requested animation has started running. If for some reason the animation |
| 262 | * is not executed, the callback will happen immediately. |
| 263 | * @return Returns a new ActivityOptions object that you can use to |
| 264 | * supply these options as the options Bundle when starting an activity. |
| 265 | * @hide |
| 266 | */ |
| 267 | public static ActivityOptions makeCustomAnimation(Context context, |
| 268 | int enterResId, int exitResId, Handler handler, OnAnimationStartedListener listener) { |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 269 | ActivityOptions opts = new ActivityOptions(); |
| 270 | opts.mPackageName = context.getPackageName(); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 271 | opts.mAnimationType = ANIM_CUSTOM; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 272 | opts.mCustomEnterResId = enterResId; |
| 273 | opts.mCustomExitResId = exitResId; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 274 | opts.setOnAnimationStartedListener(handler, listener); |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 275 | return opts; |
| 276 | } |
| 277 | |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 278 | /** |
| 279 | * Creates an ActivityOptions specifying a custom animation to run in place on an existing |
| 280 | * activity. |
| 281 | * |
| 282 | * @param context Who is defining this. This is the application that the |
| 283 | * animation resources will be loaded from. |
| 284 | * @param animId A resource ID of the animation resource to use for |
| 285 | * the incoming activity. |
| 286 | * @return Returns a new ActivityOptions object that you can use to |
| 287 | * supply these options as the options Bundle when running an in-place animation. |
| 288 | * @hide |
| 289 | */ |
| 290 | public static ActivityOptions makeCustomInPlaceAnimation(Context context, int animId) { |
| 291 | if (animId == 0) { |
| 292 | throw new RuntimeException("You must specify a valid animation."); |
| 293 | } |
| 294 | |
| 295 | ActivityOptions opts = new ActivityOptions(); |
| 296 | opts.mPackageName = context.getPackageName(); |
| 297 | opts.mAnimationType = ANIM_CUSTOM_IN_PLACE; |
| 298 | opts.mCustomInPlaceResId = animId; |
| 299 | return opts; |
| 300 | } |
| 301 | |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 302 | private void setOnAnimationStartedListener(final Handler handler, |
| 303 | final OnAnimationStartedListener listener) { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 304 | if (listener != null) { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 305 | mAnimationStartedListener = new IRemoteCallback.Stub() { |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 306 | @Override |
| 307 | public void sendResult(Bundle data) throws RemoteException { |
| 308 | handler.post(new Runnable() { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 309 | @Override public void run() { |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 310 | listener.onAnimationStarted(); |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 311 | } |
| 312 | }); |
| 313 | } |
| 314 | }; |
| 315 | } |
| 316 | } |
| 317 | |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 318 | /** |
| 319 | * Callback for use with {@link ActivityOptions#makeThumbnailScaleUpAnimation} |
| 320 | * to find out when the given animation has started running. |
Dianne Hackborn | 9944ecd | 2012-04-10 15:54:19 -0700 | [diff] [blame] | 321 | * @hide |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 322 | */ |
| 323 | public interface OnAnimationStartedListener { |
| 324 | void onAnimationStarted(); |
| 325 | } |
| 326 | |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 327 | private void setOnAnimationFinishedListener(final Handler handler, |
| 328 | final OnAnimationFinishedListener listener) { |
| 329 | if (listener != null) { |
| 330 | mAnimationFinishedListener = new IRemoteCallback.Stub() { |
| 331 | @Override |
| 332 | public void sendResult(Bundle data) throws RemoteException { |
| 333 | handler.post(new Runnable() { |
| 334 | @Override |
| 335 | public void run() { |
| 336 | listener.onAnimationFinished(); |
| 337 | } |
| 338 | }); |
| 339 | } |
| 340 | }; |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * Callback for use with {@link ActivityOptions#makeThumbnailAspectScaleDownAnimation} |
| 346 | * to find out when the given animation has drawn its last frame. |
| 347 | * @hide |
| 348 | */ |
| 349 | public interface OnAnimationFinishedListener { |
| 350 | void onAnimationFinished(); |
| 351 | } |
| 352 | |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 353 | /** |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 354 | * Create an ActivityOptions specifying an animation where the new |
| 355 | * activity is scaled from a small originating area of the screen to |
| 356 | * its final full representation. |
| 357 | * |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 358 | * <p>If the Intent this is being used with has not set its |
| 359 | * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, |
| 360 | * those bounds will be filled in for you based on the initial |
| 361 | * bounds passed in here. |
| 362 | * |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 363 | * @param source The View that the new activity is animating from. This |
| 364 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 365 | * @param startX The x starting location of the new activity, relative to <var>source</var>. |
| 366 | * @param startY The y starting location of the activity, relative to <var>source</var>. |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 367 | * @param width The initial width of the new activity. |
| 368 | * @param height The initial height of the new activity. |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 369 | * @return Returns a new ActivityOptions object that you can use to |
| 370 | * supply these options as the options Bundle when starting an activity. |
| 371 | */ |
| 372 | public static ActivityOptions makeScaleUpAnimation(View source, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 373 | int startX, int startY, int width, int height) { |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 374 | ActivityOptions opts = new ActivityOptions(); |
| 375 | opts.mPackageName = source.getContext().getPackageName(); |
| 376 | opts.mAnimationType = ANIM_SCALE_UP; |
| 377 | int[] pts = new int[2]; |
| 378 | source.getLocationOnScreen(pts); |
| 379 | opts.mStartX = pts[0] + startX; |
| 380 | opts.mStartY = pts[1] + startY; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 381 | opts.mWidth = width; |
| 382 | opts.mHeight = height; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 383 | return opts; |
| 384 | } |
| 385 | |
| 386 | /** |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 387 | * Create an ActivityOptions specifying an animation where the new |
| 388 | * activity is revealed from a small originating area of the screen to |
| 389 | * its final full representation. |
| 390 | * |
| 391 | * @param source The View that the new activity is animating from. This |
| 392 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 393 | * @param startX The x starting location of the new activity, relative to <var>source</var>. |
| 394 | * @param startY The y starting location of the activity, relative to <var>source</var>. |
| 395 | * @param width The initial width of the new activity. |
| 396 | * @param height The initial height of the new activity. |
| 397 | * @return Returns a new ActivityOptions object that you can use to |
| 398 | * supply these options as the options Bundle when starting an activity. |
| 399 | */ |
| 400 | public static ActivityOptions makeClipRevealAnimation(View source, |
| 401 | int startX, int startY, int width, int height) { |
| 402 | ActivityOptions opts = new ActivityOptions(); |
| 403 | opts.mAnimationType = ANIM_CLIP_REVEAL; |
| 404 | int[] pts = new int[2]; |
| 405 | source.getLocationOnScreen(pts); |
| 406 | opts.mStartX = pts[0] + startX; |
| 407 | opts.mStartY = pts[1] + startY; |
| 408 | opts.mWidth = width; |
| 409 | opts.mHeight = height; |
| 410 | return opts; |
| 411 | } |
| 412 | |
| 413 | /** |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 414 | * Create an ActivityOptions specifying an animation where a thumbnail |
| 415 | * is scaled from a given position to the new activity window that is |
| 416 | * being started. |
| 417 | * |
Dianne Hackborn | d367ca8 | 2012-05-07 15:49:39 -0700 | [diff] [blame] | 418 | * <p>If the Intent this is being used with has not set its |
| 419 | * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, |
| 420 | * those bounds will be filled in for you based on the initial |
| 421 | * thumbnail location and size provided here. |
| 422 | * |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 423 | * @param source The View that this thumbnail is animating from. This |
| 424 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 425 | * @param thumbnail The bitmap that will be shown as the initial thumbnail |
| 426 | * of the animation. |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 427 | * @param startX The x starting location of the bitmap, relative to <var>source</var>. |
| 428 | * @param startY The y starting location of the bitmap, relative to <var>source</var>. |
Dianne Hackborn | 9944ecd | 2012-04-10 15:54:19 -0700 | [diff] [blame] | 429 | * @return Returns a new ActivityOptions object that you can use to |
| 430 | * supply these options as the options Bundle when starting an activity. |
| 431 | */ |
| 432 | public static ActivityOptions makeThumbnailScaleUpAnimation(View source, |
| 433 | Bitmap thumbnail, int startX, int startY) { |
| 434 | return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, null); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Create an ActivityOptions specifying an animation where a thumbnail |
| 439 | * is scaled from a given position to the new activity window that is |
| 440 | * being started. |
| 441 | * |
| 442 | * @param source The View that this thumbnail is animating from. This |
| 443 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 444 | * @param thumbnail The bitmap that will be shown as the initial thumbnail |
| 445 | * of the animation. |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 446 | * @param startX The x starting location of the bitmap, relative to <var>source</var>. |
| 447 | * @param startY The y starting location of the bitmap, relative to <var>source</var>. |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 448 | * @param listener Optional OnAnimationStartedListener to find out when the |
| 449 | * requested animation has started running. If for some reason the animation |
| 450 | * is not executed, the callback will happen immediately. |
| 451 | * @return Returns a new ActivityOptions object that you can use to |
| 452 | * supply these options as the options Bundle when starting an activity. |
Dianne Hackborn | 9944ecd | 2012-04-10 15:54:19 -0700 | [diff] [blame] | 453 | * @hide |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 454 | */ |
| 455 | public static ActivityOptions makeThumbnailScaleUpAnimation(View source, |
| 456 | Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 457 | return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true); |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | /** |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 461 | * Create an ActivityOptions specifying an animation where an activity window |
| 462 | * is scaled from a given position to a thumbnail at a specified location. |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 463 | * |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 464 | * @param source The View that this thumbnail is animating to. This |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 465 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 466 | * @param thumbnail The bitmap that will be shown as the final thumbnail |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 467 | * of the animation. |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 468 | * @param startX The x end location of the bitmap, relative to <var>source</var>. |
| 469 | * @param startY The y end location of the bitmap, relative to <var>source</var>. |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 470 | * @param listener Optional OnAnimationStartedListener to find out when the |
| 471 | * requested animation has started running. If for some reason the animation |
| 472 | * is not executed, the callback will happen immediately. |
| 473 | * @return Returns a new ActivityOptions object that you can use to |
| 474 | * supply these options as the options Bundle when starting an activity. |
| 475 | * @hide |
| 476 | */ |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 477 | public static ActivityOptions makeThumbnailScaleDownAnimation(View source, |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 478 | Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 479 | return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, false); |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 482 | private static ActivityOptions makeThumbnailAnimation(View source, |
Michael Jurka | 21385cd | 2012-05-03 10:57:31 -0700 | [diff] [blame] | 483 | Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener, |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 484 | boolean scaleUp) { |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 485 | ActivityOptions opts = new ActivityOptions(); |
| 486 | opts.mPackageName = source.getContext().getPackageName(); |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 487 | opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 488 | opts.mThumbnail = thumbnail; |
| 489 | int[] pts = new int[2]; |
| 490 | source.getLocationOnScreen(pts); |
| 491 | opts.mStartX = pts[0] + startX; |
| 492 | opts.mStartY = pts[1] + startY; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 493 | opts.setOnAnimationStartedListener(source.getHandler(), listener); |
| 494 | return opts; |
| 495 | } |
| 496 | |
| 497 | /** |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 498 | * Create an ActivityOptions specifying an animation where the new activity |
| 499 | * window and a thumbnail is aspect-scaled to a new location. |
| 500 | * |
| 501 | * @param source The View that this thumbnail is animating from. This |
| 502 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 503 | * @param thumbnail The bitmap that will be shown as the initial thumbnail |
| 504 | * of the animation. |
| 505 | * @param startX The x starting location of the bitmap, relative to <var>source</var>. |
| 506 | * @param startY The y starting location of the bitmap, relative to <var>source</var>. |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 507 | * @param handler If <var>listener</var> is non-null this must be a valid |
| 508 | * Handler on which to dispatch the callback; otherwise it should be null. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 509 | * @param listener Optional OnAnimationStartedListener to find out when the |
| 510 | * requested animation has started running. If for some reason the animation |
| 511 | * is not executed, the callback will happen immediately. |
| 512 | * @return Returns a new ActivityOptions object that you can use to |
| 513 | * supply these options as the options Bundle when starting an activity. |
| 514 | * @hide |
| 515 | */ |
| 516 | public static ActivityOptions makeThumbnailAspectScaleUpAnimation(View source, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 517 | Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight, |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 518 | Handler handler, OnAnimationStartedListener listener) { |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 519 | return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 520 | targetWidth, targetHeight, handler, listener, true); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Create an ActivityOptions specifying an animation where the new activity |
| 525 | * window and a thumbnail is aspect-scaled to a new location. |
| 526 | * |
| 527 | * @param source The View that this thumbnail is animating to. This |
| 528 | * defines the coordinate space for <var>startX</var> and <var>startY</var>. |
| 529 | * @param thumbnail The bitmap that will be shown as the final thumbnail |
| 530 | * of the animation. |
| 531 | * @param startX The x end location of the bitmap, relative to <var>source</var>. |
| 532 | * @param startY The y end location of the bitmap, relative to <var>source</var>. |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 533 | * @param handler If <var>listener</var> is non-null this must be a valid |
| 534 | * Handler on which to dispatch the callback; otherwise it should be null. |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 535 | * @param listener Optional OnAnimationStartedListener to find out when the |
| 536 | * requested animation has started running. If for some reason the animation |
| 537 | * is not executed, the callback will happen immediately. |
| 538 | * @return Returns a new ActivityOptions object that you can use to |
| 539 | * supply these options as the options Bundle when starting an activity. |
| 540 | * @hide |
| 541 | */ |
| 542 | public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 543 | Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight, |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 544 | Handler handler, OnAnimationStartedListener listener) { |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 545 | return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 546 | targetWidth, targetHeight, handler, listener, false); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | private static ActivityOptions makeAspectScaledThumbnailAnimation(View source, Bitmap thumbnail, |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 550 | int startX, int startY, int targetWidth, int targetHeight, |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 551 | Handler handler, OnAnimationStartedListener listener, boolean scaleUp) { |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 552 | ActivityOptions opts = new ActivityOptions(); |
| 553 | opts.mPackageName = source.getContext().getPackageName(); |
| 554 | opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_ASPECT_SCALE_UP : |
| 555 | ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 556 | opts.mThumbnail = thumbnail; |
| 557 | int[] pts = new int[2]; |
| 558 | source.getLocationOnScreen(pts); |
| 559 | opts.mStartX = pts[0] + startX; |
| 560 | opts.mStartY = pts[1] + startY; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 561 | opts.mWidth = targetWidth; |
| 562 | opts.mHeight = targetHeight; |
Winson Chung | e494c38 | 2014-12-17 10:12:54 -0800 | [diff] [blame] | 563 | opts.setOnAnimationStartedListener(handler, listener); |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 564 | return opts; |
| 565 | } |
| 566 | |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 567 | /** @hide */ |
| 568 | public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source, |
| 569 | AppTransitionAnimationSpec[] specs, Handler handler, |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 570 | OnAnimationStartedListener onAnimationStartedListener, |
| 571 | OnAnimationFinishedListener onAnimationFinishedListener) { |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 572 | ActivityOptions opts = new ActivityOptions(); |
| 573 | opts.mPackageName = source.getContext().getPackageName(); |
| 574 | opts.mAnimationType = ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; |
| 575 | opts.mAnimSpecs = specs; |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 576 | opts.setOnAnimationStartedListener(handler, onAnimationStartedListener); |
| 577 | opts.setOnAnimationFinishedListener(handler, onAnimationFinishedListener); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 578 | return opts; |
| 579 | } |
| 580 | |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 581 | /** |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 582 | * Create an ActivityOptions to transition between Activities using cross-Activity scene |
| 583 | * animations. This method carries the position of one shared element to the started Activity. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 584 | * The position of <code>sharedElement</code> will be used as the epicenter for the |
| 585 | * exit Transition. The position of the shared element in the launched Activity will be the |
| 586 | * epicenter of its entering Transition. |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 587 | * |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 588 | * <p>This requires {@link android.view.Window#FEATURE_ACTIVITY_TRANSITIONS} to be |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 589 | * enabled on the calling Activity to cause an exit transition. The same must be in |
| 590 | * the called Activity to get an entering transition.</p> |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 591 | * @param activity The Activity whose window contains the shared elements. |
George Mount | 0b6f3e1 | 2014-06-20 07:35:23 -0700 | [diff] [blame] | 592 | * @param sharedElement The View to transition to the started Activity. |
| 593 | * @param sharedElementName The shared element name as used in the target Activity. This |
| 594 | * must not be null. |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 595 | * @return Returns a new ActivityOptions object that you can use to |
| 596 | * supply these options as the options Bundle when starting an activity. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 597 | * @see android.transition.Transition#setEpicenterCallback( |
| 598 | * android.transition.Transition.EpicenterCallback) |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 599 | */ |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 600 | public static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 601 | View sharedElement, String sharedElementName) { |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 602 | return makeSceneTransitionAnimation(activity, Pair.create(sharedElement, sharedElementName)); |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Create an ActivityOptions to transition between Activities using cross-Activity scene |
| 607 | * animations. This method carries the position of multiple shared elements to the started |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 608 | * Activity. The position of the first element in sharedElements |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 609 | * will be used as the epicenter for the exit Transition. The position of the associated |
| 610 | * shared element in the launched Activity will be the epicenter of its entering Transition. |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 611 | * |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 612 | * <p>This requires {@link android.view.Window#FEATURE_ACTIVITY_TRANSITIONS} to be |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 613 | * enabled on the calling Activity to cause an exit transition. The same must be in |
| 614 | * the called Activity to get an entering transition.</p> |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 615 | * @param activity The Activity whose window contains the shared elements. |
| 616 | * @param sharedElements The names of the shared elements to transfer to the called |
| 617 | * Activity and their associated Views. The Views must each have |
| 618 | * a unique shared element name. |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 619 | * @return Returns a new ActivityOptions object that you can use to |
| 620 | * supply these options as the options Bundle when starting an activity. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 621 | * @see android.transition.Transition#setEpicenterCallback( |
| 622 | * android.transition.Transition.EpicenterCallback) |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 623 | */ |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 624 | public static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
| 625 | Pair<View, String>... sharedElements) { |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 626 | ActivityOptions opts = new ActivityOptions(); |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 627 | if (!activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { |
George Mount | 0b6f3e1 | 2014-06-20 07:35:23 -0700 | [diff] [blame] | 628 | opts.mAnimationType = ANIM_DEFAULT; |
| 629 | return opts; |
| 630 | } |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 631 | opts.mAnimationType = ANIM_SCENE_TRANSITION; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 632 | |
| 633 | ArrayList<String> names = new ArrayList<String>(); |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 634 | ArrayList<View> views = new ArrayList<View>(); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 635 | |
| 636 | if (sharedElements != null) { |
| 637 | for (int i = 0; i < sharedElements.length; i++) { |
| 638 | Pair<View, String> sharedElement = sharedElements[i]; |
George Mount | d5f9d73 | 2014-06-05 15:43:06 -0700 | [diff] [blame] | 639 | String sharedElementName = sharedElement.second; |
| 640 | if (sharedElementName == null) { |
| 641 | throw new IllegalArgumentException("Shared element name must not be null"); |
| 642 | } |
George Mount | d5f9d73 | 2014-06-05 15:43:06 -0700 | [diff] [blame] | 643 | names.add(sharedElementName); |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 644 | View view = sharedElement.first; |
| 645 | if (view == null) { |
| 646 | throw new IllegalArgumentException("Shared element must not be null"); |
| 647 | } |
| 648 | views.add(sharedElement.first); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 649 | } |
| 650 | } |
| 651 | |
| 652 | ExitTransitionCoordinator exit = new ExitTransitionCoordinator(activity, names, names, |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 653 | views, false); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 654 | opts.mTransitionReceiver = exit; |
| 655 | opts.mSharedElementNames = names; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 656 | opts.mIsReturning = false; |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 657 | opts.mExitCoordinatorIndex = |
| 658 | activity.mActivityTransitionState.addExitTransitionCoordinator(exit); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 659 | return opts; |
| 660 | } |
| 661 | |
| 662 | /** @hide */ |
| 663 | public static ActivityOptions makeSceneTransitionAnimation(Activity activity, |
| 664 | ExitTransitionCoordinator exitCoordinator, ArrayList<String> sharedElementNames, |
| 665 | int resultCode, Intent resultData) { |
| 666 | ActivityOptions opts = new ActivityOptions(); |
| 667 | opts.mAnimationType = ANIM_SCENE_TRANSITION; |
| 668 | opts.mSharedElementNames = sharedElementNames; |
| 669 | opts.mTransitionReceiver = exitCoordinator; |
| 670 | opts.mIsReturning = true; |
| 671 | opts.mResultCode = resultCode; |
| 672 | opts.mResultData = resultData; |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 673 | opts.mExitCoordinatorIndex = |
| 674 | activity.mActivityTransitionState.addExitTransitionCoordinator(exitCoordinator); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 675 | return opts; |
| 676 | } |
| 677 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 678 | /** |
| 679 | * If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be |
| 680 | * presented to the user but will instead be only available through the recents task list. |
| 681 | * In addition, the new task wil be affiliated with the launching activity's task. |
| 682 | * Affiliated tasks are grouped together in the recents task list. |
| 683 | * |
| 684 | * <p>This behavior is not supported for activities with {@link |
| 685 | * android.R.styleable#AndroidManifestActivity_launchMode launchMode} values of |
| 686 | * <code>singleInstance</code> or <code>singleTask</code>. |
| 687 | */ |
Craig Mautner | 3b2cd1d | 2014-08-25 14:25:54 -0700 | [diff] [blame] | 688 | public static ActivityOptions makeTaskLaunchBehind() { |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 689 | final ActivityOptions opts = new ActivityOptions(); |
| 690 | opts.mAnimationType = ANIM_LAUNCH_TASK_BEHIND; |
| 691 | return opts; |
| 692 | } |
| 693 | |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 694 | /** |
| 695 | * Create a basic ActivityOptions that has no special animation associated with it. |
| 696 | * Other options can still be set. |
| 697 | */ |
| 698 | public static ActivityOptions makeBasic() { |
| 699 | final ActivityOptions opts = new ActivityOptions(); |
| 700 | return opts; |
| 701 | } |
| 702 | |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 703 | /** @hide */ |
| 704 | public boolean getLaunchTaskBehind() { |
| 705 | return mAnimationType == ANIM_LAUNCH_TASK_BEHIND; |
| 706 | } |
| 707 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 708 | private ActivityOptions() { |
| 709 | } |
| 710 | |
| 711 | /** @hide */ |
| 712 | public ActivityOptions(Bundle opts) { |
| 713 | mPackageName = opts.getString(KEY_PACKAGE_NAME); |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 714 | try { |
| 715 | mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT); |
| 716 | } catch (RuntimeException e) { |
| 717 | Slog.w(TAG, e); |
| 718 | } |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 719 | mLaunchBounds = opts.getParcelable(KEY_LAUNCH_BOUNDS); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 720 | mAnimationType = opts.getInt(KEY_ANIM_TYPE); |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 721 | switch (mAnimationType) { |
| 722 | case ANIM_CUSTOM: |
| 723 | mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0); |
| 724 | mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0); |
| 725 | mAnimationStartedListener = IRemoteCallback.Stub.asInterface( |
| 726 | opts.getBinder(KEY_ANIM_START_LISTENER)); |
| 727 | break; |
| 728 | |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 729 | case ANIM_CUSTOM_IN_PLACE: |
| 730 | mCustomInPlaceResId = opts.getInt(KEY_ANIM_IN_PLACE_RES_ID, 0); |
| 731 | break; |
| 732 | |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 733 | case ANIM_SCALE_UP: |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 734 | case ANIM_CLIP_REVEAL: |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 735 | mStartX = opts.getInt(KEY_ANIM_START_X, 0); |
| 736 | mStartY = opts.getInt(KEY_ANIM_START_Y, 0); |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 737 | mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); |
| 738 | mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 739 | break; |
| 740 | |
| 741 | case ANIM_THUMBNAIL_SCALE_UP: |
| 742 | case ANIM_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 743 | case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 744 | case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
| 745 | mThumbnail = (Bitmap) opts.getParcelable(KEY_ANIM_THUMBNAIL); |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 746 | mStartX = opts.getInt(KEY_ANIM_START_X, 0); |
| 747 | mStartY = opts.getInt(KEY_ANIM_START_Y, 0); |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 748 | mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); |
| 749 | mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 750 | mAnimationStartedListener = IRemoteCallback.Stub.asInterface( |
| 751 | opts.getBinder(KEY_ANIM_START_LISTENER)); |
| 752 | break; |
| 753 | |
| 754 | case ANIM_SCENE_TRANSITION: |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 755 | mTransitionReceiver = opts.getParcelable(KEY_TRANSITION_COMPLETE_LISTENER); |
| 756 | mIsReturning = opts.getBoolean(KEY_TRANSITION_IS_RETURNING, false); |
| 757 | mSharedElementNames = opts.getStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 758 | mResultData = opts.getParcelable(KEY_RESULT_DATA); |
| 759 | mResultCode = opts.getInt(KEY_RESULT_CODE); |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 760 | mExitCoordinatorIndex = opts.getInt(KEY_EXIT_COORDINATOR_INDEX); |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 761 | break; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 762 | } |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 763 | mLaunchStackId = opts.getInt(KEY_LAUNCH_STACK_ID, INVALID_STACK_ID); |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 764 | mDockCreateMode = opts.getInt(KEY_DOCK_CREATE_MODE, DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 765 | if (opts.containsKey(KEY_ANIM_SPECS)) { |
| 766 | Parcelable[] specs = opts.getParcelableArray(KEY_ANIM_SPECS); |
| 767 | mAnimSpecs = new AppTransitionAnimationSpec[specs.length]; |
| 768 | for (int i = specs.length - 1; i >= 0; i--) { |
| 769 | mAnimSpecs[i] = (AppTransitionAnimationSpec) specs[i]; |
| 770 | } |
| 771 | } |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 772 | if (opts.containsKey(KEY_ANIMATION_FINISHED_LISTENER)) { |
| 773 | mAnimationFinishedListener = IRemoteCallback.Stub.asInterface( |
| 774 | opts.getBinder(KEY_ANIMATION_FINISHED_LISTENER)); |
| 775 | } |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 776 | } |
| 777 | |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 778 | /** |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 779 | * Sets the bounds (window size) that the activity should be launched in. |
| 780 | * Set to null explicitly for fullscreen. |
| 781 | * <p> |
| 782 | * <strong>NOTE:<strong/> This value is ignored on devices that don't have |
| 783 | * {@link android.content.pm.PackageManager#FEATURE_FREEFORM_WINDOW_MANAGEMENT} or |
| 784 | * {@link android.content.pm.PackageManager#FEATURE_PICTURE_IN_PICTURE} enabled. |
| 785 | * @param launchBounds Launch bounds to use for the activity or null for fullscreen. |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 786 | */ |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 787 | public ActivityOptions setLaunchBounds(@Nullable Rect launchBounds) { |
| 788 | mLaunchBounds = launchBounds != null ? new Rect(launchBounds) : null; |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 789 | return this; |
| 790 | } |
| 791 | |
| 792 | /** @hide */ |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 793 | public String getPackageName() { |
| 794 | return mPackageName; |
| 795 | } |
| 796 | |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 797 | /** |
| 798 | * Returns the bounds that should be used to launch the activity. |
| 799 | * @see #setLaunchBounds(Rect) |
| 800 | * @return Bounds used to launch the activity. |
| 801 | */ |
| 802 | @Nullable |
| 803 | public Rect getLaunchBounds() { |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 804 | return mLaunchBounds; |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /** @hide */ |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 808 | public int getAnimationType() { |
| 809 | return mAnimationType; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | /** @hide */ |
| 813 | public int getCustomEnterResId() { |
| 814 | return mCustomEnterResId; |
| 815 | } |
| 816 | |
| 817 | /** @hide */ |
| 818 | public int getCustomExitResId() { |
| 819 | return mCustomExitResId; |
| 820 | } |
| 821 | |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 822 | /** @hide */ |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 823 | public int getCustomInPlaceResId() { |
| 824 | return mCustomInPlaceResId; |
| 825 | } |
| 826 | |
| 827 | /** @hide */ |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 828 | public Bitmap getThumbnail() { |
| 829 | return mThumbnail; |
| 830 | } |
| 831 | |
| 832 | /** @hide */ |
| 833 | public int getStartX() { |
| 834 | return mStartX; |
| 835 | } |
| 836 | |
| 837 | /** @hide */ |
| 838 | public int getStartY() { |
| 839 | return mStartY; |
| 840 | } |
| 841 | |
| 842 | /** @hide */ |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 843 | public int getWidth() { |
| 844 | return mWidth; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /** @hide */ |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 848 | public int getHeight() { |
| 849 | return mHeight; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | /** @hide */ |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 853 | public IRemoteCallback getOnAnimationStartListener() { |
| 854 | return mAnimationStartedListener; |
| 855 | } |
| 856 | |
| 857 | /** @hide */ |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 858 | public IRemoteCallback getAnimationFinishedListener() { |
| 859 | return mAnimationFinishedListener; |
| 860 | } |
| 861 | |
| 862 | /** @hide */ |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 863 | public int getExitCoordinatorKey() { return mExitCoordinatorIndex; } |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 864 | |
| 865 | /** @hide */ |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 866 | public void abort() { |
| 867 | if (mAnimationStartedListener != null) { |
| 868 | try { |
| 869 | mAnimationStartedListener.sendResult(null); |
| 870 | } catch (RemoteException e) { |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | /** @hide */ |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 876 | public boolean isReturning() { |
| 877 | return mIsReturning; |
| 878 | } |
| 879 | |
| 880 | /** @hide */ |
| 881 | public ArrayList<String> getSharedElementNames() { |
| 882 | return mSharedElementNames; |
| 883 | } |
| 884 | |
| 885 | /** @hide */ |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 886 | public ResultReceiver getResultReceiver() { return mTransitionReceiver; } |
| 887 | |
| 888 | /** @hide */ |
| 889 | public int getResultCode() { return mResultCode; } |
| 890 | |
| 891 | /** @hide */ |
| 892 | public Intent getResultData() { return mResultData; } |
| 893 | |
| 894 | /** @hide */ |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 895 | public PendingIntent getUsageTimeReport() { |
| 896 | return mUsageTimeReport; |
| 897 | } |
| 898 | |
| 899 | /** @hide */ |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 900 | public AppTransitionAnimationSpec[] getAnimSpecs() { return mAnimSpecs; } |
| 901 | |
| 902 | /** @hide */ |
Chong Zhang | 280d332 | 2015-11-03 17:27:26 -0800 | [diff] [blame] | 903 | public static ActivityOptions fromBundle(Bundle bOptions) { |
| 904 | return bOptions != null ? new ActivityOptions(bOptions) : null; |
| 905 | } |
| 906 | |
| 907 | /** @hide */ |
| 908 | public static void abort(ActivityOptions options) { |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 909 | if (options != null) { |
Chong Zhang | 280d332 | 2015-11-03 17:27:26 -0800 | [diff] [blame] | 910 | options.abort(); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 914 | /** @hide */ |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 915 | public int getLaunchStackId() { |
| 916 | return mLaunchStackId; |
| 917 | } |
| 918 | |
| 919 | /** @hide */ |
| 920 | public void setLaunchStackId(int launchStackId) { |
| 921 | mLaunchStackId = launchStackId; |
| 922 | } |
| 923 | |
| 924 | /** @hide */ |
| 925 | public int getDockCreateMode() { |
| 926 | return mDockCreateMode; |
| 927 | } |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 928 | |
| 929 | /** @hide */ |
| 930 | public void setDockCreateMode(int dockCreateMode) { |
| 931 | mDockCreateMode = dockCreateMode; |
| 932 | } |
| 933 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 934 | /** |
Dianne Hackborn | ddc52a8 | 2012-05-03 19:40:12 -0700 | [diff] [blame] | 935 | * Update the current values in this ActivityOptions from those supplied |
| 936 | * in <var>otherOptions</var>. Any values |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 937 | * defined in <var>otherOptions</var> replace those in the base options. |
| 938 | */ |
Dianne Hackborn | ddc52a8 | 2012-05-03 19:40:12 -0700 | [diff] [blame] | 939 | public void update(ActivityOptions otherOptions) { |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 940 | if (otherOptions.mPackageName != null) { |
| 941 | mPackageName = otherOptions.mPackageName; |
| 942 | } |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 943 | mUsageTimeReport = otherOptions.mUsageTimeReport; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 944 | mTransitionReceiver = null; |
| 945 | mSharedElementNames = null; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 946 | mIsReturning = false; |
| 947 | mResultData = null; |
| 948 | mResultCode = 0; |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 949 | mExitCoordinatorIndex = 0; |
George Mount | 00dde0b | 2014-07-01 15:27:07 -0700 | [diff] [blame] | 950 | mAnimationType = otherOptions.mAnimationType; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 951 | switch (otherOptions.mAnimationType) { |
| 952 | case ANIM_CUSTOM: |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 953 | mCustomEnterResId = otherOptions.mCustomEnterResId; |
| 954 | mCustomExitResId = otherOptions.mCustomExitResId; |
| 955 | mThumbnail = null; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 956 | if (mAnimationStartedListener != null) { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 957 | try { |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 958 | mAnimationStartedListener.sendResult(null); |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 959 | } catch (RemoteException e) { |
| 960 | } |
| 961 | } |
| 962 | mAnimationStartedListener = otherOptions.mAnimationStartedListener; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 963 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 964 | case ANIM_CUSTOM_IN_PLACE: |
| 965 | mCustomInPlaceResId = otherOptions.mCustomInPlaceResId; |
| 966 | break; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 967 | case ANIM_SCALE_UP: |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 968 | mStartX = otherOptions.mStartX; |
| 969 | mStartY = otherOptions.mStartY; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 970 | mWidth = otherOptions.mWidth; |
| 971 | mHeight = otherOptions.mHeight; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 972 | if (mAnimationStartedListener != null) { |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 973 | try { |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 974 | mAnimationStartedListener.sendResult(null); |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 975 | } catch (RemoteException e) { |
| 976 | } |
| 977 | } |
| 978 | mAnimationStartedListener = null; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 979 | break; |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 980 | case ANIM_THUMBNAIL_SCALE_UP: |
| 981 | case ANIM_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 982 | case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 983 | case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 984 | mThumbnail = otherOptions.mThumbnail; |
| 985 | mStartX = otherOptions.mStartX; |
| 986 | mStartY = otherOptions.mStartY; |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 987 | mWidth = otherOptions.mWidth; |
| 988 | mHeight = otherOptions.mHeight; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 989 | if (mAnimationStartedListener != null) { |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 990 | try { |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 991 | mAnimationStartedListener.sendResult(null); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 992 | } catch (RemoteException e) { |
| 993 | } |
| 994 | } |
| 995 | mAnimationStartedListener = otherOptions.mAnimationStartedListener; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 996 | break; |
| 997 | case ANIM_SCENE_TRANSITION: |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 998 | mTransitionReceiver = otherOptions.mTransitionReceiver; |
| 999 | mSharedElementNames = otherOptions.mSharedElementNames; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 1000 | mIsReturning = otherOptions.mIsReturning; |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1001 | mThumbnail = null; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 1002 | mAnimationStartedListener = null; |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 1003 | mResultData = otherOptions.mResultData; |
| 1004 | mResultCode = otherOptions.mResultCode; |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 1005 | mExitCoordinatorIndex = otherOptions.mExitCoordinatorIndex; |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1006 | break; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1007 | } |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1008 | mAnimSpecs = otherOptions.mAnimSpecs; |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1009 | mAnimationFinishedListener = otherOptions.mAnimationFinishedListener; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | /** |
| 1013 | * Returns the created options as a Bundle, which can be passed to |
| 1014 | * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) |
| 1015 | * Context.startActivity(Intent, Bundle)} and related methods. |
| 1016 | * Note that the returned Bundle is still owned by the ActivityOptions |
| 1017 | * object; you must not modify it, but can supply it to the startActivity |
| 1018 | * methods that take an options Bundle. |
| 1019 | */ |
| 1020 | public Bundle toBundle() { |
George Mount | 0b6f3e1 | 2014-06-20 07:35:23 -0700 | [diff] [blame] | 1021 | if (mAnimationType == ANIM_DEFAULT) { |
| 1022 | return null; |
| 1023 | } |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1024 | Bundle b = new Bundle(); |
| 1025 | if (mPackageName != null) { |
| 1026 | b.putString(KEY_PACKAGE_NAME, mPackageName); |
| 1027 | } |
Wale Ogunwale | 5122df0 | 2016-01-29 22:33:38 -0800 | [diff] [blame] | 1028 | if (mLaunchBounds != null) { |
Wale Ogunwale | 7a8fa60 | 2015-11-18 15:56:57 -0800 | [diff] [blame] | 1029 | b.putParcelable(KEY_LAUNCH_BOUNDS, mLaunchBounds); |
Chong Zhang | 0fa656b | 2015-08-31 15:17:21 -0700 | [diff] [blame] | 1030 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1031 | b.putInt(KEY_ANIM_TYPE, mAnimationType); |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 1032 | if (mUsageTimeReport != null) { |
| 1033 | b.putParcelable(KEY_USAGE_TIME_REPORT, mUsageTimeReport); |
| 1034 | } |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1035 | switch (mAnimationType) { |
| 1036 | case ANIM_CUSTOM: |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1037 | b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId); |
| 1038 | b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId); |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1039 | b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener |
Dianne Hackborn | 8437587 | 2012-06-01 19:03:50 -0700 | [diff] [blame] | 1040 | != null ? mAnimationStartedListener.asBinder() : null); |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1041 | break; |
Winson Chung | 044d529 | 2014-11-06 11:05:19 -0800 | [diff] [blame] | 1042 | case ANIM_CUSTOM_IN_PLACE: |
| 1043 | b.putInt(KEY_ANIM_IN_PLACE_RES_ID, mCustomInPlaceResId); |
| 1044 | break; |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1045 | case ANIM_SCALE_UP: |
Chet Haase | 10e23ab | 2015-02-11 15:08:38 -0800 | [diff] [blame] | 1046 | case ANIM_CLIP_REVEAL: |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1047 | b.putInt(KEY_ANIM_START_X, mStartX); |
| 1048 | b.putInt(KEY_ANIM_START_Y, mStartY); |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1049 | b.putInt(KEY_ANIM_WIDTH, mWidth); |
| 1050 | b.putInt(KEY_ANIM_HEIGHT, mHeight); |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1051 | break; |
Michael Jurka | 832cb22 | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 1052 | case ANIM_THUMBNAIL_SCALE_UP: |
| 1053 | case ANIM_THUMBNAIL_SCALE_DOWN: |
Winson Chung | a4ccb86 | 2014-08-22 15:26:27 -0700 | [diff] [blame] | 1054 | case ANIM_THUMBNAIL_ASPECT_SCALE_UP: |
| 1055 | case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1056 | b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail); |
| 1057 | b.putInt(KEY_ANIM_START_X, mStartX); |
| 1058 | b.putInt(KEY_ANIM_START_Y, mStartY); |
Winson Chung | 2e7f3bd | 2014-09-05 13:17:22 +0200 | [diff] [blame] | 1059 | b.putInt(KEY_ANIM_WIDTH, mWidth); |
| 1060 | b.putInt(KEY_ANIM_HEIGHT, mHeight); |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1061 | b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener |
Dianne Hackborn | 8078d8c | 2012-03-20 11:11:26 -0700 | [diff] [blame] | 1062 | != null ? mAnimationStartedListener.asBinder() : null); |
Dianne Hackborn | eabfb3a | 2012-04-16 16:28:22 -0700 | [diff] [blame] | 1063 | break; |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1064 | case ANIM_SCENE_TRANSITION: |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 1065 | if (mTransitionReceiver != null) { |
| 1066 | b.putParcelable(KEY_TRANSITION_COMPLETE_LISTENER, mTransitionReceiver); |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1067 | } |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 1068 | b.putBoolean(KEY_TRANSITION_IS_RETURNING, mIsReturning); |
| 1069 | b.putStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS, mSharedElementNames); |
George Mount | 62ab9b7 | 2014-05-02 13:51:17 -0700 | [diff] [blame] | 1070 | b.putParcelable(KEY_RESULT_DATA, mResultData); |
| 1071 | b.putInt(KEY_RESULT_CODE, mResultCode); |
George Mount | 1fecfb2 | 2014-06-18 14:55:55 -0700 | [diff] [blame] | 1072 | b.putInt(KEY_EXIT_COORDINATOR_INDEX, mExitCoordinatorIndex); |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1073 | break; |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1074 | } |
Wale Ogunwale | 854809c | 2015-12-27 16:18:19 -0800 | [diff] [blame] | 1075 | b.putInt(KEY_LAUNCH_STACK_ID, mLaunchStackId); |
Filip Gruszczynski | 90186c6 | 2015-10-26 14:07:00 -0700 | [diff] [blame] | 1076 | b.putInt(KEY_DOCK_CREATE_MODE, mDockCreateMode); |
Filip Gruszczynski | d64ef3e | 2015-10-27 17:58:02 -0700 | [diff] [blame] | 1077 | if (mAnimSpecs != null) { |
| 1078 | b.putParcelableArray(KEY_ANIM_SPECS, mAnimSpecs); |
| 1079 | } |
Filip Gruszczynski | 1a5203d | 2015-10-29 17:43:49 -0700 | [diff] [blame] | 1080 | if (mAnimationFinishedListener != null) { |
| 1081 | b.putBinder(KEY_ANIMATION_FINISHED_LISTENER, mAnimationFinishedListener.asBinder()); |
| 1082 | } |
Craig Mautner | bb74246 | 2014-07-07 15:28:55 -0700 | [diff] [blame] | 1083 | |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1084 | return b; |
| 1085 | } |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1086 | |
| 1087 | /** |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 1088 | * Ask the the system track that time the user spends in the app being launched, and |
| 1089 | * report it back once done. The report will be sent to the given receiver, with |
Dianne Hackborn | 67ba2c7 | 2015-06-05 14:23:38 -0700 | [diff] [blame] | 1090 | * the extras {@link #EXTRA_USAGE_TIME_REPORT} and {@link #EXTRA_USAGE_TIME_REPORT_PACKAGES} |
Dianne Hackborn | b5a380d | 2015-05-20 18:18:46 -0700 | [diff] [blame] | 1091 | * filled in. |
| 1092 | * |
| 1093 | * <p>The time interval tracked is from launching this activity until the user leaves |
| 1094 | * that activity's flow. They are considered to stay in the flow as long as |
| 1095 | * new activities are being launched or returned to from the original flow, |
| 1096 | * even if this crosses package or task boundaries. For example, if the originator |
| 1097 | * starts an activity to view an image, and while there the user selects to share, |
| 1098 | * which launches their email app in a new task, and they complete the share, the |
| 1099 | * time during that entire operation will be included until they finally hit back from |
| 1100 | * the original image viewer activity.</p> |
| 1101 | * |
| 1102 | * <p>The user is considered to complete a flow once they switch to another |
| 1103 | * activity that is not part of the tracked flow. This may happen, for example, by |
| 1104 | * using the notification shade, launcher, or recents to launch or switch to another |
| 1105 | * app. Simply going in to these navigation elements does not break the flow (although |
| 1106 | * the launcher and recents stops time tracking of the session); it is the act of |
| 1107 | * going somewhere else that completes the tracking.</p> |
| 1108 | * |
| 1109 | * @param receiver A broadcast receiver that willl receive the report. |
| 1110 | */ |
| 1111 | public void requestUsageTimeReport(PendingIntent receiver) { |
| 1112 | mUsageTimeReport = receiver; |
| 1113 | } |
| 1114 | |
| 1115 | /** |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1116 | * Return the filtered options only meant to be seen by the target activity itself |
| 1117 | * @hide |
| 1118 | */ |
| 1119 | public ActivityOptions forTargetActivity() { |
| 1120 | if (mAnimationType == ANIM_SCENE_TRANSITION) { |
| 1121 | final ActivityOptions result = new ActivityOptions(); |
| 1122 | result.update(this); |
| 1123 | return result; |
| 1124 | } |
| 1125 | |
| 1126 | return null; |
| 1127 | } |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1128 | |
Filip Gruszczynski | 198dcbf | 2016-01-18 10:02:00 -0800 | [diff] [blame] | 1129 | /** @hide */ |
| 1130 | @Override |
| 1131 | public String toString() { |
| 1132 | return "ActivityOptions(" + hashCode() + "), mPackageName=" + mPackageName |
| 1133 | + ", mAnimationType=" + mAnimationType + ", mStartX=" + mStartX + ", mStartY=" |
| 1134 | + mStartY + ", mWidth=" + mWidth + ", mHeight=" + mHeight; |
| 1135 | } |
Dianne Hackborn | 6de01a9 | 2012-03-19 19:07:40 -0700 | [diff] [blame] | 1136 | } |