Merge change 22135 into eclair
* changes: Support full length rendering.
This commit is contained in:
@@ -24,40 +24,83 @@ 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> deprecated {@link #computeLayout(IXmlPullParser, Object, int, int, 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.
|
||||
* While no methods will ever be removed, some may become deprecated, and some new ones
|
||||
* will appear.
|
||||
* <p/>If calling this method throws an {@link AbstractMethodError}, then the API level
|
||||
* should be considered to be 1.
|
||||
* should be considered to be 1.
|
||||
*/
|
||||
int getApiLevel();
|
||||
|
||||
/**
|
||||
* Initializes the Bridge object.
|
||||
* @param fontOsLocation the location of the fonts.
|
||||
* @param enumValueMap map attrName => { map enumFlagName => Integer value }.
|
||||
* @param enumValueMap map attrName => { map enumFlagName => Integer value }.
|
||||
* @return true if success.
|
||||
* @since 1
|
||||
*/
|
||||
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
|
||||
@@ -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,
|
||||
@@ -155,7 +199,7 @@ public interface ILayoutBridge {
|
||||
Map<String, Map<String, IResourceValue>> projectResources,
|
||||
Map<String, Map<String, IResourceValue>> frameworkResources,
|
||||
IProjectCallback projectCallback, ILayoutLog logger);
|
||||
|
||||
|
||||
/**
|
||||
* Clears the resource cache for a specific project.
|
||||
* <p/>This cache contains bitmaps and nine patches that are loaded from the disk and reused
|
||||
|
||||
@@ -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)
|
||||
*/
|
||||
@@ -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;
|
||||
}
|
||||
@@ -393,15 +411,33 @@ public final class Bridge implements ILayoutBridge {
|
||||
root.setBackgroundDrawable(d);
|
||||
}
|
||||
|
||||
int w_spec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY);
|
||||
int h_spec = MeasureSpec.makeMeasureSpec(screenHeight - screenOffset,
|
||||
MeasureSpec.EXACTLY);
|
||||
|
||||
// measure the views
|
||||
int w_spec = MeasureSpec.makeMeasureSpec(screenWidth, MeasureSpec.EXACTLY);
|
||||
int h_spec;
|
||||
|
||||
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);
|
||||
@@ -1017,7 +1053,7 @@ public final class Bridge implements ILayoutBridge {
|
||||
public void setWallpaperPosition(IBinder window, float x, float y) {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
|
||||
public IBinder asBinder() {
|
||||
// pass for now.
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user