diff options
author | Xavier Ducrohet <xav@android.com> | 2011-05-16 16:00:10 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-05-16 17:25:45 -0700 |
commit | 580ecb7a5212f5e14862aa91b8bc5a0964ca56d9 (patch) | |
tree | adbd81323f7efe504c2f0703202209a314bf1dad /layoutlib_api/src/com/android/ide/common/rendering/api | |
parent | b001f6889ef4c41a9d07678b4f15c3aee6321a22 (diff) | |
download | sdk-580ecb7a5212f5e14862aa91b8bc5a0964ca56d9.zip sdk-580ecb7a5212f5e14862aa91b8bc5a0964ca56d9.tar.gz sdk-580ecb7a5212f5e14862aa91b8bc5a0964ca56d9.tar.bz2 |
Add baseline/margins to ViewInfo.
Also make it so that older layoutlib that are using API5 return the
value through reflection (done in LayoutLibrary.)
Change-Id: I3a32666e525f0f1d37a13e670d1d1c659b8e2027
Diffstat (limited to 'layoutlib_api/src/com/android/ide/common/rendering/api')
5 files changed, 70 insertions, 4 deletions
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 c044353..ad2dd38 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 @@ -143,8 +143,11 @@ public abstract class Bridge { * * @return the baseline value or -1 if not applicable to the view object or if this layout * library does not implement this method. + * + * @deprecated use the extended ViewInfo. */ - public int getViewBaseline(Object viewObject) { - return -1; + @Deprecated + public Result getViewBaseline(Object viewObject) { + return NOT_IMPLEMENTED.createResult(); } } 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 6620571..a7ab7ae 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 @@ -42,7 +42,7 @@ public enum Capability { * {@link RenderSession#setProperty(Object, String, String)}<br> * The method that receives an animation listener can only use it if the * ANIMATED_VIEW_MANIPULATION, or FULL_ANIMATED_VIEW_MANIPULATION is also supported. - * */ + */ VIEW_MANIPULATION, /** Ability to play animations with<br> * {@link RenderSession#animate(Object, String, boolean, IAnimationListener)} @@ -60,5 +60,6 @@ public enum Capability { * see {@link RenderSession#moveChild(Object, Object, int, java.util.Map, IAnimationListener)} */ FULL_ANIMATED_VIEW_MANIPULATION, - ADAPTER_BINDING; + ADAPTER_BINDING, + EXTENDED_VIEWINFO; } diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java index 6152a28..a739e79 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java @@ -47,6 +47,7 @@ public class Result { ERROR_RENDER, ERROR_ANIM_NOT_FOUND, ERROR_NOT_A_DRAWABLE, + ERROR_REFLECTION, ERROR_UNKNOWN; private Result mResult; 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 f4f6b5c..1af450e 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 @@ -54,6 +54,7 @@ public class SessionParams extends RenderParams { private final RenderingMode mRenderingMode; private boolean mLayoutOnly = false; private Map<ResourceReference, AdapterBinding> mAdapterBindingMap; + private boolean mExtendedViewInfoMode = false; /** * @@ -107,6 +108,7 @@ public class SessionParams extends RenderParams { mAdapterBindingMap = new HashMap<ResourceReference, AdapterBinding>( params.mAdapterBindingMap); } + mExtendedViewInfoMode = params.mExtendedViewInfoMode; } public ILayoutPullParser getLayoutDescription() { @@ -140,4 +142,12 @@ public class SessionParams extends RenderParams { return Collections.unmodifiableMap(mAdapterBindingMap); } + + public void setExtendedViewInfoMode(boolean mode) { + mExtendedViewInfoMode = mode; + } + + public boolean getExtendedViewInfoMode() { + return mExtendedViewInfoMode; + } } diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java index 2c0c829..2671fc0 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java @@ -34,6 +34,13 @@ public class ViewInfo { private final Object mViewObject; private final Object mLayoutParamsObject; + // optional info + private int mBaseLine = Integer.MIN_VALUE; + private int mLeftMargin = Integer.MIN_VALUE; + private int mTopMargin = Integer.MIN_VALUE; + private int mRightMargin = Integer.MIN_VALUE; + private int mBottomMargin = Integer.MIN_VALUE; + public ViewInfo(String name, Object cookie, int left, int top, int right, int bottom) { this(name, cookie, left, top, right, bottom, null /*viewObject*/, null /*layoutParamsObject*/); @@ -62,6 +69,15 @@ public class ViewInfo { } } + public void setExtendedInfo(int baseLine, int leftMargin, int topMargin, + int rightMargin, int bottomMargin) { + mBaseLine = baseLine; + mLeftMargin = leftMargin; + mTopMargin = topMargin; + mRightMargin = rightMargin; + mBottomMargin = bottomMargin; + } + /** * Returns the list of children views. This is never null, but can be empty. */ @@ -130,4 +146,39 @@ public class ViewInfo { public Object getLayoutParamsObject() { return mLayoutParamsObject; } + + /** + * Returns the baseline value. If the value is unknown, returns {@link Integer#MIN_VALUE}. + */ + public int getBaseLine() { + return mBaseLine; + } + + /** + * Returns the left margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}. + */ + public int getLeftMargin() { + return mLeftMargin; + } + + /** + * Returns the top margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}. + */ + public int getTopMargin() { + return mTopMargin; + } + + /** + * Returns the right margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}. + */ + public int getRightMargin() { + return mRightMargin; + } + + /** + * Returns the bottom margin value. If the value is unknown, returns {@link Integer#MIN_VALUE}. + */ + public int getBottomMargin() { + return mBottomMargin; + } } |