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

Commit d033e67a authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Make Scenes and Transitions first-class in PhoneWindow/Themes"

parents a1dc9fc9 18e905f4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1207,6 +1207,8 @@ package android {
    field public static final int windowBackground = 16842836; // 0x1010054
    field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
    field public static final int windowContentOverlay = 16842841; // 0x1010059
    field public static final int windowContentTransitionManager = 16843765; // 0x10103f5
    field public static final int windowContentTransitions = 16843764; // 0x10103f4
    field public static final int windowDisablePreview = 16843298; // 0x1010222
    field public static final int windowEnableSplitTouch = 16843543; // 0x1010317
    field public static final int windowEnterAnimation = 16842932; // 0x10100b4
@@ -1810,6 +1812,7 @@ package android {
    field public static final int Theme_NoTitleBar_Fullscreen = 16973831; // 0x1030007
    field public static final int Theme_NoTitleBar_OverlayActionModes = 16973930; // 0x103006a
    field public static final int Theme_Panel = 16973913; // 0x1030059
    field public static final int Theme_Quantum = 16974318; // 0x10301ee
    field public static final int Theme_Translucent = 16973839; // 0x103000f
    field public static final int Theme_Translucent_NoTitleBar = 16973840; // 0x1030010
    field public static final int Theme_Translucent_NoTitleBar_Fullscreen = 16973841; // 0x1030011
@@ -26251,7 +26254,8 @@ package android.transition {
  public final class Scene {
    ctor public Scene(android.view.ViewGroup);
    ctor public Scene(android.view.ViewGroup, android.view.ViewGroup);
    ctor public Scene(android.view.ViewGroup, android.view.View);
    ctor public deprecated Scene(android.view.ViewGroup, android.view.ViewGroup);
    method public void enter();
    method public void exit();
    method public static android.transition.Scene getSceneForLayout(android.view.ViewGroup, int, android.content.Context);
@@ -29311,6 +29315,7 @@ package android.view {
    field public static final int FEATURE_ACTION_BAR = 8; // 0x8
    field public static final int FEATURE_ACTION_BAR_OVERLAY = 9; // 0x9
    field public static final int FEATURE_ACTION_MODE_OVERLAY = 10; // 0xa
    field public static final int FEATURE_CONTENT_TRANSITIONS = 11; // 0xb
    field public static final int FEATURE_CONTEXT_MENU = 6; // 0x6
    field public static final int FEATURE_CUSTOM_TITLE = 7; // 0x7
    field public static final int FEATURE_INDETERMINATE_PROGRESS = 5; // 0x5
+153 −26
Original line number Diff line number Diff line
@@ -90,6 +90,35 @@ public class ActivityOptions {
     */
    public static final String KEY_ANIM_START_LISTENER = "android:animStartListener";

    /**
     * A string array of names for the destination scene. This defines an API in the same
     * way that intent action or extra names do and should follow a similar convention:
     * "com.example.scene.FOO"
     *
     * @hide
     */
    public static final String KEY_DEST_SCENE_NAMES = "android:destSceneNames";

    /**
     * A string indicating the destination scene name that was chosen by the target.
     * Used by {@link OnSceneTransitionStartedListener}.
     * @hide
     */
    public static final String KEY_DEST_SCENE_NAME_CHOSEN = "android:destSceneNameChosen";

    /**
     * Callback for when scene transition is started.
     * @hide
     */
    public static final String KEY_SCENE_TRANSITION_START_LISTENER =
            "android:sceneTransitionStartListener";

    /**
     * Arguments for the scene transition about to begin.
     * @hide
     */
    public static final String KEY_SCENE_TRANSITION_ARGS = "android:sceneTransitionArgs";

    /** @hide */
    public static final int ANIM_NONE = 0;
    /** @hide */
@@ -100,6 +129,8 @@ public class ActivityOptions {
    public static final int ANIM_THUMBNAIL_SCALE_UP = 3;
    /** @hide */
    public static final int ANIM_THUMBNAIL_SCALE_DOWN = 4;
    /** @hide */
    public static final int ANIM_SCENE_TRANSITION = 5;

    private String mPackageName;
    private int mAnimationType = ANIM_NONE;
@@ -110,7 +141,10 @@ public class ActivityOptions {
    private int mStartY;
    private int mStartWidth;
    private int mStartHeight;
    private String[] mDestSceneNames;
    private Bundle mTransitionArgs;
    private IRemoteCallback mAnimationStartedListener;
    private IRemoteCallback mSceneTransitionStartedListener;

    /**
     * Create an ActivityOptions specifying a custom animation to run when
@@ -156,11 +190,12 @@ public class ActivityOptions {
        opts.mAnimationType = ANIM_CUSTOM;
        opts.mCustomEnterResId = enterResId;
        opts.mCustomExitResId = exitResId;
        opts.setListener(handler, listener);
        opts.setOnAnimationStartedListener(handler, listener);
        return opts;
    }

    private void setListener(Handler handler, OnAnimationStartedListener listener) {
    private void setOnAnimationStartedListener(Handler handler,
            OnAnimationStartedListener listener) {
        if (listener != null) {
            final Handler h = handler;
            final OnAnimationStartedListener finalListener = listener;
@@ -176,6 +211,24 @@ public class ActivityOptions {
        }
    }

    private void setOnSceneTransitionStartedListener(Handler handler,
            OnSceneTransitionStartedListener listener) {
        if (listener != null) {
            final Handler h = handler;
            final OnSceneTransitionStartedListener l = listener;
            mSceneTransitionStartedListener = new IRemoteCallback.Stub() {
                @Override public void sendResult(final Bundle data) throws RemoteException {
                    h.post(new Runnable() {
                        public void run() {
                            l.onSceneTransitionStarted(data != null ?
                                    data.getString(KEY_DEST_SCENE_NAME_CHOSEN) : null);
                        }
                    });
                }
            };
        }
    }

    /**
     * Callback for use with {@link ActivityOptions#makeThumbnailScaleUpAnimation}
     * to find out when the given animation has started running.
@@ -185,6 +238,15 @@ public class ActivityOptions {
        void onAnimationStarted();
    }

    /**
     * Callback for use with {@link ActivityOptions#makeSceneTransitionAnimation}
     * to find out when a transition is about to begin.
     * @hide
     */
    public interface OnSceneTransitionStartedListener {
        void onSceneTransitionStarted(String destSceneName);
    }

    /**
     * Create an ActivityOptions specifying an animation where the new
     * activity is scaled from a small originating area of the screen to
@@ -298,7 +360,23 @@ public class ActivityOptions {
        source.getLocationOnScreen(pts);
        opts.mStartX = pts[0] + startX;
        opts.mStartY = pts[1] + startY;
        opts.setListener(source.getHandler(), listener);
        opts.setOnAnimationStartedListener(source.getHandler(), listener);
        return opts;
    }

    /**
     * Create an ActivityOptions specifying an animation where an activity window is asked
     * to perform animations within the window content.
     *
     * @hide
     */
    public static ActivityOptions makeSceneTransitionAnimation(String[] destSceneNames,
            Bundle args, OnSceneTransitionStartedListener listener, Handler handler) {
        ActivityOptions opts = new ActivityOptions();
        opts.mAnimationType = ANIM_SCENE_TRANSITION;
        opts.mDestSceneNames = destSceneNames;
        opts.mTransitionArgs = args;
        opts.setOnSceneTransitionStartedListener(handler, listener);
        return opts;
    }

@@ -309,23 +387,36 @@ public class ActivityOptions {
    public ActivityOptions(Bundle opts) {
        mPackageName = opts.getString(KEY_PACKAGE_NAME);
        mAnimationType = opts.getInt(KEY_ANIM_TYPE);
        if (mAnimationType == ANIM_CUSTOM) {
        switch (mAnimationType) {
            case ANIM_CUSTOM:
                mCustomEnterResId = opts.getInt(KEY_ANIM_ENTER_RES_ID, 0);
                mCustomExitResId = opts.getInt(KEY_ANIM_EXIT_RES_ID, 0);
                mAnimationStartedListener = IRemoteCallback.Stub.asInterface(
                    opts.getIBinder(KEY_ANIM_START_LISTENER));
        } else if (mAnimationType == ANIM_SCALE_UP) {
                        opts.getBinder(KEY_ANIM_START_LISTENER));
                break;

            case ANIM_SCALE_UP:
                mStartX = opts.getInt(KEY_ANIM_START_X, 0);
                mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
                mStartWidth = opts.getInt(KEY_ANIM_START_WIDTH, 0);
                mStartHeight = opts.getInt(KEY_ANIM_START_HEIGHT, 0);
        } else if (mAnimationType == ANIM_THUMBNAIL_SCALE_UP ||
                mAnimationType == ANIM_THUMBNAIL_SCALE_DOWN) {
                break;

            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
                mThumbnail = (Bitmap)opts.getParcelable(KEY_ANIM_THUMBNAIL);
                mStartX = opts.getInt(KEY_ANIM_START_X, 0);
                mStartY = opts.getInt(KEY_ANIM_START_Y, 0);
                mAnimationStartedListener = IRemoteCallback.Stub.asInterface(
                    opts.getIBinder(KEY_ANIM_START_LISTENER));
                        opts.getBinder(KEY_ANIM_START_LISTENER));
                break;

            case ANIM_SCENE_TRANSITION:
                mDestSceneNames = opts.getStringArray(KEY_DEST_SCENE_NAMES);
                mTransitionArgs = opts.getBundle(KEY_SCENE_TRANSITION_ARGS);
                mSceneTransitionStartedListener = IRemoteCallback.Stub.asInterface(
                        opts.getBinder(KEY_SCENE_TRANSITION_START_LISTENER));
                break;
        }
    }

@@ -374,11 +465,26 @@ public class ActivityOptions {
        return mStartHeight;
    }

    /** @hide */
    public String[] getDestSceneNames() {
        return mDestSceneNames;
    }

    /** @hide */
    public Bundle getSceneTransitionArgs() {
        return mTransitionArgs;
    }

    /** @hide */
    public IRemoteCallback getOnAnimationStartListener() {
        return mAnimationStartedListener;
    }

    /** @hide */
    public IRemoteCallback getOnSceneTransitionStartedListener() {
        return mSceneTransitionStartedListener;
    }

    /** @hide */
    public void abort() {
        if (mAnimationStartedListener != null) {
@@ -411,13 +517,16 @@ public class ActivityOptions {
                mCustomEnterResId = otherOptions.mCustomEnterResId;
                mCustomExitResId = otherOptions.mCustomExitResId;
                mThumbnail = null;
                if (otherOptions.mAnimationStartedListener != null) {
                if (mAnimationStartedListener != null) {
                    try {
                        otherOptions.mAnimationStartedListener.sendResult(null);
                        mAnimationStartedListener.sendResult(null);
                    } catch (RemoteException e) {
                    }
                }
                mAnimationStartedListener = otherOptions.mAnimationStartedListener;
                mSceneTransitionStartedListener = null;
                mTransitionArgs = null;
                mDestSceneNames = null;
                break;
            case ANIM_SCALE_UP:
                mAnimationType = otherOptions.mAnimationType;
@@ -425,13 +534,16 @@ public class ActivityOptions {
                mStartY = otherOptions.mStartY;
                mStartWidth = otherOptions.mStartWidth;
                mStartHeight = otherOptions.mStartHeight;
                if (otherOptions.mAnimationStartedListener != null) {
                if (mAnimationStartedListener != null) {
                    try {
                        otherOptions.mAnimationStartedListener.sendResult(null);
                        mAnimationStartedListener.sendResult(null);
                    } catch (RemoteException e) {
                    }
                }
                mAnimationStartedListener = null;
                mSceneTransitionStartedListener = null;
                mTransitionArgs = null;
                mDestSceneNames = null;
                break;
            case ANIM_THUMBNAIL_SCALE_UP:
            case ANIM_THUMBNAIL_SCALE_DOWN:
@@ -439,13 +551,28 @@ public class ActivityOptions {
                mThumbnail = otherOptions.mThumbnail;
                mStartX = otherOptions.mStartX;
                mStartY = otherOptions.mStartY;
                if (otherOptions.mAnimationStartedListener != null) {
                if (mAnimationStartedListener != null) {
                    try {
                        otherOptions.mAnimationStartedListener.sendResult(null);
                        mAnimationStartedListener.sendResult(null);
                    } catch (RemoteException e) {
                    }
                }
                mAnimationStartedListener = otherOptions.mAnimationStartedListener;
                mSceneTransitionStartedListener = null;
                mTransitionArgs = null;
                mDestSceneNames = null;
                break;
            case ANIM_SCENE_TRANSITION:
                mAnimationType = otherOptions.mAnimationType;
                if (mSceneTransitionStartedListener != null) {
                    try {
                        mSceneTransitionStartedListener.sendResult(null);
                    } catch (RemoteException e) {
                    }
                }
                mSceneTransitionStartedListener = otherOptions.mSceneTransitionStartedListener;
                mDestSceneNames = otherOptions.mDestSceneNames;
                mAnimationStartedListener = null;
                break;
        }
    }
+10 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public final class Scene {
    private Context mContext;
    private int mLayoutId = -1;
    private ViewGroup mSceneRoot;
    private ViewGroup mLayout; // alternative to layoutId
    private View mLayout; // alternative to layoutId
    Runnable mEnterAction, mExitAction;

    /**
@@ -114,6 +114,15 @@ public final class Scene {
     * @param layout The view hierarchy of this scene, added as a child
     * of sceneRoot when this scene is entered.
     */
    public Scene(ViewGroup sceneRoot, View layout) {
        mSceneRoot = sceneRoot;
        mLayout = layout;
    }

    /**
     * @deprecated use {@link Scene(ViewGroup, View)}.
     */
    @Deprecated
    public Scene(ViewGroup sceneRoot, ViewGroup layout) {
        mSceneRoot = sceneRoot;
        mLayout = layout;
+10 −1
Original line number Diff line number Diff line
@@ -91,12 +91,21 @@ public abstract class Window {
     * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
     */
    public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
    /**
     * Flag for requesting that window content changes should be represented
     * with scenes and transitions.
     *
     * TODO Add docs
     *
     * @see #setContentView
     */
    public static final int FEATURE_CONTENT_TRANSITIONS = 11;

    /**
     * Max value used as a feature ID
     * @hide
     */
    public static final int FEATURE_MAX = FEATURE_ACTION_MODE_OVERLAY;
    public static final int FEATURE_MAX = FEATURE_CONTENT_TRANSITIONS;

    /** Flag for setting the progress bar's visibility to VISIBLE */
    public static final int PROGRESS_VISIBILITY_ON = -1;
+20 −0
Original line number Diff line number Diff line
@@ -447,6 +447,15 @@
             to {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION}. -->
        <attr name="windowTranslucentNavigation" format="boolean" />

        <!-- Flag indicating whether this window requests that content changes be performed
             as scene changes with transitions. Corresponds to
             {@link android.view.Window#FEATURE_CONTENT_TRANSITIONS}. -->
        <attr name="windowContentTransitions" format="boolean" />

        <!-- Reference to a TransitionManager XML resource defining the desired
             transitions between different window content. -->
        <attr name="windowContentTransitionManager" format="reference" />

        <!-- ============ -->
        <!-- Alert Dialog styles -->
        <!-- ============ -->
@@ -1618,6 +1627,9 @@
        <attr name="windowCloseOnTouchOutside" />
        <attr name="windowTranslucentStatus" />
        <attr name="windowTranslucentNavigation" />
        <attr name="windowContentTransitions" />
        <attr name="windowContentTransitionManager" />

        <!-- The minimum width the window is allowed to be, along the major
             axis of the screen.  That is, when in landscape.  Can be either
             an absolute dimension or a fraction of the screen size in that
@@ -4675,6 +4687,14 @@
        <attr name="fromScene" format="reference" />
        <!-- The destination scene in this scene change. -->
        <attr name="toScene" format="reference" />
        <!-- The name of the originating scene in this scene change.
             Apps should treat this name as an API in the same sense
             that an Intent action or extra key is. -->
        <attr name="fromSceneName" format="string" />
        <!-- The name of the destination scene in this scene change.
             Apps should treat this name as an API in the same sense
             that an Intent action or extra key is. -->
        <attr name="toSceneName" format="string" />
    </declare-styleable>

    <!-- ========================== -->
Loading