am 63e5d07e: Merge "Fix issue with project resources overriding framework resources." into gingerbread
This commit is contained in:
@@ -266,7 +266,7 @@ public final class BridgeContext extends Context {
|
|||||||
customStyle = parser.getAttributeValue(null /* namespace*/, "style");
|
customStyle = parser.getAttributeValue(null /* namespace*/, "style");
|
||||||
}
|
}
|
||||||
if (customStyle != null) {
|
if (customStyle != null) {
|
||||||
IResourceValue item = findResValue(customStyle);
|
IResourceValue item = findResValue(customStyle, false /*forceFrameworkOnly*/);
|
||||||
|
|
||||||
if (item instanceof IStyleResourceValue) {
|
if (item instanceof IStyleResourceValue) {
|
||||||
defStyleValues = (IStyleResourceValue)item;
|
defStyleValues = (IStyleResourceValue)item;
|
||||||
@@ -283,7 +283,7 @@ public final class BridgeContext extends Context {
|
|||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
// item is a reference to a style entry. Search for it.
|
// item is a reference to a style entry. Search for it.
|
||||||
item = findResValue(item.getValue());
|
item = findResValue(item.getValue(), false /*forceFrameworkOnly*/);
|
||||||
|
|
||||||
if (item instanceof IStyleResourceValue) {
|
if (item instanceof IStyleResourceValue) {
|
||||||
defStyleValues = (IStyleResourceValue)item;
|
defStyleValues = (IStyleResourceValue)item;
|
||||||
@@ -413,7 +413,7 @@ public final class BridgeContext extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the IResourceValue referenced by this value
|
// get the IResourceValue referenced by this value
|
||||||
IResourceValue resValue = findResValue(value);
|
IResourceValue resValue = findResValue(value, false /*forceFrameworkOnly*/);
|
||||||
|
|
||||||
// if resValue is null, but value is not null, this means it was not a reference.
|
// if resValue is null, but value is not null, this means it was not a reference.
|
||||||
// we return the name/value wrapper in a IResourceValue
|
// we return the name/value wrapper in a IResourceValue
|
||||||
@@ -449,7 +449,7 @@ public final class BridgeContext extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// else attempt to find another IResourceValue referenced by this one.
|
// else attempt to find another IResourceValue referenced by this one.
|
||||||
IResourceValue resolvedValue = findResValue(value.getValue());
|
IResourceValue resolvedValue = findResValue(value.getValue(), value.isFramework());
|
||||||
|
|
||||||
// if the value did not reference anything, then we simply return the input value
|
// if the value did not reference anything, then we simply return the input value
|
||||||
if (resolvedValue == null) {
|
if (resolvedValue == null) {
|
||||||
@@ -476,9 +476,11 @@ public final class BridgeContext extends Context {
|
|||||||
* only support the android namespace.
|
* only support the android namespace.
|
||||||
*
|
*
|
||||||
* @param reference the resource reference to search for.
|
* @param reference the resource reference to search for.
|
||||||
|
* @param forceFrameworkOnly if true all references are considered to be toward framework
|
||||||
|
* resource even if the reference does not include the android: prefix.
|
||||||
* @return a {@link IResourceValue} or <code>null</code>.
|
* @return a {@link IResourceValue} or <code>null</code>.
|
||||||
*/
|
*/
|
||||||
IResourceValue findResValue(String reference) {
|
IResourceValue findResValue(String reference, boolean forceFrameworkOnly) {
|
||||||
if (reference == null) {
|
if (reference == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -560,7 +562,8 @@ public final class BridgeContext extends Context {
|
|||||||
segments[1] = segments[1].substring(BridgeConstants.PREFIX_ANDROID.length());
|
segments[1] = segments[1].substring(BridgeConstants.PREFIX_ANDROID.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
return findResValue(segments[0], segments[1], frameworkOnly);
|
return findResValue(segments[0], segments[1],
|
||||||
|
forceFrameworkOnly ? true :frameworkOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looks like the value didn't reference anything. Return null.
|
// Looks like the value didn't reference anything. Return null.
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see android.util.XmlPullAttributes#getAttributeNameResource(int)
|
* @see android.util.XmlPullAttributes#getAttributeNameResource(int)
|
||||||
*
|
*
|
||||||
* This methods must return com.android.internal.R.attr.<name> matching
|
* This methods must return com.android.internal.R.attr.<name> matching
|
||||||
* the name of the attribute.
|
* the name of the attribute.
|
||||||
* It returns 0 if it doesn't find anything.
|
* It returns 0 if it doesn't find anything.
|
||||||
@@ -50,19 +50,19 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
public int getAttributeNameResource(int index) {
|
public int getAttributeNameResource(int index) {
|
||||||
// get the attribute name.
|
// get the attribute name.
|
||||||
String name = getAttributeName(index);
|
String name = getAttributeName(index);
|
||||||
|
|
||||||
// get the attribute namespace
|
// get the attribute namespace
|
||||||
String ns = mParser.getAttributeNamespace(index);
|
String ns = mParser.getAttributeNamespace(index);
|
||||||
|
|
||||||
if (BridgeConstants.NS_RESOURCES.equals(ns)) {
|
if (BridgeConstants.NS_RESOURCES.equals(ns)) {
|
||||||
Integer v = Bridge.getResourceValue(BridgeConstants.RES_ATTR, name);
|
Integer v = Bridge.getResourceValue(BridgeConstants.RES_ATTR, name);
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
return v.intValue();
|
return v.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is not an attribute in the android namespace, we query the customviewloader, if
|
// this is not an attribute in the android namespace, we query the customviewloader, if
|
||||||
// the namespaces match.
|
// the namespaces match.
|
||||||
if (mContext.getProjectCallback().getNamespace().equals(ns)) {
|
if (mContext.getProjectCallback().getNamespace().equals(ns)) {
|
||||||
@@ -75,7 +75,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see android.util.XmlPullAttributes#getAttributeResourceValue(int, int)
|
* @see android.util.XmlPullAttributes#getAttributeResourceValue(int, int)
|
||||||
@@ -83,7 +83,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
@Override
|
@Override
|
||||||
public int getAttributeResourceValue(int index, int defaultValue) {
|
public int getAttributeResourceValue(int index, int defaultValue) {
|
||||||
String value = getAttributeValue(index);
|
String value = getAttributeValue(index);
|
||||||
|
|
||||||
return resolveResourceValue(value, defaultValue);
|
return resolveResourceValue(value, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +94,15 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
@Override
|
@Override
|
||||||
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
|
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
|
||||||
String value = getAttributeValue(namespace, attribute);
|
String value = getAttributeValue(namespace, attribute);
|
||||||
|
|
||||||
return resolveResourceValue(value, defaultValue);
|
return resolveResourceValue(value, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int resolveResourceValue(String value, int defaultValue) {
|
private int resolveResourceValue(String value, int defaultValue) {
|
||||||
// now look for this particular value
|
// now look for this particular value
|
||||||
IResourceValue resource = mContext.resolveResValue(mContext.findResValue(value));
|
IResourceValue resource = mContext.resolveResValue(
|
||||||
|
mContext.findResValue(value, mPlatformFile));
|
||||||
|
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
Integer id = null;
|
Integer id = null;
|
||||||
if (mPlatformFile || resource.isFramework()) {
|
if (mPlatformFile || resource.isFramework()) {
|
||||||
@@ -115,7 +116,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ public final class ResourceHelper {
|
|||||||
parser.setInput(new FileReader(f));
|
parser.setInput(new FileReader(f));
|
||||||
|
|
||||||
d = Drawable.createFromXml(context.getResources(),
|
d = Drawable.createFromXml(context.getResources(),
|
||||||
// FIXME: we need to know if this resource is platform or not
|
new BridgeXmlBlockParser(parser, context, isFramework));
|
||||||
new BridgeXmlBlockParser(parser, context, false));
|
|
||||||
return d;
|
return d;
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
context.getLogger().error(e);
|
context.getLogger().error(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user