diff options
author | Xavier Ducrohet <xav@android.com> | 2012-10-16 17:18:55 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-10-16 17:30:11 -0700 |
commit | 5cf945b8f4250001cdddaba5ba1178691187137f (patch) | |
tree | ada7df2f30f0fb2ead3e981f41305a4de4754bf9 | |
parent | 1d628fc482b8545bca4e1b21cca4ad06004dae0f (diff) | |
download | sdk-5cf945b8f4250001cdddaba5ba1178691187137f.zip sdk-5cf945b8f4250001cdddaba5ba1178691187137f.tar.gz sdk-5cf945b8f4250001cdddaba5ba1178691187137f.tar.bz2 |
New API in layoutlib_api.
- Capability for fixed 9-patch scaling.
- software button param for rendering.
Change-Id: I2616dbd97dc413c2c5b5d52af6309967400d2456
5 files changed, 24 insertions, 2 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java index ccf4068..622a4d4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java @@ -50,6 +50,7 @@ import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode; import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; import com.android.resources.Density; +import com.android.sdklib.devices.ButtonType; import org.eclipse.core.resources.IProject; import org.xmlpull.v1.XmlPullParser; @@ -81,6 +82,7 @@ public class RenderService { private final ResourceResolver mResourceResolver; private final int mMinSdkVersion; private final int mTargetSdkVersion; + private final boolean mSoftwareButtons; private final LayoutLibrary mLayoutLib; private final IImageFactory mImageFactory; private final Density mDensity; @@ -120,6 +122,8 @@ public class RenderService { mProjectCallback = editor.getProjectCallback(true /*reset*/, mLayoutLib); mMinSdkVersion = editor.getMinSdkVersion(); mTargetSdkVersion = editor.getTargetSdkVersion(); + mSoftwareButtons = + config.getDevice().getDefaultHardware().getButtonType() == ButtonType.SOFT; } private RenderService(GraphicalEditorPart editor, FolderConfiguration configuration, @@ -137,6 +141,8 @@ public class RenderService { mProjectCallback = editor.getProjectCallback(true /*reset*/, mLayoutLib); mMinSdkVersion = editor.getMinSdkVersion(); mTargetSdkVersion = editor.getTargetSdkVersion(); + mSoftwareButtons = + config.getDevice().getDefaultHardware().getButtonType() == ButtonType.SOFT; // TODO: Look up device etc and offer additional configuration options here? Density density = Density.MEDIUM; @@ -398,6 +404,7 @@ public class RenderService { mProjectCallback, mMinSdkVersion, mTargetSdkVersion, + mSoftwareButtons, mLogger); // Request margin and baseline information. @@ -533,6 +540,7 @@ public class RenderService { mProjectCallback, mMinSdkVersion, mTargetSdkVersion, + mSoftwareButtons, mLogger); params.setLayoutOnly(); params.setForceNoDecor(); diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java index 30f23de..7a6eef4 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java @@ -263,6 +263,7 @@ public class ApiDemosRenderingTest extends SdkTestCase { projectCallBack, 1, // minSdkVersion 1, // targetSdkVersion + false, // softwareButtons null //logger )); diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java index 06a01d5..a19b8d5 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java @@ -32,7 +32,7 @@ import java.util.Map; */ public abstract class Bridge { - public final static int API_CURRENT = 8; + public final static int API_CURRENT = 9; /** * Returns the API level of the layout library. diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java index a7ab7ae..5ad438d 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java @@ -61,5 +61,9 @@ public enum Capability { */ FULL_ANIMATED_VIEW_MANIPULATION, ADAPTER_BINDING, - EXTENDED_VIEWINFO; + EXTENDED_VIEWINFO, + /** + * Ability to properly resize nine-patch assets. + */ + FIXED_SCALABLE_NINE_PATCH; } 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 a620b05..e3edbd2 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 @@ -52,6 +52,7 @@ 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; @@ -72,6 +73,7 @@ public class SessionParams extends RenderParams { * the project. * @param minSdkVersion the minSdkVersion of the project * @param targetSdkVersion the targetSdkVersion of the project + * @param softwareButtons whether the device use software buttons * @param log the object responsible for displaying warning/errors to the user. */ public SessionParams( @@ -83,18 +85,21 @@ public class SessionParams extends RenderParams { RenderResources renderResources, IProjectCallback projectCallback, int minSdkVersion, int targetSdkVersion, + boolean softwareButtons, LayoutLog log) { super(projectKey, screenWidth, screenHeight, density, xdpi, ydpi, 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); @@ -110,6 +115,10 @@ public class SessionParams extends RenderParams { return mRenderingMode; } + public boolean hasSoftwareButtons() { + return mSoftwareButtons; + } + public void setLayoutOnly() { mLayoutOnly = true; } |