summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-03-07 20:50:21 -0800
committerXavier Ducrohet <xav@android.com>2011-03-14 15:28:50 -0700
commit2652b618a86c28fe1914c52dd6a91139c3d9b1e7 (patch)
tree3de7d6475a0144999be2e0e8cfa0455f8e937112 /tools
parentf354ad108c794bd4c9d1aa9a4f2a526d9c27e224 (diff)
downloadframeworks_base-2652b618a86c28fe1914c52dd6a91139c3d9b1e7.zip
frameworks_base-2652b618a86c28fe1914c52dd6a91139c3d9b1e7.tar.gz
frameworks_base-2652b618a86c28fe1914c52dd6a91139c3d9b1e7.tar.bz2
Merge 6f2fb570 from honeycomb. do not merge.
LayoutLib: Fix dimension parsing to handle negative value. Also make TypedArray.getDimensionPixelSize properly handle negative values (which are not allowed). Change-Id: I03ffcef5ab7ec7ef95419566776dcc798845fd88
Diffstat (limited to 'tools')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java22
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java2
2 files changed, 10 insertions, 14 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
index c1d7600..77c1789 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java
@@ -412,9 +412,7 @@ public final class BridgeTypedArray extends TypedArray {
return LayoutParams.MATCH_PARENT;
} else if (s.equals(BridgeConstants.WRAP_CONTENT)) {
return LayoutParams.WRAP_CONTENT;
- }
-
- if (RenderResources.REFERENCE_NULL.equals(s)) {
+ } else if (RenderResources.REFERENCE_NULL.equals(s)) {
return defValue;
}
@@ -486,23 +484,21 @@ public final class BridgeTypedArray extends TypedArray {
return LayoutParams.MATCH_PARENT;
} else if (s.equals(BridgeConstants.WRAP_CONTENT)) {
return LayoutParams.WRAP_CONTENT;
- }
-
- if (RenderResources.REFERENCE_NULL.equals(s)) {
+ } else if (RenderResources.REFERENCE_NULL.equals(s)) {
return defValue;
}
- // FIXME huh?
-
float f = getDimension(index, defValue);
final int res = (int)(f+0.5f);
if (res != 0) return res;
if (f == 0) return 0;
- if (f > 0) return 1;
-
- Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT,
- "Can't convert to dimension: " + Integer.toString(index),
- null, null /*data*/);
+ if (f > 0) return 1; // this is to support ]0;1[ range (since >=1 is handled 2 lines above)
+ if (f < 0) {
+ // negative values are not allowed in pixel dimensions
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ "Negative pixel dimension: " + s,
+ null, null /*data*/);
+ }
return defValue;
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 69f46e6..649160e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -377,7 +377,7 @@ public final class ResourceHelper {
}
// check the first character
- if (buf[0] < '0' && buf[0] > '9' && buf[0] != '.') {
+ if (buf[0] < '0' && buf[0] > '9' && buf[0] != '.' && buf[0] != '-') {
return false;
}