Use Locale.ROOT for locale neutral operations
Bug: 9112465 Change-Id: I6cd63007287b5a1a57cfbabff35d53f66fc5620e
This commit is contained in:
parent
ebe0544fc8
commit
94027c7201
6 changed files with 13 additions and 12 deletions
|
@ -144,7 +144,7 @@ public final class LocaleUtils {
|
|||
public static String getMatchLevelSortedString(final int matchLevel) {
|
||||
// This works because the match levels are 0~99 (actually 0~30)
|
||||
// Ideally this should use a number of digits equals to the 1og10 of the greater matchLevel
|
||||
return String.format("%02d", MATCH_LEVEL_MAX - matchLevel);
|
||||
return String.format(Locale.ROOT, "%02d", MATCH_LEVEL_MAX - matchLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -453,7 +453,7 @@ public class Key implements Comparable<Key> {
|
|||
} else {
|
||||
label = "/" + mLabel;
|
||||
}
|
||||
return String.format("%s%s %d,%d %dx%d %s/%s/%s",
|
||||
return String.format(Locale.ROOT, "%s%s %d,%d %dx%d %s/%s/%s",
|
||||
Constants.printableCode(mCode), label, mX, mY, mWidth, mHeight, mHintLabel,
|
||||
KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType));
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public final class KeyboardId {
|
|||
public String toString() {
|
||||
final String orientation = (mOrientation == Configuration.ORIENTATION_PORTRAIT)
|
||||
? "port" : "land";
|
||||
return String.format("[%s %s:%s %s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]",
|
||||
return String.format(Locale.ROOT, "[%s %s:%s %s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]",
|
||||
elementIdToName(mElementId),
|
||||
mLocale,
|
||||
mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
|
||||
|
|
|
@ -148,7 +148,7 @@ public final class LocaleUtils {
|
|||
public static String getMatchLevelSortedString(int matchLevel) {
|
||||
// This works because the match levels are 0~99 (actually 0~30)
|
||||
// Ideally this should use a number of digits equals to the 1og10 of the greater matchLevel
|
||||
return String.format("%02d", MATCH_LEVEL_MAX - matchLevel);
|
||||
return String.format(Locale.ROOT, "%02d", MATCH_LEVEL_MAX - matchLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -379,7 +379,8 @@ public final class Suggest {
|
|||
typedWord, cur.toString(), cur.mScore);
|
||||
final String scoreInfoString;
|
||||
if (normalizedScore > 0) {
|
||||
scoreInfoString = String.format("%d (%4.2f)", cur.mScore, normalizedScore);
|
||||
scoreInfoString = String.format(
|
||||
Locale.ROOT, "%d (%4.2f)", cur.mScore, normalizedScore);
|
||||
} else {
|
||||
scoreInfoString = Integer.toString(cur.mScore);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public class KeySpecParserTests extends AndroidTestCase {
|
|||
|
||||
private static final String CODE_SETTINGS = "!code/key_settings";
|
||||
private static final String ICON_SETTINGS = "!icon/settings_key";
|
||||
private static final String CODE_SETTINGS_UPPERCASE = CODE_SETTINGS.toUpperCase();
|
||||
private static final String ICON_SETTINGS_UPPERCASE = ICON_SETTINGS.toUpperCase();
|
||||
private static final String CODE_SETTINGS_UPPERCASE = CODE_SETTINGS.toUpperCase(Locale.ROOT);
|
||||
private static final String ICON_SETTINGS_UPPERCASE = ICON_SETTINGS.toUpperCase(Locale.ROOT);
|
||||
private static final String CODE_NON_EXISTING = "!code/non_existing";
|
||||
private static final String ICON_NON_EXISTING = "!icon/non_existing";
|
||||
|
||||
|
@ -587,7 +587,7 @@ public class KeySpecParserTests extends AndroidTestCase {
|
|||
new String[] { null, "a", "b", "c" }, true);
|
||||
// Upper case specification will not work.
|
||||
assertGetBooleanValue("HAS LABEL", HAS_LABEL,
|
||||
new String[] { HAS_LABEL.toUpperCase(), "a", "b", "c" },
|
||||
new String[] { HAS_LABEL.toUpperCase(Locale.ROOT), "a", "b", "c" },
|
||||
new String[] { "!HASLABEL!", "a", "b", "c" }, false);
|
||||
|
||||
assertGetBooleanValue("No has label", HAS_LABEL,
|
||||
|
@ -600,13 +600,13 @@ public class KeySpecParserTests extends AndroidTestCase {
|
|||
// Upper case specification will not work.
|
||||
assertGetBooleanValue("Multiple has label", HAS_LABEL,
|
||||
new String[] {
|
||||
"a", HAS_LABEL.toUpperCase(), "b", "c", HAS_LABEL, "d" },
|
||||
"a", HAS_LABEL.toUpperCase(Locale.ROOT), "b", "c", HAS_LABEL, "d" },
|
||||
new String[] {
|
||||
"a", "!HASLABEL!", "b", "c", null, "d" }, true);
|
||||
// Upper case specification will not work.
|
||||
assertGetBooleanValue("Multiple has label with needs dividers", HAS_LABEL,
|
||||
new String[] {
|
||||
"a", HAS_LABEL, "b", NEEDS_DIVIDER, HAS_LABEL.toUpperCase(), "d" },
|
||||
"a", HAS_LABEL, "b", NEEDS_DIVIDER, HAS_LABEL.toUpperCase(Locale.ROOT), "d" },
|
||||
new String[] {
|
||||
"a", null, "b", NEEDS_DIVIDER, "!HASLABEL!", "d" }, true);
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ public class KeySpecParserTests extends AndroidTestCase {
|
|||
new String[] { null, "a", "b", "c" }, 3);
|
||||
// Upper case specification will not work.
|
||||
assertGetIntValue("FIXED COLUMN ORDER 3", FIXED_COLUMN_ORDER, -1,
|
||||
new String[] { FIXED_COLUMN_ORDER.toUpperCase() + "3", "a", "b", "c" },
|
||||
new String[] { FIXED_COLUMN_ORDER.toUpperCase(Locale.ROOT) + "3", "a", "b", "c" },
|
||||
new String[] { "!FIXEDCOLUMNORDER!3", "a", "b", "c" }, -1);
|
||||
|
||||
assertGetIntValue("No fixed column order", FIXED_COLUMN_ORDER, -1,
|
||||
|
@ -641,7 +641,7 @@ public class KeySpecParserTests extends AndroidTestCase {
|
|||
// Upper case specification will not work.
|
||||
assertGetIntValue("Multiple fixed column order 5,3 with has label", FIXED_COLUMN_ORDER, -1,
|
||||
new String[] {
|
||||
FIXED_COLUMN_ORDER.toUpperCase() + "5", HAS_LABEL, "a",
|
||||
FIXED_COLUMN_ORDER.toUpperCase(Locale.ROOT) + "5", HAS_LABEL, "a",
|
||||
FIXED_COLUMN_ORDER + "3", "b" },
|
||||
new String[] { "!FIXEDCOLUMNORDER!5", HAS_LABEL, "a", null, "b" }, 3);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue