Merge "Handle string resources containing html tags for style" into rvc-dev am: 25c1fbdc90
Change-Id: I140fa52a6a37e47d53fa96446765b2fcd558917f
diff --git a/bridge/src/libcore/icu/ICU_Delegate.java b/bridge/src/libcore/icu/ICU_Delegate.java
index 880344f..708cf62 100644
--- a/bridge/src/libcore/icu/ICU_Delegate.java
+++ b/bridge/src/libcore/icu/ICU_Delegate.java
@@ -75,72 +75,6 @@
}
@LayoutlibDelegate
- /*package*/ static boolean initLocaleDataNative(String locale, LocaleData result) {
-
- // Used by Calendar.
- result.firstDayOfWeek = 1;
- result.minimalDaysInFirstWeek = 1;
-
- // Used by DateFormatSymbols.
- result.amPm = new String[] { "AM", "PM" };
- result.eras = new String[] { "BC", "AD" };
-
- result.longMonthNames = new String[] { "January", "February", "March", "April", "May",
- "June", "July", "August", "September", "October", "November", "December" };
- result.shortMonthNames = new String[] { "Jan", "Feb", "Mar", "Apr", "May",
- "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- result.longStandAloneMonthNames = result.longMonthNames;
- result.shortStandAloneMonthNames = result.shortMonthNames;
-
- // The platform code expects this to begin at index 1, rather than 0. It maps it directly to
- // the constants from java.util.Calendar.<weekday>
- result.longWeekdayNames = new String[] {
- "", "Sunday", "Monday" ,"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
- result.shortWeekdayNames = new String[] {
- "", "Sun", "Mon" ,"Tue", "Wed", "Thu", "Fri", "Sat" };
- result.tinyWeekdayNames = new String[] {
- "", "S", "M", "T", "W", "T", "F", "S" };
-
- result.longStandAloneWeekdayNames = result.longWeekdayNames;
- result.shortStandAloneWeekdayNames = result.shortWeekdayNames;
- result.tinyStandAloneWeekdayNames = result.tinyWeekdayNames;
-
- result.fullTimeFormat = "";
- result.longTimeFormat = "";
- result.mediumTimeFormat = "";
- result.shortTimeFormat = "";
-
- result.fullDateFormat = "";
- result.longDateFormat = "";
- result.mediumDateFormat = "";
- result.shortDateFormat = "";
-
- // Used by DecimalFormatSymbols.
- result.zeroDigit = '0';
- result.decimalSeparator = '.';
- result.groupingSeparator = ',';
- result.patternSeparator = ' ';
- result.percent = "%";
- result.perMill = "\u2030";
- result.monetarySeparator = ' ';
- result.minusSign = "-";
- result.exponentSeparator = "e";
- result.infinity = "\u221E";
- result.NaN = "NaN";
- // Also used by Currency.
- result.currencySymbol = "$";
- result.internationalCurrencySymbol = "USD";
-
- // Used by DecimalFormat and NumberFormat.
- result.numberPattern = "%f";
- result.integerPattern = "%d";
- result.currencyPattern = "%s";
- result.percentPattern = "%f";
-
- return true;
- }
-
- @LayoutlibDelegate
/*package*/ static void setDefaultLocale(String locale) {
ICU.setDefaultLocale(locale);
}
diff --git a/rename_font/build_font.py b/rename_font/build_font.py
index a53ebbc..db0c98a 100755
--- a/rename_font/build_font.py
+++ b/rename_font/build_font.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2014 The Android Open Source Project
#
@@ -96,7 +96,7 @@
def convert_font(input_path):
filename = os.path.basename(input_path)
- print 'Converting font: ' + filename
+ print('Converting font: ' + filename)
# the path to the output file. The file name is the fontfilename.ttx
ttx_path = os.path.join(dest_dir, filename)
ttx_path = ttx_path[:-1] + 'x'
@@ -116,11 +116,11 @@
ttx.main(ttx_args)
except InvalidFontException:
# In case of invalid fonts, we exit.
- print filename + ' is not a valid font'
+ print(filename + ' is not a valid font')
raise
except Exception as e:
- print 'Error converting font: ' + filename
- print e
+ print('Error converting font: ' + filename)
+ print(e)
# Some fonts are too big to be handled by the ttx library.
# Just copy paste them.
shutil.copy(input_path, dest_dir)
@@ -136,7 +136,7 @@
found in the name table of the font. """
fonts = []
font = None
- last_name_id = sys.maxint
+ last_name_id = sys.maxsize
for namerecord in tag.iter('namerecord'):
if 'nameID' in namerecord.attrib:
name_id = int(namerecord.attrib['nameID'])
@@ -164,14 +164,14 @@
def update_tag(tag, fonts):
- last_name_id = sys.maxint
+ last_name_id = sys.maxsize
fonts_iterator = fonts.__iter__()
font = None
for namerecord in tag.iter('namerecord'):
if 'nameID' in namerecord.attrib:
name_id = int(namerecord.attrib['nameID'])
if name_id <= last_name_id:
- font = fonts_iterator.next()
+ font = next(fonts_iterator)
font = update_font_name(font)
last_name_id = name_id
if name_id == NAMEID_FAMILY:
@@ -192,7 +192,7 @@
new_family = font.family + font.version
else:
new_family = font.family
- if font.style is 'Regular' and not font.ends_in_regular:
+ if font.style == 'Regular' and not font.ends_in_regular:
font.fullname = new_family
else:
font.fullname = new_family + ' ' + font.style
@@ -205,7 +205,7 @@
'Regular' for plain fonts. However, some fonts don't obey this rule. We
keep the style info, to minimize the diff. """
string = string.strip().split()[-1]
- return string is 'Regular'
+ return string == 'Regular'
def get_version(string):
diff --git a/rename_font/build_font_single.py b/rename_font/build_font_single.py
index 22d7fdf..b254072 100755
--- a/rename_font/build_font_single.py
+++ b/rename_font/build_font_single.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2014 The Android Open Source Project
#
@@ -71,7 +71,7 @@
def main(argv):
if len(argv) < 2:
- print 'Incorrect usage: ' + str(argv)
+ print('Incorrect usage: ' + str(argv))
sys.exit('Usage: build_font_single.py /path/to/input/font.ttf /path/to/out/font.ttf')
dest_path = argv[-1]
input_path = argv[0]
@@ -85,7 +85,7 @@
def convert_font(input_path, dest_path):
filename = os.path.basename(input_path)
- print 'Converting font: ' + filename
+ print('Converting font: ' + filename)
# the path to the output file. The file name is the fontfilename.ttx
ttx_path = dest_path[:-1] + 'x'
try:
@@ -104,11 +104,11 @@
ttx.main(ttx_args)
except InvalidFontException:
# assume, like for .ttc and .otf that font might be valid, but warn.
- print 'Family and/or Style nameIDs not found in '+ filename
+ print('Family and/or Style nameIDs not found in '+ filename)
shutil.copy(input_path, dest_path)
except Exception as e:
- print 'Error converting font: ' + filename
- print e
+ print('Error converting font: ' + filename)
+ print(e)
# Some fonts are too big to be handled by the ttx library.
# Just copy paste them.
shutil.copy(input_path, dest_path)
@@ -124,7 +124,7 @@
found in the name table of the font. """
fonts = []
font = None
- last_name_id = sys.maxint
+ last_name_id = sys.maxsize
for namerecord in tag.iter('namerecord'):
if 'nameID' in namerecord.attrib:
name_id = int(namerecord.attrib['nameID'])
@@ -155,7 +155,7 @@
def update_tag(tag, fonts):
- last_name_id = sys.maxint
+ last_name_id = sys.maxsize
fonts_iterator = fonts.__iter__()
font = None
for namerecord in tag.iter('namerecord'):
@@ -165,7 +165,7 @@
if name_id < NAMEID_LIST_MIN or name_id > NAMEID_LIST_MAX:
continue
if name_id <= last_name_id:
- font = fonts_iterator.next()
+ font = next(fonts_iterator)
font = update_font_name(font)
last_name_id = name_id
if name_id == NAMEID_FAMILY:
@@ -186,7 +186,7 @@
new_family = font.family + font.version
else:
new_family = font.family
- if font.style is 'Regular' and not font.ends_in_regular:
+ if font.style == 'Regular' and not font.ends_in_regular:
font.fullname = new_family
else:
font.fullname = new_family + ' ' + font.style
@@ -199,7 +199,7 @@
'Regular' for plain fonts. However, some fonts don't obey this rule. We
keep the style info, to minimize the diff. """
string = string.strip().split()[-1]
- return string is 'Regular'
+ return string == 'Regular'
def get_version(string):
diff --git a/rename_font/test.py b/rename_font/test.py
index 2ffddf4..cf26ee9 100755
--- a/rename_font/test.py
+++ b/rename_font/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Tests build_font.py by renaming a font.
@@ -22,10 +22,10 @@
def test(self):
font_name = "Roboto-Regular.ttf"
srcdir = tempfile.mkdtemp()
- print "srcdir: " + srcdir
+ print("srcdir: " + srcdir)
shutil.copy(font_name, srcdir)
destdir = tempfile.mkdtemp()
- print "destdir: " + destdir
+ print("destdir: " + destdir)
self.assertTrue(build_font.main([srcdir, destdir]) is None)
out_path = os.path.join(destdir, font_name)
ttx.main([out_path])