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

Commit 18ab7996 authored by George Mount's avatar George Mount
Browse files

Add IN/OUT flag for all Visibility transitions.

Bug 15758206

Change-Id: If9b1871117a6808c87adc84ab9215b913ebd2704
parent 6507f2e0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1310,6 +1310,7 @@ package android {
    field public static final int viewportHeight = 16843805; // 0x101041d
    field public static final int viewportWidth = 16843804; // 0x101041c
    field public static final int visibility = 16842972; // 0x10100dc
    field public static final int visibilityMode = 16843902; // 0x101047e
    field public static final int visible = 16843156; // 0x1010194
    field public static final int vmSafeMode = 16843448; // 0x10102b8
    field public static final int voiceLanguage = 16843349; // 0x1010255
@@ -30687,6 +30688,9 @@ package android.transition {
    method public android.animation.Animator onAppear(android.view.ViewGroup, android.view.View, android.transition.TransitionValues, android.transition.TransitionValues);
    method public android.animation.Animator onDisappear(android.view.ViewGroup, android.transition.TransitionValues, int, android.transition.TransitionValues, int);
    method public android.animation.Animator onDisappear(android.view.ViewGroup, android.view.View, android.transition.TransitionValues, android.transition.TransitionValues);
    method public void setMode(int);
    field public static final int IN = 1; // 0x1
    field public static final int OUT = 2; // 0x2
  }
  public abstract class VisibilityPropagation extends android.transition.TransitionPropagation {
+8 −15
Original line number Diff line number Diff line
@@ -63,23 +63,23 @@ public class Fade extends Visibility {
    /**
     * Fading mode used in {@link #Fade(int)} to make the transition
     * operate on targets that are appearing. Maybe be combined with
     * {@link #OUT} to fade both in and out.
     * {@link #OUT} to fade both in and out. Equivalent to
     * {@link Visibility#IN}.
     */
    public static final int IN = 0x1;
    public static final int IN = Visibility.IN;

    /**
     * Fading mode used in {@link #Fade(int)} to make the transition
     * operate on targets that are disappearing. Maybe be combined with
     * {@link #IN} to fade both in and out.
     * {@link #IN} to fade both in and out. Equivalent to
     * {@link Visibility#OUT}.
     */
    public static final int OUT = 0x2;

    private int mFadingMode;
    public static final int OUT = Visibility.OUT;

    /**
     * Constructs a Fade transition that will fade targets in and out.
     */
    public Fade() {
        this(IN | OUT);
    }

    /**
@@ -90,7 +90,7 @@ public class Fade extends Visibility {
     * {@link #IN} and {@link #OUT}.
     */
    public Fade(int fadingMode) {
        mFadingMode = fadingMode;
        setMode(fadingMode);
    }

    /**
@@ -115,9 +115,6 @@ public class Fade extends Visibility {
    public Animator onAppear(ViewGroup sceneRoot, View view,
            TransitionValues startValues,
            TransitionValues endValues) {
        if ((mFadingMode & IN) != IN || endValues == null) {
            return null;
        }
        if (DBG) {
            View startView = (startValues != null) ? startValues.view : null;
            Log.d(LOG_TAG, "Fade.onAppear: startView, startVis, endView, endVis = " +
@@ -129,10 +126,6 @@ public class Fade extends Visibility {
    @Override
    public Animator onDisappear(ViewGroup sceneRoot, final View view, TransitionValues startValues,
            TransitionValues endValues) {
        if ((mFadingMode & OUT) != OUT) {
            return null;
        }

        return createAnimation(view, 1, 0);
    }

+10 −0
Original line number Diff line number Diff line
@@ -349,6 +349,16 @@ public class TransitionInflater {
            transition.setMatchOrder(parseMatchOrder(matchOrder));
        }
        a.recycle();
        if (transition instanceof Visibility) {
            a = mContext.obtainStyledAttributes(attrs,
                    com.android.internal.R.styleable.VisibilityTransition);
            int mode = a.getInt(
                    com.android.internal.R.styleable.VisibilityTransition_visibilityMode, 0);
            a.recycle();
            if (mode != 0) {
                ((Visibility)transition).setMode(mode);
            }
        }
        return transition;
    }

+37 −0
Original line number Diff line number Diff line
@@ -43,6 +43,20 @@ public abstract class Visibility extends Transition {
    private static final String PROPNAME_PARENT = "android:visibility:parent";
    private static final String PROPNAME_SCREEN_LOCATION = "android:visibility:screenLocation";

    /**
     * Mode used in {@link #setMode(int)} to make the transition
     * operate on targets that are appearing. Maybe be combined with
     * {@link #OUT} to target Visibility changes both in and out.
     */
    public static final int IN = 0x1;

    /**
     * Mode used in {@link #setMode(int)} to make the transition
     * operate on targets that are disappearing. Maybe be combined with
     * {@link #IN} to target Visibility changes both in and out.
     */
    public static final int OUT = 0x2;

    private static final String[] sTransitionProperties = {
            PROPNAME_VISIBILITY,
            PROPNAME_PARENT,
@@ -58,6 +72,22 @@ public abstract class Visibility extends Transition {
        ViewGroup endParent;
    }

    private int mMode = IN | OUT;

    /**
     * Changes the transition to support appearing and/or disappearing Views, depending
     * on <code>mode</code>.
     *
     * @param mode The behavior supported by this transition, a combination of
     *             {@link #IN} and {@link #OUT}.
     */
    public void setMode(int mode) {
        if ((mode & ~(IN | OUT)) != 0) {
            throw new IllegalArgumentException("Only IN and OUT flags are allowed");
        }
        mMode = mode;
    }

    @Override
    public String[] getTransitionProperties() {
        return sTransitionProperties;
@@ -200,6 +230,9 @@ public abstract class Visibility extends Transition {
    public Animator onAppear(ViewGroup sceneRoot,
            TransitionValues startValues, int startVisibility,
            TransitionValues endValues, int endVisibility) {
        if ((mMode & IN) != IN || endValues == null) {
            return null;
        }
        return onAppear(sceneRoot, endValues.view, startValues, endValues);
    }

@@ -260,6 +293,10 @@ public abstract class Visibility extends Transition {
    public Animator onDisappear(ViewGroup sceneRoot,
            TransitionValues startValues, int startVisibility,
            TransitionValues endValues, int endVisibility) {
        if ((mMode & OUT) != OUT) {
            return null;
        }

        View startView = (startValues != null) ? startValues.view : null;
        View endView = (endValues != null) ? endValues.view : null;
        View overlayView = null;
+17 −0
Original line number Diff line number Diff line
@@ -5338,6 +5338,8 @@
         resource are available in addition to the specific attributes of Fade
         described here. -->
    <declare-styleable name="Fade">
        <!-- Equivalent to <code>visibilityMode</code>, fadingMode works only
             with the Fade transition. -->
        <attr name="fadingMode">
            <!-- Fade will only fade appearing items in. -->
            <enum name="fade_in" value="1" />
@@ -5366,6 +5368,21 @@
        </attr>
    </declare-styleable>

    <!-- Use with {@link android.transition.Visibility} transitions, such as
         <code>slide</code>, <code>explode</code>, and <code>fade</code> to mark which
         views are supported. -->
    <declare-styleable name="VisibilityTransition">
        <!-- Changes whether the transition supports appearing and/or disappearing Views.
             Corresponds to {@link android.transition.Visibility#setMode(int)}. -->
        <attr name="visibilityMode">
            <!-- Only appearing Views will be supported. -->
            <enum name="mode_in" value="1" />
            <!-- Only disappearing Views will be supported. -->
            <enum name="mode_out" value="2" />
            <!-- Both appearing and disappearing views will be supported. -->
            <enum name="mode_in_out" value="3" />
        </attr>
    </declare-styleable>
    <!-- Use <code>target</code> as the root tag of the XML resource that
     describes a {@link android.transition.Transition#addTarget(int)
     targetId} of a transition. There can be one or more targets inside
Loading