16de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn/* 26de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Copyright (C) 2012 The Android Open Source Project 36de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 46de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 56de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * you may not use this file except in compliance with the License. 66de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * You may obtain a copy of the License at 76de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 86de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 96de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 106de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 116de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 126de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * See the License for the specific language governing permissions and 146de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * limitations under the License. 156de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 166de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 176de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornpackage android.app; 186de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 196de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornimport android.content.Context; 2062ab9b78b77b7dd851c47115f4d8d7611d657585George Mountimport android.content.Intent; 218078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.graphics.Bitmap; 226de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornimport android.os.Bundle; 238078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.Handler; 248078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.IRemoteCallback; 258078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.os.RemoteException; 26cb4b7d999e7bcba608726188421772e313e67163George Mountimport android.os.ResultReceiver; 27e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mountimport android.util.Pair; 28b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackbornimport android.util.Slog; 298078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackbornimport android.view.View; 3031a217290cf376d0573fc36e21c8940987485019George Mountimport android.view.Window; 316de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 3262ab9b78b77b7dd851c47115f4d8d7611d657585George Mountimport java.util.ArrayList; 330a778eda690a66173733a63622886e888d405c45George Mount 346de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn/** 356de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Helper class for building an options Bundle that can be used with 366de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) 376de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Context.startActivity(Intent, Bundle)} and related methods. 386de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 396de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackbornpublic class ActivityOptions { 40cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell private static final String TAG = "ActivityOptions"; 41cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell 426de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 43b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * A long in the extras delivered by {@link #requestUsageTimeReport} that contains 4467ba2c7fa25a635c640956ff3a5e64164cb23396Dianne Hackborn * the total time (in ms) the user spent in the app flow. 45b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn */ 46a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String EXTRA_USAGE_TIME_REPORT = "android.activity.usage_time"; 47b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 48b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn /** 49b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * A Bundle in the extras delivered by {@link #requestUsageTimeReport} that contains 50b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * detailed information about the time spent in each package associated with the app; 51b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * each key is a package name, whose value is a long containing the time (in ms). 52b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn */ 5367ba2c7fa25a635c640956ff3a5e64164cb23396Dianne Hackborn public static final String EXTRA_USAGE_TIME_REPORT_PACKAGES = "android.usage_time_packages"; 54b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 55b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn /** 566de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * The package name that created the options. 576de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 586de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 59a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_PACKAGE_NAME = "android:activity.packageName"; 606de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 616de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 628078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Type of animation that arguments specify. 638078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 648078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 65a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_TYPE = "android:activity.animType"; 668078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 678078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 686de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Custom enter animation resource ID. 696de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 706de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 71a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_ENTER_RES_ID = "android:activity.animEnterRes"; 726de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 736de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 746de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Custom exit animation resource ID. 756de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @hide 766de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 77a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_EXIT_RES_ID = "android:activity.animExitRes"; 786de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 798078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 80044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * Custom in-place animation resource ID. 81044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * @hide 82044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung */ 83a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_IN_PLACE_RES_ID = "android:activity.animInPlaceRes"; 84044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung 85044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung /** 868078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Bitmap for thumbnail animation. 878078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 888078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 89a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_THUMBNAIL = "android:activity.animThumbnail"; 908078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 918078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 928078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Start X position of thumbnail animation. 938078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 948078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 95a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_START_X = "android:activity.animStartX"; 968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 988078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Start Y position of thumbnail animation. 998078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 1008078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 101a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_START_Y = "android:activity.animStartY"; 1028078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 1038078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 104eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Initial width of the animation. 105eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @hide 106eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 107a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_WIDTH = "android:activity.animWidth"; 108eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 109eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 110eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Initial height of the animation. 111eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @hide 112eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 113a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_HEIGHT = "android:activity.animHeight"; 114eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 115eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 1168078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Callback for when animation is started. 1178078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @hide 1188078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 119a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn public static final String KEY_ANIM_START_LISTENER = "android:activity.animStartListener"; 1208078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 12118e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell /** 1220a778eda690a66173733a63622886e888d405c45George Mount * For Activity transitions, the calling Activity's TransitionListener used to 1230a778eda690a66173733a63622886e888d405c45George Mount * notify the called Activity when the shared element and the exit transitions 1240a778eda690a66173733a63622886e888d405c45George Mount * complete. 12518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell */ 1260a778eda690a66173733a63622886e888d405c45George Mount private static final String KEY_TRANSITION_COMPLETE_LISTENER 127a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn = "android:activity.transitionCompleteListener"; 128a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn 129a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_TRANSITION_IS_RETURNING 130a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn = "android:activity.transitionIsReturning"; 131a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_TRANSITION_SHARED_ELEMENTS 132a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn = "android:activity.sharedElementNames"; 133a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_RESULT_DATA = "android:activity.resultData"; 134a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_RESULT_CODE = "android:activity.resultCode"; 135a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_EXIT_COORDINATOR_INDEX 136a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn = "android:activity.exitCoordinatorIndex"; 137a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn 138a750a63d639f6936af456df904fa6b9ba941885eDianne Hackborn private static final String KEY_USAGE_TIME_REPORT = "android:activity.usageTimeReport"; 139b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 1408078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 1418078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final int ANIM_NONE = 0; 1428078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 1438078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static final int ANIM_CUSTOM = 1; 1448078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 145eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static final int ANIM_SCALE_UP = 2; 146eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 147832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static final int ANIM_THUMBNAIL_SCALE_UP = 3; 14821385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka /** @hide */ 149832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4; 15018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell /** @hide */ 15118e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell public static final int ANIM_SCENE_TRANSITION = 5; 1520b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount /** @hide */ 1530b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount public static final int ANIM_DEFAULT = 6; 154bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner /** @hide */ 155bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner public static final int ANIM_LAUNCH_TASK_BEHIND = 7; 156a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung /** @hide */ 157a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung public static final int ANIM_THUMBNAIL_ASPECT_SCALE_UP = 8; 158a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung /** @hide */ 159a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung public static final int ANIM_THUMBNAIL_ASPECT_SCALE_DOWN = 9; 160044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung /** @hide */ 161044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung public static final int ANIM_CUSTOM_IN_PLACE = 10; 16210e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase /** @hide */ 16310e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase public static final int ANIM_CLIP_REVEAL = 11; 1648078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 1656de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private String mPackageName; 1668078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mAnimationType = ANIM_NONE; 1676de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private int mCustomEnterResId; 1686de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private int mCustomExitResId; 169044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung private int mCustomInPlaceResId; 1708078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private Bitmap mThumbnail; 1718078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mStartX; 1728078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private int mStartY; 1732e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung private int mWidth; 1742e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung private int mHeight; 1758078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn private IRemoteCallback mAnimationStartedListener; 17662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount private ResultReceiver mTransitionReceiver; 17762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount private boolean mIsReturning; 17862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount private ArrayList<String> mSharedElementNames; 17962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount private Intent mResultData; 18062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount private int mResultCode; 1811fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount private int mExitCoordinatorIndex; 182b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn private PendingIntent mUsageTimeReport; 1836de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 1846de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 1856de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Create an ActivityOptions specifying a custom animation to run when 1866de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the activity is displayed. 1876de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * 1886de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param context Who is defining this. This is the application that the 1896de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * animation resources will be loaded from. 1906de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param enterResId A resource ID of the animation resource to use for 1916de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the incoming activity. Use 0 for no animation. 1926de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @param exitResId A resource ID of the animation resource to use for 1936de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * the outgoing activity. Use 0 for no animation. 1946de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 1956de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * supply these options as the options Bundle when starting an activity. 1966de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 1976de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public static ActivityOptions makeCustomAnimation(Context context, 1986de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn int enterResId, int exitResId) { 19984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn return makeCustomAnimation(context, enterResId, exitResId, null, null); 20084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 20184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn 20284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn /** 20384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * Create an ActivityOptions specifying a custom animation to run when 20484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the activity is displayed. 20584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * 20684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param context Who is defining this. This is the application that the 20784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * animation resources will be loaded from. 20884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param enterResId A resource ID of the animation resource to use for 20984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the incoming activity. Use 0 for no animation. 21084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param exitResId A resource ID of the animation resource to use for 21184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * the outgoing activity. Use 0 for no animation. 21284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param handler If <var>listener</var> is non-null this must be a valid 21384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * Handler on which to dispatch the callback; otherwise it should be null. 21484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @param listener Optional OnAnimationStartedListener to find out when the 21584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * requested animation has started running. If for some reason the animation 21684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * is not executed, the callback will happen immediately. 21784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 21884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * supply these options as the options Bundle when starting an activity. 21984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn * @hide 22084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn */ 22184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn public static ActivityOptions makeCustomAnimation(Context context, 22284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn int enterResId, int exitResId, Handler handler, OnAnimationStartedListener listener) { 2236de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn ActivityOptions opts = new ActivityOptions(); 2246de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mPackageName = context.getPackageName(); 2258078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mAnimationType = ANIM_CUSTOM; 2266de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mCustomEnterResId = enterResId; 2276de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn opts.mCustomExitResId = exitResId; 22818e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell opts.setOnAnimationStartedListener(handler, listener); 2296de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return opts; 2306de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 2316de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 232044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung /** 233044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * Creates an ActivityOptions specifying a custom animation to run in place on an existing 234044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * activity. 235044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * 236044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * @param context Who is defining this. This is the application that the 237044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * animation resources will be loaded from. 238044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * @param animId A resource ID of the animation resource to use for 239044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * the incoming activity. 240044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * @return Returns a new ActivityOptions object that you can use to 241044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * supply these options as the options Bundle when running an in-place animation. 242044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung * @hide 243044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung */ 244044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung public static ActivityOptions makeCustomInPlaceAnimation(Context context, int animId) { 245044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung if (animId == 0) { 246044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung throw new RuntimeException("You must specify a valid animation."); 247044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung } 248044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung 249044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung ActivityOptions opts = new ActivityOptions(); 250044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung opts.mPackageName = context.getPackageName(); 251044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung opts.mAnimationType = ANIM_CUSTOM_IN_PLACE; 252044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung opts.mCustomInPlaceResId = animId; 253044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung return opts; 254044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung } 255044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung 25618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell private void setOnAnimationStartedListener(Handler handler, 25718e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell OnAnimationStartedListener listener) { 25884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn if (listener != null) { 25984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn final Handler h = handler; 26084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn final OnAnimationStartedListener finalListener = listener; 26184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = new IRemoteCallback.Stub() { 26284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn @Override public void sendResult(Bundle data) throws RemoteException { 26384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn h.post(new Runnable() { 26484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn @Override public void run() { 26584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn finalListener.onAnimationStarted(); 26684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 26784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn }); 26884375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 26984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn }; 27084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 27184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 27284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn 2738078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** 2748078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Callback for use with {@link ActivityOptions#makeThumbnailScaleUpAnimation} 2758078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * to find out when the given animation has started running. 2769944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @hide 2778078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 2788078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public interface OnAnimationStartedListener { 2798078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn void onAnimationStarted(); 2808078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 2818078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 28218e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell /** 283eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * Create an ActivityOptions specifying an animation where the new 284eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * activity is scaled from a small originating area of the screen to 285eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * its final full representation. 286eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * 287d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * <p>If the Intent this is being used with has not set its 288d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, 289d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * those bounds will be filled in for you based on the initial 290d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * bounds passed in here. 291d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * 292eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param source The View that the new activity is animating from. This 293eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 294eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the new activity, relative to <var>source</var>. 295eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the activity, relative to <var>source</var>. 2962e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung * @param width The initial width of the new activity. 2972e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung * @param height The initial height of the new activity. 298eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 299eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * supply these options as the options Bundle when starting an activity. 300eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn */ 301eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn public static ActivityOptions makeScaleUpAnimation(View source, 3022e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung int startX, int startY, int width, int height) { 303eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn ActivityOptions opts = new ActivityOptions(); 304eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mPackageName = source.getContext().getPackageName(); 305eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mAnimationType = ANIM_SCALE_UP; 306eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn int[] pts = new int[2]; 307eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn source.getLocationOnScreen(pts); 308eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartX = pts[0] + startX; 309eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn opts.mStartY = pts[1] + startY; 3102e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung opts.mWidth = width; 3112e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung opts.mHeight = height; 312eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn return opts; 313eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 314eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 315eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** 31610e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * Create an ActivityOptions specifying an animation where the new 31710e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * activity is revealed from a small originating area of the screen to 31810e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * its final full representation. 31910e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * 32010e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @param source The View that the new activity is animating from. This 32110e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * defines the coordinate space for <var>startX</var> and <var>startY</var>. 32210e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @param startX The x starting location of the new activity, relative to <var>source</var>. 32310e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @param startY The y starting location of the activity, relative to <var>source</var>. 32410e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @param width The initial width of the new activity. 32510e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @param height The initial height of the new activity. 32610e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * @return Returns a new ActivityOptions object that you can use to 32710e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase * supply these options as the options Bundle when starting an activity. 32810e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase */ 32910e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase public static ActivityOptions makeClipRevealAnimation(View source, 33010e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase int startX, int startY, int width, int height) { 33110e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase ActivityOptions opts = new ActivityOptions(); 33210e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase opts.mAnimationType = ANIM_CLIP_REVEAL; 33310e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase int[] pts = new int[2]; 33410e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase source.getLocationOnScreen(pts); 33510e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase opts.mStartX = pts[0] + startX; 33610e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase opts.mStartY = pts[1] + startY; 33710e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase opts.mWidth = width; 33810e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase opts.mHeight = height; 33910e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase return opts; 34010e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase } 34110e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase 34210e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase /** 3438078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * Create an ActivityOptions specifying an animation where a thumbnail 3448078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * is scaled from a given position to the new activity window that is 3458078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * being started. 3468078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * 347d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * <p>If the Intent this is being used with has not set its 348d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * {@link android.content.Intent#setSourceBounds Intent.setSourceBounds}, 349d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * those bounds will be filled in for you based on the initial 350d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * thumbnail location and size provided here. 351d367ca88eeede24e7d9a51ae85996a9d08d734b2Dianne Hackborn * 3528078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param source The View that this thumbnail is animating from. This 3538078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 3548078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param thumbnail The bitmap that will be shown as the initial thumbnail 3558078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * of the animation. 356eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the bitmap, relative to <var>source</var>. 357eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the bitmap, relative to <var>source</var>. 3589944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @return Returns a new ActivityOptions object that you can use to 3599944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * supply these options as the options Bundle when starting an activity. 3609944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn */ 3619944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn public static ActivityOptions makeThumbnailScaleUpAnimation(View source, 3629944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn Bitmap thumbnail, int startX, int startY) { 3639944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn return makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY, null); 3649944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn } 3659944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn 3669944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn /** 3679944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * Create an ActivityOptions specifying an animation where a thumbnail 3689944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * is scaled from a given position to the new activity window that is 3699944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * being started. 3709944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * 3719944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @param source The View that this thumbnail is animating from. This 3729944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * defines the coordinate space for <var>startX</var> and <var>startY</var>. 3739944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @param thumbnail The bitmap that will be shown as the initial thumbnail 3749944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * of the animation. 375eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startX The x starting location of the bitmap, relative to <var>source</var>. 376eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn * @param startY The y starting location of the bitmap, relative to <var>source</var>. 3778078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @param listener Optional OnAnimationStartedListener to find out when the 3788078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * requested animation has started running. If for some reason the animation 3798078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * is not executed, the callback will happen immediately. 3808078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * @return Returns a new ActivityOptions object that you can use to 3818078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn * supply these options as the options Bundle when starting an activity. 3829944ecd28e1c56c4e9f0a50ed6e8be2110ba5c31Dianne Hackborn * @hide 3838078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn */ 3848078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public static ActivityOptions makeThumbnailScaleUpAnimation(View source, 3858078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { 386832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, true); 38721385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka } 38821385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka 38921385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka /** 390832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * Create an ActivityOptions specifying an animation where an activity window 391832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * is scaled from a given position to a thumbnail at a specified location. 39221385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * 393832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param source The View that this thumbnail is animating to. This 39421385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * defines the coordinate space for <var>startX</var> and <var>startY</var>. 395832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param thumbnail The bitmap that will be shown as the final thumbnail 39621385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * of the animation. 397832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param startX The x end location of the bitmap, relative to <var>source</var>. 398832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka * @param startY The y end location of the bitmap, relative to <var>source</var>. 39921385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @param listener Optional OnAnimationStartedListener to find out when the 40021385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * requested animation has started running. If for some reason the animation 40121385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * is not executed, the callback will happen immediately. 40221385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @return Returns a new ActivityOptions object that you can use to 40321385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * supply these options as the options Bundle when starting an activity. 40421385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka * @hide 40521385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka */ 406832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka public static ActivityOptions makeThumbnailScaleDownAnimation(View source, 40721385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener) { 408832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka return makeThumbnailAnimation(source, thumbnail, startX, startY, listener, false); 40921385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka } 41021385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka 411832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka private static ActivityOptions makeThumbnailAnimation(View source, 41221385cd83d7d7938b57a4acbaa236dd4c7804ed4Michael Jurka Bitmap thumbnail, int startX, int startY, OnAnimationStartedListener listener, 413832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka boolean scaleUp) { 4148078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn ActivityOptions opts = new ActivityOptions(); 4158078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mPackageName = source.getContext().getPackageName(); 416832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_SCALE_UP : ANIM_THUMBNAIL_SCALE_DOWN; 4178078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mThumbnail = thumbnail; 4188078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn int[] pts = new int[2]; 4198078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn source.getLocationOnScreen(pts); 4208078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mStartX = pts[0] + startX; 4218078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn opts.mStartY = pts[1] + startY; 42218e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell opts.setOnAnimationStartedListener(source.getHandler(), listener); 42318e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell return opts; 42418e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell } 42518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell 42618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell /** 427a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * Create an ActivityOptions specifying an animation where the new activity 428a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * window and a thumbnail is aspect-scaled to a new location. 429a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * 430a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param source The View that this thumbnail is animating from. This 431a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * defines the coordinate space for <var>startX</var> and <var>startY</var>. 432a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param thumbnail The bitmap that will be shown as the initial thumbnail 433a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * of the animation. 434a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param startX The x starting location of the bitmap, relative to <var>source</var>. 435a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param startY The y starting location of the bitmap, relative to <var>source</var>. 436e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung * @param handler If <var>listener</var> is non-null this must be a valid 437e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung * Handler on which to dispatch the callback; otherwise it should be null. 438a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param listener Optional OnAnimationStartedListener to find out when the 439a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * requested animation has started running. If for some reason the animation 440a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * is not executed, the callback will happen immediately. 441a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @return Returns a new ActivityOptions object that you can use to 442a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * supply these options as the options Bundle when starting an activity. 443a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @hide 444a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung */ 445a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung public static ActivityOptions makeThumbnailAspectScaleUpAnimation(View source, 4462e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight, 447e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung Handler handler, OnAnimationStartedListener listener) { 4482e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, 449e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung targetWidth, targetHeight, handler, listener, true); 450a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung } 451a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung 452a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung /** 453a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * Create an ActivityOptions specifying an animation where the new activity 454a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * window and a thumbnail is aspect-scaled to a new location. 455a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * 456a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param source The View that this thumbnail is animating to. This 457a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * defines the coordinate space for <var>startX</var> and <var>startY</var>. 458a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param thumbnail The bitmap that will be shown as the final thumbnail 459a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * of the animation. 460a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param startX The x end location of the bitmap, relative to <var>source</var>. 461a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param startY The y end location of the bitmap, relative to <var>source</var>. 462e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung * @param handler If <var>listener</var> is non-null this must be a valid 463e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung * Handler on which to dispatch the callback; otherwise it should be null. 464a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @param listener Optional OnAnimationStartedListener to find out when the 465a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * requested animation has started running. If for some reason the animation 466a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * is not executed, the callback will happen immediately. 467a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @return Returns a new ActivityOptions object that you can use to 468a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * supply these options as the options Bundle when starting an activity. 469a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung * @hide 470a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung */ 471a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung public static ActivityOptions makeThumbnailAspectScaleDownAnimation(View source, 4722e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung Bitmap thumbnail, int startX, int startY, int targetWidth, int targetHeight, 473e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung Handler handler, OnAnimationStartedListener listener) { 4742e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung return makeAspectScaledThumbnailAnimation(source, thumbnail, startX, startY, 475e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung targetWidth, targetHeight, handler, listener, false); 476a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung } 477a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung 478a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung private static ActivityOptions makeAspectScaledThumbnailAnimation(View source, Bitmap thumbnail, 4792e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung int startX, int startY, int targetWidth, int targetHeight, 480e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung Handler handler, OnAnimationStartedListener listener, boolean scaleUp) { 481a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung ActivityOptions opts = new ActivityOptions(); 482a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung opts.mPackageName = source.getContext().getPackageName(); 483a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung opts.mAnimationType = scaleUp ? ANIM_THUMBNAIL_ASPECT_SCALE_UP : 484a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung ANIM_THUMBNAIL_ASPECT_SCALE_DOWN; 485a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung opts.mThumbnail = thumbnail; 486a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung int[] pts = new int[2]; 487a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung source.getLocationOnScreen(pts); 488a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung opts.mStartX = pts[0] + startX; 489a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung opts.mStartY = pts[1] + startY; 4902e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung opts.mWidth = targetWidth; 4912e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung opts.mHeight = targetHeight; 492e494c382c0caf35f225dfb55f0e3b992c14d79f5Winson Chung opts.setOnAnimationStartedListener(handler, listener); 493a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung return opts; 494a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung } 495a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung 496a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung /** 497e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * Create an ActivityOptions to transition between Activities using cross-Activity scene 498e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * animations. This method carries the position of one shared element to the started Activity. 49931a217290cf376d0573fc36e21c8940987485019George Mount * The position of <code>sharedElement</code> will be used as the epicenter for the 50031a217290cf376d0573fc36e21c8940987485019George Mount * exit Transition. The position of the shared element in the launched Activity will be the 50131a217290cf376d0573fc36e21c8940987485019George Mount * epicenter of its entering Transition. 5020a778eda690a66173733a63622886e888d405c45George Mount * 5039826f636ad4fe3714d60972acd918e09eb44d971George Mount * <p>This requires {@link android.view.Window#FEATURE_ACTIVITY_TRANSITIONS} to be 5040a778eda690a66173733a63622886e888d405c45George Mount * enabled on the calling Activity to cause an exit transition. The same must be in 5050a778eda690a66173733a63622886e888d405c45George Mount * the called Activity to get an entering transition.</p> 50662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * @param activity The Activity whose window contains the shared elements. 5070b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount * @param sharedElement The View to transition to the started Activity. 5080b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount * @param sharedElementName The shared element name as used in the target Activity. This 5090b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount * must not be null. 510e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * @return Returns a new ActivityOptions object that you can use to 511e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * supply these options as the options Bundle when starting an activity. 51231a217290cf376d0573fc36e21c8940987485019George Mount * @see android.transition.Transition#setEpicenterCallback( 51331a217290cf376d0573fc36e21c8940987485019George Mount * android.transition.Transition.EpicenterCallback) 514e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount */ 51562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public static ActivityOptions makeSceneTransitionAnimation(Activity activity, 51631a217290cf376d0573fc36e21c8940987485019George Mount View sharedElement, String sharedElementName) { 51762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount return makeSceneTransitionAnimation(activity, Pair.create(sharedElement, sharedElementName)); 518e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount } 519e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount 520e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount /** 521e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * Create an ActivityOptions to transition between Activities using cross-Activity scene 522e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * animations. This method carries the position of multiple shared elements to the started 52362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * Activity. The position of the first element in sharedElements 52431a217290cf376d0573fc36e21c8940987485019George Mount * will be used as the epicenter for the exit Transition. The position of the associated 52531a217290cf376d0573fc36e21c8940987485019George Mount * shared element in the launched Activity will be the epicenter of its entering Transition. 5260a778eda690a66173733a63622886e888d405c45George Mount * 5279826f636ad4fe3714d60972acd918e09eb44d971George Mount * <p>This requires {@link android.view.Window#FEATURE_ACTIVITY_TRANSITIONS} to be 528e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * enabled on the calling Activity to cause an exit transition. The same must be in 529e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * the called Activity to get an entering transition.</p> 53062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * @param activity The Activity whose window contains the shared elements. 53162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * @param sharedElements The names of the shared elements to transfer to the called 53262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * Activity and their associated Views. The Views must each have 53362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount * a unique shared element name. 534e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * @return Returns a new ActivityOptions object that you can use to 535e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount * supply these options as the options Bundle when starting an activity. 53631a217290cf376d0573fc36e21c8940987485019George Mount * @see android.transition.Transition#setEpicenterCallback( 53731a217290cf376d0573fc36e21c8940987485019George Mount * android.transition.Transition.EpicenterCallback) 53818e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell */ 53962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public static ActivityOptions makeSceneTransitionAnimation(Activity activity, 54062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount Pair<View, String>... sharedElements) { 5410b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount ActivityOptions opts = new ActivityOptions(); 5429826f636ad4fe3714d60972acd918e09eb44d971George Mount if (!activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { 5430b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount opts.mAnimationType = ANIM_DEFAULT; 5440b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount return opts; 5455d1be5364412450afdbf7525f7431bdb4625f377George Mount } 54618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell opts.mAnimationType = ANIM_SCENE_TRANSITION; 54762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 54862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount ArrayList<String> names = new ArrayList<String>(); 5491fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount ArrayList<View> views = new ArrayList<View>(); 55062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 55162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount if (sharedElements != null) { 55262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount for (int i = 0; i < sharedElements.length; i++) { 55362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount Pair<View, String> sharedElement = sharedElements[i]; 554d5f9d735b7e48f2ac60773c9c76b4b5f19a0cc72George Mount String sharedElementName = sharedElement.second; 555d5f9d735b7e48f2ac60773c9c76b4b5f19a0cc72George Mount if (sharedElementName == null) { 556d5f9d735b7e48f2ac60773c9c76b4b5f19a0cc72George Mount throw new IllegalArgumentException("Shared element name must not be null"); 557d5f9d735b7e48f2ac60773c9c76b4b5f19a0cc72George Mount } 558d5f9d735b7e48f2ac60773c9c76b4b5f19a0cc72George Mount names.add(sharedElementName); 5591fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount View view = sharedElement.first; 5601fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount if (view == null) { 5611fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount throw new IllegalArgumentException("Shared element must not be null"); 5621fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount } 5631fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount views.add(sharedElement.first); 56462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount } 56562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount } 56662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 56762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount ExitTransitionCoordinator exit = new ExitTransitionCoordinator(activity, names, names, 5681fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount views, false); 56962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mTransitionReceiver = exit; 57062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mSharedElementNames = names; 57162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mIsReturning = false; 5721fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount opts.mExitCoordinatorIndex = 5731fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount activity.mActivityTransitionState.addExitTransitionCoordinator(exit); 57462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount return opts; 57562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount } 57662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 57762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 57862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public static ActivityOptions makeSceneTransitionAnimation(Activity activity, 57962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount ExitTransitionCoordinator exitCoordinator, ArrayList<String> sharedElementNames, 58062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount int resultCode, Intent resultData) { 58162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount ActivityOptions opts = new ActivityOptions(); 58262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mAnimationType = ANIM_SCENE_TRANSITION; 58362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mSharedElementNames = sharedElementNames; 58462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mTransitionReceiver = exitCoordinator; 58562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mIsReturning = true; 58662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mResultCode = resultCode; 58762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount opts.mResultData = resultData; 5881fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount opts.mExitCoordinatorIndex = 5891fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount activity.mActivityTransitionState.addExitTransitionCoordinator(exitCoordinator); 5908078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return opts; 5918078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 5928078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 593bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner /** 594bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be 595bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * presented to the user but will instead be only available through the recents task list. 596bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * In addition, the new task wil be affiliated with the launching activity's task. 597bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * Affiliated tasks are grouped together in the recents task list. 598bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * 599bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * <p>This behavior is not supported for activities with {@link 600bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * android.R.styleable#AndroidManifestActivity_launchMode launchMode} values of 601bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner * <code>singleInstance</code> or <code>singleTask</code>. 602bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner */ 6033b2cd1d59fd894ac67a044c6c540fa69360a34a2Craig Mautner public static ActivityOptions makeTaskLaunchBehind() { 604bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner final ActivityOptions opts = new ActivityOptions(); 605bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner opts.mAnimationType = ANIM_LAUNCH_TASK_BEHIND; 606bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner return opts; 607bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner } 608bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner 609b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn /** 610b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * Create a basic ActivityOptions that has no special animation associated with it. 611b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * Other options can still be set. 612b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn */ 613b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn public static ActivityOptions makeBasic() { 614b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn final ActivityOptions opts = new ActivityOptions(); 615b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn return opts; 616b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } 617b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 618bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner /** @hide */ 619bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner public boolean getLaunchTaskBehind() { 620bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner return mAnimationType == ANIM_LAUNCH_TASK_BEHIND; 621bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner } 622bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner 6236de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn private ActivityOptions() { 6246de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6256de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6266de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 6276de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public ActivityOptions(Bundle opts) { 6286de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mPackageName = opts.getString(KEY_PACKAGE_NAME); 629b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn try { 630b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT); 631b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } catch (RuntimeException e) { 632b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn Slog.w(TAG, e); 633b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } 6348078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationType = opts.getInt(KEY_ANIM_TYPE); 63518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell switch (mAnimationType) { 63618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_CUSTOM: 63718e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0); 63818e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0); 63918e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener = IRemoteCallback.Stub.asInterface( 64018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell opts.getBinder(KEY_ANIM_START_LISTENER)); 64118e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell break; 64218e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell 643044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung case ANIM_CUSTOM_IN_PLACE: 644044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung mCustomInPlaceResId = opts.getInt(KEY_ANIM_IN_PLACE_RES_ID, 0); 645044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung break; 646044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung 64718e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_SCALE_UP: 64810e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase case ANIM_CLIP_REVEAL: 64918e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mStartX = opts.getInt(KEY_ANIM_START_X, 0); 65018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mStartY = opts.getInt(KEY_ANIM_START_Y, 0); 6512e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); 6522e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); 65318e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell break; 65418e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell 65518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_THUMBNAIL_SCALE_UP: 65618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_THUMBNAIL_SCALE_DOWN: 657a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_UP: 658a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: 659a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung mThumbnail = (Bitmap) opts.getParcelable(KEY_ANIM_THUMBNAIL); 66018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mStartX = opts.getInt(KEY_ANIM_START_X, 0); 66118e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mStartY = opts.getInt(KEY_ANIM_START_Y, 0); 6622e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); 6632e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mHeight = opts.getInt(KEY_ANIM_HEIGHT, 0); 66418e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener = IRemoteCallback.Stub.asInterface( 66518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell opts.getBinder(KEY_ANIM_START_LISTENER)); 66618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell break; 66718e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell 66818e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_SCENE_TRANSITION: 66962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mTransitionReceiver = opts.getParcelable(KEY_TRANSITION_COMPLETE_LISTENER); 67062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mIsReturning = opts.getBoolean(KEY_TRANSITION_IS_RETURNING, false); 67162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mSharedElementNames = opts.getStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS); 67262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultData = opts.getParcelable(KEY_RESULT_DATA); 67362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultCode = opts.getInt(KEY_RESULT_CODE); 6741fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount mExitCoordinatorIndex = opts.getInt(KEY_EXIT_COORDINATOR_INDEX); 67518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell break; 6766de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6776de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6786de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6796de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 6806de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public String getPackageName() { 6816de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mPackageName; 6826de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6836de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6846de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 6858078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getAnimationType() { 6868078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mAnimationType; 6876de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6886de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6896de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 6906de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public int getCustomEnterResId() { 6916de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mCustomEnterResId; 6926de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6936de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6946de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** @hide */ 6956de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public int getCustomExitResId() { 6966de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return mCustomExitResId; 6976de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 6986de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 6998078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 700044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung public int getCustomInPlaceResId() { 701044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung return mCustomInPlaceResId; 702044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung } 703044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung 704044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung /** @hide */ 7058078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public Bitmap getThumbnail() { 7068078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mThumbnail; 7078078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7088078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 7098078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 7108078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getStartX() { 7118078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mStartX; 7128078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7138078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 7148078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 7158078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public int getStartY() { 7168078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn return mStartY; 7178078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7188078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 7198078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 7202e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung public int getWidth() { 7212e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung return mWidth; 722eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 723eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 724eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 7252e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung public int getHeight() { 7262e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung return mHeight; 727eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn } 728eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn 729eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn /** @hide */ 730206e30cd93afe3eb72ec94178324417db5424ed2George Mount public IRemoteCallback getOnAnimationStartListener() { 731206e30cd93afe3eb72ec94178324417db5424ed2George Mount return mAnimationStartedListener; 732206e30cd93afe3eb72ec94178324417db5424ed2George Mount } 733f10587faadb9080a7bf9991cbe04bac5525da482George Mount 734f10587faadb9080a7bf9991cbe04bac5525da482George Mount /** @hide */ 7351fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount public int getExitCoordinatorKey() { return mExitCoordinatorIndex; } 736e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount 737e180337ee99b9155fe441ea55451f4d2167b5d9aGeorge Mount /** @hide */ 7388078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn public void abort() { 7398078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn if (mAnimationStartedListener != null) { 7408078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn try { 7418078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationStartedListener.sendResult(null); 7428078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } catch (RemoteException e) { 7438078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7448078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7458078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 7468078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn 7478078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn /** @hide */ 74862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public boolean isReturning() { 74962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount return mIsReturning; 75062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount } 75162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 75262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 75362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public ArrayList<String> getSharedElementNames() { 75462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount return mSharedElementNames; 75562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount } 75662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 75762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 75862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public ResultReceiver getResultReceiver() { return mTransitionReceiver; } 75962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 76062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 76162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public int getResultCode() { return mResultCode; } 76262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 76362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 76462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public Intent getResultData() { return mResultData; } 76562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 76662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount /** @hide */ 767b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn public PendingIntent getUsageTimeReport() { 768b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn return mUsageTimeReport; 769b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } 770b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 771b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn /** @hide */ 77262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount public static void abort(Bundle options) { 77362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount if (options != null) { 77462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount (new ActivityOptions(options)).abort(); 77531a217290cf376d0573fc36e21c8940987485019George Mount } 77631a217290cf376d0573fc36e21c8940987485019George Mount } 77731a217290cf376d0573fc36e21c8940987485019George Mount 7786de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 779ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn * Update the current values in this ActivityOptions from those supplied 780ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn * in <var>otherOptions</var>. Any values 7816de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * defined in <var>otherOptions</var> replace those in the base options. 7826de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 783ddc52a80b5280d4a67180a6caae8c7dead00157fDianne Hackborn public void update(ActivityOptions otherOptions) { 7846de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn if (otherOptions.mPackageName != null) { 7856de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn mPackageName = otherOptions.mPackageName; 7866de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 787b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn mUsageTimeReport = otherOptions.mUsageTimeReport; 78862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mTransitionReceiver = null; 78962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mSharedElementNames = null; 79062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mIsReturning = false; 79162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultData = null; 79262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultCode = 0; 7931fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount mExitCoordinatorIndex = 0; 79400dde0bd469ba7a34369dcaaa701bd06fdf6c3adGeorge Mount mAnimationType = otherOptions.mAnimationType; 7958078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn switch (otherOptions.mAnimationType) { 7968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn case ANIM_CUSTOM: 7978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mCustomEnterResId = otherOptions.mCustomEnterResId; 7988078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mCustomExitResId = otherOptions.mCustomExitResId; 7998078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mThumbnail = null; 80018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell if (mAnimationStartedListener != null) { 80184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn try { 80218e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener.sendResult(null); 80384375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } catch (RemoteException e) { 80484375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 80584375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 80684375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = otherOptions.mAnimationStartedListener; 8078078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 808044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung case ANIM_CUSTOM_IN_PLACE: 809044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung mCustomInPlaceResId = otherOptions.mCustomInPlaceResId; 810044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung break; 811eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn case ANIM_SCALE_UP: 812eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartX = otherOptions.mStartX; 813eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn mStartY = otherOptions.mStartY; 8142e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mWidth = otherOptions.mWidth; 8152e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mHeight = otherOptions.mHeight; 81618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell if (mAnimationStartedListener != null) { 81784375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn try { 81818e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener.sendResult(null); 81984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } catch (RemoteException e) { 82084375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 82184375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn } 82284375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn mAnimationStartedListener = null; 823eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 824832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_UP: 825832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_DOWN: 826a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_UP: 827a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: 8288078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mThumbnail = otherOptions.mThumbnail; 8298078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartX = otherOptions.mStartX; 8308078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mStartY = otherOptions.mStartY; 8312e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mWidth = otherOptions.mWidth; 8322e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung mHeight = otherOptions.mHeight; 83318e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell if (mAnimationStartedListener != null) { 8348078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn try { 83518e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener.sendResult(null); 8368078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } catch (RemoteException e) { 8378078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 8388078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn } 8398078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn mAnimationStartedListener = otherOptions.mAnimationStartedListener; 84018e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell break; 84118e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell case ANIM_SCENE_TRANSITION: 84262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mTransitionReceiver = otherOptions.mTransitionReceiver; 84362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mSharedElementNames = otherOptions.mSharedElementNames; 84462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mIsReturning = otherOptions.mIsReturning; 845cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell mThumbnail = null; 84618e905f42d017c4721d33bd25d7d39ef8d64b5d5Adam Powell mAnimationStartedListener = null; 84762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultData = otherOptions.mResultData; 84862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount mResultCode = otherOptions.mResultCode; 8491fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount mExitCoordinatorIndex = otherOptions.mExitCoordinatorIndex; 8508078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 8516de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 8526de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 8536de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn 8546de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn /** 8556de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Returns the created options as a Bundle, which can be passed to 8566de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * {@link android.content.Context#startActivity(android.content.Intent, android.os.Bundle) 8576de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Context.startActivity(Intent, Bundle)} and related methods. 8586de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * Note that the returned Bundle is still owned by the ActivityOptions 8596de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * object; you must not modify it, but can supply it to the startActivity 8606de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn * methods that take an options Bundle. 8616de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn */ 8626de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn public Bundle toBundle() { 8630b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount if (mAnimationType == ANIM_DEFAULT) { 8640b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount return null; 8650b6f3e1afa78467cfe166c222295df1f7ed7d4c0George Mount } 8666de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn Bundle b = new Bundle(); 8676de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn if (mPackageName != null) { 8686de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn b.putString(KEY_PACKAGE_NAME, mPackageName); 8696de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 870bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner b.putInt(KEY_ANIM_TYPE, mAnimationType); 871b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn if (mUsageTimeReport != null) { 872b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn b.putParcelable(KEY_USAGE_TIME_REPORT, mUsageTimeReport); 873b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } 8748078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn switch (mAnimationType) { 8758078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn case ANIM_CUSTOM: 8768078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId); 8778078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId); 878cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener 87984375876fcef73c5fa9c3de205c7db908ee14e15Dianne Hackborn != null ? mAnimationStartedListener.asBinder() : null); 8808078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn break; 881044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung case ANIM_CUSTOM_IN_PLACE: 882044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung b.putInt(KEY_ANIM_IN_PLACE_RES_ID, mCustomInPlaceResId); 883044d52934e57a337665f707aa4be1d423ee3fb29Winson Chung break; 884eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn case ANIM_SCALE_UP: 88510e23ab61b820fb3149b2f89003753d98ebd6a80Chet Haase case ANIM_CLIP_REVEAL: 886eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_X, mStartX); 887eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn b.putInt(KEY_ANIM_START_Y, mStartY); 8882e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung b.putInt(KEY_ANIM_WIDTH, mWidth); 8892e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung b.putInt(KEY_ANIM_HEIGHT, mHeight); 890eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 891832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_UP: 892832cb229cd748505c90f74ae8154fc3557d61a73Michael Jurka case ANIM_THUMBNAIL_SCALE_DOWN: 893a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_UP: 894a4ccb86ddc8f9f486aee25fb836f4aff97bf7679Winson Chung case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: 8958078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail); 8968078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_START_X, mStartX); 8978078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn b.putInt(KEY_ANIM_START_Y, mStartY); 8982e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung b.putInt(KEY_ANIM_WIDTH, mWidth); 8992e7f3bdcc9ec0b3e95b565b943ecee2210f4b937Winson Chung b.putInt(KEY_ANIM_HEIGHT, mHeight); 900cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener 9018078d8c8a282ca81344febe7256f63b1e805e3aaDianne Hackborn != null ? mAnimationStartedListener.asBinder() : null); 902eabfb3a36e9469c5e219f92b39b7200104319185Dianne Hackborn break; 903cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell case ANIM_SCENE_TRANSITION: 90462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount if (mTransitionReceiver != null) { 90562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount b.putParcelable(KEY_TRANSITION_COMPLETE_LISTENER, mTransitionReceiver); 9060a778eda690a66173733a63622886e888d405c45George Mount } 90762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount b.putBoolean(KEY_TRANSITION_IS_RETURNING, mIsReturning); 90862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount b.putStringArrayList(KEY_TRANSITION_SHARED_ELEMENTS, mSharedElementNames); 90962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount b.putParcelable(KEY_RESULT_DATA, mResultData); 91062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount b.putInt(KEY_RESULT_CODE, mResultCode); 9111fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount b.putInt(KEY_EXIT_COORDINATOR_INDEX, mExitCoordinatorIndex); 912cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell break; 9136de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 914bb742462781a73bb25516067c8fe6311c1c8a93eCraig Mautner 9156de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn return b; 9166de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn } 917cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell 918cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell /** 919b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * Ask the the system track that time the user spends in the app being launched, and 920b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * report it back once done. The report will be sent to the given receiver, with 92167ba2c7fa25a635c640956ff3a5e64164cb23396Dianne Hackborn * the extras {@link #EXTRA_USAGE_TIME_REPORT} and {@link #EXTRA_USAGE_TIME_REPORT_PACKAGES} 922b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * filled in. 923b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * 924b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * <p>The time interval tracked is from launching this activity until the user leaves 925b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * that activity's flow. They are considered to stay in the flow as long as 926b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * new activities are being launched or returned to from the original flow, 927b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * even if this crosses package or task boundaries. For example, if the originator 928b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * starts an activity to view an image, and while there the user selects to share, 929b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * which launches their email app in a new task, and they complete the share, the 930b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * time during that entire operation will be included until they finally hit back from 931b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * the original image viewer activity.</p> 932b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * 933b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * <p>The user is considered to complete a flow once they switch to another 934b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * activity that is not part of the tracked flow. This may happen, for example, by 935b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * using the notification shade, launcher, or recents to launch or switch to another 936b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * app. Simply going in to these navigation elements does not break the flow (although 937b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * the launcher and recents stops time tracking of the session); it is the act of 938b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * going somewhere else that completes the tracking.</p> 939b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * 940b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn * @param receiver A broadcast receiver that willl receive the report. 941b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn */ 942b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn public void requestUsageTimeReport(PendingIntent receiver) { 943b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn mUsageTimeReport = receiver; 944b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn } 945b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn 946b5a380d409a1431a38db978864b9d85b689e3cceDianne Hackborn /** 947cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell * Return the filtered options only meant to be seen by the target activity itself 948cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell * @hide 949cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell */ 950cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell public ActivityOptions forTargetActivity() { 951cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell if (mAnimationType == ANIM_SCENE_TRANSITION) { 952cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell final ActivityOptions result = new ActivityOptions(); 953cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell result.update(this); 954cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell return result; 955cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell } 956cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell 957cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell return null; 958cfbe9be5b3b701d95fb24fa0f7c8d9be43eec776Adam Powell } 9590a778eda690a66173733a63622886e888d405c45George Mount 9606de01a9b03ad6f8a1af4a0d893d952caa4b69d39Dianne Hackborn} 961