Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Unified Diff: build/android/gyp/generate_v14_compatible_resources.py

Issue 445753002: [Android] Temporarily suppress RTL start&end check error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698