summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-11-11 18:22:45 -0800
committerXavier Ducrohet <xav@android.com>2010-11-12 14:02:49 -0800
commitcf52390eee4c9ae792ef63af1528b2e71b33a04f (patch)
tree1c384883b14b8c4f93b1bea574471e83b2a33493 /tools
parent6e079a32bceb85a44da3b396f8d37e718d1421d5 (diff)
downloadframeworks_base-cf52390eee4c9ae792ef63af1528b2e71b33a04f.zip
frameworks_base-cf52390eee4c9ae792ef63af1528b2e71b33a04f.tar.gz
frameworks_base-cf52390eee4c9ae792ef63af1528b2e71b33a04f.tar.bz2
Layoutlib: Fill the default prop value map for View objects.
Change-Id: I35426ced17a10eb092fac2153276f1202692876f
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java6
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java48
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java7
3 files changed, 33 insertions, 28 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
index 5fcb9ff..8b67166 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeLayoutScene.java
@@ -22,6 +22,7 @@ import com.android.layoutlib.api.ViewInfo;
import com.android.layoutlib.bridge.impl.LayoutSceneImpl;
import java.awt.image.BufferedImage;
+import java.util.Map;
/**
* An implementation of {@link LayoutScene}.
@@ -52,6 +53,11 @@ public class BridgeLayoutScene extends LayoutScene {
}
@Override
+ public Map<String, String> getDefaultViewPropertyValues(Object viewObject) {
+ return mScene.getDefaultViewPropertyValues(viewObject);
+ }
+
+ @Override
public SceneResult render() {
synchronized (mBridge) {
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 79aecff..02db2cf 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
@@ -63,6 +63,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
+import java.util.IdentityHashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.Map.Entry;
@@ -82,6 +83,9 @@ public final class BridgeContext extends Activity {
private final Map<String, Map<String, IResourceValue>> mFrameworkResources;
private final Map<IStyleResourceValue, IStyleResourceValue> mStyleInheritanceMap;
+ private final Map<Object, Map<String, String>> mDefaultPropMaps =
+ new IdentityHashMap<Object, Map<String,String>>();
+
// maps for dynamically generated id representing style objects (IStyleResourceValue)
private Map<Integer, IStyleResourceValue> mDynamicIdToStyleMap;
private Map<IStyleResourceValue, Integer> mStyleToDynamicIdMap;
@@ -180,6 +184,9 @@ public final class BridgeContext extends Activity {
return mLogger;
}
+ public Map<String, String> getDefaultPropMap(Object key) {
+ return mDefaultPropMaps.get(key);
+ }
// ------------- Activity Methods
@@ -285,13 +292,16 @@ public final class BridgeContext extends Activity {
return null;
}
- Object key = null;
+ Map<String, String> defaultPropMap = null;
if (parser != null) {
- key = parser.getViewKey();
- }
- if (key != null) {
- String attrs_name = Bridge.resolveResourceValue(attrs);
- System.out.println("KEY: " + key.toString() + "(" + attrs_name + ")");
+ Object key = parser.getViewKey();
+ if (key != null) {
+ defaultPropMap = mDefaultPropMaps.get(key);
+ if (defaultPropMap == null) {
+ defaultPropMap = new HashMap<String, String>();
+ mDefaultPropMaps.put(key, defaultPropMap);
+ }
+ }
}
boolean[] frameworkAttributes = new boolean[1];
@@ -309,9 +319,6 @@ public final class BridgeContext extends Activity {
customStyle = parser.getAttributeValue(null /* namespace*/, "style");
}
if (customStyle != null) {
- if (key != null) {
- print("style", customStyle, false);
- }
IResourceValue item = findResValue(customStyle, false /*forceFrameworkOnly*/);
if (item instanceof IStyleResourceValue) {
@@ -323,8 +330,8 @@ public final class BridgeContext extends Activity {
// get the name from the int.
String defStyleName = searchAttr(defStyleAttr);
- if (key != null) {
- print("style", defStyleName, true);
+ if (defaultPropMap != null) {
+ defaultPropMap.put("style", defStyleName);
}
// look for the style in the current theme, and its parent:
@@ -385,20 +392,16 @@ public final class BridgeContext extends Activity {
// if we found a value, we make sure this doesn't reference another value.
// So we resolve it.
if (resValue != null) {
- if (key != null) {
- print(name, resValue.getValue(), true);
+ // put the first default value, before the resolution.
+ if (defaultPropMap != null) {
+ defaultPropMap.put(name, resValue.getValue());
}
resValue = resolveResValue(resValue);
- } else if (key != null) {
- print(name, "<unknown>", true);
}
ta.bridgeSetValue(index, name, resValue);
} else {
- if (key != null) {
- print(name, value, false);
- }
// 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));
@@ -411,15 +414,6 @@ public final class BridgeContext extends Activity {
return ta;
}
- private void print(String name, String value, boolean isDefault) {
- System.out.print("\t" + name + " : " + value);
- if (isDefault) {
- System.out.println(" (default)");
- } else {
- System.out.println("");
- }
- }
-
@Override
public Looper getMainLooper() {
return Looper.myLooper();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
index d8a59ce..b0316a3 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/LayoutSceneImpl.java
@@ -665,7 +665,8 @@ public class LayoutSceneImpl {
ViewInfo result = new ViewInfo(view.getClass().getName(),
context.getViewKey(view),
- view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
+ view.getLeft(), view.getTop(), view.getRight(), view.getBottom(),
+ view, view.getLayoutParams());
if (view instanceof ViewGroup) {
ViewGroup group = ((ViewGroup) view);
@@ -686,4 +687,8 @@ public class LayoutSceneImpl {
public ViewInfo getViewInfo() {
return mViewInfo;
}
+
+ public Map<String, String> getDefaultViewPropertyValues(Object viewObject) {
+ return mContext.getDefaultPropMap(viewObject);
+ }
}