From f976c3d42bc2f14333bae5ed26d96c45d207a443 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 15 Apr 2014 09:01:32 -0700 Subject: Add ability to exclude Views in transition XML. Bug 14259955 Change-Id: I47bb10c530c9fec8910ddd96156fc38d6027e1f6 --- api/current.txt | 2 ++ core/java/android/transition/Transition.java | 3 ++- .../android/transition/TransitionInflater.java | 26 +++++++++++++++------- core/res/res/values/attrs.xml | 4 ++++ core/res/res/values/public.xml | 2 ++ 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/api/current.txt b/api/current.txt index 47791242eb91..b81c83347b7e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -501,7 +501,9 @@ package android { field public static final int entries = 16842930; // 0x10100b2 field public static final int entryValues = 16843256; // 0x10101f8 field public static final int eventsInterceptionEnabled = 16843389; // 0x101027d + field public static final int excludeClass = 16843854; // 0x101044e field public static final int excludeFromRecents = 16842775; // 0x1010017 + field public static final int excludeId = 16843853; // 0x101044d field public static final int exitFadeDuration = 16843533; // 0x101030d field public static final int expandableListPreferredChildIndicatorLeft = 16842834; // 0x1010052 field public static final int expandableListPreferredChildIndicatorRight = 16842835; // 0x1010053 diff --git a/core/java/android/transition/Transition.java b/core/java/android/transition/Transition.java index c67d6fa9cbd4..d8392f5812c0 100644 --- a/core/java/android/transition/Transition.java +++ b/core/java/android/transition/Transition.java @@ -89,7 +89,8 @@ import java.util.List; * transition uses a fadingMode of {@link Fade#OUT} instead of the default * out-in behavior. Finally, note the use of the targets sub-tag, which * takes a set of {@link android.R.styleable#TransitionTarget target} tags, each - * of which lists a specific targetId which this transition acts upon. + * of which lists a specific targetId, excludeId, or + * excludeClass, which this transition acts upon. * Use of targets is optional, but can be used to either limit the time spent checking * attributes on unchanging views, or limiting the types of animations run on specific views. * In this case, we know that only the grayscaleContainer will be diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java index 14ecc1532581..1aa412a3c4d8 100644 --- a/core/java/android/transition/TransitionInflater.java +++ b/core/java/android/transition/TransitionInflater.java @@ -210,7 +210,6 @@ public class TransitionInflater { int type; int depth = parser.getDepth(); - ArrayList targetIds = new ArrayList(); while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { @@ -225,18 +224,29 @@ public class TransitionInflater { int id = a.getResourceId( com.android.internal.R.styleable.TransitionTarget_targetId, -1); if (id >= 0) { - targetIds.add(id); + transition.addTarget(id); + } else { + id = a.getResourceId( + com.android.internal.R.styleable.TransitionTarget_excludeId, -1); + if (id >= 0) { + transition.excludeTarget(id, true); + } else { + String className = a.getString( + com.android.internal.R.styleable.TransitionTarget_excludeClass); + if (className != null) { + try { + Class clazz = Class.forName(className); + transition.excludeTarget(clazz, true); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Could not create " + className, e); + } + } + } } } else { throw new RuntimeException("Unknown scene name: " + parser.getName()); } } - int numTargets = targetIds.size(); - if (numTargets > 0) { - for (int i = 0; i < numTargets; ++i) { - transition.addTarget(targetIds.get(i)); - } - } } private Transition loadTransition(Transition transition, AttributeSet attrs) diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index abac60e17978..e35239fa43fd 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -5025,6 +5025,10 @@ + + + +