am 2dd2e2d7: am 99b93d17: Fix a bug where autocorrection status would be wrong.
* commit '2dd2e2d7dff8c4446d536bd23fc94a5538c24ddf': Fix a bug where autocorrection status would be wrong.main
commit
99e91fc8ec
|
@ -1460,7 +1460,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
||||||
return StringUtils.capitalizeFirstCharacter(locale.getLanguage(), locale);
|
return StringUtils.capitalizeFirstCodePoint(locale.getLanguage(), locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get InputMethodSubtype's middle display name in its locale.
|
// Get InputMethodSubtype's middle display name in its locale.
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class CapsModeUtils {
|
||||||
if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
|
if (WordComposer.CAPS_MODE_AUTO_SHIFT_LOCKED == capitalizeMode) {
|
||||||
return s.toUpperCase(locale);
|
return s.toUpperCase(locale);
|
||||||
} else if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
|
} else if (WordComposer.CAPS_MODE_AUTO_SHIFTED == capitalizeMode) {
|
||||||
return StringUtils.toTitleCase(s, locale);
|
return StringUtils.capitalizeFirstCodePoint(s, locale);
|
||||||
} else {
|
} else {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,16 +106,17 @@ public final class StringUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String capitalizeFirstCharacter(final String s, final Locale locale) {
|
public static String capitalizeFirstCodePoint(final String s, final Locale locale) {
|
||||||
if (s.length() <= 1) {
|
if (s.length() <= 1) {
|
||||||
return s.toUpperCase(locale);
|
return s.toUpperCase(locale);
|
||||||
}
|
}
|
||||||
// Please refer to the comment below in {@link #toTitleCase(String,Locale)}.
|
// Please refer to the comment below in
|
||||||
|
// {@link #capitalizeFirstAndDowncaseRest(String,Locale)} as this has the same shortcomings
|
||||||
final int cutoff = s.offsetByCodePoints(0, 1);
|
final int cutoff = s.offsetByCodePoints(0, 1);
|
||||||
return s.substring(0, cutoff).toUpperCase(locale) + s.substring(cutoff);
|
return s.substring(0, cutoff).toUpperCase(locale) + s.substring(cutoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toTitleCase(final String s, final Locale locale) {
|
public static String capitalizeFirstAndDowncaseRest(final String s, final Locale locale) {
|
||||||
if (s.length() <= 1) {
|
if (s.length() <= 1) {
|
||||||
return s.toUpperCase(locale);
|
return s.toUpperCase(locale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ public final class SubtypeLocale {
|
||||||
final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
|
final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
|
||||||
displayName = locale.getDisplayName(displayLocale);
|
displayName = locale.getDisplayName(displayLocale);
|
||||||
}
|
}
|
||||||
return StringUtils.capitalizeFirstCharacter(displayName, displayLocale);
|
return StringUtils.capitalizeFirstCodePoint(displayName, displayLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// InputMethodSubtype's display name in its locale.
|
// InputMethodSubtype's display name in its locale.
|
||||||
|
@ -243,7 +243,7 @@ public final class SubtypeLocale {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return StringUtils.capitalizeFirstCharacter(
|
return StringUtils.capitalizeFirstCodePoint(
|
||||||
getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
|
getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ public final class Suggest {
|
||||||
if (isAllUpperCase) {
|
if (isAllUpperCase) {
|
||||||
sb.append(wordInfo.mWord.toUpperCase(locale));
|
sb.append(wordInfo.mWord.toUpperCase(locale));
|
||||||
} else if (isFirstCharCapitalized) {
|
} else if (isFirstCharCapitalized) {
|
||||||
sb.append(StringUtils.toTitleCase(wordInfo.mWord, locale));
|
sb.append(StringUtils.capitalizeFirstCodePoint(wordInfo.mWord, locale));
|
||||||
} else {
|
} else {
|
||||||
sb.append(wordInfo.mWord);
|
sb.append(wordInfo.mWord);
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
} else if (StringUtils.CAPITALIZE_FIRST == capitalizeType) {
|
} else if (StringUtils.CAPITALIZE_FIRST == capitalizeType) {
|
||||||
for (int i = 0; i < mSuggestions.size(); ++i) {
|
for (int i = 0; i < mSuggestions.size(); ++i) {
|
||||||
// Likewise
|
// Likewise
|
||||||
mSuggestions.set(i, StringUtils.toTitleCase(
|
mSuggestions.set(i, StringUtils.capitalizeFirstCodePoint(
|
||||||
mSuggestions.get(i).toString(), locale));
|
mSuggestions.get(i).toString(), locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
|
||||||
// If the lower case version is not in the dictionary, it's still possible
|
// If the lower case version is not in the dictionary, it's still possible
|
||||||
// that we have an all-caps version of a word that needs to be capitalized
|
// that we have an all-caps version of a word that needs to be capitalized
|
||||||
// according to the dictionary. E.g. "GERMANS" only exists in the dictionary as "Germans".
|
// according to the dictionary. E.g. "GERMANS" only exists in the dictionary as "Germans".
|
||||||
return dict.isValidWord(StringUtils.toTitleCase(lowerCaseText, mLocale));
|
return dict.isValidWord(StringUtils.capitalizeFirstAndDowncaseRest(lowerCaseText, mLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note : this must be reentrant
|
// Note : this must be reentrant
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class SpacebarTextTests extends AndroidTestCase {
|
||||||
final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
|
final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
|
||||||
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
|
||||||
final String spacebarText = MainKeyboardView.getShortDisplayName(subtype);
|
final String spacebarText = MainKeyboardView.getShortDisplayName(subtype);
|
||||||
final String languageCode = StringUtils.capitalizeFirstCharacter(
|
final String languageCode = StringUtils.capitalizeFirstCodePoint(
|
||||||
locale.getLanguage(), locale);
|
locale.getLanguage(), locale);
|
||||||
if (SubtypeLocale.isNoLanguage(subtype)) {
|
if (SubtypeLocale.isNoLanguage(subtype)) {
|
||||||
assertEquals(subtypeName, "", spacebarText);
|
assertEquals(subtypeName, "", spacebarText);
|
||||||
|
|
|
@ -93,23 +93,43 @@ public class StringUtilsTests extends AndroidTestCase {
|
||||||
StringUtils.removeFromCsvIfExists("key", "key1,key,key3,key,key5"));
|
StringUtils.removeFromCsvIfExists("key", "key1,key,key3,key,key5"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToTitleCase() {
|
|
||||||
|
public void testCapitalizeFirstCodePoint() {
|
||||||
assertEquals("SSaa",
|
assertEquals("SSaa",
|
||||||
StringUtils.toTitleCase("ßaa", Locale.GERMAN));
|
StringUtils.capitalizeFirstCodePoint("ßaa", Locale.GERMAN));
|
||||||
assertEquals("Aßa",
|
assertEquals("Aßa",
|
||||||
StringUtils.toTitleCase("aßa", Locale.GERMAN));
|
StringUtils.capitalizeFirstCodePoint("aßa", Locale.GERMAN));
|
||||||
assertEquals("Iab",
|
assertEquals("Iab",
|
||||||
StringUtils.toTitleCase("iab", Locale.ENGLISH));
|
StringUtils.capitalizeFirstCodePoint("iab", Locale.ENGLISH));
|
||||||
assertEquals("Camelcase",
|
assertEquals("cAmElCaSe",
|
||||||
StringUtils.toTitleCase("cAmElCaSe", Locale.ENGLISH));
|
StringUtils.capitalizeFirstCodePoint("cAmElCaSe", Locale.ENGLISH));
|
||||||
assertEquals("İab",
|
assertEquals("İab",
|
||||||
StringUtils.toTitleCase("iab", new Locale("tr")));
|
StringUtils.capitalizeFirstCodePoint("iab", new Locale("tr")));
|
||||||
|
assertEquals("AİB",
|
||||||
|
StringUtils.capitalizeFirstCodePoint("AİB", new Locale("tr")));
|
||||||
|
assertEquals("A",
|
||||||
|
StringUtils.capitalizeFirstCodePoint("a", Locale.ENGLISH));
|
||||||
|
assertEquals("A",
|
||||||
|
StringUtils.capitalizeFirstCodePoint("A", Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCapitalizeFirstAndDowncaseRest() {
|
||||||
|
assertEquals("SSaa",
|
||||||
|
StringUtils.capitalizeFirstAndDowncaseRest("ßaa", Locale.GERMAN));
|
||||||
|
assertEquals("Aßa",
|
||||||
|
StringUtils.capitalizeFirstAndDowncaseRest("aßa", Locale.GERMAN));
|
||||||
|
assertEquals("Iab",
|
||||||
|
StringUtils.capitalizeFirstAndDowncaseRest("iab", Locale.ENGLISH));
|
||||||
|
assertEquals("Camelcase",
|
||||||
|
StringUtils.capitalizeFirstAndDowncaseRest("cAmElCaSe", Locale.ENGLISH));
|
||||||
|
assertEquals("İab",
|
||||||
|
StringUtils.capitalizeFirstAndDowncaseRest("iab", new Locale("tr")));
|
||||||
assertEquals("Aib",
|
assertEquals("Aib",
|
||||||
StringUtils.toTitleCase("AİB", new Locale("tr")));
|
StringUtils.capitalizeFirstAndDowncaseRest("AİB", new Locale("tr")));
|
||||||
assertEquals("A",
|
assertEquals("A",
|
||||||
StringUtils.toTitleCase("a", Locale.ENGLISH));
|
StringUtils.capitalizeFirstAndDowncaseRest("a", Locale.ENGLISH));
|
||||||
assertEquals("A",
|
assertEquals("A",
|
||||||
StringUtils.toTitleCase("A", Locale.ENGLISH));
|
StringUtils.capitalizeFirstAndDowncaseRest("A", Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetCapitalizationType() {
|
public void testGetCapitalizationType() {
|
||||||
|
|
Loading…
Reference in New Issue