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

Commit 206e30cd authored by George Mount's avatar George Mount
Browse files

Revert "Change Activity Scene Transitions to be more automatic."

This reverts commit f10587fa.

Change-Id: I2785a3d2d6b667cad6d61dcbbc1c624161735fa4
parent 1ec1370a
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ package android {
    field public static final int canRetrieveWindowContent = 16843653; // 0x1010385
    field public static final int candidatesTextStyleSpans = 16843312; // 0x1010230
    field public static final deprecated int capitalize = 16843113; // 0x1010169
    field public static final int castsShadow = 16843775; // 0x10103ff
    field public static final int castsShadow = 16843777; // 0x1010401
    field public static final int category = 16843752; // 0x10103e8
    field public static final int centerBright = 16842956; // 0x10100cc
    field public static final int centerColor = 16843275; // 0x101020b
@@ -542,6 +542,7 @@ package android {
    field public static final int fromAlpha = 16843210; // 0x10101ca
    field public static final int fromDegrees = 16843187; // 0x10101b3
    field public static final int fromScene = 16843741; // 0x10103dd
    field public static final int fromSceneName = 16843773; // 0x10103fd
    field public static final int fromXDelta = 16843206; // 0x10101c6
    field public static final int fromXScale = 16843202; // 0x10101c2
    field public static final int fromYDelta = 16843208; // 0x10101c8
@@ -889,7 +890,7 @@ package android {
    field public static final int required = 16843406; // 0x101028e
    field public static final int requiredAccountType = 16843734; // 0x10103d6
    field public static final int requiredForAllUsers = 16843728; // 0x10103d0
    field public static final int requiredForProfile = 16843776; // 0x1010400
    field public static final int requiredForProfile = 16843778; // 0x1010402
    field public static final int requiresFadingEdge = 16843685; // 0x10103a5
    field public static final int requiresSmallestWidthDp = 16843620; // 0x1010364
    field public static final int resizeMode = 16843619; // 0x1010363
@@ -960,7 +961,7 @@ package android {
    field public static final int shadowRadius = 16843108; // 0x1010164
    field public static final int shape = 16843162; // 0x101019a
    field public static final int shareInterpolator = 16843195; // 0x10101bb
    field public static final int sharedElementName = 16843773; // 0x10103fd
    field public static final int sharedElementName = 16843775; // 0x10103ff
    field public static final int sharedUserId = 16842763; // 0x101000b
    field public static final int sharedUserLabel = 16843361; // 0x1010261
    field public static final int shouldDisableView = 16843246; // 0x10101ee
@@ -1144,6 +1145,7 @@ package android {
    field public static final int toAlpha = 16843211; // 0x10101cb
    field public static final int toDegrees = 16843188; // 0x10101b4
    field public static final int toScene = 16843742; // 0x10103de
    field public static final int toSceneName = 16843774; // 0x10103fe
    field public static final int toXDelta = 16843207; // 0x10101c7
    field public static final int toXScale = 16843203; // 0x10101c3
    field public static final int toYDelta = 16843209; // 0x10101c9
@@ -1159,7 +1161,7 @@ package android {
    field public static final int transformPivotX = 16843552; // 0x1010320
    field public static final int transformPivotY = 16843553; // 0x1010321
    field public static final int transition = 16843743; // 0x10103df
    field public static final int transitionGroup = 16843774; // 0x10103fe
    field public static final int transitionGroup = 16843776; // 0x1010400
    field public static final int transitionOrdering = 16843744; // 0x10103e0
    field public static final int translationX = 16843554; // 0x1010322
    field public static final int translationY = 16843555; // 0x1010323
@@ -3039,6 +3041,7 @@ package android.app {
    method public int getTaskId();
    method public final java.lang.CharSequence getTitle();
    method public final int getTitleColor();
    method public android.os.Bundle getTransitionArgs();
    method public final int getVolumeControlStream();
    method public android.view.Window getWindow();
    method public android.view.WindowManager getWindowManager();
@@ -3060,8 +3063,6 @@ package android.app {
    method public void onAttachFragment(android.app.Fragment);
    method public void onAttachedToWindow();
    method public void onBackPressed();
    method public void onCaptureSharedElementEnd();
    method public void onCaptureSharedElementStart(android.transition.Transition);
    method protected void onChildTitleChanged(android.app.Activity, java.lang.CharSequence);
    method public void onConfigurationChanged(android.content.res.Configuration);
    method public void onContentChanged();
@@ -3136,6 +3137,7 @@ 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 setEarlyBackgroundTransition(boolean);
    method public final void setFeatureDrawable(int, android.graphics.drawable.Drawable);
    method public final void setFeatureDrawableAlpha(int, int);
    method public final void setFeatureDrawableResource(int, int);
@@ -3160,9 +3162,7 @@ package android.app {
    method public final deprecated void showDialog(int);
    method public final deprecated boolean showDialog(int, android.os.Bundle);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public void startActivity(android.content.Intent, android.util.Pair<android.view.View, java.lang.String>...);
    method public void startActivityForResult(android.content.Intent, int);
    method public void startActivityForResult(android.content.Intent, int, android.util.Pair<android.view.View, java.lang.String>...);
    method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
    method public void startActivityFromChild(android.app.Activity, android.content.Intent, int);
    method public void startActivityFromChild(android.app.Activity, android.content.Intent, int, android.os.Bundle);
@@ -3178,6 +3178,7 @@ package android.app {
    method public boolean startNextMatchingActivity(android.content.Intent);
    method public boolean startNextMatchingActivity(android.content.Intent, android.os.Bundle);
    method public void startSearch(java.lang.String, boolean, android.os.Bundle, boolean);
    method protected void startSharedElementTransition(android.os.Bundle);
    method public deprecated void stopManagingCursor(android.database.Cursor);
    method public void takeKeyEvents(boolean);
    method public void triggerSearch(java.lang.String, android.os.Bundle);
@@ -3348,6 +3349,7 @@ package android.app {
  public class ActivityOptions {
    method public static android.app.ActivityOptions makeCustomAnimation(android.content.Context, int, int);
    method public static android.app.ActivityOptions makeScaleUpAnimation(android.view.View, int, int, int, int);
    method public static android.app.ActivityOptions makeSceneTransitionAnimation(android.os.Bundle);
    method public static android.app.ActivityOptions makeThumbnailScaleUpAnimation(android.view.View, android.graphics.Bitmap, int, int);
    method public android.os.Bundle toBundle();
    method public void update(android.app.ActivityOptions);
@@ -26818,11 +26820,15 @@ package android.transition {
    ctor public TransitionManager();
    method public static void beginDelayedTransition(android.view.ViewGroup);
    method public static void beginDelayedTransition(android.view.ViewGroup, android.transition.Transition);
    method public android.transition.Transition getNamedTransition(java.lang.String, android.transition.Scene);
    method public android.transition.Transition getNamedTransition(android.transition.Scene, java.lang.String);
    method public java.lang.String[] getTargetSceneNames(android.transition.Scene);
    method public static void go(android.transition.Scene);
    method public static void go(android.transition.Scene, android.transition.Transition);
    method public void setExitTransition(android.transition.Scene, android.transition.Transition);
    method public void setTransition(android.transition.Scene, android.transition.Transition);
    method public void setTransition(android.transition.Scene, android.transition.Scene, android.transition.Transition);
    method public void setTransition(android.transition.Scene, java.lang.String, android.transition.Transition);
    method public void setTransition(java.lang.String, android.transition.Scene, android.transition.Transition);
    method public void transitionTo(android.transition.Scene);
  }
@@ -29793,7 +29799,6 @@ package android.view {
    method public abstract boolean isFloating();
    method public abstract boolean isShortcutKey(int, android.view.KeyEvent);
    method public final void makeActive();
    method public void mapTransitionTargets(java.util.Map<java.lang.String, java.lang.String>);
    method protected abstract void onActive();
    method public abstract void onConfigurationChanged(android.content.res.Configuration);
    method public abstract void openPanel(int, android.view.KeyEvent);
@@ -29832,7 +29837,6 @@ package android.view {
    method public abstract void setTitle(java.lang.CharSequence);
    method public abstract deprecated void setTitleColor(int);
    method public void setTransitionManager(android.transition.TransitionManager);
    method public void setTriggerEarlyEnterTransition(boolean);
    method public void setType(int);
    method public void setUiOptions(int);
    method public void setUiOptions(int, int);
+58 −92
Original line number Diff line number Diff line
@@ -18,10 +18,8 @@ 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.Pair;
import android.util.SuperNotCalledException;
import com.android.internal.app.ActionBarImpl;
import com.android.internal.policy.PolicyManager;
@@ -95,7 +93,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * An activity is a single, focused thing that the user can do.  Almost all
@@ -3449,53 +3446,7 @@ public class Activity extends ContextThemeWrapper
     * @see #startActivity
     */
    public void startActivityForResult(Intent intent, int requestCode) {
        ArrayMap<String, View> sharedElements = new ArrayMap<String, View>();

        if (mActionBar != null) {
            mActionBar.captureSharedElements(sharedElements);
        }
        Bundle opts = mWindow.startExitTransition(sharedElements);
        startActivityForResult(intent, requestCode, opts);
    }

    /**
     * Same as {@link #startActivityForResult(android.content.Intent, int)} except that
     * shared element state is passed to the called Activity during the Activity Scene Transition.
     * The Activity must have a TransitionManager with a Transition associated with exiting
     * the current Scene.
     * @param intent The intent to start.
     * @param requestCode If >= 0, this code will be returned in
     *                    onActivityResult() when the activity exits.
     * @param sharedElements Views to be transitioned to the called Activity and their
     *                       names as used in the called Activity.
     *                       Views must not have null shared element name, however, if the
     *                       Pair has a null name, the shared element name will be reused
     *                       for the launched Activity's shared element name.
     * @see android.transition.TransitionManager#setExitTransition(android.transition.Scene, android.transition.Transition)
     * @see View#setSharedElementName(String)
     */
    public void startActivityForResult(Intent intent, int requestCode,
            Pair<View, String>... sharedElements) {
        ArrayMap<String, View> sharedElementMap = new ArrayMap<String, View>();
        if (sharedElements != null) {
            for (Pair<View, String> sharedElement: sharedElements) {
                View view = sharedElement.first;
                String sharedElementName = view.getSharedElementName();
                if (sharedElementName == null) {
                    throw new IllegalArgumentException("sharedElement must have a non-null "
                            + "sharedElementName");
                }
                String name = sharedElement.second == null
                        ? sharedElementName : sharedElement.second;
                sharedElementMap.put(name, view);
            }
        }
        if (mActionBar != null) {
            mActionBar.captureSharedElements(sharedElementMap);
        }

        Bundle options = mWindow.startExitTransition(sharedElementMap);
        startActivityForResult(intent, requestCode, options);
        startActivityForResult(intent, requestCode, null);
    }

    /**
@@ -3533,6 +3484,14 @@ 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) {
            ActivityOptions activityOptions = new ActivityOptions(options);
            if (activityOptions.getAnimationType() == ActivityOptions.ANIM_SCENE_TRANSITION) {
                getWindow().startExitTransition(activityOptions);
                options = activityOptions.toBundle();
            }
        }
        if (mParent == null) {
            Instrumentation.ActivityResult ar =
                mInstrumentation.execStartActivity(
@@ -3705,25 +3664,7 @@ public class Activity extends ContextThemeWrapper
     */
    @Override
    public void startActivity(Intent intent) {
        startActivity(intent, (Pair<View, String>[]) null);
    }

    /**
     * Same as {@link #startActivity(android.content.Intent)} except that shared element
     * state is passed to the called Activity during the Activity Scene Transition.
     * The Activity must have a TransitionManager with a Transition associated with exiting
     * the current Scene.
     * @param intent The intent to start.
     * @param sharedElements Views to be transitioned to the called Activity and their
     *                       names as used in the called Activity.
     *                       Views must not have null shared element name, however, if the
     *                       Pair has a null name, the shared element name will be reused
     *                       for the launched Activity's shared element name.
     * @see android.transition.TransitionManager#setExitTransition(android.transition.Scene, android.transition.Transition)
     * @see View#setSharedElementName(String)
     */
    public void startActivity(Intent intent, Pair<View, String>... sharedElements) {
        startActivityForResult(intent, -1, sharedElements);
        startActivity(intent, null);
    }

    /**
@@ -4779,8 +4720,7 @@ 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);
    }
    
    /**
@@ -5389,6 +5329,12 @@ 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);
@@ -5403,16 +5349,6 @@ 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();
                    }
                };

            }
@@ -5606,23 +5542,53 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * 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.
     * 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>
     *
     * @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.
     * @return The Bundle passed into Bundle parameter of
     *         {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.os.Bundle)}
     *         in the calling Activity.
     */
    public void onCaptureSharedElementStart(Transition transition) {
    public Bundle getTransitionArgs() {
        if (mTransitionActivityOptions == null) {
            return null;
        }
        return mTransitionActivityOptions.getSceneTransitionArgs();
    }

    /**
     * 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.
     */
    protected void startSharedElementTransition(Bundle transitionArgs) {
    }

    /**
     * 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.
     * 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 onCaptureSharedElementEnd() {
    public void setEarlyBackgroundTransition(boolean fadeEarly) {
        if (mTransitionActivityOptions == null) {
            return;
        }
        mWindow.setEarlyBackgroundTransition(fadeEarly);
    }

    /**
+89 −64

File changed.

Preview size limit exceeded, changes collapsed.

+22 −23
Original line number Diff line number Diff line
@@ -552,7 +552,8 @@ public abstract class Transition implements Cloneable {
        return false;
    }

    private static ArrayMap<Animator, AnimationInfo> getRunningAnimators() {
    /** @hide */
    public static ArrayMap<Animator, AnimationInfo> getRunningAnimators() {
        ArrayMap<Animator, AnimationInfo> runningAnimators = sRunningAnimators.get();
        if (runningAnimators == null) {
            runningAnimators = new ArrayMap<Animator, AnimationInfo>();
@@ -1112,7 +1113,6 @@ public abstract class Transition implements Cloneable {
                }
            }
        }
        if (view.getParent() instanceof ViewGroup) {
        TransitionValues values = new TransitionValues();
        values.view = view;
        if (start) {
@@ -1139,7 +1139,6 @@ public abstract class Transition implements Cloneable {
                mEndValues.itemIdValues.put(itemId, values);
            }
        }
        }
        if (view instanceof ViewGroup) {
            // Don't traverse child hierarchy if there are any child-excludes on this view
            if (mTargetIdChildExcludes != null && mTargetIdChildExcludes.contains(id)) {
+31 −12
Original line number Diff line number Diff line
@@ -285,27 +285,46 @@ 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);
        Scene fromScene = (fromId < 0) ? null: Scene.getSceneForLayout(sceneRoot, fromId, mContext);
        if (fromId >= 0) fromScene = Scene.getSceneForLayout(sceneRoot, fromId, mContext);
        int toId = a.getResourceId(
                com.android.internal.R.styleable.TransitionManager_toScene, -1);
        Scene toScene = (toId < 0) ? null : Scene.getSceneForLayout(sceneRoot, toId, mContext);

        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);
        if (transitionId >= 0) {
            Transition transition = inflateTransition(transitionId);
            if (transition != null) {
                if (fromScene == null) {
                    if (toScene == null) {
                        throw new RuntimeException("No matching fromScene or toScene " +
                                "for transition ID " + transitionId);
                    } else {
                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);
                }
                } else if (toScene == null) {
                    transitionManager.setExitTransition(fromScene, transition);
                if (fromName != null) {
                    if (toScene != null) {
                        transitionManager.setTransition(fromName, toScene, transition);
                    } else {
                    transitionManager.setTransition(fromScene, toScene, transition);
                        throw new RuntimeException("No matching toScene for given fromSceneName " +
                                "for transition ID " + transitionId);
                    }
                }
            }
        }
Loading