Skip to content

Commit 44e63a2

Browse files
author
Xavier Ducrohet
committed
Support rendering layout that use the new res-auto namespace.
Change-Id: I9b89c965dc8c9458e74c15ab8ff765e16e1b32c2
1 parent 5786f5c commit 44e63a2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public class BridgeConstants {
3939
/** Namespace for the resource XML */
4040
public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
4141

42+
/** App auto namespace */
43+
public final static String NS_APP_RES_AUTO = "http://schemas.android.com/apk/res-auto";
44+
4245
public final static String R = "com.android.internal.R";
4346

4447

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
import android.content.res.BridgeTypedArray;
5050
import android.content.res.Configuration;
5151
import android.content.res.Resources;
52-
import android.content.res.TypedArray;
5352
import android.content.res.Resources.Theme;
53+
import android.content.res.TypedArray;
5454
import android.database.DatabaseErrorHandler;
5555
import android.database.sqlite.SQLiteDatabase;
5656
import android.database.sqlite.SQLiteDatabase.CursorFactory;
@@ -78,8 +78,8 @@
7878
import java.util.HashMap;
7979
import java.util.IdentityHashMap;
8080
import java.util.Map;
81-
import java.util.TreeMap;
8281
import java.util.Map.Entry;
82+
import java.util.TreeMap;
8383
import java.util.concurrent.atomic.AtomicBoolean;
8484
import java.util.concurrent.atomic.AtomicReference;
8585

@@ -615,7 +615,8 @@ public TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs,
615615
}
616616

617617
String namespace = BridgeConstants.NS_RESOURCES;
618-
if (frameworkAttributes.get() == false) {
618+
boolean useFrameworkNS = frameworkAttributes.get();
619+
if (useFrameworkNS == false) {
619620
// need to use the application namespace
620621
namespace = mProjectCallback.getNamespace();
621622
}
@@ -628,6 +629,12 @@ public TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs,
628629
String value = null;
629630
if (set != null) {
630631
value = set.getAttributeValue(namespace, name);
632+
633+
// if this is an app attribute, and the first get fails, try with the
634+
// new res-auto namespace as well
635+
if (useFrameworkNS == false && value == null) {
636+
value = set.getAttributeValue(BridgeConstants.NS_APP_RES_AUTO, name);
637+
}
631638
}
632639

633640
// if there's no direct value for this attribute in the XML, we look for default

0 commit comments

Comments
 (0)