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

Commit d4c3c91d authored by George Mount's avatar George Mount
Browse files

Allow antroid.transition Transitions in fragments.

Bug 15274281
Bug 15189829

Change-Id: I8e2974430b84a611866fe20afe1f5745e803683f
parent e54a764c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4203,6 +4203,9 @@ package android.app {
    method public abstract android.app.FragmentTransaction setBreadCrumbTitle(java.lang.CharSequence);
    method public abstract android.app.FragmentTransaction setCustomAnimations(int, int);
    method public abstract android.app.FragmentTransaction setCustomAnimations(int, int, int, int);
    method public abstract android.app.FragmentTransaction setCustomTransition(int, int);
    method public abstract android.app.FragmentTransaction setSharedElement(android.view.View, java.lang.String);
    method public abstract android.app.FragmentTransaction setSharedElements(android.util.Pair<android.view.View, java.lang.String>...);
    method public abstract android.app.FragmentTransaction setTransition(int);
    method public abstract android.app.FragmentTransaction setTransitionStyle(int);
    method public abstract android.app.FragmentTransaction show(android.app.Fragment);
+6 −2
Original line number Diff line number Diff line
@@ -293,13 +293,17 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        if (transition == null || views == null || views.isEmpty()) {
            return null;
        }
        // Add the targets to a set containing transition so that transition
        // remains unaffected. We don't want to modify the targets of transition itself.
        TransitionSet set = new TransitionSet();
        set.addTransition(transition);
        if (views != null) {
            for (View view : views) {
                set.addTarget(view);
            }
        }
        // By adding the transition after addTarget, we prevent addTarget from
        // affecting transition.
        set.addTransition(transition);
        return set;
    }

+454 −90

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -1494,7 +1494,7 @@ final class FragmentManagerImpl extends FragmentManager {
                return false;
            }
            final BackStackRecord bss = mBackStack.remove(last);
            bss.popFromBackStack(true);
            bss.popFromBackStack(true, null);
            reportBackStackChanged();
        } else {
            int index = -1;
@@ -1538,9 +1538,10 @@ final class FragmentManagerImpl extends FragmentManager {
                states.add(mBackStack.remove(i));
            }
            final int LAST = states.size()-1;
            BackStackRecord.TransitionState state = null;
            for (int i=0; i<=LAST; i++) {
                if (DEBUG) Log.v(TAG, "Popping back stack state: " + states.get(i));
                states.get(i).popFromBackStack(i == LAST);
                state = states.get(i).popFromBackStack(i == LAST, state);
            }
            reportBackStackChanged();
        }
+33 −0
Original line number Diff line number Diff line
package android.app;

import android.util.Pair;
import android.view.View;

/**
 * API for performing a set of Fragment operations.
 *
@@ -168,6 +171,36 @@ public abstract class FragmentTransaction {
     */
    public abstract FragmentTransaction setTransition(int transit);

    /**
     * Set a {@link android.transition.Transition} resource id to use with this transaction.
     * <var>transitionId</var> will be played for fragments when going forward and when popping
     * the back stack.
     * @param sceneRootId The ID of the element acting as the scene root for the transition.
     *                    This should be a ViewGroup containing all Fragments in the transaction.
     * @param transitionId The resource ID for the Transition used during the Fragment transaction.
     */
    public abstract FragmentTransaction setCustomTransition(int sceneRootId, int transitionId);

    /**
     * Used with {@link #setCustomTransition(int, int)} to map a View from a removed or hidden
     * Fragment to a View from a shown or added Fragment.
     * <var>sharedElement</var> must have a unique viewName in the View hierarchy.
     * @param sharedElement A View in a disappearing Fragment to match with a View in an
     *                      appearing Fragment.
     * @param name The viewName for a View in an appearing Fragment to match to the shared
     *             element.
     */
    public abstract FragmentTransaction setSharedElement(View sharedElement, String name);

    /**
     * Used with {@link #setCustomTransition(int, int)} to map multiple Views from removed or hidden
     * Fragments to a Views from a shown or added Fragments. Views in
     * <var>sharedElements</var> must have unique viewNames in the View hierarchy.
     * @param sharedElements Pairs of Views in disappearing Fragments to viewNames in
     *                       appearing Fragments.
     */
    public abstract FragmentTransaction setSharedElements(Pair<View, String>... sharedElements);

    /**
     * Set a custom style resource that will be used for resolving transit
     * animations.
Loading