Merge change 21241 into donut

* changes:
  Layoutlib now uses the dimen status_bar_height instead of hard-coded value
This commit is contained in:
Android (Google) Code Review
2009-08-14 10:57:25 -07:00
2 changed files with 36 additions and 11 deletions

View File

@@ -358,7 +358,7 @@ public final class Bridge implements ILayoutBridge {
windowBackground = context.findItemInStyle(currentTheme, "windowBackground");
windowBackground = context.resolveResValue(windowBackground);
screenOffset = getScreenOffset(currentTheme, context);
screenOffset = getScreenOffset(frameworkResources, currentTheme, context);
}
// we need to make sure the Looper has been initialized for this thread.
@@ -673,9 +673,13 @@ public final class Bridge implements ILayoutBridge {
/**
* Returns the top screen offset. This depends on whether the current theme defines the user
* of the title and status bars.
* @param frameworkResources The framework resources
* @param currentTheme The current theme
* @param context The context
* @return the pixel height offset
*/
private int getScreenOffset(IStyleResourceValue currentTheme, BridgeContext context) {
private int getScreenOffset(Map<String, Map<String, IResourceValue>> frameworkResources,
IStyleResourceValue currentTheme, BridgeContext context) {
int offset = 0;
// get the title bar flag from the current theme.
@@ -687,22 +691,25 @@ public final class Bridge implements ILayoutBridge {
// if there's a value and it's true (default is false)
if (value == null || value.getValue() == null ||
XmlUtils.convertValueToBoolean(value.getValue(), false /* defValue */) == false) {
// default size of the window title bar
int defaultOffset = DEFAULT_TITLE_BAR_HEIGHT;
// get value from the theme.
value = context.findItemInStyle(currentTheme, "windowTitleSize");
// resolve it
value = context.resolveResValue(value);
// default value
offset = DEFAULT_TITLE_BAR_HEIGHT;
// get the real value;
if (value != null) {
// get the numerical value, if available
TypedValue typedValue = ResourceHelper.getValue(value.getValue());
if (typedValue != null) {
offset = (int)typedValue.getDimension(context.getResources().mMetrics);
// compute the pixel value based on the display metrics
defaultOffset = (int)typedValue.getDimension(context.getResources().mMetrics);
}
}
offset += defaultOffset;
}
// get the fullscreen flag from the current theme.
@@ -713,8 +720,25 @@ public final class Bridge implements ILayoutBridge {
if (value == null || value.getValue() == null ||
XmlUtils.convertValueToBoolean(value.getValue(), false /* defValue */) == false) {
// FIXME: Right now this is hard-coded in the platform, but once there's a constant, we'll need to use it.
offset += DEFAULT_STATUS_BAR_HEIGHT;
// default value
int defaultOffset = DEFAULT_STATUS_BAR_HEIGHT;
// get the real value, first the list of Dimensions from the framework map
Map<String, IResourceValue> dimens = frameworkResources.get(BridgeConstants.RES_DIMEN);
// now get the value
value = dimens.get("status_bar_height");
if (value != null) {
TypedValue typedValue = ResourceHelper.getValue(value.getValue());
if (typedValue != null) {
// compute the pixel value based on the display metrics
defaultOffset = (int)typedValue.getDimension(context.getResources().mMetrics);
}
}
// add the computed offset.
offset += defaultOffset;
}
return offset;

View File

@@ -45,11 +45,12 @@ public class BridgeConstants {
public final static String PREFIX_RESOURCE_REF = "@";
public final static String PREFIX_ANDROID_THEME_REF = "?android:";
public final static String PREFIX_THEME_REF = "?";
public final static String PREFIX_ANDROID = "android:";
public final static String RES_STYLE = "style";
public final static String RES_ATTR = "attr";
public final static String RES_DIMEN = "dimen";
public final static String RES_DRAWABLE = "drawable";
public final static String RES_COLOR = "color";
public final static String RES_LAYOUT = "layout";