OSDN Git Service

Update the Layoutlib API to contain part of the current config.
authorXavier Ducrohet <xav@android.com>
Thu, 27 Jan 2011 21:10:25 +0000 (13:10 -0800)
committerXavier Ducrohet <xav@android.com>
Thu, 27 Jan 2011 23:43:01 +0000 (15:43 -0800)
Right now only the screen size is needed. We can add more to Params
as needed.

Since we should use the existing enum classes for this, I moved
all the current enum from sdklib into a new jar file called
resources.jar.

ADT, sdklib, layoutlib_api all depend on it.

Changes to resources should always be API compatible and the result
should be copied into the in-dev platform branch in prebuilt, similar
to layoutlib_api. See the README.txt files in layoutlib_api/ and
resources/

Change-Id: I877ba3cad555ec497954bb0866639e51e7751020

70 files changed:
eclipse/plugins/com.android.ide.eclipse.adt/.classpath
eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParser.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/ImageOverlay.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/PlayAnimationMenu.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/DockModeQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/EnumBasedResourceQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/KeyboardStateQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationMethodQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NavigationStateQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/NightModeQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/PixelDensityQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenOrientationQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenRatioQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/ScreenSizeQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TextInputMethodQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/TouchScreenQualifier.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/manager/SingleResourceFile.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/LayoutDeviceHandler.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/ui/ConfigurationSelector.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
eclipse/plugins/com.android.ide.eclipse.tests/.classpath
eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/UiElementPullParserTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/DockModeQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/KeyboardStateQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NavigationMethodQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/PixelDensityQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenOrientationQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenSizeQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TextInputMethodQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TouchScreenQualifierTest.java
eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java
eclipse/scripts/create_adt_symlinks.sh
eclipse/scripts/create_test_symlinks.sh
layoutlib_api/.classpath
layoutlib_api/Android.mk
layoutlib_api/README.txt [new file with mode: 0644]
layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
layoutlib_api/src/com/android/ide/common/rendering/api/Params.java
layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java [deleted file]
layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java
resources/.classpath [new file with mode: 0644]
resources/.gitignore [new file with mode: 0644]
resources/.project [new file with mode: 0644]
resources/Android.mk [new file with mode: 0644]
resources/README.txt [new file with mode: 0644]
resources/src/com/android/resources/Density.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/Density.java with 98% similarity]
resources/src/com/android/resources/DockMode.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/DockMode.java with 98% similarity]
resources/src/com/android/resources/Keyboard.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/Keyboard.java with 98% similarity]
resources/src/com/android/resources/KeyboardState.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/KeyboardState.java with 98% similarity]
resources/src/com/android/resources/Navigation.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/Navigation.java with 98% similarity]
resources/src/com/android/resources/NavigationState.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/NavigationState.java with 98% similarity]
resources/src/com/android/resources/NightMode.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/NightMode.java with 98% similarity]
resources/src/com/android/resources/ResourceEnum.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/ResourceEnum.java with 98% similarity]
resources/src/com/android/resources/ScreenOrientation.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/ScreenOrientation.java with 98% similarity]
resources/src/com/android/resources/ScreenRatio.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/ScreenRatio.java with 98% similarity]
resources/src/com/android/resources/ScreenSize.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/ScreenSize.java with 98% similarity]
resources/src/com/android/resources/TouchScreen.java [moved from sdkmanager/libs/sdklib/src/com/android/sdklib/resources/TouchScreen.java with 98% similarity]
sdkmanager/app/etc/manifest.txt
sdkmanager/libs/sdklib/.classpath
sdkmanager/libs/sdklib/src/Android.mk
sdkmanager/libs/sdklib/src/com/android/sdklib/internal/export/ProjectConfig.java
sdkmanager/libs/sdklib/src/com/android/sdklib/xml/AndroidManifestParser.java
sdkmanager/libs/sdklib/src/com/android/sdklib/xml/ManifestData.java
sdkmanager/libs/sdklib/tests/com/android/sdklib/xml/AndroidManifestParserTest.java

index 609ea66..0e42f20 100644 (file)
@@ -12,6 +12,7 @@
        <classpathentry kind="lib" path="libs/sdklib.jar" sourcepath="/SdkLib"/>
        <classpathentry kind="lib" path="libs/sdkstats.jar" sourcepath="/SdkStatsService"/>
        <classpathentry kind="lib" path="libs/sdkuilib.jar" sourcepath="/SdkUiLib"/>
+       <classpathentry kind="lib" path="libs/resources.jar"/>
        <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
        <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
        <classpathentry kind="output" path="bin"/>
index d7aae3b..0409880 100644 (file)
@@ -12,7 +12,8 @@ Bundle-ClassPath: .,
  libs/commons-compress-1.0.jar,
  libs/kxml2-2.3.0.jar,
  libs/layoutlib_api.jar,
- libs/ide_common.jar
+ libs/ide_common.jar,
+ libs/resources.jar
 Bundle-Activator: com.android.ide.eclipse.adt.AdtPlugin
 Bundle-Vendor: The Android Open Source Project
 Require-Bundle: com.android.ide.eclipse.ddms,
@@ -52,6 +53,7 @@ Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.t
  com.android.ide.common.rendering;x-friends:="com.android.ide.eclipse.tests",
  com.android.ide.common.rendering.api;x-friends:="com.android.ide.eclipse.tests",
  com.android.ide.common.rendering.legacy;x-friends:="com.android.ide.eclipse.tests",
+ com.android.ide.common.resources;x-friends:="com.android.ide.eclipse.tests",
  com.android.ide.common.resources.platform;x-friends:="com.android.ide.eclipse.tests",
  com.android.ide.common.sdk;x-friends:="com.android.ide.eclipse.tests",
  com.android.ide.eclipse.adt;x-friends:="com.android.ide.eclipse.tests",
@@ -106,6 +108,7 @@ Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.t
  com.android.layoutlib.api;x-friends:="com.android.ide.eclipse.tests",
  com.android.ninepatch;x-friends:="com.android.ide.eclipse.tests",
  com.android.prefs;x-friends:="com.android.ide.eclipse.tests",
+ com.android.resources;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.annotations;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.build;x-friends:="com.android.ide.eclipse.tests",
@@ -116,7 +119,6 @@ Export-Package: com.android.ide.common.api;x-friends:="com.android.ide.eclipse.t
  com.android.sdklib.internal.repository;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.io;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.repository;x-friends:="com.android.ide.eclipse.tests",
- com.android.sdklib.resources;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.util;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdklib.xml;x-friends:="com.android.ide.eclipse.tests",
  com.android.sdkstats;x-friends:="com.android.ide.eclipse.tests",
index ec77994..790cbc2 100644 (file)
@@ -22,7 +22,6 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT;
 import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT;
 
 import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.ResourceDensity;
 import com.android.ide.common.rendering.api.ViewInfo;
 import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.LayoutDescriptors;
 import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
@@ -30,6 +29,7 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
 import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+import com.android.resources.Density;
 import com.android.sdklib.IAndroidTarget;
 import com.android.sdklib.SdkConstants;
 
@@ -571,7 +571,7 @@ public final class UiElementPullParser extends BasePullParser {
                         case COMPLEX_UNIT_DIP:
                         case COMPLEX_UNIT_SP: // intended fall-through since we don't
                                               // adjust for font size
-                            f *= (float)mDensityValue / ResourceDensity.DEFAULT_DENSITY;
+                            f *= (float)mDensityValue / Density.DEFAULT_DENSITY;
                             break;
                         case COMPLEX_UNIT_PT:
                             f *= mXdpi * (1.0f / 72);
index 179674d..923caad 100644 (file)
@@ -38,14 +38,14 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolderType
 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
 import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
 import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice;
-import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice.DeviceConfig;
 import com.android.ide.eclipse.adt.internal.sdk.LayoutDeviceManager;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+import com.android.ide.eclipse.adt.internal.sdk.LayoutDevice.DeviceConfig;
+import com.android.resources.Density;
+import com.android.resources.DockMode;
+import com.android.resources.NightMode;
+import com.android.resources.ScreenOrientation;
 import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.resources.Density;
-import com.android.sdklib.resources.DockMode;
-import com.android.sdklib.resources.NightMode;
-import com.android.sdklib.resources.ScreenOrientation;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
index 902d3d0..8e4b12f 100644 (file)
@@ -20,7 +20,6 @@ import static com.android.ide.common.layout.LayoutConstants.ANDROID_STRING_PREFI
 import static com.android.ide.common.layout.LayoutConstants.SCROLL_VIEW;
 import static com.android.ide.common.layout.LayoutConstants.STRING_PREFIX;
 import static com.android.ide.eclipse.adt.AndroidConstants.ANDROID_PKG;
-import static com.android.sdklib.resources.Density.DEFAULT_DENSITY;
 
 import com.android.ide.common.rendering.LayoutLibrary;
 import com.android.ide.common.rendering.StaticRenderSession;
@@ -28,10 +27,10 @@ import com.android.ide.common.rendering.api.Capability;
 import com.android.ide.common.rendering.api.ILayoutPullParser;
 import com.android.ide.common.rendering.api.LayoutLog;
 import com.android.ide.common.rendering.api.Params;
-import com.android.ide.common.rendering.api.Params.RenderingMode;
 import com.android.ide.common.rendering.api.RenderSession;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.ide.common.rendering.api.Result;
+import com.android.ide.common.rendering.api.Params.RenderingMode;
 import com.android.ide.common.resources.ResourceResolver;
 import com.android.ide.common.sdk.LoadStatus;
 import com.android.ide.eclipse.adt.AdtPlugin;
@@ -42,14 +41,14 @@ import com.android.ide.eclipse.adt.internal.editors.layout.ContextPullParser;
 import com.android.ide.eclipse.adt.internal.editors.layout.ExplodedRenderingHelper;
 import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor;
 import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor;
-import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ChangeFlags;
-import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ILayoutReloadListener;
 import com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback;
 import com.android.ide.eclipse.adt.internal.editors.layout.UiElementPullParser;
+import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ChangeFlags;
+import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ILayoutReloadListener;
 import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite;
+import com.android.ide.eclipse.adt.internal.editors.layout.configuration.LayoutCreatorDialog;
 import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.CustomButton;
 import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.IConfigListener;
-import com.android.ide.eclipse.adt.internal.editors.layout.configuration.LayoutCreatorDialog;
 import com.android.ide.eclipse.adt.internal.editors.layout.gle2.IncludeFinder.Reference;
 import com.android.ide.eclipse.adt.internal.editors.layout.gre.RulesEngine;
 import com.android.ide.eclipse.adt.internal.editors.ui.DecorComposite;
@@ -59,6 +58,7 @@ import com.android.ide.eclipse.adt.internal.editors.xml.Hyperlinks;
 import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
 import com.android.ide.eclipse.adt.internal.resources.ResourceType;
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
+import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
 import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFile;
 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolderType;
@@ -68,6 +68,7 @@ import com.android.ide.eclipse.adt.internal.sdk.Sdk;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk.ITargetChangeListener;
 import com.android.ide.eclipse.adt.io.IFileWrapper;
 import com.android.ide.eclipse.adt.io.IFolderWrapper;
+import com.android.resources.Density;
 import com.android.sdklib.IAndroidTarget;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.io.IAbstractFile;
@@ -1308,7 +1309,7 @@ public class GraphicalEditorPart extends EditorPart
      * @return the scale to multiple layout coordinates with to obtain the dip position
      */
     public float getDipScale() {
-        return DEFAULT_DENSITY / (float) mConfigComposite.getDensity().getDpiValue();
+        return Density.DEFAULT_DENSITY / (float) mConfigComposite.getDensity().getDpiValue();
     }
 
     // --- private methods ---
@@ -1672,6 +1673,11 @@ public class GraphicalEditorPart extends EditorPart
                 mTargetSdkVersion,
                 logger);
 
+        ScreenSizeQualifier ssq = mConfigComposite.getCurrentConfig().getScreenSizeQualifier();
+        if (ssq != null) {
+            params.setConfigScreenSize(ssq.getValue());
+        }
+
         if (transparentBackground) {
             // It doesn't matter what the background color is as long as the alpha
             // is 0 (fully transparent). We're using red to make it more obvious if
index 0c1772b..95382ae 100644 (file)
@@ -84,9 +84,10 @@ public class ImageOverlay extends Overlay implements IImageFactory {
      * an empty document.
      *
      * @param awtImage The AWT image to be rendered as an SWT image.
+     * @param isAlphaChannelImage whether the alpha channel of the image is relevant
      * @return The corresponding SWT image, or null.
      */
-    public synchronized Image setImage(BufferedImage awtImage, boolean isFloatingWindow) {
+    public synchronized Image setImage(BufferedImage awtImage, boolean isAlphaChannelImage) {
         if (awtImage != mAwtImage || awtImage == null) {
             mAwtImage = null;
 
@@ -97,12 +98,13 @@ public class ImageOverlay extends Overlay implements IImageFactory {
             if (awtImage == null) {
                 mImage = null;
             } else {
-                mImage = SwtUtils.convertToSwt(mCanvas.getDisplay(), awtImage, true, -1);
+                mImage = SwtUtils.convertToSwt(mCanvas.getDisplay(), awtImage,
+                        isAlphaChannelImage, -1);
             }
         } else {
             assert awtImage instanceof SwtReadyBufferedImage;
 
-            if (isFloatingWindow) {
+            if (isAlphaChannelImage) {
                 mImage = SwtUtils.convertToSwt(mCanvas.getDisplay(), awtImage, true, -1);
             } else {
                 mImage = ((SwtReadyBufferedImage)awtImage).getSwtImage();
index 7fbeb89..c7f8919 100755 (executable)
@@ -520,7 +520,7 @@ public class LayoutCanvas extends Canvas {
 
         mViewHierarchy.setSession(session, explodedNodes);
         if (mViewHierarchy.isValid() && session != null) {
-            Image image = mImageOverlay.setImage(session.getImage(), session.isFloatingWindow());
+            Image image = mImageOverlay.setImage(session.getImage(), session.isAlphaChannelImage());
 
             mOutlinePage.setModel(mViewHierarchy.getRoot());
 
index 5ccbb66..f0cb09b 100644 (file)
@@ -164,7 +164,7 @@ public class PlayAnimationMenu extends SubmenuAction {
                                 }
 
                                 ImageOverlay imageOverlay = mCanvas.getImageOverlay();
-                                imageOverlay.setImage(s.getImage(), s.isFloatingWindow());
+                                imageOverlay.setImage(s.getImage(), s.isAlphaChannelImage());
                                 synchronized (this) {
                                     if (mPendingDrawing == false) {
                                         mCanvas.getDisplay().asyncExec(new Runnable() {
index f92fe55..37af3b4 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.DockMode;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.DockMode;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index 88b8fc8..3cf6091 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.KeyboardState;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.KeyboardState;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index c4d84ee..5faa293 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.Navigation;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index cf63160..8cea2d3 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.NavigationState;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.NavigationState;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index 03093cf..15aea6b 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.NightMode;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.NightMode;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index 5237ab0..32fc0c5 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.Density;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.Density;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index 107d7f4..d7d6bd3 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.ResourceEnum;
-import com.android.sdklib.resources.ScreenOrientation;
+import com.android.resources.ResourceEnum;
+import com.android.resources.ScreenOrientation;
 
 import org.eclipse.swt.graphics.Image;
 
index 8ae11a8..4444273 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.ResourceEnum;
-import com.android.sdklib.resources.ScreenRatio;
+import com.android.resources.ResourceEnum;
+import com.android.resources.ScreenRatio;
 
 import org.eclipse.swt.graphics.Image;
 
index ed07380..023a861 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.ResourceEnum;
-import com.android.sdklib.resources.ScreenSize;
+import com.android.resources.ResourceEnum;
+import com.android.resources.ScreenSize;
 
 import org.eclipse.swt.graphics.Image;
 
index e6276e8..b5ce166 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.ResourceEnum;
+import com.android.resources.Keyboard;
+import com.android.resources.ResourceEnum;
 
 import org.eclipse.swt.graphics.Image;
 
index 23ef94f..f3b8eb0 100644 (file)
@@ -17,8 +17,8 @@
 package com.android.ide.eclipse.adt.internal.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
-import com.android.sdklib.resources.ResourceEnum;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.ResourceEnum;
+import com.android.resources.TouchScreen;
 
 import org.eclipse.swt.graphics.Image;
 
index c282884..403b266 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.ide.eclipse.adt.internal.resources.manager;
 
 import com.android.ide.common.rendering.api.DensityBasedResourceValue;
-import com.android.ide.common.rendering.api.ResourceDensity;
 import com.android.ide.common.rendering.api.ResourceValue;
 import com.android.ide.eclipse.adt.internal.resources.ResourceType;
 import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier;
@@ -79,7 +78,7 @@ public class SingleResourceFile extends ResourceFile {
                     mType.getName(),
                     getResourceName(mType),
                     file.getOsLocation(),
-                    ResourceDensity.getEnum(qualifier.getValue().getDpiValue()),
+                    qualifier.getValue(),
                     isFramework());
         }
     }
index 1d715b0..12c58e8 100644 (file)
@@ -29,15 +29,15 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenRatio
 import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
 import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
 import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
-import com.android.sdklib.resources.Density;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.KeyboardState;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.NavigationState;
-import com.android.sdklib.resources.ScreenOrientation;
-import com.android.sdklib.resources.ScreenRatio;
-import com.android.sdklib.resources.ScreenSize;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.Density;
+import com.android.resources.Keyboard;
+import com.android.resources.KeyboardState;
+import com.android.resources.Navigation;
+import com.android.resources.NavigationState;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.ScreenRatio;
+import com.android.resources.ScreenSize;
+import com.android.resources.TouchScreen;
 
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
index 1a968a2..e8ca524 100644 (file)
@@ -36,18 +36,18 @@ import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMe
 import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
 import com.android.ide.eclipse.adt.internal.resources.configurations.VersionQualifier;
 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
-import com.android.sdklib.resources.Density;
-import com.android.sdklib.resources.DockMode;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.KeyboardState;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.NavigationState;
-import com.android.sdklib.resources.NightMode;
-import com.android.sdklib.resources.ResourceEnum;
-import com.android.sdklib.resources.ScreenOrientation;
-import com.android.sdklib.resources.ScreenRatio;
-import com.android.sdklib.resources.ScreenSize;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.Density;
+import com.android.resources.DockMode;
+import com.android.resources.Keyboard;
+import com.android.resources.KeyboardState;
+import com.android.resources.Navigation;
+import com.android.resources.NavigationState;
+import com.android.resources.NightMode;
+import com.android.resources.ResourceEnum;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.ScreenRatio;
+import com.android.resources.ScreenSize;
+import com.android.resources.TouchScreen;
 
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ISelection;
index 9cb746d..7c35ac8 100644 (file)
@@ -24,10 +24,10 @@ import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
 import com.android.ide.eclipse.adt.internal.sdk.Sdk;
 import com.android.ide.eclipse.adt.internal.wizards.newproject.NewProjectCreationPage.IMainInfo;
 import com.android.ide.eclipse.adt.internal.wizards.newproject.NewTestProjectCreationPage.TestInfo;
+import com.android.resources.Density;
 import com.android.sdklib.IAndroidTarget;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.io.StreamException;
-import com.android.sdklib.resources.Density;
 
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
index b3b276a..b9a72c4 100644 (file)
@@ -13,5 +13,6 @@
        <classpathentry kind="lib" path="/adt/libs/ninepatch.jar" sourcepath="/ninepatch"/>
        <classpathentry kind="lib" path="/adt/libs/sdklib.jar" sourcepath="/SdkLib"/>
        <classpathentry kind="lib" path="/adt/libs/sdkuilib.jar" sourcepath="/SdkUiLib"/>
+       <classpathentry kind="lib" path="/adt/libs/resources.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 2d6d014..c11c189 100644 (file)
@@ -39,17 +39,18 @@ import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
 import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
 import com.android.ide.eclipse.tests.SdkTestCase;
+import com.android.layoutlib.api.IXmlPullParser;
+import com.android.resources.Density;
+import com.android.resources.Keyboard;
+import com.android.resources.KeyboardState;
+import com.android.resources.Navigation;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.ScreenRatio;
+import com.android.resources.ScreenSize;
+import com.android.resources.TouchScreen;
 import com.android.sdklib.IAndroidTarget;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.io.FolderWrapper;
-import com.android.sdklib.resources.Density;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.KeyboardState;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.ScreenOrientation;
-import com.android.sdklib.resources.ScreenRatio;
-import com.android.sdklib.resources.ScreenSize;
-import com.android.sdklib.resources.TouchScreen;
 
 import org.kxml2.io.KXmlParser;
 import org.xmlpull.v1.XmlPullParser;
index d74b8be..e0292ee 100644 (file)
@@ -23,8 +23,8 @@ import com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescripto
 import com.android.ide.eclipse.adt.internal.editors.descriptors.TextAttributeDescriptor;
 import com.android.ide.eclipse.adt.internal.editors.mock.MockXmlNode;
 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
+import com.android.resources.Density;
 import com.android.sdklib.SdkConstants;
-import com.android.sdklib.resources.Density;
 
 import org.w3c.dom.Node;
 import org.xmlpull.v1.XmlPullParser;
index 0ae0a08..b97d1f8 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.KeyboardStateQualifier;
-import com.android.sdklib.resources.KeyboardState;
+import com.android.resources.KeyboardState;
 
 import junit.framework.TestCase;
 
index 384f29f..ebc34ad 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.NavigationMethodQualifier;
-import com.android.sdklib.resources.Navigation;
+import com.android.resources.Navigation;
 
 import junit.framework.TestCase;
 
index f165d7f..747e6d7 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.PixelDensityQualifier;
-import com.android.sdklib.resources.Density;
+import com.android.resources.Density;
 
 import junit.framework.TestCase;
 
index 452a1ff..b960c97 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenOrientationQualifier;
-import com.android.sdklib.resources.ScreenOrientation;
+import com.android.resources.ScreenOrientation;
 
 import junit.framework.TestCase;
 
index c605db5..26cf1f3 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.ScreenSizeQualifier;
-import com.android.sdklib.resources.ScreenSize;
+import com.android.resources.ScreenSize;
 
 import junit.framework.TestCase;
 
index e51c12d..f9ba80b 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.TextInputMethodQualifier;
-import com.android.sdklib.resources.Keyboard;
+import com.android.resources.Keyboard;
 
 import junit.framework.TestCase;
 
index 209bb57..1dafa8b 100644 (file)
@@ -18,7 +18,7 @@ package com.android.ide.eclipse.adt.internal.editors.resources.configurations;
 
 import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
 import com.android.ide.eclipse.adt.internal.resources.configurations.TouchScreenQualifier;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.TouchScreen;
 
 import junit.framework.TestCase;
 
index c371934..f8dc9fb 100644 (file)
@@ -27,15 +27,15 @@ import com.android.ide.eclipse.adt.internal.resources.manager.SingleResourceFile
 import com.android.ide.eclipse.adt.io.IFileWrapper;
 import com.android.ide.eclipse.adt.io.IFolderWrapper;
 import com.android.ide.eclipse.mock.Mocks;
+import com.android.resources.DockMode;
+import com.android.resources.Keyboard;
+import com.android.resources.KeyboardState;
+import com.android.resources.Navigation;
+import com.android.resources.NavigationState;
+import com.android.resources.NightMode;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.TouchScreen;
 import com.android.sdklib.io.IAbstractFolder;
-import com.android.sdklib.resources.DockMode;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.KeyboardState;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.NavigationState;
-import com.android.sdklib.resources.NightMode;
-import com.android.sdklib.resources.ScreenOrientation;
-import com.android.sdklib.resources.TouchScreen;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
index dd8cb77..6b70bf4 100755 (executable)
@@ -16,7 +16,7 @@ BACK=`echo $DEST | sed 's@[^/]*@..@g'`
 
 mkdir -p $DEST
 
-LIBS="sdkstats androidprefs layoutlib_api ide_common ninepatch sdklib sdkuilib"
+LIBS="sdkstats androidprefs layoutlib_api ide_common ninepatch sdklib sdkuilib resources"
 
 echo "make java libs ..."
 make -j3 showcommands $LIBS || die "ADT: Fail to build one of $LIBS."
index dca9bf3..83651a3 100755 (executable)
@@ -48,14 +48,12 @@ if [ "$HOST" == "Linux" ]; then
         ln -svf $BACK/out/host/linux-x86/framework/$LIB.jar "$DEST/"
     done
     ln -svf $BACK/out/host/linux-x86/framework/kxml2-2.3.0.jar        "$DEST/"
-    ln -svf $BACK/out/host/linux-x86/framework/layoutlib.jar          "$DEST/"
 
 elif [ "$HOST" == "Darwin" ]; then
     for LIB in $LIBS; do
         ln -svf $BACK/out/host/darwin-x86/framework/$LIB.jar "$DEST/"
     done
     ln -svf $BACK/out/host/darwin-x86/framework/kxml2-2.3.0.jar       "$DEST/"
-    ln -svf $BACK/out/host/darwin-x86/framework/layoutlib.jar         "$DEST/"
 
 elif [ "${HOST:0:6}" == "CYGWIN" ]; then
     for LIB in $LIBS; do
@@ -65,35 +63,19 @@ elif [ "${HOST:0:6}" == "CYGWIN" ]; then
         cp -v "prebuilt/common/kxml2/kxml2-2.3.0.jar" "$DEST/"
     fi
 
-    LIBS="layoutlib.jar"
-    NEED_MAKE="yes"
-    for LIB in $LIBS ; do
-        SRCJAR="out/host/windows-x86/framework/$LIB"
-        DSTJAR="$DEST/$LIB"
-        if [[ $NEED_MAKE ]] && ! diff -q "$SRCJAR" "$DSTJAR" >/dev/null ; then
-            MAKE_LIBS="${LIBS//.jar/}"
-            echo "Make java libs: $MAKE_LIBS"
-            make -j3 showcommands $MAKE_LIBS || die "adt-tests: Failed to build one of $LIBS."
-            NEED_MAKE=""
-        fi
-        
-        cp -v "$SRCJAR" "$DSTJAR"
-    done
-
     chmod -v a+rx "$DEST"/*.jar
 else
     echo "Unsupported platform ($HOST). Nothing done."
 fi
 
-# create link to ddmlib tests
-DEST=$BASE/unittests/com/android
-cpdir $DEST sdk/ddms/libs/ddmlib/tests/src/com/android/ddmlib
-cpdir $DEST sdk/sdkmanager/libs/sdklib/tests/com/android/sdklib
-
 # Cleanup old obsolete symlink
+
+DEST=$BASE/unittests/com/android
 [[ -e $DEST/sdkuilib || -L $DEST/sdkuilib ]] && rm -rfv $DEST/sdkuilib
+[[ -e $DEST/ddmlib || -L $DEST/ddmlib ]] && rm -rfv $DEST/ddmlib
+[[ -e $DEST/sdklib || -L $DEST/sdklib ]] && rm -rfv $DEST/sdklib
 
 DEST=$BASE/unittests/com/android/layoutlib
-mkdir -p $DEST
-cpdir $DEST frameworks/base/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge
-cpdir $DEST frameworks/base/tools/layoutlib/bridge/tests/com/android/layoutlib/testdata
+[[ -e $DEST/bridge || -L $DEST/bridge ]] && rm -rfv $DEST/bridge
+[[ -e $DEST/testdata || -L $DEST/testdata ]] && rm -rfv $DEST/testdata
+
index a09ce5f..bae87a9 100644 (file)
@@ -3,5 +3,6 @@
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/resources"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index d60987c..4ebf1f6 100644 (file)
@@ -19,6 +19,7 @@ include $(CLEAR_VARS)
 LOCAL_SRC_FILES := $(call all-java-files-under,src)
 
 LOCAL_JAVA_LIBRARIES := \
+       resources \
        kxml2-2.3.0
 
 LOCAL_MODULE := layoutlib_api
diff --git a/layoutlib_api/README.txt b/layoutlib_api/README.txt
new file mode 100644 (file)
index 0000000..487a1a2
--- /dev/null
@@ -0,0 +1,16 @@
+LayoutLib API is a jar describing the API used to load and interact with layoutlib.jar
+It is to be packaged with clients accessing layoutlib.jar
+
+Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform.
+
+IMPORTANT NOTE REGARDING CHANGES IN LAYOUTLIB_API:
+
+- The API must stay compatible. This is because while layoutlib.jar compiles against it,
+  the client provides the implementation and must be able to load earlier versions of layoutlib.jar.
+  This is true for all the classes under com.android.ide.common.rendering.api and
+  com.android.layoutlib.api although the latter is obsolete and should not be changed at all.
+
+- Updated version of layoutlib_api should be copied to the current in-dev branch of
+  prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar
+  The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this
+  prebuilt jar file.
\ No newline at end of file
index d190b62..4d0d51f 100644 (file)
@@ -21,10 +21,10 @@ import com.android.layoutlib.api.IDensityBasedResourceValue;
 @SuppressWarnings("deprecation")
 public class DensityBasedResourceValue extends ResourceValue implements IDensityBasedResourceValue {
 
-    private ResourceDensity mDensity;
+    private com.android.resources.Density mDensity;
 
     public DensityBasedResourceValue(String type, String name, String value,
-            ResourceDensity density, boolean isFramework) {
+            com.android.resources.Density density, boolean isFramework) {
         super(type, name, value, isFramework);
         mDensity = density;
     }
@@ -33,7 +33,7 @@ public class DensityBasedResourceValue extends ResourceValue implements IDensity
      * Returns the density for which this resource is configured.
      * @return the density.
      */
-    public ResourceDensity getResourceDensity() {
+    public com.android.resources.Density getResourceDensity() {
         return mDensity;
     }
 
@@ -41,6 +41,6 @@ public class DensityBasedResourceValue extends ResourceValue implements IDensity
      * @deprecated use {@link #getResourceDensity()} instead.
      */
     public Density getDensity() {
-        return Density.getEnum(mDensity.getDpi());
+        return Density.getEnum(mDensity.getDpiValue());
     }
 }
index 4bb41f1..fb4b423 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.ide.common.rendering.api;
 
+import com.android.resources.ScreenSize;
+
 
 public class Params {
 
@@ -64,6 +66,8 @@ public class Params {
 
     private IImageFactory mImageFactory = null;
 
+    private ScreenSize mConfigScreenSize = null;
+
     /**
      *
      * @param layoutDescription the {@link ILayoutPullParser} letting the LayoutLib Bridge visit the
@@ -137,6 +141,7 @@ public class Params {
         mCustomBackgroundColor = params.mCustomBackgroundColor;
         mTimeout = params.mTimeout;
         mImageFactory = params.mImageFactory;
+        mConfigScreenSize = params.mConfigScreenSize;
     }
 
     public void setOverrideBgColor(int color) {
@@ -152,6 +157,10 @@ public class Params {
         mImageFactory = imageFactory;
     }
 
+    public void setConfigScreenSize(ScreenSize size) {
+        mConfigScreenSize  = size;
+    }
+
     public ILayoutPullParser getLayoutDescription() {
         return mLayoutDescription;
     }
@@ -219,4 +228,8 @@ public class Params {
     public IImageFactory getImageFactory() {
         return mImageFactory;
     }
+
+    public ScreenSize getConfigScreenSize() {
+        return mConfigScreenSize;
+    }
 }
index 5a00ebc..9bdd146 100644 (file)
@@ -74,13 +74,11 @@ public class RenderSession {
     }
 
     /**
-     * Returns true if the current session is rendered as a floating window.
-     * <p/>
-     * If true this means the alpha channel of {@link #getImage()} should be respected. If false,
-     * if can be dropped if it's more convenient/faster.
-     * @return whether the current session is rendered as a floating window.
+     * Returns true if the current image alpha channel is relevant.
+     *
+     * @return whether the image alpha channel is relevant.
      */
-    public boolean isFloatingWindow() {
+    public boolean isAlphaChannelImage() {
         return true;
     }
 
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java
deleted file mode 100644 (file)
index ca92eae..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.rendering.api;
-
-/**
- * Enum representing the density class of Android resources.
- */
-public enum ResourceDensity {
-    XHIGH(320),
-    HIGH(240),
-    MEDIUM(160),
-    LOW(120),
-    NODPI(0);
-
-    public final static int DEFAULT_DENSITY = 160;
-
-    private final int mDpi;
-
-    ResourceDensity(int dpi) {
-        mDpi = dpi;
-    }
-
-    /**
-     * Returns the dot-per-inch value associated with the density.
-     * @return the dpi value.
-     */
-    public int getDpi() {
-        return mDpi;
-    }
-
-    /**
-     * Returns the enum matching the given dpi.
-     * @param dpi The dpi
-     * @return the enum for the dpi or null if no match was found.
-     */
-    public static ResourceDensity getEnum(int dpi) {
-        for (ResourceDensity d : values()) {
-            if (d.mDpi == dpi) {
-                return d;
-            }
-        }
-
-        return null;
-    }
-}
index 4e55d54..dce907c 100644 (file)
@@ -17,7 +17,6 @@
 package com.android.layoutlib.api;
 
 import com.android.ide.common.rendering.api.DensityBasedResourceValue;
-import com.android.ide.common.rendering.api.ResourceDensity;
 
 /**
  * Represents an Android Resources that has a density info attached to it.
@@ -29,7 +28,7 @@ public interface IDensityBasedResourceValue extends IResourceValue {
     /**
      * Density.
      *
-     * @deprecated use {@link ResourceDensity}.
+     * @deprecated use {@link com.android.resources.Density}.
      */
     @Deprecated
     public static enum Density {
diff --git a/resources/.classpath b/resources/.classpath
new file mode 100644 (file)
index 0000000..fb50116
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/resources/.gitignore b/resources/.gitignore
new file mode 100644 (file)
index 0000000..fe99505
--- /dev/null
@@ -0,0 +1,2 @@
+bin
+
diff --git a/resources/.project b/resources/.project
new file mode 100644 (file)
index 0000000..36b452a
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>resources</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/resources/Android.mk b/resources/Android.mk
new file mode 100644 (file)
index 0000000..5027a01
--- /dev/null
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under,src)
+
+LOCAL_JAVA_LIBRARIES := \
+
+LOCAL_MODULE := resources
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/resources/README.txt b/resources/README.txt
new file mode 100644 (file)
index 0000000..9b90814
--- /dev/null
@@ -0,0 +1,16 @@
+resources.jar contains resource configuration enums. It is used by various tools, but also
+by layoutlib.jar
+
+Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform.
+
+IMPORTANT NOTE REGARDING CHANGES IN resources.jar:
+
+- The API must stay compatible. This is because while layoutlib.jar compiles against it,
+  the client provides the implementation and must be able to load earlier versions of layoutlib.jar.
+  This is true for all the classes under com.android.ide.common.rendering.api and
+  com.android.layoutlib.api although the latter is obsolete and should not be changed at all.
+
+- Updated version of layoutlib_api should be copied to the current in-dev branch of
+  prebuilt/common/resources/resources-prebuilt.jar
+  The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this
+  prebuilt jar file.
\ No newline at end of file
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.sdklib.resources;
+package com.android.resources;
 
 /**
  * Dock enum.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.sdklib.resources;
+package com.android.resources;
 
 /**
  * Keyboard enum.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.sdklib.resources;
+package com.android.resources;
 
 /**
  * An enum representing a resource qualifier value.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.sdklib.resources;
+package com.android.resources;
 
 /**
  * Screen size enum.
index af31991..50f3e66 100644 (file)
@@ -1,2 +1,2 @@
 Main-Class: com.android.sdkmanager.Main
-Class-Path: androidprefs.jar sdklib.jar sdkuilib.jar org.eclipse.jface_3.4.2.M20090107-0800.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar org.eclipse.core.commands_3.4.0.I20080509-2000.jar
+Class-Path: androidprefs.jar resources.jar sdklib.jar sdkuilib.jar org.eclipse.jface_3.4.2.M20090107-0800.jar org.eclipse.equinox.common_3.4.0.v20080421-2006.jar org.eclipse.core.commands_3.4.0.I20080509-2000.jar
index 123ceef..b3528a4 100644 (file)
@@ -6,5 +6,6 @@
        <classpathentry combineaccessrules="false" kind="src" path="/AndroidPrefs"/>
        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
        <classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/commons-compress/commons-compress-1.0.jar"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/resources"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 5a7a7c7..3c91e88 100644 (file)
@@ -21,6 +21,7 @@ LOCAL_JAVA_RESOURCE_DIRS := .
 LOCAL_JAR_MANIFEST := ../manifest.txt
 LOCAL_JAVA_LIBRARIES := \
         androidprefs \
+        resources \
         commons-compress-1.0
 
 LOCAL_MODULE := sdklib
index 271e427..8f6fcc0 100644 (file)
 
 package com.android.sdklib.internal.export;
 
+import com.android.resources.Density;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.internal.export.MultiApkExportHelper.ExportException;
 import com.android.sdklib.internal.project.ApkSettings;
 import com.android.sdklib.internal.project.ProjectProperties;
 import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
-import com.android.sdklib.resources.Density;
 import com.android.sdklib.xml.ManifestData;
 import com.android.sdklib.xml.ManifestData.SupportsScreens;
 
index d7ca8ec..9a67735 100644 (file)
 
 package com.android.sdklib.xml;
 
+import com.android.resources.Keyboard;
+import com.android.resources.Navigation;
+import com.android.resources.TouchScreen;
 import com.android.sdklib.SdkConstants;
 import com.android.sdklib.io.IAbstractFile;
 import com.android.sdklib.io.IAbstractFolder;
 import com.android.sdklib.io.StreamException;
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.TouchScreen;
 import com.android.sdklib.xml.ManifestData.Activity;
 import com.android.sdklib.xml.ManifestData.Instrumentation;
 import com.android.sdklib.xml.ManifestData.SupportsScreens;
index 88f2af9..c4b8c0f 100644 (file)
@@ -16,9 +16,9 @@
 
 package com.android.sdklib.xml;
 
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.Keyboard;
+import com.android.resources.Navigation;
+import com.android.resources.TouchScreen;
 
 import java.util.ArrayList;
 import java.util.Set;
index a9a7edf..02725f4 100644 (file)
@@ -16,9 +16,9 @@
 
 package com.android.sdklib.xml;
 
-import com.android.sdklib.resources.Keyboard;
-import com.android.sdklib.resources.Navigation;
-import com.android.sdklib.resources.TouchScreen;
+import com.android.resources.Keyboard;
+import com.android.resources.Navigation;
+import com.android.resources.TouchScreen;
 import com.android.sdklib.xml.ManifestData.UsesFeature;
 import com.android.sdklib.xml.ManifestData.UsesLibrary;