diff options
author | Xavier Ducrohet <xav@android.com> | 2010-12-15 16:08:57 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2010-12-21 10:27:22 -0800 |
commit | 95b17a5e62eeeb7b38ef668508df43a1ee9e0880 (patch) | |
tree | ca77258cf072446e38d2a68acab77aac8dd3a73e /layoutlib_api/src | |
parent | 77e0fdebe08d39f550544571989649533d043223 (diff) | |
download | sdk-95b17a5e62eeeb7b38ef668508df43a1ee9e0880.zip sdk-95b17a5e62eeeb7b38ef668508df43a1ee9e0880.tar.gz sdk-95b17a5e62eeeb7b38ef668508df43a1ee9e0880.tar.bz2 |
LayoutLib API refactoring
Change-Id: I40abba4c4f786755c2a1c0e70df4d7bc08e2bcde
Diffstat (limited to 'layoutlib_api/src')
23 files changed, 328 insertions, 149 deletions
diff --git a/layoutlib_api/src/com/android/layoutlib/api/LayoutBridge.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java index a3bd921..b2c2109 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/LayoutBridge.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Bridge.java @@ -14,16 +14,18 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; + +import java.io.File; import java.util.EnumSet; import java.util.Map; /** - * Entry point of the Layout Lib. Extensions of this class provide a method to compute + * Entry point of the Layout Library. Extensions of this class provide a method to compute * and render a layout. */ -public abstract class LayoutBridge { +public abstract class Bridge { public final static int API_CURRENT = 5; @@ -32,6 +34,7 @@ public abstract class LayoutBridge { * <p/> * While no methods will ever be removed, some may become deprecated, and some new ones * will appear. + * <p/>All Layout libraries based on {@link Bridge} return at minimum an API level of 5. */ public abstract int getApiLevel(); @@ -47,11 +50,11 @@ public abstract class LayoutBridge { /** * Initializes the Bridge object. * - * @param fontOsLocation the location of the fonts. + * @param fontLocation the location of the fonts. * @param enumValueMap map attrName => { map enumFlagName => Integer value }. * @return true if success. */ - public boolean init(String fontOsLocation, Map<String, Map<String, Integer>> enumValueMap) { + public boolean init(File fontLocation, Map<String, Map<String, Integer>> enumValueMap) { return false; } @@ -64,12 +67,12 @@ public abstract class LayoutBridge { /** * Starts a layout session by inflating and rendering it. The method returns a - * {@link LayoutScene} on which further actions can be taken. + * {@link RenderSession} on which further actions can be taken. * - * @return a new {@link LayoutScene} object that contains the result of the scene creation and + * @return a new {@link RenderSession} object that contains the result of the scene creation and * first rendering. */ - public LayoutScene createScene(SceneParams params) { + public RenderSession createSession(Params params) { return null; } @@ -79,6 +82,8 @@ public abstract class LayoutBridge { * until this method is called. * <p/>The cache is not configuration dependent and should only be cleared when a * resource changes (at this time only bitmaps and 9 patches go into the cache). + * <p/> + * The project key provided must be similar to the one passed in {@link Params}. * * @param projectKey the key for the project. */ diff --git a/layoutlib_api/src/com/android/layoutlib/api/Capability.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java index 87ceca1..abbab45 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/Capability.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Capability.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; /** * Enum describing the layout bridge capabilities. diff --git a/layoutlib_api/src/com/android/layoutlib/api/DensityBasedResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java index 78b084c..d190b62 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/DensityBasedResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/DensityBasedResourceValue.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; + +import com.android.layoutlib.api.IDensityBasedResourceValue; @SuppressWarnings("deprecation") public class DensityBasedResourceValue extends ResourceValue implements IDensityBasedResourceValue { diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java new file mode 100644 index 0000000..81a2320 --- /dev/null +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/IAnimationListener.java @@ -0,0 +1,48 @@ +/* + * 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; + + +import java.awt.image.BufferedImage; + +public interface IAnimationListener { + /** + * Called when a new animation frame is available for display. + * + * <p>The {@link RenderSession} object is provided as a convenience. It should be queried + * for the image through {@link RenderSession#getImage()}. + * + * <p>If no {@link IImageFactory} is used, then each new animation frame will be rendered + * in its own new {@link BufferedImage} object. However if an image factory is used, and it + * always re-use the same object, then the image is only guaranteed to be valid during + * this method call. As soon as this method return the image content will be overridden + * with new drawing. + * + */ + void onNewFrame(RenderSession scene); + + /** + * Called when the animation is done playing. + */ + void done(Result result); + + /** + * Return true to cancel the animation. + */ + boolean isCanceled(); + +} diff --git a/layoutlib_api/src/com/android/layoutlib/api/IImageFactory.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java index 626423e..c05c7c6 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IImageFactory.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/IImageFactory.java @@ -14,7 +14,8 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; + import java.awt.image.BufferedImage; @@ -25,7 +26,7 @@ import java.awt.image.BufferedImage; * rendered. The goal is to let the layoutlib caller create an image that's optimized for its use * case. * - * If no factory is passed in {@link SceneParams#setImageFactory(IImageFactory)}, then a default + * If no factory is passed in {@link Params#setImageFactory(IImageFactory)}, then a default * {@link BufferedImage} of type {@link BufferedImage#TYPE_INT_ARGB} is created. * */ diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java new file mode 100644 index 0000000..4b033d9 --- /dev/null +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ILayoutPullParser.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008 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 org.xmlpull.v1.XmlPullParser; + +/** + * Extended version of {@link XmlPullParser} to use with + * {@link Bridge#createScene(SceneParams)} + */ +public interface ILayoutPullParser extends XmlPullParser { + + /** + * Returns a cookie for the current XML node. + * <p/>This cookie will be passed back in the {@link ViewInfo} objects, allowing association + * of a particular XML node with its result from the layout computation. + * + * @see ViewInfo#getCookie() + */ + Object getViewCookie(); + + /** + * Returns a custom parser for the layout of the given name. + * @param layoutName the name of the layout. + * @return returns a custom parser or null if no custom parsers are needed. + * + * @since 5 + */ + ILayoutPullParser getParser(String layoutName); +} + diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java new file mode 100644 index 0000000..67e082e --- /dev/null +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/IProjectCallback.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2008 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; + +/** + * Callback for project information needed by the Layout Library. + * Classes implementing this interface provide methods giving access to some project data, like + * resource resolution, namespace information, and instantiation of custom view. + */ +public interface IProjectCallback { + + /** + * Loads a custom view with the given constructor signature and arguments. + * @param name The fully qualified name of the class. + * @param constructorSignature The signature of the class to use + * @param constructorArgs The arguments to use on the constructor + * @return A newly instantiated android.view.View object. + * @throws ClassNotFoundException + * @throws Exception + */ + @SuppressWarnings("unchecked") + Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs) + throws ClassNotFoundException, Exception; + + /** + * Returns the namespace of the application. + * <p/>This lets the Layout Lib load custom attributes for custom views. + */ + String getNamespace(); + + /** + * Resolves the id of a resource Id. + * <p/>The resource id is the value of a <code>R.<type>.<name></code>, and + * this method will return both the type and name of the resource. + * @param id the Id to resolve. + * @return an array of 2 strings containing the resource name and type, or null if the id + * does not match any resource. + */ + String[] resolveResourceValue(int id); + + /** + * Resolves the id of a resource Id of type int[] + * <p/>The resource id is the value of a R.styleable.<name>, and this method will + * return the name of the resource. + * @param id the Id to resolve. + * @return the name of the resource or <code>null</code> if not found. + */ + String resolveResourceValue(int[] id); + + /** + * Returns the id of a resource. + * <p/>The provided type and name must match an existing constant defined as + * <code>R.<type>.<name></code>. + * @param type the type of the resource + * @param name the name of the resource + * @return an Integer containing the resource Id, or <code>null</code> if not found. + */ + Integer getResourceValue(String type, String name); + +} diff --git a/layoutlib_api/src/com/android/layoutlib/api/LayoutLog.java b/layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java index 052750e..a735f81 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/LayoutLog.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/LayoutLog.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; public class LayoutLog { @@ -35,4 +35,8 @@ public class LayoutLog { public void error(String tag, String message, Throwable throwable) { } + + public void fidelityWarning(String tag, String message, Throwable throwable) { + + } } diff --git a/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java index 309f9fd..59e790e 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/SceneParams.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Params.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; import java.util.Map; -public class SceneParams { +public class Params { public final static long DEFAULT_TIMEOUT = 250; //ms @@ -45,7 +45,7 @@ public class SceneParams { } } - private IXmlPullParser mLayoutDescription; + private ILayoutPullParser mLayoutDescription; private Object mProjectKey; private int mScreenWidth; private int mScreenHeight; @@ -68,7 +68,7 @@ public class SceneParams { /** * - * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the + * @param layoutDescription the {@link ILayoutPullParser} letting the LayoutLib Bridge visit the * layout file. * @param projectKey An Object identifying the project. This is used for the cache mechanism. * @param screenWidth the screen width @@ -81,17 +81,17 @@ public class SceneParams { * @param isProjectTheme true if the theme is a project theme, false if it is a framework theme. * @param projectResources the resources of the project. The map contains (String, map) pairs * where the string is the type of the resource reference used in the layout file, and the - * map contains (String, {@link IResourceValue}) pairs where the key is the resource name, + * map contains (String, {@link ResourceValue}) pairs where the key is the resource name, * and the value is the resource value. * @param frameworkResources the framework resources. The map contains (String, map) pairs * where the string is the type of the resource reference used in the layout file, and the map - * contains (String, {@link IResourceValue}) pairs where the key is the resource name, and the + * contains (String, {@link ResourceValue}) pairs where the key is the resource name, and the * value is the resource value. * @param projectCallback The {@link IProjectCallback} object to get information from * the project. * @param log the object responsible for displaying warning/errors to the user. */ - public SceneParams(IXmlPullParser layoutDescription, + public Params(ILayoutPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, RenderingMode renderingMode, int density, float xdpi, float ydpi, @@ -120,7 +120,7 @@ public class SceneParams { /** * Copy constructor. */ - public SceneParams(SceneParams params) { + public Params(Params params) { mLayoutDescription = params.mLayoutDescription; mProjectKey = params.mProjectKey; mScreenWidth = params.mScreenWidth; @@ -141,12 +141,12 @@ public class SceneParams { mImageFactory = params.mImageFactory; } - public void setCustomBackgroundColor(int color) { + public void setOverrideBgColor(int color) { mCustomBackgroundEnabled = true; mCustomBackgroundColor = color; } - public void setCustomTimeout(long timeout) { + public void setTimeout(long timeout) { mTimeout = timeout; } @@ -154,7 +154,7 @@ public class SceneParams { mImageFactory = imageFactory; } - public IXmlPullParser getLayoutDescription() { + public ILayoutPullParser getLayoutDescription() { return mLayoutDescription; } @@ -190,7 +190,7 @@ public class SceneParams { return mThemeName; } - public boolean getIsProjectTheme() { + public boolean isProjectTheme() { return mIsProjectTheme; } @@ -210,11 +210,11 @@ public class SceneParams { return mLog; } - public boolean isCustomBackgroundEnabled() { + public boolean isBgColorOverridden() { return mCustomBackgroundEnabled; } - public int getCustomBackgroundColor() { + public int getOverrideBgColor() { return mCustomBackgroundColor; } diff --git a/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java index 8bfa7ed..12a28de 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/LayoutScene.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/RenderSession.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; -import static com.android.layoutlib.api.SceneResult.SceneStatus.NOT_IMPLEMENTED; +import static com.android.ide.common.rendering.api.Result.Status.NOT_IMPLEMENTED; -import com.android.layoutlib.api.SceneResult.SceneStatus; +import com.android.ide.common.rendering.api.Result.Status; import java.awt.image.BufferedImage; import java.util.Map; @@ -26,45 +26,18 @@ import java.util.Map; /** * An object allowing interaction with an Android layout. * - * This is returned by {@link LayoutBridge#createScene(SceneParams)}. + * This is returned by {@link Bridge#createScene(Params)}. * and can then be used for subsequent actions on the layout. * * @since 5 * */ -public class LayoutScene { - - public interface IAnimationListener { - /** - * Called when a new animation frame is available for display. - * - * <p>The {@link LayoutScene} object is provided as a convenience. It should be queried - * for the image through {@link LayoutScene#getImage()}. - * - * <p>If no {@link IImageFactory} is used, then each new animation frame will be rendered - * in its own new {@link BufferedImage} object. However if an image factory is used, and it - * always re-use the same object, then the image is only guaranteed to be valid during - * this method call. As soon as this method return the image content will be overridden - * with new drawing. - * - */ - void onNewFrame(LayoutScene scene); - - /** - * Called when the animation is done playing. - */ - void done(SceneResult result); - - /** - * Return true to cancel the animation. - */ - boolean isCanceled(); - } +public class RenderSession { /** * Returns the last operation result. */ - public SceneResult getResult() { + public Result getResult() { return NOT_IMPLEMENTED.createResult(); } @@ -73,8 +46,8 @@ public class LayoutScene { * <p> * * This is reset to a new instance every time {@link #render()} is called and can be - * <code>null</code> if the call failed (and the method returned a {@link SceneResult} with - * {@link SceneStatus#ERROR_UNKNOWN} or {@link SceneStatus#NOT_IMPLEMENTED}. + * <code>null</code> if the call failed (and the method returned a {@link Result} with + * {@link Status#ERROR_UNKNOWN} or {@link Status#NOT_IMPLEMENTED}. * <p/> * This can be safely modified by the caller. */ @@ -86,8 +59,8 @@ public class LayoutScene { * Returns the rendering of the full layout. * <p> * This is reset to a new instance every time {@link #render()} is called and can be - * <code>null</code> if the call failed (and the method returned a {@link SceneResult} with - * {@link SceneStatus#ERROR_UNKNOWN} or {@link SceneStatus#NOT_IMPLEMENTED}. + * <code>null</code> if the call failed (and the method returned a {@link Result} with + * {@link Status#ERROR_UNKNOWN} or {@link Status#NOT_IMPLEMENTED}. * <p/> * This can be safely modified by the caller. */ @@ -102,7 +75,7 @@ public class LayoutScene { * @param viewObject the view object. * @return a map of the default property values or null. */ - public Map<String, String> getDefaultViewPropertyValues(Object viewObject) { + public Map<String, String> getDefaultProperties(Object viewObject) { return null; } @@ -113,10 +86,10 @@ public class LayoutScene { * * This is equivalent to calling <code>render(SceneParams.DEFAULT_TIMEOUT)</code> * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult render() { - return render(SceneParams.DEFAULT_TIMEOUT); + public Result render() { + return render(Params.DEFAULT_TIMEOUT); } /** @@ -124,16 +97,16 @@ public class LayoutScene { * In case of success, this should be followed by calls to {@link #getRootView()} and * {@link #getImage()} to access the result of the rendering. * - * The {@link LayoutBridge} is only able to inflate or render one layout at a time. There + * The {@link Bridge} is only able to inflate or render one layout at a time. There * is an internal lock object whenever such an action occurs. The timeout parameter is used * when attempting to acquire the lock. If the timeout expires, the method will return - * {@link SceneStatus#ERROR_TIMEOUT}. + * {@link Status#ERROR_TIMEOUT}. * * @param timeout timeout for the rendering, in milliseconds. * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult render(long timeout) { + public Result render(long timeout) { return NOT_IMPLEMENTED.createResult(); } @@ -149,9 +122,29 @@ public class LayoutScene { * @param propertyName * @param propertyValue * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. + * + * @throws IllegalArgumentException if the view object is not an android.view.View + */ + public Result setProperty(Object objectView, String propertyName, String propertyValue) { + return NOT_IMPLEMENTED.createResult(); + } + + /** + * returns the value of a given property on a given object. + * <p/> + * This returns a {@link Result} object. If the operation of querying the object for its + * property was successful (check {@link Result#isSuccess()}), then the property value + * is set in the result and can be accessed through {@link Result#getData()}. + * + * @param objectView + * @param propertyName + * + * @return a {@link Result} indicating the status of the action. + * + * @throws IllegalArgumentException if the view object is not an android.view.View */ - public SceneResult setProperty(Object objectView, String propertyName, String propertyValue) { + public Result getProperty(Object objectView, String propertyName) { return NOT_IMPLEMENTED.createResult(); } @@ -168,19 +161,19 @@ public class LayoutScene { * The child stays in the view hierarchy after the rendering is done. To remove it call * {@link #removeChild(Object, IAnimationListener)} * <p/> - * The returned {@link SceneResult} object will contain the android.view.View object for - * the newly inflated child. It is accessible through {@link SceneResult#getData()}. + * The returned {@link Result} object will contain the android.view.View object for + * the newly inflated child. It is accessible through {@link Result#getData()}. * * @param parentView the parent View object to receive the new child. - * @param childXml an {@link IXmlPullParser} containing the content of the new child, including - * ViewGroup.LayoutParams attributes. + * @param childXml an {@link ILayoutPullParser} containing the content of the new child, + * including ViewGroup.LayoutParams attributes. * @param index the index at which position to add the new child into the parent. -1 means at * the end. * @param listener an optional {@link IAnimationListener}. * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult insertChild(Object parentView, IXmlPullParser childXml, int index, + public Result insertChild(Object parentView, ILayoutPullParser childXml, int index, IAnimationListener listener) { return NOT_IMPLEMENTED.createResult(); } @@ -201,7 +194,7 @@ public class LayoutScene { * The child stays in the view hierarchy after the rendering is done. To remove it call * {@link #removeChild(Object, IAnimationListener)} * <p/> - * The returned {@link SceneResult} object will contain the android.view.ViewGroup.LayoutParams + * The returned {@link Result} object will contain the android.view.ViewGroup.LayoutParams * object created from the <var>layoutParams</var> map if it was non <code>null</code>. * * @param parentView the parent View object to receive the child. Can be the current parent @@ -214,9 +207,9 @@ public class LayoutScene { * be inflated and set with the content of the map. * @param listener an optional {@link IAnimationListener}. * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult moveChild(Object parentView, Object childView, int index, + public Result moveChild(Object parentView, Object childView, int index, Map<String, String> layoutParams, IAnimationListener listener) { return NOT_IMPLEMENTED.createResult(); } @@ -232,9 +225,9 @@ public class LayoutScene { * @param childView the view object to remove from its parent * @param listener an optional {@link IAnimationListener}. * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult removeChild(Object childView, IAnimationListener listener) { + public Result removeChild(Object childView, IAnimationListener listener) { return NOT_IMPLEMENTED.createResult(); } @@ -248,9 +241,9 @@ public class LayoutScene { * @param animationName the name of the animation (res/anim) to play. * @param listener the listener callback. * - * @return a {@link SceneResult} indicating the status of the action. + * @return a {@link Result} indicating the status of the action. */ - public SceneResult animate(Object targetObject, String animationName, + public Result animate(Object targetObject, String animationName, boolean isFrameworkAnimation, IAnimationListener listener) { return NOT_IMPLEMENTED.createResult(); } diff --git a/layoutlib_api/src/com/android/layoutlib/api/ResourceDensity.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java index cebb8df..ca92eae 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ResourceDensity.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceDensity.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; /** * Enum representing the density class of Android resources. diff --git a/layoutlib_api/src/com/android/layoutlib/api/ResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java index 41f440d..f59f3c3 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ResourceValue.java @@ -14,7 +14,9 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; + +import com.android.layoutlib.api.IResourceValue; /** * Represents an android resource with a name and a string value. diff --git a/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java b/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java index 2954671..172a7e7 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/SceneResult.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/Result.java @@ -14,20 +14,20 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; /** * Scene result class. This is an immutable class. * <p/> * This cannot be allocated directly, instead use - * {@link SceneStatus#createResult()}, - * {@link SceneStatus#createResult(String, Throwable)}, - * {@link SceneStatus#createResult(String)} - * {@link SceneStatus#createResult(Object)} + * {@link Status#createResult()}, + * {@link Status#createResult(String, Throwable)}, + * {@link Status#createResult(String)} + * {@link Status#createResult(Object)} */ -public class SceneResult { +public class Result { - private final SceneStatus mStatus; + private final Status mStatus; private final String mErrorMessage; private final Throwable mThrowable; private Object mData; @@ -36,7 +36,7 @@ public class SceneResult { * Scene Status enum. * <p/>This indicates the status of all scene actions. */ - public enum SceneStatus { + public enum Status { SUCCESS, NOT_IMPLEMENTED, ERROR_TIMEOUT, @@ -48,31 +48,31 @@ public class SceneResult { ERROR_ANIM_NOT_FOUND, ERROR_UNKNOWN; - private SceneResult mResult; + private Result mResult; /** - * Returns a {@link SceneResult} object with this status. + * Returns a {@link Result} object with this status. * @return an instance of SceneResult; */ - public SceneResult createResult() { + public Result createResult() { // don't want to get generic error that way. assert this != ERROR_UNKNOWN; if (mResult == null) { - mResult = new SceneResult(this); + mResult = new Result(this); } return mResult; } /** - * Returns a {@link SceneResult} object with this status, and the given data. + * Returns a {@link Result} object with this status, and the given data. * @return an instance of SceneResult; * - * @see SceneResult#getData() + * @see Result#getData() */ - public SceneResult createResult(Object data) { - SceneResult res = createResult(); + public Result createResult(Object data) { + Result res = createResult(); if (data != null) { res = res.getCopyWithData(data); @@ -87,8 +87,8 @@ public class SceneResult { * @param throwable the throwable * @return an instance of SceneResult. */ - public SceneResult createResult(String errorMessage, Throwable throwable) { - return new SceneResult(this, errorMessage, throwable); + public Result createResult(String errorMessage, Throwable throwable) { + return new Result(this, errorMessage, throwable); } /** @@ -96,36 +96,36 @@ public class SceneResult { * @param errorMessage the error message * @return an instance of SceneResult. */ - public SceneResult createResult(String errorMessage) { - return new SceneResult(this, errorMessage, null /*throwable*/); + public Result createResult(String errorMessage) { + return new Result(this, errorMessage, null /*throwable*/); } } /** - * Creates a {@link SceneResult} object with the given SceneStatus. + * Creates a {@link Result} object with the given SceneStatus. * * @param status the status. Must not be null. */ - private SceneResult(SceneStatus status) { + private Result(Status status) { this(status, null, null); } /** - * Creates a {@link SceneResult} object with the given SceneStatus, and the given message + * Creates a {@link Result} object with the given SceneStatus, and the given message * and {@link Throwable} * * @param status the status. Must not be null. * @param errorMessage an optional error message. * @param t an optional exception. */ - private SceneResult(SceneStatus status, String errorMessage, Throwable t) { + private Result(Status status, String errorMessage, Throwable t) { assert status != null; mStatus = status; mErrorMessage = errorMessage; mThrowable = t; } - private SceneResult(SceneResult result) { + private Result(Result result) { mStatus = result.mStatus; mErrorMessage = result.mErrorMessage; mThrowable = result.mThrowable; @@ -137,8 +137,8 @@ public class SceneResult { * * @return returns a new SceneResult instance. */ - public SceneResult getCopyWithData(Object data) { - SceneResult r = new SceneResult(this); + public Result getCopyWithData(Object data) { + Result r = new Result(this); r.mData = data; return r; } @@ -151,19 +151,19 @@ public class SceneResult { * @return <code>true</code> if the status is successful. */ public boolean isSuccess() { - return mStatus == SceneStatus.SUCCESS; + return mStatus == Status.SUCCESS; } /** * Returns the status. This is never null. */ - public SceneStatus getStatus() { + public Status getStatus() { return mStatus; } /** * Returns the error message. This is only non-null when {@link #getStatus()} returns - * {@link SceneStatus#ERROR_UNKNOWN} + * {@link Status#ERROR_UNKNOWN} */ public String getErrorMessage() { return mErrorMessage; @@ -171,7 +171,7 @@ public class SceneResult { /** * Returns the exception. This is only non-null when {@link #getStatus()} returns - * {@link SceneStatus#ERROR_UNKNOWN} + * {@link Status#ERROR_UNKNOWN} */ public Throwable getException() { return mThrowable; diff --git a/layoutlib_api/src/com/android/layoutlib/api/StyleResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java index 8052b4e..a9f499f 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/StyleResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/StyleResourceValue.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; + +import com.android.layoutlib.api.IResourceValue; +import com.android.layoutlib.api.IStyleResourceValue; import java.util.HashMap; diff --git a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java b/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java index 4a6c93d..2c0c829 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ViewInfo.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/ViewInfo.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.layoutlib.api; +package com.android.ide.common.rendering.api; import java.util.Collections; import java.util.List; @@ -22,7 +22,7 @@ import java.util.List; /** * Layout information for a specific view object */ -public final class ViewInfo { +public class ViewInfo { private final Object mCookie; private final String mName; @@ -72,7 +72,7 @@ public final class ViewInfo { /** * Returns the cookie associated with the XML node. Can be null. * - * @see IXmlPullParser#getViewKey() + * @see ILayoutPullParser#getViewKey() */ public Object getCookie() { return mCookie; diff --git a/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java b/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java index bc319c2..4e55d54 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java +++ b/layoutlib_api/src/com/android/layoutlib/api/IDensityBasedResourceValue.java @@ -16,6 +16,9 @@ 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. * @deprecated use {@link DensityBasedResourceValue}. diff --git a/layoutlib_api/src/com/android/layoutlib/api/ILayoutBridge.java b/layoutlib_api/src/com/android/layoutlib/api/ILayoutBridge.java index f5d3660..56d2e36 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ILayoutBridge.java +++ b/layoutlib_api/src/com/android/layoutlib/api/ILayoutBridge.java @@ -16,6 +16,8 @@ package com.android.layoutlib.api; +import com.android.ide.common.rendering.api.Bridge; + import java.util.Map; /** @@ -26,7 +28,7 @@ import java.util.Map; * <p/> * Changes in API level 5: * <ul> - * <li>Bridge should extend {@link LayoutBridge} instead of implementing {@link ILayoutBridge}.</li> + * <li>Bridge should extend {@link Bridge} instead of implementing {@link ILayoutBridge}.</li> * </ul> * Changes in API level 4: * <ul> @@ -44,7 +46,7 @@ import java.util.Map; * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> - * @deprecated Extend {@link LayoutBridge} instead. + * @deprecated Extend {@link Bridge} instead. */ @Deprecated public interface ILayoutBridge { @@ -102,7 +104,7 @@ public interface ILayoutBridge { * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link LayoutBridge#createScene(SceneParams)} + * @deprecated use {@link Bridge#createScene(SceneParams)} * @since 4 */ @Deprecated @@ -139,7 +141,7 @@ public interface ILayoutBridge { * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link LayoutBridge#createScene(SceneParams)} + * @deprecated use {@link Bridge#createScene(SceneParams)} * @since 3 */ @Deprecated @@ -172,7 +174,7 @@ public interface ILayoutBridge { * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link LayoutBridge#createScene(SceneParams)} + * @deprecated use {@link Bridge#createScene(SceneParams)} * @since 2 */ @Deprecated @@ -204,7 +206,7 @@ public interface ILayoutBridge { * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return a new {@link ILayoutResult} object that contains the result of the layout. - * @deprecated use {@link LayoutBridge#createScene(SceneParams)} + * @deprecated use {@link Bridge#createScene(SceneParams)} * @since 1 */ @Deprecated diff --git a/layoutlib_api/src/com/android/layoutlib/api/ILayoutLog.java b/layoutlib_api/src/com/android/layoutlib/api/ILayoutLog.java index 9931f3e..38a22b8 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ILayoutLog.java +++ b/layoutlib_api/src/com/android/layoutlib/api/ILayoutLog.java @@ -16,6 +16,8 @@ package com.android.layoutlib.api; +import com.android.ide.common.rendering.api.LayoutLog; + /** * Callback interface to display warnings/errors that happened during the computation and * rendering of the layout. diff --git a/layoutlib_api/src/com/android/layoutlib/api/ILayoutResult.java b/layoutlib_api/src/com/android/layoutlib/api/ILayoutResult.java index a4d6da0..46255c4 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/ILayoutResult.java +++ b/layoutlib_api/src/com/android/layoutlib/api/ILayoutResult.java @@ -16,13 +16,16 @@ package com.android.layoutlib.api; +import com.android.ide.common.rendering.api.Bridge; +import com.android.ide.common.rendering.api.RenderSession; + import java.awt.image.BufferedImage; /** * The result of a layout computation through {@link ILayoutBridge}. * * @since 1 - * @deprecated use {@link LayoutScene} as returned by {@link LayoutBridge#createScene(SceneParams)} + * @deprecated use {@link RenderSession} as returned by {@link Bridge#createScene(SceneParams)} */ public interface ILayoutResult { /** diff --git a/layoutlib_api/src/com/android/layoutlib/api/IProjectCallback.java b/layoutlib_api/src/com/android/layoutlib/api/IProjectCallback.java index fbdd918..65e2a87 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IProjectCallback.java +++ b/layoutlib_api/src/com/android/layoutlib/api/IProjectCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * 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. @@ -17,11 +17,11 @@ package com.android.layoutlib.api; /** - * Callback for project information needed by the Layout Library. - * Classes implementing this interface provide methods giving access to some project data, like - * resource resolution, namespace information, and instantiation of custom view. + * + * @deprecated + * */ -public interface IProjectCallback { +public interface IProjectCallback { /** * Loads a custom view with the given constructor signature and arguments. @@ -70,5 +70,4 @@ public interface IProjectCallback { * @return an Integer containing the resource Id, or <code>null</code> if not found. */ Integer getResourceValue(String type, String name); - } diff --git a/layoutlib_api/src/com/android/layoutlib/api/IResourceValue.java b/layoutlib_api/src/com/android/layoutlib/api/IResourceValue.java index 8a3e754..9a00801 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IResourceValue.java +++ b/layoutlib_api/src/com/android/layoutlib/api/IResourceValue.java @@ -16,6 +16,8 @@ package com.android.layoutlib.api; +import com.android.ide.common.rendering.api.ResourceValue; + /** * Represents an android resource with a name and a string value. * @deprecated use {@link ResourceValue}. diff --git a/layoutlib_api/src/com/android/layoutlib/api/IStyleResourceValue.java b/layoutlib_api/src/com/android/layoutlib/api/IStyleResourceValue.java index 33133c9..21036ca 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IStyleResourceValue.java +++ b/layoutlib_api/src/com/android/layoutlib/api/IStyleResourceValue.java @@ -16,6 +16,8 @@ package com.android.layoutlib.api; +import com.android.ide.common.rendering.api.StyleResourceValue; + /** * Represents an android style resources with a name and a list of children {@link IResourceValue}. * @deprecated Use {@link StyleResourceValue}. diff --git a/layoutlib_api/src/com/android/layoutlib/api/IXmlPullParser.java b/layoutlib_api/src/com/android/layoutlib/api/IXmlPullParser.java index c3c738f..b4d10a2 100644 --- a/layoutlib_api/src/com/android/layoutlib/api/IXmlPullParser.java +++ b/layoutlib_api/src/com/android/layoutlib/api/IXmlPullParser.java @@ -19,8 +19,7 @@ package com.android.layoutlib.api; import org.xmlpull.v1.XmlPullParser; /** - * Extended version of {@link XmlPullParser} to use with - * {@link LayoutBridge#createScene(SceneParams)} + * @deprecated */ public interface IXmlPullParser extends XmlPullParser { @@ -30,14 +29,4 @@ public interface IXmlPullParser extends XmlPullParser { * of a particular XML node with its result from the layout computation. */ Object getViewKey(); - - /** - * Returns a custom parser for the layout of the given name. - * @param layoutName the name of the layout. - * @return returns a custom parser or null if no custom parsers are needed. - * - * @since 5 - */ - IXmlPullParser getParser(String layoutName); } - |