Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88dcd1a5 authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "API Review: Change SharedElementListener to SharedElementCallback." into lmp-dev

parents f9fb30f5 6558056e
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -3544,8 +3544,8 @@ package android.app {
    method public void setContentView(android.view.View);
    method public void setContentView(android.view.View, android.view.ViewGroup.LayoutParams);
    method public final void setDefaultKeyMode(int);
    method public void setEnterSharedElementListener(android.app.SharedElementListener);
    method public void setExitSharedElementListener(android.app.SharedElementListener);
    method public void setEnterSharedElementCallback(android.app.SharedElementCallback);
    method public void setExitSharedElementCallback(android.app.SharedElementCallback);
    method public final void setFeatureDrawable(int, android.graphics.drawable.Drawable);
    method public final void setFeatureDrawableAlpha(int, int);
    method public final void setFeatureDrawableResource(int, int);
@@ -4319,9 +4319,9 @@ package android.app {
    method public void setAllowEnterTransitionOverlap(boolean);
    method public void setAllowReturnTransitionOverlap(boolean);
    method public void setArguments(android.os.Bundle);
    method public void setEnterSharedElementTransitionListener(android.app.SharedElementListener);
    method public void setEnterSharedElementTransitionCallback(android.app.SharedElementCallback);
    method public void setEnterTransition(android.transition.Transition);
    method public void setExitSharedElementTransitionListener(android.app.SharedElementListener);
    method public void setExitSharedElementTransitionCallback(android.app.SharedElementCallback);
    method public void setExitTransition(android.transition.Transition);
    method public void setHasOptionsMenu(boolean);
    method public void setInitialSavedState(android.app.Fragment.SavedState);
@@ -5192,14 +5192,14 @@ package android.app {
    field public static final int START_STICKY_COMPATIBILITY = 0; // 0x0
  }
  public abstract class SharedElementListener {
    ctor public SharedElementListener();
    method public android.os.Parcelable captureSharedElementSnapshot(android.view.View, android.graphics.Matrix, android.graphics.RectF);
    method public android.view.View createSnapshotView(android.content.Context, android.os.Parcelable);
    method public void handleRejectedSharedElements(java.util.List<android.view.View>);
    method public void remapSharedElements(java.util.List<java.lang.String>, java.util.Map<java.lang.String, android.view.View>);
    method public void setSharedElementEnd(java.util.List<java.lang.String>, java.util.List<android.view.View>, java.util.List<android.view.View>);
    method public void setSharedElementStart(java.util.List<java.lang.String>, java.util.List<android.view.View>, java.util.List<android.view.View>);
  public abstract class SharedElementCallback {
    ctor public SharedElementCallback();
    method public android.os.Parcelable onCaptureSharedElementSnapshot(android.view.View, android.graphics.Matrix, android.graphics.RectF);
    method public android.view.View onCreateSnapshotView(android.content.Context, android.os.Parcelable);
    method public void onMapSharedElements(java.util.List<java.lang.String>, java.util.Map<java.lang.String, android.view.View>);
    method public void onRejectSharedElements(java.util.List<android.view.View>);
    method public void onSharedElementEnd(java.util.List<java.lang.String>, java.util.List<android.view.View>, java.util.List<android.view.View>);
    method public void onSharedElementStart(java.util.List<java.lang.String>, java.util.List<android.view.View>, java.util.List<android.view.View>);
  }
  public deprecated class TabActivity extends android.app.ActivityGroup {
+14 −14
Original line number Diff line number Diff line
@@ -788,8 +788,8 @@ public class Activity extends ContextThemeWrapper
    final Handler mHandler = new Handler();

    ActivityTransitionState mActivityTransitionState = new ActivityTransitionState();
    SharedElementListener mEnterTransitionListener = SharedElementListener.NULL_LISTENER;
    SharedElementListener mExitTransitionListener = SharedElementListener.NULL_LISTENER;
    SharedElementCallback mEnterTransitionListener = SharedElementCallback.NULL_CALLBACK;
    SharedElementCallback mExitTransitionListener = SharedElementCallback.NULL_CALLBACK;

    /** Return the intent that started this activity. */
    public Intent getIntent() {
@@ -5779,33 +5779,33 @@ public class Activity extends ContextThemeWrapper

    /**
     * When {@link android.app.ActivityOptions#makeSceneTransitionAnimation(Activity,
     * android.view.View, String)} was used to start an Activity, <var>listener</var>
     * android.view.View, String)} was used to start an Activity, <var>callback</var>
     * will be called to handle shared elements on the <i>launched</i> Activity. This requires
     * {@link Window#FEATURE_CONTENT_TRANSITIONS}.
     *
     * @param listener Used to manipulate shared element transitions on the launched Activity.
     * @param callback Used to manipulate shared element transitions on the launched Activity.
     */
    public void setEnterSharedElementListener(SharedElementListener listener) {
        if (listener == null) {
            listener = SharedElementListener.NULL_LISTENER;
    public void setEnterSharedElementCallback(SharedElementCallback callback) {
        if (callback == null) {
            callback = SharedElementCallback.NULL_CALLBACK;
        }
        mEnterTransitionListener = listener;
        mEnterTransitionListener = callback;
    }

    /**
     * When {@link android.app.ActivityOptions#makeSceneTransitionAnimation(Activity,
     * android.view.View, String)} was used to start an Activity, <var>listener</var>
     * android.view.View, String)} was used to start an Activity, <var>callback</var>
     * will be called to handle shared elements on the <i>launching</i> Activity. Most
     * calls will only come when returning from the started Activity.
     * This requires {@link Window#FEATURE_CONTENT_TRANSITIONS}.
     *
     * @param listener Used to manipulate shared element transitions on the launching Activity.
     * @param callback Used to manipulate shared element transitions on the launching Activity.
     */
    public void setExitSharedElementListener(SharedElementListener listener) {
        if (listener == null) {
            listener = SharedElementListener.NULL_LISTENER;
    public void setExitSharedElementCallback(SharedElementCallback callback) {
        if (callback == null) {
            callback = SharedElementCallback.NULL_CALLBACK;
        }
        mExitTransitionListener = listener;
        mExitTransitionListener = callback;
    }

    /**
+7 −7
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
    final protected ArrayList<View> mSharedElements = new ArrayList<View>();
    final protected ArrayList<String> mSharedElementNames = new ArrayList<String>();
    final protected ArrayList<View> mTransitioningViews = new ArrayList<View>();
    protected SharedElementListener mListener;
    protected SharedElementCallback mListener;
    protected ResultReceiver mResultReceiver;
    final private FixedEpicenterCallback mEpicenterCallback = new FixedEpicenterCallback();
    final protected boolean mIsReturning;
@@ -208,7 +208,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {

    public ActivityTransitionCoordinator(Window window,
            ArrayList<String> allSharedElementNames,
            SharedElementListener listener, boolean isReturning) {
            SharedElementCallback listener, boolean isReturning) {
        super(new Handler());
        mWindow = window;
        mListener = listener;
@@ -218,7 +218,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {

    protected void viewsReady(ArrayMap<String, View> sharedElements) {
        sharedElements.retainAll(mAllSharedElementNames);
        mListener.remapSharedElements(mAllSharedElementNames, sharedElements);
        mListener.onMapSharedElements(mAllSharedElementNames, sharedElements);
        mSharedElementNames.addAll(sharedElements.keySet());
        mSharedElements.addAll(sharedElements.values());
        if (getViewsTransition() != null) {
@@ -458,12 +458,12 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
                        tempMatrix, tempRect, null);
            }
        }
        mListener.setSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
        mListener.onSharedElementStart(mSharedElementNames, mSharedElements, snapshots);
        return originalImageState;
    }

    protected void notifySharedElementEnd(ArrayList<View> snapshots) {
        mListener.setSharedElementEnd(mSharedElementNames, mSharedElements, snapshots);
        mListener.onSharedElementEnd(mSharedElementNames, mSharedElements, snapshots);
    }

    protected void scheduleSetSharedElementEnd(final ArrayList<View> snapshots) {
@@ -526,7 +526,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
                Parcelable parcelable = sharedElementBundle.getParcelable(KEY_SNAPSHOT);
                View snapshot = null;
                if (parcelable != null) {
                    snapshot = mListener.createSnapshotView(context, parcelable);
                    snapshot = mListener.onCreateSnapshotView(context, parcelable);
                }
                if (snapshot != null) {
                    setSharedElementState(snapshot, name, state, null, null, decorLoc);
@@ -618,7 +618,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        sharedElementBundle.putFloat(KEY_TRANSLATION_Z, view.getTranslationZ());
        sharedElementBundle.putFloat(KEY_ELEVATION, view.getElevation());

        Parcelable bitmap = mListener.captureSharedElementSnapshot(view, tempMatrix, tempBounds);
        Parcelable bitmap = mListener.onCaptureSharedElementSnapshot(view, tempMatrix, tempBounds);
        if (bitmap != null) {
            sharedElementBundle.putParcelable(KEY_SNAPSHOT, bitmap);
        }
+12 −12
Original line number Diff line number Diff line
@@ -1128,11 +1128,11 @@ final class BackStackRecord extends FragmentTransaction implements
        }

        if (isBack) {
            outFragment.mEnterTransitionListener.remapSharedElements(
            outFragment.mEnterTransitionCallback.onMapSharedElements(
                    mSharedElementTargetNames, namedViews);
            setBackNameOverrides(state, namedViews, false);
        } else {
            outFragment.mExitTransitionListener.remapSharedElements(
            outFragment.mExitTransitionCallback.onMapSharedElements(
                    mSharedElementTargetNames, namedViews);
            setNameOverrides(state, namedViews, false);
        }
@@ -1248,14 +1248,14 @@ final class BackStackRecord extends FragmentTransaction implements
            }

            // Notify the start of the transition.
            SharedElementListener listener = isBack ?
                    outFragment.mEnterTransitionListener :
                    inFragment.mEnterTransitionListener;
            SharedElementCallback callback = isBack ?
                    outFragment.mEnterTransitionCallback :
                    inFragment.mEnterTransitionCallback;
            tempNames.clear();
            tempNames.addAll(namedViews.keySet());
            tempViewList.clear();
            tempViewList.addAll(namedViews.values());
            listener.setSharedElementStart(tempNames, tempViewList, null);
            callback.onSharedElementStart(tempNames, tempViewList, null);

            // Set the epicenter of the exit transition
            if (mSharedElementTargetNames != null && exitTransition != null) {
@@ -1337,11 +1337,11 @@ final class BackStackRecord extends FragmentTransaction implements
                    tempViews2, isBack);
            // remap shared elements and set the name mapping used in the shared element transition.
            if (isBack) {
                inFragment.mExitTransitionListener.remapSharedElements(
                inFragment.mExitTransitionCallback.onMapSharedElements(
                        mSharedElementTargetNames, namedViews);
                setBackNameOverrides(state, namedViews, true);
            } else {
                inFragment.mEnterTransitionListener.remapSharedElements(
                inFragment.mEnterTransitionCallback.onMapSharedElements(
                        mSharedElementTargetNames, namedViews);
                setNameOverrides(state, namedViews, true);
            }
@@ -1355,14 +1355,14 @@ final class BackStackRecord extends FragmentTransaction implements
            }

            int containerId = inFragments.keyAt(i);
            SharedElementListener sharedElementListener = isBack ?
                    outFragments.get(containerId).mEnterTransitionListener :
                    inFragment.mEnterTransitionListener;
            SharedElementCallback sharedElementCallback = isBack ?
                    outFragments.get(containerId).mEnterTransitionCallback :
                    inFragment.mEnterTransitionCallback;
            tempNames.clear();
            tempNames.addAll(namedViews.keySet());
            tempViews.clear();
            tempViews.addAll(namedViews.values());
            sharedElementListener.setSharedElementEnd(tempNames, tempViews, null);
            sharedElementCallback.onSharedElementEnd(tempNames, tempViews, null);
        }

        // Don't include any newly-hidden fragments in the transition.
+2 −4
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.animation.ObjectAnimator;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.ResultReceiver;
import android.text.TextUtils;
import android.transition.Transition;
@@ -209,7 +207,7 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
        }
    }

    private static SharedElementListener getListener(Activity activity, boolean isReturning) {
    private static SharedElementCallback getListener(Activity activity, boolean isReturning) {
        return isReturning ? activity.mExitTransitionListener : activity.mEnterTransitionListener;
    }

@@ -294,7 +292,7 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
        ArrayList<String> rejectedNames = new ArrayList<String>(mAllSharedElementNames);
        rejectedNames.removeAll(mSharedElementNames);
        ArrayList<View> rejectedSnapshots = createSnapshots(sharedElementState, rejectedNames);
        mListener.handleRejectedSharedElements(rejectedSnapshots);
        mListener.onRejectSharedElements(rejectedSnapshots);
        startRejectedAnimations(rejectedSnapshots);

        // Now start shared element transition
Loading