aboutsummaryrefslogtreecommitdiffstats
path: root/lint
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2011-11-28 16:36:25 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-28 16:36:25 -0800
commit3162c11700e77c045aadaac8983716fcc779f290 (patch)
treebe2473022322364d155ecb4281423cda517b2f8d /lint
parent02a5c958428a36bf54fd082723145a15d483de60 (diff)
parent078fab80c375a38ecaa9c0be80b90ab480e675c7 (diff)
downloadsdk-3162c11700e77c045aadaac8983716fcc779f290.zip
sdk-3162c11700e77c045aadaac8983716fcc779f290.tar.gz
sdk-3162c11700e77c045aadaac8983716fcc779f290.tar.bz2
Merge "Don't flag selector states with custom attributes as unreachable"
Diffstat (limited to 'lint')
-rw-r--r--lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java12
-rw-r--r--lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/StateListDetectorTest.java6
-rw-r--r--lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/drawable/states2.xml7
3 files changed, 25 insertions, 0 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java
index e1f923e..ab42d03 100644
--- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java
+++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/StateListDetector.java
@@ -16,6 +16,8 @@
package com.android.tools.lint.checks;
+import static com.android.tools.lint.detector.api.LintConstants.ANDROID_URI;
+
import com.android.resources.ResourceFolderType;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Context;
@@ -83,6 +85,16 @@ public class StateListDetector extends ResourceXmlDetector {
if (attribute.getLocalName().startsWith("state_")) {
hasState = true;
break;
+ } else {
+ String namespaceUri = attribute.getNamespaceURI();
+ if (namespaceUri != null && namespaceUri.length() > 0 &&
+ !ANDROID_URI.equals(namespaceUri)) {
+ // There is a custom attribute on this item.
+ // This could be a state, see
+ // http://code.google.com/p/android/issues/detail?id=22339
+ // so don't flag this one.
+ hasState = true;
+ }
}
}
if (!hasState) {
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/StateListDetectorTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/StateListDetectorTest.java
index da6bbf4..b0994fe 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/StateListDetectorTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/StateListDetectorTest.java
@@ -31,4 +31,10 @@ public class StateListDetectorTest extends AbstractCheckTest {
"later states not reachable",
lintProject("res/drawable/states.xml"));
}
+
+ public void testCustomStates() throws Exception {
+ assertEquals(
+ "No warnings.",
+ lintProject("res/drawable/states2.xml"));
+ }
}
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/drawable/states2.xml b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/drawable/states2.xml
new file mode 100644
index 0000000..dac176d
--- /dev/null
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/data/res/drawable/states2.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res/com.domain.pkg">
+<item
+ app:mystate_custom="false"
+ android:drawable="@drawable/item" />
+</selector>