aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-03-16 14:49:49 -0700
committerXavier Ducrohet <xav@android.com>2012-03-16 15:13:45 -0700
commit8818ca4db2f1ae396964912bf8035ee88988f4dd (patch)
treeea6af86d983f35246c18489da6bc3e39e58812c4 /ide_common/src/com/android/ide/common/resources/ValueResourceParser.java
parent45a6d2d3883b33a3a8391c0c491b9d6476b0d2e2 (diff)
downloadsdk-8818ca4db2f1ae396964912bf8035ee88988f4dd.zip
sdk-8818ca4db2f1ae396964912bf8035ee88988f4dd.tar.gz
sdk-8818ca4db2f1ae396964912bf8035ee88988f4dd.tar.bz2
Properly support attr ns when used in styles.
Previously we just stripped the namespace prefix when reading attribute names in styles and declare-styleables. This was bad if one created a declare-styleable mixing platform and app attributes that were named the same. This change is Eclipse side only and prevents ADT crashed (due to stack overflows) but the rendering won't be correct. An updated version of layoutlib using API 8 is necessary. Change-Id: I3029f3e06cdd96cd46af511bb029bc5274b935ad
Diffstat (limited to 'ide_common/src/com/android/ide/common/resources/ValueResourceParser.java')
-rw-r--r--ide_common/src/com/android/ide/common/resources/ValueResourceParser.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java b/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java
index 3a5a6a3..7c11dd7 100644
--- a/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java
+++ b/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java
@@ -129,16 +129,29 @@ public final class ValueResourceParser extends DefaultHandler {
if (name != null) {
if (mCurrentStyle != null) {
- // the name can, in some cases, contain a prefix! we remove it.
+ // is the attribute in the android namespace?
+ boolean isFrameworkAttr = mIsFramework;
if (name.startsWith(DEFAULT_NS_PREFIX)) {
name = name.substring(DEFAULT_NS_PREFIX_LEN);
+ isFrameworkAttr = true;
}
mCurrentValue = new ResourceValue(null, name, mIsFramework);
- mCurrentStyle.addValue(mCurrentValue);
+ mCurrentStyle.addValue(mCurrentValue, isFrameworkAttr);
} else if (mCurrentDeclareStyleable != null) {
- mCurrentAttr = new AttrResourceValue(ResourceType.ATTR, name, mIsFramework);
+ // is the attribute in the android namespace?
+ boolean isFramework = mIsFramework;
+ if (name.startsWith(DEFAULT_NS_PREFIX)) {
+ name = name.substring(DEFAULT_NS_PREFIX_LEN);
+ isFramework = true;
+ }
+
+ mCurrentAttr = new AttrResourceValue(ResourceType.ATTR, name, isFramework);
mCurrentDeclareStyleable.addValue(mCurrentAttr);
+
+ // also add it to the repository.
+ mRepository.addResourceValue(mCurrentAttr);
+
} else if (mCurrentAttr != null) {
// get the enum/flag value
String value = attributes.getValue(ATTR_VALUE);