Merge "LayoutLib: Misc fixes." into honeycomb

This commit is contained in:
Xavier Ducrohet
2011-01-14 15:26:30 -08:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 19 deletions

View File

@@ -254,6 +254,11 @@ public final class BridgeContext extends Activity {
return null;
}
// needed by SearchView
if (INPUT_METHOD_SERVICE.equals(service)) {
return null;
}
throw new UnsupportedOperationException("Unsupported Service: " + service);
}
@@ -443,7 +448,7 @@ public final class BridgeContext extends Activity {
} else {
// there is a value in the XML, but we need to resolve it in case it's
// referencing another resource or a theme value.
ta.bridgeSetValue(index, name, resolveValue(null, name, value));
ta.bridgeSetValue(index, name, resolveValue(null, name, value, isPlatformFile));
}
}
}
@@ -506,21 +511,24 @@ public final class BridgeContext extends Activity {
* @param type the type of the resource
* @param name the name of the attribute containing this value.
* @param value the resource value, or reference to resolve
* @param isFrameworkValue whether the value is a framework value.
*
* @return the resolved resource value or <code>null</code> if it failed to resolve it.
*/
private ResourceValue resolveValue(String type, String name, String value) {
private ResourceValue resolveValue(String type, String name, String value,
boolean isFrameworkValue) {
if (value == null) {
return null;
}
// get the ResourceValue referenced by this value
ResourceValue resValue = findResValue(value, false /*forceFrameworkOnly*/);
ResourceValue resValue = findResValue(value, isFrameworkValue);
// if resValue is null, but value is not null, this means it was not a reference.
// we return the name/value wrapper in a ResourceValue. the isFramework flag doesn't
// matter.
if (resValue == null) {
return new ResourceValue(type, name, value, false /*isFramework*/);
return new ResourceValue(type, name, value, isFrameworkValue);
}
// we resolved a first reference, but we need to make sure this isn't a reference also.
@@ -701,6 +709,15 @@ public final class BridgeContext extends Activity {
if (item != null) {
return item;
}
// if it was not found and the type is an id, it is possible that the ID was
// generated dynamically when compiling the framework resources.
// Look for it in the R map.
if (BridgeConstants.RES_ID.equals(resType)) {
if (Bridge.getResourceValue(resType, resName) != null) {
return new ResourceValue(resType, resName, true);
}
}
}
// didn't find the resource anywhere.

View File

@@ -393,27 +393,26 @@ public class GcSnapshot {
* @param bitmap the bitmap to link to.
*/
public void setBitmap(Bitmap_Delegate bitmap) {
assert mLayers.size() == 0;
// create a new Layer for the bitmap. This will be the base layer.
Graphics2D graphics2D = bitmap.getImage().createGraphics();
Layer baseLayer = new Layer(graphics2D, bitmap);
// add it to the list.
// Set the current transform and clip which can either come from mTransform/mClip if they
// were set when there was no bitmap/layers or from the current base layers if there is
// one already.
graphics2D.setTransform(getTransform());
// reset mTransform in case there was one.
mTransform = null;
baseLayer.setClip(getClip());
// reset mClip in case there was one.
mClip = null;
// replace whatever current layers we have with this.
mLayers.clear();
mLayers.add(baseLayer);
// if transform and clip where modified before, get the information and give it to the
// layer.
if (mTransform != null) {
graphics2D.setTransform(mTransform);
mTransform = null;
}
if (mClip != null) {
baseLayer.setClip(mClip);
mClip = null;
}
}
public void translate(float dx, float dy) {