Index: build/android/gyp/generate_v14_compatible_resources.py |
diff --git a/build/android/gyp/generate_v14_compatible_resources.py b/build/android/gyp/generate_v14_compatible_resources.py |
index 2f1d81212eac7130bd32f56561b8dc9764ed337e..ccc69da246aa892f4b37c59a86b40bd2ae01311b 100755 |
--- a/build/android/gyp/generate_v14_compatible_resources.py |
+++ b/build/android/gyp/generate_v14_compatible_resources.py |
@@ -54,6 +54,15 @@ ATTRIBUTES_TO_MAP = dict(['android:' + k, 'android:' + v] for k, v |
ATTRIBUTES_TO_MAP_REVERSED = dict([v, k] for k, v |
in ATTRIBUTES_TO_MAP.iteritems()) |
+# Attributes that are allowed to use if both are used in the same element. |
+ALLOWED_ATTRIBUTE_PAIRS = {'layout_marginStart' : 'layout_marginLeft', |
+ 'layout_marginEnd' : 'layout_marginRight'} |
+ |
+ALLOWED_ATTRIBUTE_PAIRS = dict(['android:' + k, 'android:' + v] for k, v |
+ in ALLOWED_ATTRIBUTE_PAIRS.iteritems()) |
+ |
+ALLOWED_ATTRIBUTE_PAIRS.update(dict([v, k] for k, v |
+ in ALLOWED_ATTRIBUTE_PAIRS.iteritems())) |
def IterateXmlElements(node): |
"""minidom helper function that iterates all the element nodes. |
@@ -124,7 +133,19 @@ def GenerateV14LayoutResourceDom(dom, filename, assert_not_deprecated=True): |
# Iterate all the elements' attributes to find attributes to convert. |
for element in IterateXmlElements(dom): |
+ attribute_names = [name for name, value in element.attributes.items()] |
for name, value in list(element.attributes.items()): |
+ # Some Left&Right attributes safe to use. So we allow those attributes, |
+ # while still forcing they are used in a pair as Android recommended. |
+ # http://android-developers.blogspot.com/2013/03/ |
+ # native-rtl-support-in-android-42.html |
+ # |
+ # e.g. |
+ # android:layout_marginStart="10dp" |
+ # android:layout_marginLeft="10dp" |
+ if (ALLOWED_ATTRIBUTE_PAIRS.get(name) in attribute_names): |
+ continue |
+ |
# Convert any API 17 Start/End attributes to Left/Right attributes. |
# For example, from paddingStart="10dp" to paddingLeft="10dp" |
# Note: gravity attributes are not necessary to convert because |