Loading tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java +53 −9 Original line number Diff line number Diff line Loading @@ -24,21 +24,26 @@ import java.util.Map; * <p/> * <p/>{@link #getApiLevel()} gives the ability to know which methods are available. * <p/> * Changes in API level 4: * <ul> * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, boolean, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> * Changes in API level 3: * <ul> * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> * Changes in API level 2: * <ul> * <li>{@link #getApiLevel()}</li> * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>new API Level method: {@link #getApiLevel()}</li> * <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> */ public interface ILayoutBridge { final int API_CURRENT = 3; final int API_CURRENT = 4; /** * Returns the API level of the layout library. Loading @@ -58,6 +63,44 @@ public interface ILayoutBridge { */ boolean init(String fontOsLocation, Map<String, Map<String, Integer>> enumValueMap); /** * Computes and renders a layout * @param layoutDescription the {@link IXmlPullParser} 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 * @param screenHeight the screen height * @param renderFullHeight if true, the rendering will render the full height needed by the * layout. If the layout needs less than <var>screenHeight</var> then the rendering will * use <var>screenHeight</var> as the 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 themeName The name of the theme to use. * @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, * 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 * value is the resource value. * @param projectCallback The {@link IProjectCallback} object to get information from * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return an {@link ILayoutResult} object that contains the result of the layout. * @since 4 */ ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, boolean renderFullHeight, int density, float xdpi, float ydpi, String themeName, boolean isProjectTheme, Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback projectCallback, ILayoutLog logger); /** * Computes and renders a layout * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the Loading @@ -84,6 +127,7 @@ public interface ILayoutBridge { * @return an {@link ILayoutResult} object that contains the result of the layout. * @since 3 */ @Deprecated ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, int density, float xdpi, float ydpi, Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +41 −5 Original line number Diff line number Diff line Loading @@ -312,6 +312,7 @@ public final class Bridge implements ILayoutBridge { } /* * For compatilibty purposes, we implement the old deprecated version of computeLayout. * (non-Javadoc) * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) */ Loading @@ -321,6 +322,23 @@ public final class Bridge implements ILayoutBridge { Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback customViewLoader, ILayoutLog logger) { return computeLayout(layoutDescription, projectKey, screenWidth, screenHeight, false /* renderFullHeight */, density, xdpi, ydpi, themeName, isProjectTheme, projectResources, frameworkResources, customViewLoader, logger); } /* * (non-Javadoc) * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, boolean, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) */ public ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, boolean renderFullHeight, int density, float xdpi, float ydpi, String themeName, boolean isProjectTheme, Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback customViewLoader, ILayoutLog logger) { if (logger == null) { logger = sDefaultLogger; } Loading Loading @@ -393,15 +411,33 @@ public final class Bridge implements ILayoutBridge { root.setBackgroundDrawable(d); } // measure the views int w_spec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY); int h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.EXACTLY); int h_spec; // measure the views if (renderFullHeight) { // measure the full height needed by the layout. h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.UNSPECIFIED); // this lets us know the actual needed size view.measure(w_spec, h_spec); int neededHeight = root.getChildAt(0).getMeasuredHeight(); if (neededHeight > screenHeight - screenOffset) { screenHeight = neededHeight + screenOffset; } } // remeasure with only the size we need // This must always be done before the call to layout h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.EXACTLY); view.measure(w_spec, h_spec); // now do the layout. view.layout(0, screenOffset, screenWidth, screenHeight); // draw them // draw the views Canvas canvas = new Canvas(screenWidth, screenHeight - screenOffset, logger); root.draw(canvas); Loading Loading
tools/layoutlib/api/src/com/android/layoutlib/api/ILayoutBridge.java +53 −9 Original line number Diff line number Diff line Loading @@ -24,21 +24,26 @@ import java.util.Map; * <p/> * <p/>{@link #getApiLevel()} gives the ability to know which methods are available. * <p/> * Changes in API level 4: * <ul> * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, boolean, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> * Changes in API level 3: * <ul> * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>new render method: {@link #computeLayout(IXmlPullParser, Object, int, int, int, float, float, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * </ul> * Changes in API level 2: * <ul> * <li>{@link #getApiLevel()}</li> * <li>{@link #computeLayout(IXmlPullParser, Object, int, int, String, boolean, Map, Map, IProjectCallback, ILayoutLog)}</li> * <li>new API Level method: {@link #getApiLevel()}</li> * <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> */ public interface ILayoutBridge { final int API_CURRENT = 3; final int API_CURRENT = 4; /** * Returns the API level of the layout library. Loading @@ -58,6 +63,44 @@ public interface ILayoutBridge { */ boolean init(String fontOsLocation, Map<String, Map<String, Integer>> enumValueMap); /** * Computes and renders a layout * @param layoutDescription the {@link IXmlPullParser} 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 * @param screenHeight the screen height * @param renderFullHeight if true, the rendering will render the full height needed by the * layout. If the layout needs less than <var>screenHeight</var> then the rendering will * use <var>screenHeight</var> as the 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 themeName The name of the theme to use. * @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, * 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 * value is the resource value. * @param projectCallback The {@link IProjectCallback} object to get information from * the project. * @param logger the object responsible for displaying warning/errors to the user. * @return an {@link ILayoutResult} object that contains the result of the layout. * @since 4 */ ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, boolean renderFullHeight, int density, float xdpi, float ydpi, String themeName, boolean isProjectTheme, Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback projectCallback, ILayoutLog logger); /** * Computes and renders a layout * @param layoutDescription the {@link IXmlPullParser} letting the LayoutLib Bridge visit the Loading @@ -84,6 +127,7 @@ public interface ILayoutBridge { * @return an {@link ILayoutResult} object that contains the result of the layout. * @since 3 */ @Deprecated ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, int density, float xdpi, float ydpi, Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +41 −5 Original line number Diff line number Diff line Loading @@ -312,6 +312,7 @@ public final class Bridge implements ILayoutBridge { } /* * For compatilibty purposes, we implement the old deprecated version of computeLayout. * (non-Javadoc) * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) */ Loading @@ -321,6 +322,23 @@ public final class Bridge implements ILayoutBridge { Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback customViewLoader, ILayoutLog logger) { return computeLayout(layoutDescription, projectKey, screenWidth, screenHeight, false /* renderFullHeight */, density, xdpi, ydpi, themeName, isProjectTheme, projectResources, frameworkResources, customViewLoader, logger); } /* * (non-Javadoc) * @see com.android.layoutlib.api.ILayoutBridge#computeLayout(com.android.layoutlib.api.IXmlPullParser, java.lang.Object, int, int, boolean, int, float, float, java.lang.String, boolean, java.util.Map, java.util.Map, com.android.layoutlib.api.IProjectCallback, com.android.layoutlib.api.ILayoutLog) */ public ILayoutResult computeLayout(IXmlPullParser layoutDescription, Object projectKey, int screenWidth, int screenHeight, boolean renderFullHeight, int density, float xdpi, float ydpi, String themeName, boolean isProjectTheme, Map<String, Map<String, IResourceValue>> projectResources, Map<String, Map<String, IResourceValue>> frameworkResources, IProjectCallback customViewLoader, ILayoutLog logger) { if (logger == null) { logger = sDefaultLogger; } Loading Loading @@ -393,15 +411,33 @@ public final class Bridge implements ILayoutBridge { root.setBackgroundDrawable(d); } // measure the views int w_spec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY); int h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.EXACTLY); int h_spec; // measure the views if (renderFullHeight) { // measure the full height needed by the layout. h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.UNSPECIFIED); // this lets us know the actual needed size view.measure(w_spec, h_spec); int neededHeight = root.getChildAt(0).getMeasuredHeight(); if (neededHeight > screenHeight - screenOffset) { screenHeight = neededHeight + screenOffset; } } // remeasure with only the size we need // This must always be done before the call to layout h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset, MeasureSpec.EXACTLY); view.measure(w_spec, h_spec); // now do the layout. view.layout(0, screenOffset, screenWidth, screenHeight); // draw them // draw the views Canvas canvas = new Canvas(screenWidth, screenHeight - screenOffset, logger); root.draw(canvas); Loading