aboutsummaryrefslogtreecommitdiffstats
path: root/layoutlib_api
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-01-27 13:10:25 -0800
committerXavier Ducrohet <xav@android.com>2011-01-27 15:43:01 -0800
commit6685d3a8cb5fe1374e36358c1436a70c6bca1659 (patch)
treec33e4a93f88af21b57de381d9ae730d40ce4e547 /layoutlib_api
parent1a90318f6a72ea6111919ab1484f702b2a08bbc0 (diff)
downloadsdk-6685d3a8cb5fe1374e36358c1436a70c6bca1659.zip
sdk-6685d3a8cb5fe1374e36358c1436a70c6bca1659.tar.gz
sdk-6685d3a8cb5fe1374e36358c1436a70c6bca1659.tar.bz2
Update the Layoutlib API to contain part of the current config.
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
Diffstat (limited to 'layoutlib_api')
-rw-r--r--layoutlib_api/.classpath1
-rw-r--r--layoutlib_api/Android.mk1
-rw-r--r--layoutlib_api/README.txt16
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java8
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/Params.java13
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java10
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java59
-rw-r--r--layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java3
8 files changed, 40 insertions, 71 deletions
diff --git a/layoutlib_api/.classpath b/layoutlib_api/.classpath
index a09ce5f..bae87a9 100644
--- a/layoutlib_api/.classpath
+++ b/layoutlib_api/.classpath
@@ -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>
diff --git a/layoutlib_api/Android.mk b/layoutlib_api/Android.mk
index d60987c..4ebf1f6 100644
--- a/layoutlib_api/Android.mk
+++ b/layoutlib_api/Android.mk
@@ -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
index 0000000..487a1a2
--- /dev/null
+++ b/layoutlib_api/README.txt
@@ -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
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
index d190b62..4d0d51f 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java
@@ -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());
}
}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java
index 4bb41f1..fb4b423 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java
@@ -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;
+ }
}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
index 5a00ebc..9bdd146 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java
@@ -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
index ca92eae..0000000
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java
+++ /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;
- }
-}
diff --git a/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java b/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java
index 4e55d54..dce907c 100644
--- a/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java
+++ b/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java
@@ -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 {