summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-01-14 15:03:52 -0800
committerXavier Ducrohet <xav@android.com>2011-01-14 15:15:34 -0800
commit0831b3fae504e8fa94e6b1cc0d4e6c3fccaef231 (patch)
tree7937fe077b86e18113c6f7552af85dbeeee0764a /tools
parentc6684f9e9790e92960504e9b32f20f27003d9f37 (diff)
downloadframeworks_base-0831b3fae504e8fa94e6b1cc0d4e6c3fccaef231.zip
frameworks_base-0831b3fae504e8fa94e6b1cc0d4e6c3fccaef231.tar.gz
frameworks_base-0831b3fae504e8fa94e6b1cc0d4e6c3fccaef231.tar.bz2
LayoutLib: Misc fixes.
- Fix resource resolution for framework resources of type "id" that are dynamically generated through "@+id/..." - Proper implementation of setBitmap on a canvas that already has a bitmap. Transform/clip are kepts but the existing layers are replaced with the new bitmap - return a null service for INPUT_METHOD_SERVICE in Context.getSystemService Change-Id: I35e46fff50e6492a8995e95427d5f38bc945429d
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java25
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java27
2 files changed, 34 insertions, 18 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index dc027b7..f5fc036 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -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.
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
index b3f1fff..c4ebb8a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/GcSnapshot.java
@@ -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.
- mLayers.add(baseLayer);
+ // 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.
- // if transform and clip where modified before, get the information and give it to the
- // layer.
+ graphics2D.setTransform(getTransform());
+ // reset mTransform in case there was one.
+ mTransform = null;
- if (mTransform != null) {
- graphics2D.setTransform(mTransform);
- 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 (mClip != null) {
- baseLayer.setClip(mClip);
- mClip = null;
- }
}
public void translate(float dx, float dy) {