summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Xavier Ducrohet <xav@android.com> 2009-08-18 08:44:59 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2009-08-18 08:44:59 -0700
commit1a8c1599de630ae4199b71cb3eca75d7db9c40d6 (patch)
tree5508bab41808c7f7ef40df92d34feb7e3dbd79eb
parent0deb41abc68ff05b6c2e06175982f9d22a5abd92 (diff)
parentc1c432f57b782ed9d8d65be7ea1bee1e1d7d7839 (diff)
am c1c432f5: Merge change 21241 into donut
Merge commit 'c1c432f57b782ed9d8d65be7ea1bee1e1d7d7839' into eclair * commit 'c1c432f57b782ed9d8d65be7ea1bee1e1d7d7839': Layoutlib now uses the dimen status_bar_height instead of hard-coded value
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java42
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java5
2 files changed, 36 insertions, 11 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index e941b7f8765a..c5981267c5dc 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -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;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
index b426247e7a49..b5b7ceb75e54 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeConstants.java
@@ -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";