summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-07-29 17:41:39 -0700
committerXavier Ducrohet <xav@android.com>2011-08-01 15:08:26 -0700
commitd2f664d42cc29507b01a98622298b69131463825 (patch)
tree21379de5fe0625ffcfb9e776dafef6d1e2614f6f /tools
parentf7be31ee1062722855602c6b0227f01bdb7c0b80 (diff)
downloadframeworks_base-d2f664d42cc29507b01a98622298b69131463825.zip
frameworks_base-d2f664d42cc29507b01a98622298b69131463825.tar.gz
frameworks_base-d2f664d42cc29507b01a98622298b69131463825.tar.bz2
Misc layoutlib fix in preparation of the access change in framework code.
Change-Id: I873adb7345514be6daa5c4fea4ebabb515f203e2
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/android/content/res/BridgeResources.java (renamed from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java)23
-rw-r--r--tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java (renamed from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java)8
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java2
-rw-r--r--tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java38
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java8
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java2
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java1
7 files changed, 28 insertions, 54 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
index 1756496..e039898 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
@@ -14,13 +14,15 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.android;
+package android.content.res;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.layoutlib.bridge.impl.ParserFactory;
import com.android.layoutlib.bridge.impl.ResourceHelper;
import com.android.ninepatch.NinePatch;
@@ -30,13 +32,6 @@ import com.android.util.Pair;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.AssetManager;
-import android.content.res.ColorStateList;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@@ -94,7 +89,7 @@ public final class BridgeResources extends Resources {
* <p/>
* {@link Bridge} calls this method after setting up a new bridge.
*/
- /*package*/ static Resources initSystem(BridgeContext context,
+ /*package*/ public static Resources initSystem(BridgeContext context,
AssetManager assets,
DisplayMetrics metrics,
Configuration config,
@@ -110,7 +105,7 @@ public final class BridgeResources extends Resources {
* Disposes the static {@link Resources#mSystem} to make sure we don't leave objects
* around that would prevent us from unloading the library.
*/
- /*package*/ static void disposeSystem() {
+ /*package*/ public static void disposeSystem() {
if (Resources.mSystem instanceof BridgeResources) {
((BridgeResources)(Resources.mSystem)).mContext = null;
((BridgeResources)(Resources.mSystem)).mProjectCallback = null;
@@ -336,7 +331,7 @@ public final class BridgeResources extends Resources {
if (ResourceHelper.parseFloatAttribute(
value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return mTmpValue.getDimension(mMetrics);
+ return mTmpValue.getDimension(getDisplayMetrics());
}
}
}
@@ -359,7 +354,8 @@ public final class BridgeResources extends Resources {
if (ResourceHelper.parseFloatAttribute(
value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return TypedValue.complexToDimensionPixelOffset(mTmpValue.data, mMetrics);
+ return TypedValue.complexToDimensionPixelOffset(mTmpValue.data,
+ getDisplayMetrics());
}
}
}
@@ -382,7 +378,8 @@ public final class BridgeResources extends Resources {
if (ResourceHelper.parseFloatAttribute(
value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return TypedValue.complexToDimensionPixelSize(mTmpValue.data, mMetrics);
+ return TypedValue.complexToDimensionPixelSize(mTmpValue.data,
+ getDisplayMetrics());
}
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
index fc2f2f8..9deed32 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.android;
+package android.content.res;
import com.android.ide.common.rendering.api.DeclareStyleableResourceValue;
import com.android.ide.common.rendering.api.LayoutLog;
@@ -24,6 +24,8 @@ import com.android.ide.common.rendering.api.StyleResourceValue;
import com.android.internal.util.XmlUtils;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.BridgeConstants;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.layoutlib.bridge.impl.ParserFactory;
import com.android.layoutlib.bridge.impl.ResourceHelper;
import com.android.resources.ResourceType;
@@ -445,7 +447,7 @@ public final class BridgeTypedArray extends TypedArray {
}
if (ResourceHelper.parseFloatAttribute(mNames[index], s, mValue, true /*requireUnit*/)) {
- return mValue.getDimension(mBridgeResources.mMetrics);
+ return mValue.getDimension(mBridgeResources.getDisplayMetrics());
}
// looks like we were unable to resolve the dimension value
@@ -572,7 +574,7 @@ public final class BridgeTypedArray extends TypedArray {
}
if (ResourceHelper.parseFloatAttribute(mNames[index], s, mValue, true /*requireUnit*/)) {
- float f = mValue.getDimension(mBridgeResources.mMetrics);
+ float f = mValue.getDimension(mBridgeResources.getDisplayMetrics());
final int res = (int)(f+0.5f);
if (res != 0) return res;
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
index 080b85f..945b3cd 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
@@ -17,12 +17,12 @@
package android.graphics;
import com.android.layoutlib.bridge.Bridge;
-import com.android.layoutlib.bridge.android.BridgeResources.NinePatchInputStream;
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.ninepatch.NinePatchChunk;
import com.android.resources.Density;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+import android.content.res.BridgeResources.NinePatchInputStream;
import android.graphics.BitmapFactory.Options;
import java.io.FileDescriptor;
diff --git a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
index 3ef3288..64efa7e 100644
--- a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
@@ -38,11 +38,15 @@ import java.io.IOException;
*/
public class LayoutInflater_Delegate {
+ private static final String TAG_MERGE = "merge";
+
public static boolean sIsInInclude = false;
/**
* Recursive method used to descend down the xml hierarchy and instantiate
* views, instantiate their children, and then call onFinishInflate().
+ *
+ * This implementation just records the merge status before calling the default implementation.
*/
@LayoutlibDelegate
/*package*/ static void rInflate(LayoutInflater thisInflater,
@@ -58,37 +62,7 @@ public class LayoutInflater_Delegate {
// ---- START DEFAULT IMPLEMENTATION.
- final int depth = parser.getDepth();
- int type;
-
- while (((type = parser.next()) != XmlPullParser.END_TAG ||
- parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
-
- if (type != XmlPullParser.START_TAG) {
- continue;
- }
-
- final String name = parser.getName();
-
- if (LayoutInflater.TAG_REQUEST_FOCUS.equals(name)) {
- thisInflater.parseRequestFocus(parser, parent);
- } else if (LayoutInflater.TAG_INCLUDE.equals(name)) {
- if (parser.getDepth() == 0) {
- throw new InflateException("<include /> cannot be the root element");
- }
- thisInflater.parseInclude(parser, parent, attrs);
- } else if (LayoutInflater.TAG_MERGE.equals(name)) {
- throw new InflateException("<merge /> must be the root element");
- } else {
- final View view = thisInflater.createViewFromTag(parent, name, attrs);
- final ViewGroup viewGroup = (ViewGroup) parent;
- final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs);
- thisInflater.rInflate(parser, view, attrs, true);
- viewGroup.addView(view, params);
- }
- }
-
- if (finishInflate) parent.onFinishInflate();
+ thisInflater.rInflate_Original(parser, parent, attrs, finishInflate);
// ---- END DEFAULT IMPLEMENTATION.
@@ -138,7 +112,7 @@ public class LayoutInflater_Delegate {
final String childName = childParser.getName();
- if (LayoutInflater.TAG_MERGE.equals(childName)) {
+ if (TAG_MERGE.equals(childName)) {
// Inflate all children.
thisInflater.rInflate(childParser, parent, childAttrs, false);
} else {
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 69e0de9..b38b3b8 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
@@ -47,6 +47,8 @@ import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
+import android.content.res.BridgeResources;
+import android.content.res.BridgeTypedArray;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -813,7 +815,7 @@ public final class BridgeContext extends Activity {
return null;
}
- int getDynamicIdByStyle(StyleResourceValue resValue) {
+ public int getDynamicIdByStyle(StyleResourceValue resValue) {
if (mDynamicIdToStyleMap == null) {
// create the maps.
mDynamicIdToStyleMap = new HashMap<Integer, StyleResourceValue>();
@@ -843,7 +845,7 @@ public final class BridgeContext extends Activity {
return null;
}
- int getFrameworkResourceValue(ResourceType resType, String resName, int defValue) {
+ public int getFrameworkResourceValue(ResourceType resType, String resName, int defValue) {
Integer value = Bridge.getResourceId(resType, resName);
if (value != null) {
return value.intValue();
@@ -852,7 +854,7 @@ public final class BridgeContext extends Activity {
return defValue;
}
- int getProjectResourceValue(ResourceType resType, String resName, int defValue) {
+ public int getProjectResourceValue(ResourceType resType, String resName, int defValue) {
if (mProjectCallback != null) {
Integer value = mProjectCallback.getResourceId(resType, resName);
if (value != null) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
index df701d5..72ed351 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java
@@ -230,7 +230,7 @@ abstract class CustomBar extends LinearLayout {
if (ResourceHelper.parseFloatAttribute("textSize", textSize.getValue(), out,
true /*requireUnit*/)) {
textView.setTextSize(
- out.getDimension(bridgeContext.getResources().mMetrics));
+ out.getDimension(bridgeContext.getResources().getDisplayMetrics()));
}
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
index 9bf52c7..b027b6a 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
@@ -167,5 +167,4 @@ public class Main {
return true;
}
-
}