summaryrefslogtreecommitdiff
path: root/core/java/android/app/ActivityOptions.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2013-11-06 14:58:58 -0800
committerAdam Powell <adamp@google.com>2013-12-05 10:06:19 -0800
commitcfbe9be5b3b701d95fb24fa0f7c8d9be43eec776 (patch)
treea130c8227af97db3cfe74f61daeb0b3a1181b752 /core/java/android/app/ActivityOptions.java
parentf254ed9a98bd343feefab3d5737568539b693605 (diff)
Add support for cross-activity scenes and transitions
* Add theme attributes for specifying a top-level TransitionManager for an activity window. * Add window feature for automatic content transitions. This automatically assigns/creates a Scene for setContentView calls. * Add named transitions. This allows apps to define APIs for handshake-agreements about which exit/entrance transitions to play. * Add new transition type for ActivityOptions. This lets the system use ActivityOptions to communicate transition specifics and arguments to the called activity. * Have ActivityManager pass appropriate ActivityOptions through to the called Activity. Have the called activity call back into the caller to let it know which transition of a possible requested set was chosen. Still to do: * Define and pass arguments for transitions. This will require defining a Parcelable version of TransitionValues and deciding how much leeway apps should have for these things. * Determine how to appropriately filter the ActivityOptions bundle so that only appropriate data reaches the target. * Determine if generalizing the auto-Scenes functionality to ViewGroups is appropriate. Change-Id: I10684b926129ab2fbc1adec9ef31767237acae79
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
-rw-r--r--core/java/android/app/ActivityOptions.java52
1 files changed, 48 insertions, 4 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index 44f68595a75e..582ce3c1e186 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -22,6 +22,8 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.RemoteException;
+import android.text.TextUtils;
+import android.util.Log;
import android.view.View;
/**
@@ -30,6 +32,8 @@ import android.view.View;
* Context.startActivity(Intent, Bundle)} and related methods.
*/
public class ActivityOptions {
+ private static final String TAG = "ActivityOptions";
+
/**
* The package name that created the options.
* @hide
@@ -481,8 +485,19 @@ public class ActivityOptions {
}
/** @hide */
- public IRemoteCallback getOnSceneTransitionStartedListener() {
- return mSceneTransitionStartedListener;
+ public void dispatchSceneTransitionStarted(String destScene) {
+ if (mSceneTransitionStartedListener != null) {
+ Bundle data = null;
+ if (!TextUtils.isEmpty(destScene)) {
+ data = new Bundle();
+ data.putString(KEY_DEST_SCENE_NAME_CHOSEN, destScene);
+ }
+ try {
+ mSceneTransitionStartedListener.sendResult(data);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Caught exception dispatching scene transition start", e);
+ }
+ }
}
/** @hide */
@@ -493,6 +508,12 @@ public class ActivityOptions {
} catch (RemoteException e) {
}
}
+ if (mSceneTransitionStartedListener != null) {
+ try {
+ mSceneTransitionStartedListener.sendResult(null);
+ } catch (RemoteException e) {
+ }
+ }
}
/** @hide */
@@ -572,6 +593,8 @@ public class ActivityOptions {
}
mSceneTransitionStartedListener = otherOptions.mSceneTransitionStartedListener;
mDestSceneNames = otherOptions.mDestSceneNames;
+ mTransitionArgs = otherOptions.mTransitionArgs;
+ mThumbnail = null;
mAnimationStartedListener = null;
break;
}
@@ -595,7 +618,7 @@ public class ActivityOptions {
b.putInt(KEY_ANIM_TYPE, mAnimationType);
b.putInt(KEY_ANIM_ENTER_RES_ID, mCustomEnterResId);
b.putInt(KEY_ANIM_EXIT_RES_ID, mCustomExitResId);
- b.putIBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
+ b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
!= null ? mAnimationStartedListener.asBinder() : null);
break;
case ANIM_SCALE_UP:
@@ -611,10 +634,31 @@ public class ActivityOptions {
b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail);
b.putInt(KEY_ANIM_START_X, mStartX);
b.putInt(KEY_ANIM_START_Y, mStartY);
- b.putIBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
+ b.putBinder(KEY_ANIM_START_LISTENER, mAnimationStartedListener
!= null ? mAnimationStartedListener.asBinder() : null);
break;
+ case ANIM_SCENE_TRANSITION:
+ b.putInt(KEY_ANIM_TYPE, mAnimationType);
+ b.putStringArray(KEY_DEST_SCENE_NAMES, mDestSceneNames);
+ b.putBundle(KEY_SCENE_TRANSITION_ARGS, mTransitionArgs);
+ b.putBinder(KEY_SCENE_TRANSITION_START_LISTENER, mSceneTransitionStartedListener
+ != null ? mSceneTransitionStartedListener.asBinder() : null);
+ break;
}
return b;
}
+
+ /**
+ * Return the filtered options only meant to be seen by the target activity itself
+ * @hide
+ */
+ public ActivityOptions forTargetActivity() {
+ if (mAnimationType == ANIM_SCENE_TRANSITION) {
+ final ActivityOptions result = new ActivityOptions();
+ result.update(this);
+ return result;
+ }
+
+ return null;
+ }
}