OSDN Git Service

Add min/targetSdkVersion to the LayoutLib API.
authorXavier Ducrohet <xav@android.com>
Tue, 18 Jan 2011 06:48:40 +0000 (22:48 -0800)
committerXavier Ducrohet <xav@android.com>
Tue, 18 Jan 2011 06:53:03 +0000 (22:53 -0800)
This will allow some widgets to properly behave based on the
minSdkVersion and targetSdkVersion of the project during
rendering.

Change-Id: I96d432b8b92fbc211ce122da51bd18049708c14f

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.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
layoutlib_api/src/com/android/ide/common/rendering/api/Params.java

index a857dc7..15d46e9 100644 (file)
@@ -1642,6 +1642,8 @@ public class GraphicalEditorPart extends EditorPart
                 density, xdpi, ydpi,
                 resolver,
                 mProjectCallback,
+                1 /*minSdkVersion*/,
+                1 /*targetSdkVersion */,
                 logger);
 
         if (transparentBackground) {
index 05b360f..2d6d014 100644 (file)
@@ -215,6 +215,8 @@ public class ApiDemosRenderingTest extends SdkTestCase {
                     160, // ydpi
                     resolver,
                     projectCallBack,
+                    1, // minSdkVersion
+                    1, // targetSdkVersion
                     null //logger
                     ));
 
index 3cede41..4bb41f1 100644 (file)
@@ -54,6 +54,8 @@ public class Params {
     private final float mYdpi;
     private final RenderResources mRenderResources;
     private final IProjectCallback mProjectCallback;
+    private final int mMinSdkVersion;
+    private final int mTargetSdkVersion;
     private final LayoutLog mLog;
 
     private boolean mCustomBackgroundEnabled;
@@ -85,6 +87,8 @@ public class Params {
      * value is the resource value.
      * @param projectCallback The {@link IProjectCallback} object to get information from
      * the project.
+     * @param minSdkVersion the minSdkVersion of the project
+     * @param targetSdkVersion the targetSdkVersion of the project
      * @param log the object responsible for displaying warning/errors to the user.
      */
     public Params(ILayoutPullParser layoutDescription,
@@ -92,7 +96,9 @@ public class Params {
             int screenWidth, int screenHeight, RenderingMode renderingMode,
             int density, float xdpi, float ydpi,
             RenderResources renderResources,
-            IProjectCallback projectCallback, LayoutLog log) {
+            IProjectCallback projectCallback,
+            int minSdkVersion, int targetSdkVersion,
+            LayoutLog log) {
         mLayoutDescription = layoutDescription;
         mProjectKey = projectKey;
         mScreenWidth = screenWidth;
@@ -103,6 +109,8 @@ public class Params {
         mYdpi = ydpi;
         mRenderResources = renderResources;
         mProjectCallback = projectCallback;
+        mMinSdkVersion = minSdkVersion;
+        mTargetSdkVersion = targetSdkVersion;
         mLog = log;
         mCustomBackgroundEnabled = false;
         mTimeout = DEFAULT_TIMEOUT;
@@ -122,6 +130,8 @@ public class Params {
         mYdpi = params.mYdpi;
         mRenderResources = params.mRenderResources;
         mProjectCallback = params.mProjectCallback;
+        mMinSdkVersion = params.mMinSdkVersion;
+        mTargetSdkVersion = params.mTargetSdkVersion;
         mLog = params.mLog;
         mCustomBackgroundEnabled = params.mCustomBackgroundEnabled;
         mCustomBackgroundColor = params.mCustomBackgroundColor;
@@ -150,6 +160,14 @@ public class Params {
         return mProjectKey;
     }
 
+    public int getMinSdkVersion() {
+        return mMinSdkVersion;
+    }
+
+    public int getTargetSdkVersion() {
+        return mTargetSdkVersion;
+    }
+
     public int getScreenWidth() {
         return mScreenWidth;
     }