Add ability to exclude Views in transition XML.
Bug 14259955
Change-Id: I47bb10c530c9fec8910ddd96156fc38d6027e1f6
diff --git a/api/current.txt b/api/current.txt
index 4779124..b81c833 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -501,7 +501,9 @@
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 c67d6fa..d8392f5 100644
--- a/core/java/android/transition/Transition.java
+++ b/core/java/android/transition/Transition.java
@@ -89,7 +89,8 @@
* transition uses a fadingMode of {@link Fade#OUT} instead of the default
* out-in behavior. Finally, note the use of the <code>targets</code> sub-tag, which
* takes a set of {@link android.R.styleable#TransitionTarget target} tags, each
- * of which lists a specific <code>targetId</code> which this transition acts upon.
+ * of which lists a specific <code>targetId</code>, <code>excludeId</code>, or
+ * <code>excludeClass</code>, 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 <code>grayscaleContainer</code> will be
diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java
index 14ecc15..1aa412a 100644
--- a/core/java/android/transition/TransitionInflater.java
+++ b/core/java/android/transition/TransitionInflater.java
@@ -210,7 +210,6 @@
int type;
int depth = parser.getDepth();
- ArrayList<Integer> targetIds = new ArrayList<Integer>();
while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
&& type != XmlPullParser.END_DOCUMENT) {
@@ -225,18 +224,29 @@
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 abac60e..e35239f 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5025,6 +5025,10 @@
<declare-styleable name="TransitionTarget">
<!-- The id of a target on which this transition will animate changes. -->
<attr name="targetId" format="reference" />
+ <!-- The id of a target to exclude from this transition. -->
+ <attr name="excludeId" format="reference" />
+ <!-- The fully-qualified name of the Class to exclude from this transition. -->
+ <attr name="excludeClass" format="string" />
</declare-styleable>
<!-- Use <code>set</code> as the root tag of the XML resource that
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 85ef004..c7f446b 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2164,6 +2164,8 @@
<public type="attr" name="sessionService" />
<public type="attr" name="switchStyle" />
<public type="attr" name="elevation" />
+ <public type="attr" name="excludeId" />
+ <public type="attr" name="excludeClass" />
<public-padding type="dimen" name="l_resource_pad" end="0x01050010" />