From a78b2d22568d47492ba937fde87e6c6996a995a4 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Fri, 6 Jan 2017 11:44:40 -0800 Subject: Update background text images in recovery Locale texts are missing in the recovery log due to an extra empty locale chunk in the png file. Fix the bug in the app and regenerate all the background texts and compress the file with pngcrush + zopflipng. Bug: 34054052 Test: Locale texts logged successfully on angler Change-Id: I89f823a53c1eb69756183e8e11113216d093304f --- .../src/com/android/recovery_l10n/Main.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tools/recovery_l10n') diff --git a/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java b/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java index ac94bde1c..30d45f6ae 100644 --- a/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java +++ b/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java @@ -38,6 +38,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; import java.util.HashMap; import java.util.Locale; @@ -148,11 +149,28 @@ public class Main extends Activity { mText = (TextView) findViewById(R.id.text); String[] localeNames = getAssets().getLocales(); - Arrays.sort(localeNames); + Arrays.sort(localeNames, new Comparator() { + // Override the string comparator so that en is sorted behind en_US. + // As a result, en_US will be matched first in recovery. + @Override + public int compare(String s1, String s2) { + if (s1.equals(s2)) { + return 0; + } else if (s1.startsWith(s2)) { + return -1; + } else if (s2.startsWith(s1)) { + return 1; + } + return s1.compareTo(s2); + } + }); + ArrayList locales = new ArrayList(); for (String localeName : localeNames) { Log.i(TAG, "locale = " + localeName); - locales.add(Locale.forLanguageTag(localeName)); + if (!localeName.isEmpty()) { + locales.add(Locale.forLanguageTag(localeName)); + } } final Runnable seq = buildSequence(locales.toArray(new Locale[0])); -- cgit v1.2.3