From 8818ca4db2f1ae396964912bf8035ee88988f4dd Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 16 Mar 2012 14:49:49 -0700 Subject: 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 --- .../ide/common/resources/ValueResourceParser.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'ide_common/src/com/android/ide/common/resources/ValueResourceParser.java') 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); -- cgit v1.1