Merge "Change Activity Scene Transitions to be more automatic redo."
This commit is contained in:
@ -18,6 +18,7 @@ package android.app;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.SuperNotCalledException;
|
||||
@ -3316,7 +3317,7 @@ public class Activity extends ContextThemeWrapper
|
||||
@Nullable Bundle appSearchData, boolean globalSearch) {
|
||||
ensureSearchManager();
|
||||
mSearchManager.startSearch(initialQuery, selectInitialQuery, getComponentName(),
|
||||
appSearchData, globalSearch);
|
||||
appSearchData, globalSearch);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3446,7 +3447,11 @@ public class Activity extends ContextThemeWrapper
|
||||
* @see #startActivity
|
||||
*/
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
startActivityForResult(intent, requestCode, null);
|
||||
Bundle options = null;
|
||||
if (mWindow.hasFeature(Window.FEATURE_CONTENT_TRANSITIONS)) {
|
||||
options = ActivityOptions.makeSceneTransitionAnimation(null).toBundle();
|
||||
}
|
||||
startActivityForResult(intent, requestCode, options);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3484,12 +3489,15 @@ public class Activity extends ContextThemeWrapper
|
||||
* @see #startActivity
|
||||
*/
|
||||
public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options) {
|
||||
TransitionManager tm = getContentTransitionManager();
|
||||
if (tm != null && options != null) {
|
||||
if (options != null) {
|
||||
ActivityOptions activityOptions = new ActivityOptions(options);
|
||||
if (activityOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
|
||||
getWindow().startExitTransition(activityOptions);
|
||||
options = activityOptions.toBundle();
|
||||
if (mActionBar != null) {
|
||||
ArrayMap<String, View> sharedElementMap = new ArrayMap<String, View>();
|
||||
mActionBar.captureSharedElements(sharedElementMap);
|
||||
activityOptions.addSharedElements(sharedElementMap);
|
||||
}
|
||||
options = mWindow.startExitTransition(activityOptions);
|
||||
}
|
||||
}
|
||||
if (mParent == null) {
|
||||
@ -3664,7 +3672,7 @@ public class Activity extends ContextThemeWrapper
|
||||
*/
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
startActivity(intent, null);
|
||||
this.startActivity(intent, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4720,7 +4728,8 @@ public class Activity extends ContextThemeWrapper
|
||||
*/
|
||||
public final void setProgressBarIndeterminate(boolean indeterminate) {
|
||||
getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
|
||||
indeterminate ? Window.PROGRESS_INDETERMINATE_ON : Window.PROGRESS_INDETERMINATE_OFF);
|
||||
indeterminate ? Window.PROGRESS_INDETERMINATE_ON
|
||||
: Window.PROGRESS_INDETERMINATE_OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5329,12 +5338,6 @@ public class Activity extends ContextThemeWrapper
|
||||
if (activityOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
|
||||
mTransitionActivityOptions = activityOptions;
|
||||
sceneTransitionListener = new Window.SceneTransitionListener() {
|
||||
@Override
|
||||
public void enterSharedElement(Bundle transitionArgs) {
|
||||
startSharedElementTransition(transitionArgs);
|
||||
mTransitionActivityOptions = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nullPendingTransition() {
|
||||
overridePendingTransition(0, 0);
|
||||
@ -5349,6 +5352,16 @@ public class Activity extends ContextThemeWrapper
|
||||
public void convertToTranslucent() {
|
||||
Activity.this.convertToTranslucent(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sharedElementStart(Transition transition) {
|
||||
Activity.this.onCaptureSharedElementStart(transition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sharedElementEnd() {
|
||||
Activity.this.onCaptureSharedElementEnd();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@ -5542,53 +5555,23 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entering Activity transition args. Will be null if
|
||||
* {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)} was
|
||||
* not used to pass a Bundle to startActivity. The Bundle passed to that method in the
|
||||
* calling Activity is returned here.
|
||||
* <p>After startSharedElementTransition is called, this method will return null.</p>
|
||||
* Called when setting up Activity Scene transitions when the start state for shared
|
||||
* elements has been captured. Override this method to modify the start position of shared
|
||||
* elements for the entry Transition.
|
||||
*
|
||||
* @return The Bundle passed into Bundle parameter of
|
||||
* {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)}
|
||||
* in the calling Activity.
|
||||
* @param transition The <code>Transition</code> being used to change
|
||||
* bounds of shared elements in the source Activity to
|
||||
* the bounds defined by the entering Scene.
|
||||
*/
|
||||
public Bundle getTransitionArgs() {
|
||||
if (mTransitionActivityOptions == null) {
|
||||
return null;
|
||||
}
|
||||
return mTransitionActivityOptions.getSceneTransitionArgs();
|
||||
public void onCaptureSharedElementStart(Transition transition) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to transfer a shared element from a calling Activity to this Activity.
|
||||
* Shared elements will be made VISIBLE before this call. The Activity is responsible
|
||||
* for transitioning the shared elements from their location to the eventual destination.
|
||||
* The shared element will be laid out a the destination when this method is called.
|
||||
*
|
||||
* @param transitionArgs The same as returned from {@link #getTransitionArgs()}, this should
|
||||
* contain information from the calling Activity to tell where the
|
||||
* shared element should be placed.
|
||||
* Called when setting up Activity Scene transitions when the final state for
|
||||
* shared elements state has been captured. Override this method to modify the destination
|
||||
* position of shared elements for the entry Transition.
|
||||
*/
|
||||
protected void startSharedElementTransition(Bundle transitionArgs) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls how the background fade is triggered when there is an entering Activity transition.
|
||||
* If fadeEarly is true, the Window background will fade in as soon as the shared elements are
|
||||
* ready to switch. If fadeEarly is false, the background will fade only after the calling
|
||||
* Activity's exit transition completes. By default, the Window will fade in when the calling
|
||||
* Activity's exit transition completes.
|
||||
*
|
||||
* @param fadeEarly Set to true to fade out the exiting Activity as soon as the shared elements
|
||||
* are transferred. Set to false to fade out the exiting Activity as soon as
|
||||
* the shared element is transferred.
|
||||
* @see android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)
|
||||
*/
|
||||
public void setEarlyBackgroundTransition(boolean fadeEarly) {
|
||||
if (mTransitionActivityOptions == null) {
|
||||
return;
|
||||
}
|
||||
mWindow.setEarlyBackgroundTransition(fadeEarly);
|
||||
public void onCaptureSharedElementEnd() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package android.app;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
@ -24,8 +23,8 @@ import android.os.Handler;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.transition.Transition;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -99,12 +98,6 @@ public class ActivityOptions {
|
||||
*/
|
||||
public static final String KEY_ANIM_START_LISTENER = "android:animStartListener";
|
||||
|
||||
/**
|
||||
* Arguments for the scene transition about to begin.
|
||||
* @hide
|
||||
*/
|
||||
public static final String KEY_SCENE_TRANSITION_ARGS = "android:sceneTransitionArgs";
|
||||
|
||||
/**
|
||||
* For Activity transitions, the calling Activity's TransitionListener used to
|
||||
* notify the called Activity when the shared element and the exit transitions
|
||||
@ -120,9 +113,15 @@ public class ActivityOptions {
|
||||
private static final String KEY_TRANSITION_TARGET_LISTENER = "android:transitionTargetListener";
|
||||
|
||||
/**
|
||||
* The shared element's texture ID (TODO: not used yet).
|
||||
* The names of shared elements that are transitioned to the started Activity.
|
||||
* This is also the name of shared elements that the started Activity accepted.
|
||||
*/
|
||||
private static final String KEY_SHARED_ELEMENT_TEXTURE_ID = "android:sharedElementTextureId";
|
||||
private static final String KEY_SHARED_ELEMENT_NAMES = "android:shared_element_names";
|
||||
|
||||
/**
|
||||
* The shared elements names of the views in the calling Activity.
|
||||
*/
|
||||
private static final String KEY_LOCAL_ELEMENT_NAMES = "android:local_element_names";
|
||||
|
||||
/** @hide */
|
||||
public static final int ANIM_NONE = 0;
|
||||
@ -146,9 +145,10 @@ public class ActivityOptions {
|
||||
private int mStartY;
|
||||
private int mStartWidth;
|
||||
private int mStartHeight;
|
||||
private Bundle mTransitionArgs;
|
||||
private IRemoteCallback mAnimationStartedListener;
|
||||
private IRemoteCallback mTransitionCompleteListener;
|
||||
private ArrayList<String> mSharedElementNames;
|
||||
private ArrayList<String> mLocalElementNames;
|
||||
|
||||
/**
|
||||
* Create an ActivityOptions specifying a custom animation to run when
|
||||
@ -226,7 +226,7 @@ public class ActivityOptions {
|
||||
|
||||
/** @hide */
|
||||
public interface ActivityTransitionTarget {
|
||||
void sharedElementTransitionComplete();
|
||||
void sharedElementTransitionComplete(Bundle transitionArgs);
|
||||
void exitTransitionComplete();
|
||||
}
|
||||
|
||||
@ -348,35 +348,51 @@ public class ActivityOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ActivityOptions to transition between Activities using cross-Activity animation.
|
||||
* When visual elements are to carry between Activities, args should be used to tell the called
|
||||
* Activity about the location and size.
|
||||
*
|
||||
* TODO: Provide facility to capture layout and bitmap of shared elements.
|
||||
*
|
||||
* <p>When
|
||||
* {@link android.app.Activity#startActivities(android.content.Intent[], android.os.Bundle)}
|
||||
* is used with the {@link #toBundle()} result, the Activity's content scene will automatically
|
||||
* transition out by setting their visibility to {@link View#INVISIBLE}. Shared elements
|
||||
* ({@link android.view.View#setSharedElementName(String)}) are unmodified during the
|
||||
* transition to allow the started Activity to seamlessly take it over. ViewGroups typically
|
||||
* don't transition out, and instead transition out their children unless they have a
|
||||
* background. To modify this behavior, use
|
||||
* {@link android.view.ViewGroup#setTransitionGroup(boolean)}.</p>
|
||||
* Create an ActivityOptions to transition between Activities using cross-Activity scene
|
||||
* animations. This method carries the position of one shared element to the started Activity.
|
||||
*
|
||||
* <p>This requires {@link android.view.Window#FEATURE_CONTENT_TRANSITIONS} to be
|
||||
* enabled on the calling Activity to cause an exit transition. The same must be in
|
||||
* the called Activity to get an entering transition.</p>
|
||||
*
|
||||
* @param args Contains information for transferring a view between this Activity and the
|
||||
* target Activity. Will be used by the called Activity to transition the
|
||||
* view to its eventual destination
|
||||
* @see android.app.Activity#startSharedElementTransition(android.os.Bundle)
|
||||
* @param sharedElement The View to transition to the started Activity. sharedElement must
|
||||
* have a non-null sharedElementName.
|
||||
* @param sharedElementName The shared element name as used in the target Activity. This may
|
||||
* be null if it has the same name as sharedElement.
|
||||
* @return Returns a new ActivityOptions object that you can use to
|
||||
* supply these options as the options Bundle when starting an activity.
|
||||
*/
|
||||
public static ActivityOptions makeSceneTransitionAnimation(Bundle args) {
|
||||
public static ActivityOptions makeSceneTransitionAnimation(View sharedElement,
|
||||
String sharedElementName) {
|
||||
return makeSceneTransitionAnimation(
|
||||
new Pair<View, String>(sharedElement, sharedElementName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ActivityOptions to transition between Activities using cross-Activity scene
|
||||
* animations. This method carries the position of multiple shared elements to the started
|
||||
* Activity.
|
||||
*
|
||||
* <p>This requires {@link android.view.Window#FEATURE_CONTENT_TRANSITIONS} to be
|
||||
* enabled on the calling Activity to cause an exit transition. The same must be in
|
||||
* the called Activity to get an entering transition.</p>
|
||||
* @param sharedElements The View to transition to the started Activity along with the
|
||||
* shared element name as used in the started Activity. The view
|
||||
* must have a non-null sharedElementName.
|
||||
* @return Returns a new ActivityOptions object that you can use to
|
||||
* supply these options as the options Bundle when starting an activity.
|
||||
*/
|
||||
public static ActivityOptions makeSceneTransitionAnimation(
|
||||
Pair<View, String>... sharedElements) {
|
||||
ActivityOptions opts = new ActivityOptions();
|
||||
opts.mAnimationType = ANIM_SCENE_TRANSITION;
|
||||
opts.mTransitionArgs = args;
|
||||
opts.mSharedElementNames = new ArrayList<String>();
|
||||
opts.mLocalElementNames = new ArrayList<String>();
|
||||
|
||||
if (sharedElements != null) {
|
||||
for (Pair<View, String> sharedElement : sharedElements) {
|
||||
opts.addSharedElement(sharedElement.first, sharedElement.second);
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
@ -412,9 +428,10 @@ public class ActivityOptions {
|
||||
break;
|
||||
|
||||
case ANIM_SCENE_TRANSITION:
|
||||
mTransitionArgs = opts.getBundle(KEY_SCENE_TRANSITION_ARGS);
|
||||
mTransitionCompleteListener = IRemoteCallback.Stub.asInterface(
|
||||
opts.getBinder(KEY_TRANSITION_COMPLETE_LISTENER));
|
||||
mSharedElementNames = opts.getStringArrayList(KEY_SHARED_ELEMENT_NAMES);
|
||||
mLocalElementNames = opts.getStringArrayList(KEY_LOCAL_ELEMENT_NAMES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -464,18 +481,20 @@ public class ActivityOptions {
|
||||
return mStartHeight;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public Bundle getSceneTransitionArgs() {
|
||||
return mTransitionArgs;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public IRemoteCallback getOnAnimationStartListener() {
|
||||
return mAnimationStartedListener;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void dispatchSceneTransitionStarted(final ActivityTransitionTarget target) {
|
||||
public ArrayList<String> getSharedElementNames() { return mSharedElementNames; }
|
||||
|
||||
/** @hide */
|
||||
public ArrayList<String> getLocalElementNames() { return mLocalElementNames; }
|
||||
|
||||
/** @hide */
|
||||
public void dispatchSceneTransitionStarted(final ActivityTransitionTarget target,
|
||||
ArrayList<String> sharedElementNames) {
|
||||
boolean listenerSent = false;
|
||||
if (mTransitionCompleteListener != null) {
|
||||
IRemoteCallback callback = new IRemoteCallback.Stub() {
|
||||
@ -484,13 +503,13 @@ public class ActivityOptions {
|
||||
if (data == null) {
|
||||
target.exitTransitionComplete();
|
||||
} else {
|
||||
// TODO: Use texture id
|
||||
target.sharedElementTransitionComplete();
|
||||
target.sharedElementTransitionComplete(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBinder(KEY_TRANSITION_TARGET_LISTENER, callback.asBinder());
|
||||
bundle.putStringArrayList(KEY_SHARED_ELEMENT_NAMES, sharedElementNames);
|
||||
try {
|
||||
mTransitionCompleteListener.sendResult(bundle);
|
||||
listenerSent = true;
|
||||
@ -499,11 +518,22 @@ public class ActivityOptions {
|
||||
}
|
||||
}
|
||||
if (!listenerSent) {
|
||||
target.sharedElementTransitionComplete();
|
||||
target.sharedElementTransitionComplete(null);
|
||||
target.exitTransitionComplete();
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void dispatchSharedElementsReady() {
|
||||
if (mTransitionCompleteListener != null) {
|
||||
try {
|
||||
mTransitionCompleteListener.sendResult(null);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Couldn't synchronize shared elements", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void abort() {
|
||||
if (mAnimationStartedListener != null) {
|
||||
@ -530,6 +560,8 @@ public class ActivityOptions {
|
||||
if (otherOptions.mPackageName != null) {
|
||||
mPackageName = otherOptions.mPackageName;
|
||||
}
|
||||
mSharedElementNames = null;
|
||||
mLocalElementNames = null;
|
||||
switch (otherOptions.mAnimationType) {
|
||||
case ANIM_CUSTOM:
|
||||
mAnimationType = otherOptions.mAnimationType;
|
||||
@ -544,7 +576,6 @@ public class ActivityOptions {
|
||||
}
|
||||
mAnimationStartedListener = otherOptions.mAnimationStartedListener;
|
||||
mTransitionCompleteListener = null;
|
||||
mTransitionArgs = null;
|
||||
break;
|
||||
case ANIM_SCALE_UP:
|
||||
mAnimationType = otherOptions.mAnimationType;
|
||||
@ -560,7 +591,6 @@ public class ActivityOptions {
|
||||
}
|
||||
mAnimationStartedListener = null;
|
||||
mTransitionCompleteListener = null;
|
||||
mTransitionArgs = null;
|
||||
break;
|
||||
case ANIM_THUMBNAIL_SCALE_UP:
|
||||
case ANIM_THUMBNAIL_SCALE_DOWN:
|
||||
@ -576,14 +606,14 @@ public class ActivityOptions {
|
||||
}
|
||||
mAnimationStartedListener = otherOptions.mAnimationStartedListener;
|
||||
mTransitionCompleteListener = null;
|
||||
mTransitionArgs = null;
|
||||
break;
|
||||
case ANIM_SCENE_TRANSITION:
|
||||
mAnimationType = otherOptions.mAnimationType;
|
||||
mTransitionCompleteListener = otherOptions.mTransitionCompleteListener;
|
||||
mTransitionArgs = otherOptions.mTransitionArgs;
|
||||
mThumbnail = null;
|
||||
mAnimationStartedListener = null;
|
||||
mSharedElementNames = otherOptions.mSharedElementNames;
|
||||
mLocalElementNames = otherOptions.mLocalElementNames;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -627,11 +657,12 @@ public class ActivityOptions {
|
||||
break;
|
||||
case ANIM_SCENE_TRANSITION:
|
||||
b.putInt(KEY_ANIM_TYPE, mAnimationType);
|
||||
b.putBundle(KEY_SCENE_TRANSITION_ARGS, mTransitionArgs);
|
||||
if (mTransitionCompleteListener != null) {
|
||||
b.putBinder(KEY_TRANSITION_COMPLETE_LISTENER,
|
||||
mTransitionCompleteListener.asBinder());
|
||||
}
|
||||
b.putStringArrayList(KEY_SHARED_ELEMENT_NAMES, mSharedElementNames);
|
||||
b.putStringArrayList(KEY_LOCAL_ELEMENT_NAMES, mLocalElementNames);
|
||||
break;
|
||||
}
|
||||
return b;
|
||||
@ -652,32 +683,52 @@ public class ActivityOptions {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public interface SharedElementSource {
|
||||
int getTextureId();
|
||||
public void addSharedElements(Map<String, View> sharedElements) {
|
||||
for (Map.Entry<String, View> entry : sharedElements.entrySet()) {
|
||||
addSharedElement(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* In the calling Activity when transitioning out, sets the Transition to listen for
|
||||
* changes.
|
||||
* @hide
|
||||
*/
|
||||
public void setExitTransition(Transition transition, SharedElementSource sharedElementSource) {
|
||||
mTransitionCompleteListener = new ExitTransitionListener(transition, sharedElementSource);
|
||||
/** @hide */
|
||||
public void updateSceneTransitionAnimation(Transition exitTransition,
|
||||
Transition sharedElementTransition, SharedElementSource sharedElementSource) {
|
||||
mTransitionCompleteListener = new ExitTransitionListener(exitTransition,
|
||||
sharedElementTransition, sharedElementSource);
|
||||
}
|
||||
|
||||
private void addSharedElement(View view, String name) {
|
||||
String sharedElementName = view.getSharedElementName();
|
||||
if (name == null) {
|
||||
name = sharedElementName;
|
||||
}
|
||||
mSharedElementNames.add(name);
|
||||
mLocalElementNames.add(sharedElementName);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public interface SharedElementSource {
|
||||
Bundle getSharedElementExitState();
|
||||
void acceptedSharedElements(ArrayList<String> sharedElementNames);
|
||||
void hideSharedElements();
|
||||
}
|
||||
|
||||
private static class ExitTransitionListener extends IRemoteCallback.Stub
|
||||
implements Transition.TransitionListener, Animator.AnimatorListener {
|
||||
private ArrayList<Animator> mSharedElementAnimators = new ArrayList<Animator>();
|
||||
implements Transition.TransitionListener {
|
||||
private boolean mSharedElementNotified;
|
||||
private Transition mExitTransition;
|
||||
private Transition mSharedElementTransition;
|
||||
private IRemoteCallback mTransitionCompleteCallback;
|
||||
private boolean mExitComplete;
|
||||
private boolean mSharedElementComplete;
|
||||
private SharedElementSource mSharedElementSource;
|
||||
|
||||
public ExitTransitionListener(Transition transition, SharedElementSource sharedElementSource) {
|
||||
public ExitTransitionListener(Transition exitTransition, Transition sharedElementTransition,
|
||||
SharedElementSource sharedElementSource) {
|
||||
mSharedElementSource = sharedElementSource;
|
||||
mExitTransition = transition;
|
||||
mExitTransition = exitTransition;
|
||||
mExitTransition.addListener(this);
|
||||
mSharedElementTransition = sharedElementTransition;
|
||||
mSharedElementTransition.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -685,36 +736,36 @@ public class ActivityOptions {
|
||||
if (data != null) {
|
||||
mTransitionCompleteCallback = IRemoteCallback.Stub.asInterface(
|
||||
data.getBinder(KEY_TRANSITION_TARGET_LISTENER));
|
||||
ArrayList<String> sharedElementNames
|
||||
= data.getStringArrayList(KEY_SHARED_ELEMENT_NAMES);
|
||||
mSharedElementSource.acceptedSharedElements(sharedElementNames);
|
||||
notifySharedElement();
|
||||
notifyExit();
|
||||
} else {
|
||||
mSharedElementSource.hideSharedElements();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionStart(Transition transition) {
|
||||
ArrayMap<Animator, Transition.AnimationInfo> runningAnimators
|
||||
= Transition.getRunningAnimators();
|
||||
for (Map.Entry<Animator, Transition.AnimationInfo> entry : runningAnimators.entrySet()) {
|
||||
if (entry.getValue().view.getSharedElementName() != null) {
|
||||
mSharedElementAnimators.add(entry.getKey());
|
||||
entry.getKey().addListener(this);
|
||||
}
|
||||
}
|
||||
notifySharedElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionEnd(Transition transition) {
|
||||
mExitComplete = true;
|
||||
notifyExit();
|
||||
mExitTransition.removeListener(this);
|
||||
if (transition == mExitTransition) {
|
||||
mExitComplete = true;
|
||||
notifyExit();
|
||||
mExitTransition.removeListener(this);
|
||||
} else {
|
||||
mSharedElementComplete = true;
|
||||
notifySharedElement();
|
||||
mSharedElementTransition.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionCancel(Transition transition) {
|
||||
mExitComplete = true;
|
||||
notifyExit();
|
||||
mExitTransition.removeListener(this);
|
||||
onTransitionEnd(transition);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -725,34 +776,13 @@ public class ActivityOptions {
|
||||
public void onTransitionResume(Transition transition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mSharedElementAnimators.remove(animation);
|
||||
notifySharedElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mSharedElementAnimators.remove(animation);
|
||||
notifySharedElement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
}
|
||||
|
||||
private void notifySharedElement() {
|
||||
if (!mSharedElementNotified && mSharedElementAnimators.isEmpty()
|
||||
if (!mSharedElementNotified && mSharedElementComplete
|
||||
&& mTransitionCompleteCallback != null) {
|
||||
mSharedElementNotified = true;
|
||||
try {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(KEY_SHARED_ELEMENT_TEXTURE_ID, mSharedElementSource.getTextureId());
|
||||
mTransitionCompleteCallback.sendResult(bundle);
|
||||
Bundle sharedElementState = mSharedElementSource.getSharedElementExitState();
|
||||
mTransitionCompleteCallback.sendResult(sharedElementState);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Couldn't notify that the transition ended", e);
|
||||
}
|
||||
|
@ -552,8 +552,7 @@ public abstract class Transition implements Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public static ArrayMap<Animator, AnimationInfo> getRunningAnimators() {
|
||||
private static ArrayMap<Animator, AnimationInfo> getRunningAnimators() {
|
||||
ArrayMap<Animator, AnimationInfo> runningAnimators = sRunningAnimators.get();
|
||||
if (runningAnimators == null) {
|
||||
runningAnimators = new ArrayMap<Animator, AnimationInfo>();
|
||||
@ -1113,30 +1112,32 @@ public abstract class Transition implements Cloneable {
|
||||
}
|
||||
}
|
||||
}
|
||||
TransitionValues values = new TransitionValues();
|
||||
values.view = view;
|
||||
if (start) {
|
||||
captureStartValues(values);
|
||||
} else {
|
||||
captureEndValues(values);
|
||||
}
|
||||
if (start) {
|
||||
if (!isListViewItem) {
|
||||
mStartValues.viewValues.put(view, values);
|
||||
if (id >= 0) {
|
||||
mStartValues.idValues.put((int) id, values);
|
||||
}
|
||||
if (view.getParent() instanceof ViewGroup) {
|
||||
TransitionValues values = new TransitionValues();
|
||||
values.view = view;
|
||||
if (start) {
|
||||
captureStartValues(values);
|
||||
} else {
|
||||
mStartValues.itemIdValues.put(itemId, values);
|
||||
captureEndValues(values);
|
||||
}
|
||||
} else {
|
||||
if (!isListViewItem) {
|
||||
mEndValues.viewValues.put(view, values);
|
||||
if (id >= 0) {
|
||||
mEndValues.idValues.put((int) id, values);
|
||||
if (start) {
|
||||
if (!isListViewItem) {
|
||||
mStartValues.viewValues.put(view, values);
|
||||
if (id >= 0) {
|
||||
mStartValues.idValues.put((int) id, values);
|
||||
}
|
||||
} else {
|
||||
mStartValues.itemIdValues.put(itemId, values);
|
||||
}
|
||||
} else {
|
||||
mEndValues.itemIdValues.put(itemId, values);
|
||||
if (!isListViewItem) {
|
||||
mEndValues.viewValues.put(view, values);
|
||||
if (id >= 0) {
|
||||
mEndValues.idValues.put((int) id, values);
|
||||
}
|
||||
} else {
|
||||
mEndValues.itemIdValues.put(itemId, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (view instanceof ViewGroup) {
|
||||
|
@ -285,46 +285,27 @@ public class TransitionInflater {
|
||||
com.android.internal.R.styleable.TransitionManager);
|
||||
int transitionId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_transition, -1);
|
||||
Scene fromScene = null, toScene = null;
|
||||
int fromId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_fromScene, -1);
|
||||
if (fromId >= 0) fromScene = Scene.getSceneForLayout(sceneRoot, fromId, mContext);
|
||||
Scene fromScene = (fromId < 0) ? null: Scene.getSceneForLayout(sceneRoot, fromId, mContext);
|
||||
int toId = a.getResourceId(
|
||||
com.android.internal.R.styleable.TransitionManager_toScene, -1);
|
||||
if (toId >= 0) toScene = Scene.getSceneForLayout(sceneRoot, toId, mContext);
|
||||
String fromName = a.getString(
|
||||
com.android.internal.R.styleable.TransitionManager_fromSceneName);
|
||||
String toName = a.getString(
|
||||
com.android.internal.R.styleable.TransitionManager_toSceneName);
|
||||
Scene toScene = (toId < 0) ? null : Scene.getSceneForLayout(sceneRoot, toId, mContext);
|
||||
|
||||
if (transitionId >= 0) {
|
||||
Transition transition = inflateTransition(transitionId);
|
||||
if (transition != null) {
|
||||
if (fromScene != null) {
|
||||
boolean hasDest = false;
|
||||
if (toScene != null) {
|
||||
transitionManager.setTransition(fromScene, toScene, transition);
|
||||
hasDest = true;
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(toName)) {
|
||||
transitionManager.setTransition(fromScene, toName, transition);
|
||||
hasDest = true;
|
||||
}
|
||||
|
||||
if (!hasDest) {
|
||||
throw new RuntimeException("No matching toScene or toSceneName for given " +
|
||||
"fromScene for transition ID " + transitionId);
|
||||
}
|
||||
} else if (toId >= 0) {
|
||||
transitionManager.setTransition(toScene, transition);
|
||||
}
|
||||
if (fromName != null) {
|
||||
if (toScene != null) {
|
||||
transitionManager.setTransition(fromName, toScene, transition);
|
||||
} else {
|
||||
throw new RuntimeException("No matching toScene for given fromSceneName " +
|
||||
if (fromScene == null) {
|
||||
if (toScene == null) {
|
||||
throw new RuntimeException("No matching fromScene or toScene " +
|
||||
"for transition ID " + transitionId);
|
||||
} else {
|
||||
transitionManager.setTransition(toScene, transition);
|
||||
}
|
||||
} else if (toScene == null) {
|
||||
transitionManager.setExitTransition(fromScene, transition);
|
||||
} else {
|
||||
transitionManager.setTransition(fromScene, toScene, transition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +70,9 @@ public class TransitionManager {
|
||||
private static final String[] EMPTY_STRINGS = new String[0];
|
||||
|
||||
ArrayMap<Scene, Transition> mSceneTransitions = new ArrayMap<Scene, Transition>();
|
||||
ArrayMap<Scene, Transition> mExitSceneTransitions = new ArrayMap<Scene, Transition>();
|
||||
ArrayMap<Scene, ArrayMap<Scene, Transition>> mScenePairTransitions =
|
||||
new ArrayMap<Scene, ArrayMap<Scene, Transition>>();
|
||||
ArrayMap<Scene, ArrayMap<String, Transition>> mSceneNameTransitions =
|
||||
new ArrayMap<Scene, ArrayMap<String, Transition>>();
|
||||
ArrayMap<String, ArrayMap<Scene, Transition>> mNameSceneTransitions =
|
||||
new ArrayMap<String, ArrayMap<Scene, Transition>>();
|
||||
private static ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>
|
||||
sRunningTransitions =
|
||||
new ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>();
|
||||
@ -121,6 +118,21 @@ public class TransitionManager {
|
||||
mSceneTransitions.put(scene, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a specific transition to occur when the given scene is exited. This
|
||||
* has the lowest priority -- if a Scene-to-Scene transition or
|
||||
* Scene enter transition can be applied, it will.
|
||||
*
|
||||
* @param scene The scene which, when exited, will cause the given
|
||||
* transition to run.
|
||||
* @param transition The transition that will play when the given scene is
|
||||
* exited. A value of null will result in the default behavior of
|
||||
* using the default transition instead.
|
||||
*/
|
||||
public void setExitTransition(Scene scene, Transition transition) {
|
||||
mExitSceneTransitions.put(scene, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a specific transition to occur when the given pair of scenes is
|
||||
* exited/entered.
|
||||
@ -169,6 +181,9 @@ public class TransitionManager {
|
||||
}
|
||||
}
|
||||
transition = mSceneTransitions.get(scene);
|
||||
if (transition == null && sceneRoot != null) {
|
||||
transition = mExitSceneTransitions.get(Scene.getCurrentScene(sceneRoot));
|
||||
}
|
||||
return (transition != null) ? transition : sDefaultTransition;
|
||||
}
|
||||
|
||||
@ -224,138 +239,31 @@ public class TransitionManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the transition from a named scene to a target defined scene if one has been
|
||||
* Retrieve the transition to a target defined scene if one has been
|
||||
* associated with this TransitionManager.
|
||||
*
|
||||
* <p>A named scene is an indirect link for a transition. Fundamentally a named
|
||||
* scene represents a potentially arbitrary intersection point of two otherwise independent
|
||||
* transitions. Activity A may define a transition from scene X to "com.example.scene.FOO"
|
||||
* while activity B may define a transition from scene "com.example.scene.FOO" to scene Y.
|
||||
* In this way applications may define an API for more sophisticated transitions between
|
||||
* caller and called activities very similar to the way that <code>Intent</code> extras
|
||||
* define APIs for arguments and data propagation between activities.</p>
|
||||
*
|
||||
* @param fromName Named scene that this transition corresponds to
|
||||
* @param toScene Target scene that this transition will move to
|
||||
* @return Transition corresponding to the given fromName and toScene or null
|
||||
* @return Transition corresponding to the given toScene or null
|
||||
* if no association exists in this TransitionManager
|
||||
*
|
||||
* @see #setTransition(String, Scene, Transition)
|
||||
* @see #setTransition(Scene, Transition)
|
||||
* @hide
|
||||
*/
|
||||
public Transition getNamedTransition(String fromName, Scene toScene) {
|
||||
ArrayMap<Scene, Transition> m = mNameSceneTransitions.get(fromName);
|
||||
if (m != null) {
|
||||
return m.get(toScene);
|
||||
}
|
||||
return null;
|
||||
public Transition getEnterTransition(Scene toScene) {
|
||||
return mSceneTransitions.get(toScene);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the transition from a defined scene to a target named scene if one has been
|
||||
* associated with this TransitionManager.
|
||||
*
|
||||
* <p>A named scene is an indirect link for a transition. Fundamentally a named
|
||||
* scene represents a potentially arbitrary intersection point of two otherwise independent
|
||||
* transitions. Activity A may define a transition from scene X to "com.example.scene.FOO"
|
||||
* while activity B may define a transition from scene "com.example.scene.FOO" to scene Y.
|
||||
* In this way applications may define an API for more sophisticated transitions between
|
||||
* caller and called activities very similar to the way that <code>Intent</code> extras
|
||||
* define APIs for arguments and data propagation between activities.</p>
|
||||
*
|
||||
* @param fromScene Scene that this transition starts from
|
||||
* @param toName Name of the target scene
|
||||
* @return Transition corresponding to the given fromScene and toName or null
|
||||
* @return Transition corresponding to the given fromScene or null
|
||||
* if no association exists in this TransitionManager
|
||||
* @hide
|
||||
*/
|
||||
public Transition getNamedTransition(Scene fromScene, String toName) {
|
||||
ArrayMap<String, Transition> m = mSceneNameTransitions.get(fromScene);
|
||||
if (m != null) {
|
||||
return m.get(toName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the supported target named scenes when transitioning away from the given scene.
|
||||
*
|
||||
* <p>A named scene is an indirect link for a transition. Fundamentally a named
|
||||
* scene represents a potentially arbitrary intersection point of two otherwise independent
|
||||
* transitions. Activity A may define a transition from scene X to "com.example.scene.FOO"
|
||||
* while activity B may define a transition from scene "com.example.scene.FOO" to scene Y.
|
||||
* In this way applications may define an API for more sophisticated transitions between
|
||||
* caller and called activities very similar to the way that <code>Intent</code> extras
|
||||
* define APIs for arguments and data propagation between activities.</p>
|
||||
*
|
||||
* @param fromScene Scene to transition from
|
||||
* @return An array of Strings naming each supported transition starting from
|
||||
* <code>fromScene</code>. If no transitions to a named scene from the given
|
||||
* scene are supported this function will return a String[] of length 0.
|
||||
*
|
||||
* @see #setTransition(Scene, String, Transition)
|
||||
*/
|
||||
public String[] getTargetSceneNames(Scene fromScene) {
|
||||
final ArrayMap<String, Transition> m = mSceneNameTransitions.get(fromScene);
|
||||
if (m == null) {
|
||||
return EMPTY_STRINGS;
|
||||
}
|
||||
final int count = m.size();
|
||||
final String[] result = new String[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
result[i] = m.keyAt(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a transition from a specific scene to a named scene.
|
||||
*
|
||||
* <p>A named scene is an indirect link for a transition. Fundamentally a named
|
||||
* scene represents a potentially arbitrary intersection point of two otherwise independent
|
||||
* transitions. Activity A may define a transition from scene X to "com.example.scene.FOO"
|
||||
* while activity B may define a transition from scene "com.example.scene.FOO" to scene Y.
|
||||
* In this way applications may define an API for more sophisticated transitions between
|
||||
* caller and called activities very similar to the way that <code>Intent</code> extras
|
||||
* define APIs for arguments and data propagation between activities.</p>
|
||||
*
|
||||
* @param fromScene Scene to transition from
|
||||
* @param toName Named scene to transition to
|
||||
* @param transition Transition to use
|
||||
*
|
||||
* @see #getTargetSceneNames(Scene)
|
||||
*/
|
||||
public void setTransition(Scene fromScene, String toName, Transition transition) {
|
||||
ArrayMap<String, Transition> m = mSceneNameTransitions.get(fromScene);
|
||||
if (m == null) {
|
||||
m = new ArrayMap<String, Transition>();
|
||||
mSceneNameTransitions.put(fromScene, m);
|
||||
}
|
||||
m.put(toName, transition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a transition from a named scene to a concrete scene.
|
||||
*
|
||||
* <p>A named scene is an indirect link for a transition. Fundamentally a named
|
||||
* scene represents a potentially arbitrary intersection point of two otherwise independent
|
||||
* transitions. Activity A may define a transition from scene X to "com.example.scene.FOO"
|
||||
* while activity B may define a transition from scene "com.example.scene.FOO" to scene Y.
|
||||
* In this way applications may define an API for more sophisticated transitions between
|
||||
* caller and called activities very similar to the way that <code>Intent</code> extras
|
||||
* define APIs for arguments and data propagation between activities.</p>
|
||||
*
|
||||
* @param fromName Named scene to transition from
|
||||
* @param toScene Scene to transition to
|
||||
* @param transition Transition to use
|
||||
*
|
||||
* @see #getNamedTransition(String, Scene)
|
||||
*/
|
||||
public void setTransition(String fromName, Scene toScene, Transition transition) {
|
||||
ArrayMap<Scene, Transition> m = mNameSceneTransitions.get(fromName);
|
||||
if (m == null) {
|
||||
m = new ArrayMap<Scene, Transition>();
|
||||
mNameSceneTransitions.put(fromName, m);
|
||||
}
|
||||
m.put(toScene, transition);
|
||||
public Transition getExitTransition(Scene fromScene) {
|
||||
return mExitSceneTransitions.get(fromScene);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -18842,6 +18844,33 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Views in the hierarchy affected by entering and exiting Activity Scene transitions.
|
||||
* @param transitioningViews This View will be added to transitioningViews if it is VISIBLE and
|
||||
* a normal View or a ViewGroup with
|
||||
* {@link android.view.ViewGroup#isTransitionGroup()} true.
|
||||
* @hide
|
||||
*/
|
||||
public void captureTransitioningViews(List<View> transitioningViews) {
|
||||
if (getVisibility() == View.VISIBLE) {
|
||||
transitioningViews.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all Views that have {@link #getSharedElementName()} non-null to sharedElements.
|
||||
* @param sharedElements Will contain all Views in the hierarchy having a shared element name.
|
||||
* @hide
|
||||
*/
|
||||
public void findSharedElements(Map<String, View> sharedElements) {
|
||||
if (getVisibility() == VISIBLE) {
|
||||
String sharedElementName = getSharedElementName();
|
||||
if (sharedElementName != null) {
|
||||
sharedElements.put(sharedElementName, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
|
@ -31,6 +31,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
@ -50,6 +51,8 @@ import com.android.internal.util.Predicate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||
|
||||
@ -2300,14 +2303,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
||||
* individually during the transition.
|
||||
* @return True if the ViewGroup should be acted on together during an Activity transition.
|
||||
* The default value is false when the background is null and true when the background
|
||||
* is not null.
|
||||
* @see android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)
|
||||
* is not null or if {@link #getSharedElementName()} is not null.
|
||||
*/
|
||||
public boolean isTransitionGroup() {
|
||||
if ((mGroupFlags & FLAG_IS_TRANSITION_GROUP_SET) != 0) {
|
||||
return ((mGroupFlags & FLAG_IS_TRANSITION_GROUP) != 0);
|
||||
} else {
|
||||
return getBackground() != null;
|
||||
return getBackground() != null || getSharedElementName() != null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2318,7 +2320,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
||||
* in Activity transitions. If false, the ViewGroup won't transition,
|
||||
* only its children. If true, the entire ViewGroup will transition
|
||||
* together.
|
||||
* @see android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)
|
||||
*/
|
||||
public void setTransitionGroup(boolean isTransitionGroup) {
|
||||
mGroupFlags |= FLAG_IS_TRANSITION_GROUP_SET;
|
||||
@ -5880,6 +5881,37 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
||||
protected void onSetLayoutParams(View child, LayoutParams layoutParams) {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void captureTransitioningViews(List<View> transitioningViews) {
|
||||
if (getVisibility() != View.VISIBLE) {
|
||||
return;
|
||||
}
|
||||
if (isTransitionGroup()) {
|
||||
transitioningViews.add(this);
|
||||
} else {
|
||||
int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View child = getChildAt(i);
|
||||
child.captureTransitioningViews(transitioningViews);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void findSharedElements(Map<String, View> sharedElements) {
|
||||
if (getVisibility() != VISIBLE) {
|
||||
return;
|
||||
}
|
||||
super.findSharedElements(sharedElements);
|
||||
int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View child = getChildAt(i);
|
||||
child.findSharedElements(sharedElements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* LayoutParams are used by views to tell their parents how they want to be
|
||||
* laid out. See
|
||||
|
@ -29,9 +29,12 @@ import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemProperties;
|
||||
import android.transition.Scene;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Abstract base class for a top-level window look and behavior policy. An
|
||||
* instance of this class should be used as the top-level view added to the
|
||||
@ -1386,30 +1389,43 @@ public abstract class Window {
|
||||
* @hide
|
||||
*/
|
||||
public interface SceneTransitionListener {
|
||||
void enterSharedElement(Bundle transitionArgs);
|
||||
void nullPendingTransition();
|
||||
void convertFromTranslucent();
|
||||
void convertToTranslucent();
|
||||
void sharedElementStart(Transition transition);
|
||||
void sharedElementEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls how the background fade is triggered. If fadeEarly is true, the Window background
|
||||
* will fade in as soon as the shared elements are ready to switch. If fadeEarly is false,
|
||||
* the background will fade only after the calling Activity's exit transition completes.
|
||||
* By default, the Window will fade in when the calling Activity's exit transition completes.
|
||||
* Controls when the Activity enter scene is triggered and the background is faded in. If
|
||||
* triggerEarly is true, the enter scene will begin as soon as possible and the background
|
||||
* will fade in when all shared elements are ready to begin transitioning. If triggerEarly is
|
||||
* false, the Activity enter scene and background fade will be triggered when the calling
|
||||
* Activity's exit transition completes.
|
||||
*
|
||||
* @param fadeEarly Set to true to fade out the exiting Activity as soon as the shared elements
|
||||
* are transferred. Set to false to fade out the exiting Activity as soon as
|
||||
* the shared element is transferred.
|
||||
* @hide
|
||||
* @param triggerEarly Set to true to have the Activity enter scene transition in as early as
|
||||
* possible or set to false to wait for the calling Activity to exit first.
|
||||
*/
|
||||
public void setEarlyBackgroundTransition(boolean fadeEarly) {
|
||||
public void setTriggerEarlyEnterTransition(boolean triggerEarly) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the exit transition.
|
||||
* @hide
|
||||
*/
|
||||
public void startExitTransition(ActivityOptions activityOptions) {
|
||||
public Bundle startExitTransition(ActivityOptions options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* On entering Activity Scene transitions, shared element names may be mapped from a
|
||||
* source Activity's specified name to a unique shared element name in the View hierarchy.
|
||||
* Under most circumstances, mapping is not necessary - a single View will have the
|
||||
* shared element name given by the calling Activity. However, if there are several similar
|
||||
* Views (e.g. in a ListView), the correct shared element must be mapped.
|
||||
* @param sharedElementNames A mapping from the calling Activity's assigned shared element
|
||||
* name to a unique shared element name in the View hierarchy.
|
||||
*/
|
||||
public void mapTransitionTargets(Map<String, String> sharedElementNames) {
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ import android.widget.SpinnerAdapter;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ActionBarImpl is the ActionBar implementation used
|
||||
@ -355,6 +356,10 @@ public class ActionBarImpl extends ActionBar {
|
||||
setSubtitle(mContext.getString(resId));
|
||||
}
|
||||
|
||||
public void captureSharedElements(Map<String, View> sharedElements) {
|
||||
mContainerView.findSharedElements(sharedElements);
|
||||
}
|
||||
|
||||
public void setSelectedNavigationItem(int position) {
|
||||
switch (mActionView.getNavigationMode()) {
|
||||
case NAVIGATION_MODE_TABS:
|
||||
|
Reference in New Issue
Block a user