From a9090705efcc44f015486944e5aeb926173a7968 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Tue, 4 Aug 2015 11:56:44 -0700 Subject: [PATCH 1/2] Fix layout mirroring. Change-Id: I7db398aa2d11dac1210e84922138f78f0c23bb9b --- .../bridge/src/com/android/layoutlib/bridge/impl/Layout.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java index c72c97930b26c..cbd041593d950 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/Layout.java @@ -131,6 +131,7 @@ class Layout extends RelativeLayout { HardwareConfig hwConfig = getParams().getHardwareConfig(); Density density = hwConfig.getDensity(); boolean isRtl = Bridge.isLocaleRtl(getParams().getLocale()); + setLayoutDirection(isRtl? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR); NavigationBar navBar = null; if (mBuilder.hasNavBar()) { From 0437cac76c24dc6cac7b530e6d80f789565550ec Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Tue, 4 Aug 2015 11:57:10 -0700 Subject: [PATCH 2/2] Make getInt in BridgeTypedArray accept empty String. The XML editor already warns about the empty strings in places where an int value is required. There's no need to show another warning for it in the rendering panel. Also, the rendering might have also failed when the empty string is encountered. Try an continue the rendering, because no rendering state is really bad. Change-Id: I85106f37e4462f237e85f0b065b4ce8a4bfabf4d --- .../bridge/src/android/content/res/BridgeTypedArray.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java index 2e515fbe74643..6a61090475736 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java @@ -239,15 +239,12 @@ public final class BridgeTypedArray extends TypedArray { public int getInt(int index, int defValue) { String s = getString(index); try { - if (s != null) { - return convertValueToInt(s, defValue); - } + return convertValueToInt(s, defValue); } catch (NumberFormatException e) { Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format("\"%1$s\" in attribute \"%2$s\" is not a valid integer", s, mNames[index]), null); - return defValue; } return defValue; } @@ -949,7 +946,7 @@ public final class BridgeTypedArray extends TypedArray { * "XXXXXXXX" > 80000000. */ private static int convertValueToInt(@Nullable String charSeq, int defValue) { - if (null == charSeq) + if (null == charSeq || charSeq.isEmpty()) return defValue; int sign = 1;