aboutsummaryrefslogtreecommitdiffstats
path: root/layoutlib_api
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-10-17 14:17:32 -0700
committerXavier Ducrohet <xav@android.com>2012-10-17 16:34:16 -0700
commitc431088d54a4571f5596e6d1da0069eab62f371b (patch)
tree92fb65044fb0bd706715399ed85e7ca8aa25f3d1 /layoutlib_api
parent5ca0b319f38c007af636d8d3796293bf5cb9a302 (diff)
downloadsdk-c431088d54a4571f5596e6d1da0069eab62f371b.zip
sdk-c431088d54a4571f5596e6d1da0069eab62f371b.tar.gz
sdk-c431088d54a4571f5596e6d1da0069eab62f371b.tar.bz2
Update Layoutlib_api to use a class for h/w config.
Change-Id: Iead02d468590407ec274357f1a1c57ed8d5cc24c
Diffstat (limited to 'layoutlib_api')
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java12
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java91
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java73
-rw-r--r--layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java15
4 files changed, 135 insertions, 56 deletions
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java
index 346d67d..b566ad3 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/DrawableParams.java
@@ -16,7 +16,6 @@
package com.android.ide.common.rendering.api;
-import com.android.resources.Density;
/**
* Rendering parameters for {@link Bridge#renderDrawable(DrawableParams)}
@@ -32,11 +31,7 @@ public class DrawableParams extends RenderParams {
*
* @param drawable the {@link ResourceValue} identifying the drawable.
* @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 hardwareConfig the {@link HardwareConfig}.
* @param renderResources a {@link RenderResources} object providing access to the resources.
* @param projectCallback The {@link IProjectCallback} object to get information from
* the project.
@@ -47,13 +42,12 @@ public class DrawableParams extends RenderParams {
public DrawableParams(
ResourceValue drawable,
Object projectKey,
- int screenWidth, int screenHeight,
- Density density, float xdpi, float ydpi,
+ HardwareConfig hardwareConfig,
RenderResources renderResources,
IProjectCallback projectCallback,
int minSdkVersion, int targetSdkVersion,
LayoutLog log) {
- super(projectKey, screenWidth, screenHeight, density, xdpi, ydpi,
+ super(projectKey, hardwareConfig,
renderResources, projectCallback, minSdkVersion, targetSdkVersion, log);
mDrawable = drawable;
}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java b/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java
new file mode 100644
index 0000000..89f1424
--- /dev/null
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/HardwareConfig.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2012 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;
+
+import com.android.resources.Density;
+import com.android.resources.ScreenOrientation;
+import com.android.resources.ScreenSize;
+
+/**
+ * Hardware configuration for the rendering.
+ * This is immutable.
+ *
+ * @since 9
+ */
+public class HardwareConfig {
+
+ private final int mScreenWidth;
+ private final int mScreenHeight;
+ private final Density mDensity;
+ private final float mXdpi;
+ private final float mYdpi;
+ private final ScreenOrientation mOrientation;
+ private final ScreenSize mScreenSize;
+
+ private final boolean mSoftwareButtons;
+
+ public HardwareConfig(
+ int screenWidth,
+ int screenHeight,
+ Density density,
+ float xdpi,
+ float ydpi,
+ ScreenSize screenSize,
+ ScreenOrientation orientation,
+ boolean softwareButtons) {
+ mScreenWidth = screenWidth;
+ mScreenHeight = screenHeight;
+ mDensity = density;
+ mXdpi = xdpi;
+ mYdpi = ydpi;
+ mScreenSize = screenSize;
+ mOrientation = orientation;
+ mSoftwareButtons = softwareButtons;
+ }
+
+ public int getScreenWidth() {
+ return mScreenWidth;
+ }
+
+ public int getScreenHeight() {
+ return mScreenHeight;
+ }
+
+ public Density getDensity() {
+ return mDensity;
+ }
+
+ public float getXdpi() {
+ return mXdpi;
+ }
+
+ public float getYdpi() {
+ return mYdpi;
+ }
+
+ public ScreenSize getScreenSize() {
+ return mScreenSize;
+ }
+
+ public ScreenOrientation getOrientation() {
+ return mOrientation;
+ }
+
+ public boolean hasSoftwareButtons() {
+ return mSoftwareButtons;
+ }
+}
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java
index f89dcfe..2e53f14 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderParams.java
@@ -29,11 +29,7 @@ public abstract class RenderParams {
public final static long DEFAULT_TIMEOUT = 250; //ms
private final Object mProjectKey;
- private final int mScreenWidth;
- private final int mScreenHeight;
- private final Density mDensity;
- private final float mXdpi;
- private final float mYdpi;
+ private final HardwareConfig mHardwareConfig;
private final RenderResources mRenderResources;
private final IProjectCallback mProjectCallback;
private final int mMinSdkVersion;
@@ -46,7 +42,6 @@ public abstract class RenderParams {
private IImageFactory mImageFactory = null;
- private ScreenSize mConfigScreenSize = null;
private String mAppIcon = null;
private String mAppLabel = null;
private String mLocale = null;
@@ -55,11 +50,7 @@ public abstract class RenderParams {
/**
*
* @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 hardwareConfig the {@link HardwareConfig}.
* @param renderResources a {@link RenderResources} object providing access to the resources.
* @param projectCallback The {@link IProjectCallback} object to get information from
* the project.
@@ -69,18 +60,13 @@ public abstract class RenderParams {
*/
public RenderParams(
Object projectKey,
- int screenWidth, int screenHeight,
- Density density, float xdpi, float ydpi,
+ HardwareConfig hardwareConfig,
RenderResources renderResources,
IProjectCallback projectCallback,
int minSdkVersion, int targetSdkVersion,
LayoutLog log) {
mProjectKey = projectKey;
- mScreenWidth = screenWidth;
- mScreenHeight = screenHeight;
- mDensity = density;
- mXdpi = xdpi;
- mYdpi = ydpi;
+ mHardwareConfig = hardwareConfig;
mRenderResources = renderResources;
mProjectCallback = projectCallback;
mMinSdkVersion = minSdkVersion;
@@ -95,11 +81,7 @@ public abstract class RenderParams {
*/
public RenderParams(RenderParams params) {
mProjectKey = params.mProjectKey;
- mScreenWidth = params.mScreenWidth;
- mScreenHeight = params.mScreenHeight;
- mDensity = params.mDensity;
- mXdpi = params.mXdpi;
- mYdpi = params.mYdpi;
+ mHardwareConfig = params.mHardwareConfig;
mRenderResources = params.mRenderResources;
mProjectCallback = params.mProjectCallback;
mMinSdkVersion = params.mMinSdkVersion;
@@ -109,7 +91,6 @@ public abstract class RenderParams {
mCustomBackgroundColor = params.mCustomBackgroundColor;
mTimeout = params.mTimeout;
mImageFactory = params.mImageFactory;
- mConfigScreenSize = params.mConfigScreenSize;
mAppIcon = params.mAppIcon;
mAppLabel = params.mAppLabel;
mLocale = params.mLocale;
@@ -129,10 +110,6 @@ public abstract class RenderParams {
mImageFactory = imageFactory;
}
- public void setConfigScreenSize(ScreenSize size) {
- mConfigScreenSize = size;
- }
-
public void setAppIcon(String appIcon) {
mAppIcon = appIcon;
}
@@ -153,6 +130,10 @@ public abstract class RenderParams {
return mProjectKey;
}
+ public HardwareConfig getHardwareConfig() {
+ return mHardwareConfig;
+ }
+
public int getMinSdkVersion() {
return mMinSdkVersion;
}
@@ -161,24 +142,44 @@ public abstract class RenderParams {
return mTargetSdkVersion;
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public int getScreenWidth() {
- return mScreenWidth;
+ return mHardwareConfig.getScreenWidth();
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public int getScreenHeight() {
- return mScreenHeight;
+ return mHardwareConfig.getScreenHeight();
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public Density getDensity() {
- return mDensity;
+ return mHardwareConfig.getDensity();
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public float getXdpi() {
- return mXdpi;
+ return mHardwareConfig.getXdpi();
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public float getYdpi() {
- return mYdpi;
+ return mHardwareConfig.getYdpi();
}
public RenderResources getResources() {
@@ -209,8 +210,12 @@ public abstract class RenderParams {
return mImageFactory;
}
+ /**
+ * @deprecated Use {@link #getHardwareConfig()}
+ */
+ @Deprecated
public ScreenSize getConfigScreenSize() {
- return mConfigScreenSize;
+ return mHardwareConfig.getScreenSize();
}
public String getAppIcon() {
diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
index e3edbd2..f440de1 100644
--- a/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
+++ b/layoutlib_api/src/com/android/ide/common/rendering/api/SessionParams.java
@@ -16,8 +16,6 @@
package com.android.ide.common.rendering.api;
-import com.android.resources.Density;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -52,7 +50,6 @@ public class SessionParams extends RenderParams {
private final ILayoutPullParser mLayoutDescription;
private final RenderingMode mRenderingMode;
- private final boolean mSoftwareButtons;
private boolean mLayoutOnly = false;
private Map<ResourceReference, AdapterBinding> mAdapterBindingMap;
private boolean mExtendedViewInfoMode = false;
@@ -80,26 +77,22 @@ public class SessionParams extends RenderParams {
ILayoutPullParser layoutDescription,
RenderingMode renderingMode,
Object projectKey,
- int screenWidth, int screenHeight,
- Density density, float xdpi, float ydpi,
+ HardwareConfig hardwareConfig,
RenderResources renderResources,
IProjectCallback projectCallback,
int minSdkVersion, int targetSdkVersion,
- boolean softwareButtons,
LayoutLog log) {
- super(projectKey, screenWidth, screenHeight, density, xdpi, ydpi,
+ super(projectKey, hardwareConfig,
renderResources, projectCallback, minSdkVersion, targetSdkVersion, log);
mLayoutDescription = layoutDescription;
mRenderingMode = renderingMode;
- mSoftwareButtons = softwareButtons;
}
public SessionParams(SessionParams params) {
super(params);
mLayoutDescription = params.mLayoutDescription;
mRenderingMode = params.mRenderingMode;
- mSoftwareButtons = params.mSoftwareButtons;
if (params.mAdapterBindingMap != null) {
mAdapterBindingMap = new HashMap<ResourceReference, AdapterBinding>(
params.mAdapterBindingMap);
@@ -115,10 +108,6 @@ public class SessionParams extends RenderParams {
return mRenderingMode;
}
- public boolean hasSoftwareButtons() {
- return mSoftwareButtons;
- }
-
public void setLayoutOnly() {
mLayoutOnly = true;
}