From 076357b8567458d4b6dfdcf839ef751634cd2bfb Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 14:04:24 -0800 Subject: auto import from //depot/cupcake/@132589 --- tools/aapt/Images.cpp | 8 --- .../com/android/layoutlib/api/ILayoutBridge.java | 57 +++------------------- .../src/com/android/layoutlib/bridge/Bridge.java | 42 ++-------------- .../android/layoutlib/bridge/BridgeContext.java | 21 ++++---- tools/preload/Android.mk | 14 +----- 5 files changed, 22 insertions(+), 120 deletions(-) (limited to 'tools') diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index edb12ea..4c776fb 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -859,14 +859,6 @@ 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 df1876d..0810d29 100644 --- a/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java +++ b/tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java @@ -24,35 +24,28 @@ import java.util.Map; *

*

{@link #getApiLevel()} gives the ability to know which methods are available. *

- * Changes in API level 3: - *

* Changes in API level 2: * */ public interface ILayoutBridge { - final int API_CURRENT = 3; + final int API_CURRENT = 2; /** * 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. - *

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 */ @@ -63,42 +56,8 @@ 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 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 - * 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. - * @since 3 - */ - ILayoutResult computeLayout(IXmlPullParser layoutDescription, - Object projectKey, - int screenWidth, int screenHeight, int density, float xdpi, float ydpi, - String themeName, boolean isProjectTheme, - Map> projectResources, - Map> 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 screenWidth + * @param screenHeight * @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 @@ -113,10 +72,8 @@ 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, 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, @@ -145,7 +102,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, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)} + * @deprecated Use {@link #computeLayout(IXmlPullParser, Object, int, int, 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 6abc452d..82fe365 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -40,7 +40,6 @@ 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; @@ -73,8 +72,6 @@ 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); } @@ -280,40 +277,20 @@ public final class Bridge implements ILayoutBridge { isProjectTheme = true; } - return computeLayout(layoutDescription, projectKey, - screenWidth, screenHeight, DisplayMetrics.DEFAULT_DENSITY, - DisplayMetrics.DEFAULT_DENSITY, DisplayMetrics.DEFAULT_DENSITY, - themeName, isProjectTheme, + return computeLayout(layoutDescription, projectKey, screenWidth, screenHeight, 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> projectResources, Map> 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> projectResources, - Map> frameworkResources, - IProjectCallback customViewLoader, ILayoutLog logger) { if (logger == null) { logger = sDefaultLogger; } @@ -321,7 +298,7 @@ public final class Bridge implements ILayoutBridge { synchronized (sDefaultLogger) { sLogger = logger; } - + // find the current theme and compute the style inheritance map Map styleParentMap = new HashMap(); @@ -332,16 +309,7 @@ public final class Bridge implements ILayoutBridge { BridgeContext context = null; try { - // 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, + context = new BridgeContext(projectKey, 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 baa3d53..0df20e4 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java @@ -87,21 +87,14 @@ public final class BridgeContext extends Context { private BridgeContentResolver mContentResolver; /** - * @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 projectKey + * @param currentTheme + * @param projectResources + * @param frameworkResources * @param styleInheritanceMap * @param customViewLoader */ - public BridgeContext(Object projectKey, DisplayMetrics metrics, + public BridgeContext(Object projectKey, IStyleResourceValue currentTheme, Map> projectResources, Map> frameworkResources, @@ -112,6 +105,10 @@ 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 e6fa103..d3457fe 100644 --- a/tools/preload/Android.mk +++ b/tools/preload/Android.mk @@ -2,19 +2,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -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_SRC_FILES := *.java LOCAL_MODULE:= preload -- cgit v1.1