summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
commit3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch)
treeaa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /tools
parent15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff)
downloadframeworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.zip
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.gz
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.bz2
auto import from //depot/cupcake/@137055
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/Images.cpp8
-rw-r--r--tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java57
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java42
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java21
-rw-r--r--tools/preload/Android.mk14
5 files changed, 120 insertions, 22 deletions
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index 4c776fb..edb12ea 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -859,6 +859,14 @@ static void write_png(const char* imageName,
analyze_image(imageName, imageInfo, grayscaleTolerance, rgbPalette, alphaPalette,
&paletteEntries, &hasTransparency, &color_type, outRows);
+
+ // If the image is a 9-patch, we need to preserve it as a ARGB file to make
+ // sure the pixels will not be pre-dithered/clamped until we decide they are
+ if (imageInfo.is9Patch && (color_type == PNG_COLOR_TYPE_RGB ||
+ color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)) {
+ color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ }
+
switch (color_type) {
case PNG_COLOR_TYPE_PALETTE:
NOISY(printf("Image %s has %d colors%s, using PNG_COLOR_TYPE_PALETTE\n",
diff --git a/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java b/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java
index 0810d29..df1876d 100644
--- a/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java
+++ b/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java
@@ -24,28 +24,35 @@ import java.util.Map;
* <p/>
* <p/>{@link #getApiLevel()} gives the ability to know which methods are available.
* <p/>
+ * Changes in API level 3:
+ * <ul>
+ * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li>
+ * <li> deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li>
+ * </ul>
* Changes in API level 2:
* <ul>
* <li>{@link #getApiLevel()}</li>
- * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)},
- * deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, Map, Map, IProjectCallback, ILayoutLog)}.</li>
+ * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li>
+ * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, Map, Map, IProjectCallback, ILayoutLog)}</li>
* </ul>
*/
public interface ILayoutBridge {
- final int API_CURRENT = 2;
+ final int API_CURRENT = 3;
/**
* Returns the API level of the layout library.
* While no methods will ever be removed, some may become deprecated, and some new ones
* will appear.
+ * <p/>If calling this method throws an {@link AbstractMethodError}, then the API level
+ * should be considered to be 1.
*/
int getApiLevel();
/**
* Initializes the Bridge object.
* @param fontOsLocation the location of the fonts.
- * @param enumValueMap map attrName => { map enumFlagName => Integer value }.
+ * @param enumValueMap map attrName => { map enumFlagName => Integer value }.
* @return true if success.
* @since 1
*/
@@ -56,8 +63,11 @@ public interface ILayoutBridge {
* @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the
* layout file.
* @param projectKey An Object identifying the project. This is used for the cache mechanism.
- * @param screenWidth
- * @param screenHeight
+ * @param screenWidth the screen width
+ * @param screenHeight the screen height
+ * @param density the density factor for the screen.
+ * @param xdpi the screen actual dpi in X
+ * @param ydpi the screen actual dpi in Y
* @param themeName The name of the theme to use.
* @param isProjectTheme true if the theme is a project theme, false if it is a framework theme.
* @param projectResources the resources of the project. The map contains (String, map) pairs
@@ -72,8 +82,41 @@ public interface ILayoutBridge {
* the project.
* @param logger the object responsible for displaying warning/errors to the user.
* @return an {@link ILayoutResult} object that contains the result of the layout.
+ * @since 3
+ */
+ ILayoutResult computeLayout(IXmlPullParser layoutDescription,
+ Object projectKey,
+ int screenWidth, int screenHeight, int density, float xdpi, float ydpi,
+ String themeName, boolean isProjectTheme,
+ Map<String, Map<String, IResourceValue>> projectResources,
+ Map<String, Map<String, IResourceValue>> frameworkResources,
+ IProjectCallback projectCallback, ILayoutLog logger);
+
+ /**
+ * Computes and renders a layout
+ * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the
+ * layout file.
+ * @param projectKey An Object identifying the project. This is used for the cache mechanism.
+ * @param screenWidth the screen width
+ * @param screenHeight the screen height
+ * @param themeName The name of the theme to use.
+ * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme.
+ * @param projectResources the resources of the project. The map contains (String, map) pairs
+ * where the string is the type of the resource reference used in the layout file, and the
+ * map contains (String, {@link IResourceValue}) pairs where the key is the resource name,
+ * and the value is the resource value.
+ * @param frameworkResources the framework resources. The map contains (String, map) pairs
+ * where the string is the type of the resource reference used in the layout file, and the map
+ * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the
+ * value is the resource value.
+ * @param projectCallback The {@link IProjectCallback} object to get information from
+ * the project.
+ * @param logger the object responsible for displaying warning/errors to the user.
+ * @return an {@link ILayoutResult} object that contains the result of the layout.
+ * @deprecated Use {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}
* @since 2
*/
+ @Deprecated
ILayoutResult computeLayout(IXmlPullParser layoutDescription,
Object projectKey,
int screenWidth, int screenHeight, String themeName, boolean isProjectTheme,
@@ -102,7 +145,7 @@ public interface ILayoutBridge {
* the project.
* @param logger the object responsible for displaying warning/errors to the user.
* @return an {@link ILayoutResult} object that contains the result of the layout.
- * @deprecated Use {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}.
+ * @deprecated Use {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}
* @since 1
*/
@Deprecated
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index 82fe365..6abc452d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -40,6 +40,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
+import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.BridgeInflater;
import android.view.IWindow;
@@ -72,6 +73,8 @@ public final class Bridge implements ILayoutBridge {
private static final int DEFAULT_STATUS_BAR_HEIGHT = 25;
public static class StaticMethodNotImplementedException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
public StaticMethodNotImplementedException(String msg) {
super(msg);
}
@@ -277,20 +280,40 @@ public final class Bridge implements ILayoutBridge {
isProjectTheme = true;
}
- return computeLayout(layoutDescription, projectKey, screenWidth, screenHeight, themeName, isProjectTheme,
+ return computeLayout(layoutDescription, projectKey,
+ screenWidth, screenHeight, DisplayMetrics.DEFAULT_DENSITY,
+ DisplayMetrics.DEFAULT_DENSITY, DisplayMetrics.DEFAULT_DENSITY,
+ themeName, isProjectTheme,
projectResources, frameworkResources, customViewLoader, logger);
}
/*
+ * For compatilibty purposes, we implement the old deprecated version of computeLayout.
* (non-Javadoc)
* @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog)
*/
- public ILayoutResult computeLayout(IXmlPullParser layoutDescription,
- Object projectKey,
+ public ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey,
int screenWidth, int screenHeight, String themeName, boolean isProjectTheme,
Map<String, Map<String, IResourceValue>> projectResources,
Map<String, Map<String, IResourceValue>> frameworkResources,
IProjectCallback customViewLoader, ILayoutLog logger) {
+ return computeLayout(layoutDescription, projectKey,
+ screenWidth, screenHeight, DisplayMetrics.DEFAULT_DENSITY,
+ DisplayMetrics.DEFAULT_DENSITY, DisplayMetrics.DEFAULT_DENSITY,
+ themeName, isProjectTheme,
+ projectResources, frameworkResources, customViewLoader, logger);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog)
+ */
+ public ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey,
+ int screenWidth, int screenHeight, int density, float xdpi, float ydpi,
+ String themeName, boolean isProjectTheme,
+ Map<String, Map<String, IResourceValue>> projectResources,
+ Map<String, Map<String, IResourceValue>> frameworkResources,
+ IProjectCallback customViewLoader, ILayoutLog logger) {
if (logger == null) {
logger = sDefaultLogger;
}
@@ -298,7 +321,7 @@ public final class Bridge implements ILayoutBridge {
synchronized (sDefaultLogger) {
sLogger = logger;
}
-
+
// find the current theme and compute the style inheritance map
Map<IStyleResourceValue, IStyleResourceValue> styleParentMap =
new HashMap<IStyleResourceValue, IStyleResourceValue>();
@@ -309,7 +332,16 @@ public final class Bridge implements ILayoutBridge {
BridgeContext context = null;
try {
- context = new BridgeContext(projectKey, currentTheme, projectResources,
+ // setup the display Metrics.
+ DisplayMetrics metrics = new DisplayMetrics();
+ metrics.density = density / (float) DisplayMetrics.DEFAULT_DENSITY;
+ metrics.scaledDensity = metrics.density;
+ metrics.widthPixels = screenWidth;
+ metrics.heightPixels = screenHeight;
+ metrics.xdpi = xdpi;
+ metrics.ydpi = ydpi;
+
+ context = new BridgeContext(projectKey, metrics, currentTheme, projectResources,
frameworkResources, styleParentMap, customViewLoader, logger);
BridgeInflater inflater = new BridgeInflater(context, customViewLoader);
context.setBridgeInflater(inflater);
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
index 0df20e4..baa3d53 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
@@ -87,14 +87,21 @@ public final class BridgeContext extends Context {
private BridgeContentResolver mContentResolver;
/**
- * @param projectKey
- * @param currentTheme
- * @param projectResources
- * @param frameworkResources
+ * @param projectKey An Object identifying the project. This is used for the cache mechanism.
+ * @param metrics the {@link DisplayMetrics}.
+ * @param themeName The name of the theme to use.
+ * @param projectResources the resources of the project. The map contains (String, map) pairs
+ * where the string is the type of the resource reference used in the layout file, and the
+ * map contains (String, {@link IResourceValue}) pairs where the key is the resource name,
+ * and the value is the resource value.
+ * @param frameworkResources the framework resources. The map contains (String, map) pairs
+ * where the string is the type of the resource reference used in the layout file, and the map
+ * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the
+ * value is the resource value.
* @param styleInheritanceMap
* @param customViewLoader
*/
- public BridgeContext(Object projectKey,
+ public BridgeContext(Object projectKey, DisplayMetrics metrics,
IStyleResourceValue currentTheme,
Map<String, Map<String, IResourceValue>> projectResources,
Map<String, Map<String, IResourceValue>> frameworkResources,
@@ -105,10 +112,6 @@ public final class BridgeContext extends Context {
mLogger = logger;
Configuration config = new Configuration();
- DisplayMetrics metrics = new DisplayMetrics();
- metrics.setToDefaults();
-
-
AssetManager assetManager = BridgeAssetManager.initSystem();
mResources = BridgeResources.initSystem(
this,
diff --git a/tools/preload/Android.mk b/tools/preload/Android.mk
index d3457fe..e6fa103 100644
--- a/tools/preload/Android.mk
+++ b/tools/preload/Android.mk
@@ -2,7 +2,19 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := *.java
+LOCAL_SRC_FILES := \
+ ClassRank.java \
+ Compile.java \
+ LoadedClass.java \
+ MemoryUsage.java \
+ Operation.java \
+ Policy.java \
+ PrintCsv.java \
+ PrintPsTree.java \
+ Proc.java \
+ Record.java \
+ Root.java \
+ WritePreloadedClassFile.java
LOCAL_MODULE:= preload