diff options
-rw-r--r-- | api/current.txt | 4 | ||||
-rw-r--r-- | core/java/android/transition/Fade.java | 23 | ||||
-rw-r--r-- | core/java/android/transition/TransitionInflater.java | 10 | ||||
-rw-r--r-- | core/java/android/transition/Visibility.java | 37 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 17 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 1 |
6 files changed, 77 insertions, 15 deletions
diff --git a/api/current.txt b/api/current.txt index acecca3..84c4f53 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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 { diff --git a/core/java/android/transition/Fade.java b/core/java/android/transition/Fade.java index e70dc0c..71559da 100644 --- a/core/java/android/transition/Fade.java +++ b/core/java/android/transition/Fade.java @@ -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); } diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java index 58d743c..9e43201 100644 --- a/core/java/android/transition/TransitionInflater.java +++ b/core/java/android/transition/TransitionInflater.java @@ -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; } diff --git a/core/java/android/transition/Visibility.java b/core/java/android/transition/Visibility.java index 947e1a7..aa9f04e 100644 --- a/core/java/android/transition/Visibility.java +++ b/core/java/android/transition/Visibility.java @@ -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; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index a8a4d7a..a092160 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -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 diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 727d286..3206457 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2215,6 +2215,7 @@ <public type="attr" name="actionModeShareDrawable" /> <public type="attr" name="actionModeFindDrawable" /> <public type="attr" name="actionModeWebSearchDrawable" /> + <public type="attr" name="visibilityMode" /> <public-padding type="dimen" name="l_resource_pad" end="0x01050010" /> |