Loading java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +4 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ class BinaryDictionaryGetter { // This assumes '%' is fully available as a non-separator, normal // character in a file name. This is probably true for all file systems. final StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); ++i) { final int nameLength = name.length(); for (int i = 0; i < nameLength; i = name.offsetByCodePoints(i, 1)) { final int codePoint = name.codePointAt(i); if (isFileNameCharacter(codePoint)) { sb.appendCodePoint(codePoint); Loading @@ -92,7 +93,8 @@ class BinaryDictionaryGetter { */ private static String getWordListIdFromFileName(final String fname) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < fname.length(); ++i) { final int fnameLength = fname.length(); for (int i = 0; i < fnameLength; i = fname.offsetByCodePoints(i, 1)) { final int codePoint = fname.codePointAt(i); if ('%' != codePoint) { sb.appendCodePoint(codePoint); Loading java/src/com/android/inputmethod/latin/SettingsValues.java +4 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,8 @@ public class SettingsValues { mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols); mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols); if (LatinImeLogger.sDBG) { for (int i = 0; i < mMagicSpaceStrippers.length(); ++i) { final int length = mMagicSpaceStrippers.length(); for (int i = 0; i < length; i = mMagicSpaceStrippers.offsetByCodePoints(i, 1)) { if (isMagicSpaceSwapper(mMagicSpaceStrippers.codePointAt(i))) { throw new RuntimeException("Char code " + mMagicSpaceStrippers.codePointAt(i) + " is both a magic space swapper and stripper."); Loading Loading @@ -234,10 +235,12 @@ public class SettingsValues { } public boolean isMagicSpaceStripper(int code) { // TODO: this does not work if the code does not fit in a char return mMagicSpaceStrippers.contains(String.valueOf((char)code)); } public boolean isMagicSpaceSwapper(int code) { // TODO: this does not work if the code does not fit in a char return mMagicSpaceSwappers.contains(String.valueOf((char)code)); } Loading java/src/com/android/inputmethod/latin/WordComposer.java +2 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,8 @@ public class WordComposer { if (mTrailingSingleQuotesCount > 0) { --mTrailingSingleQuotesCount; } else { for (int i = mTypedWord.length() - 1; i >= 0; --i) { for (int i = mTypedWord.offsetByCodePoints(mTypedWord.length(), -1); i >= 0; i = mTypedWord.offsetByCodePoints(i, -1)) { if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break; ++mTrailingSingleQuotesCount; } Loading java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +5 −6 Original line number Diff line number Diff line Loading @@ -431,9 +431,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService // If the first char is not uppercase, then the word is either all lower case, // and in either case we return CAPITALIZE_NONE. if (!Character.isUpperCase(text.codePointAt(0))) return CAPITALIZE_NONE; final int len = text.codePointCount(0, text.length()); final int len = text.length(); int capsCount = 1; for (int i = 1; i < len; ++i) { for (int i = 1; i < len; i = text.offsetByCodePoints(i, 1)) { if (1 != capsCount && i != capsCount) break; if (Character.isUpperCase(text.codePointAt(i))) ++capsCount; } Loading Loading @@ -522,13 +522,12 @@ public class AndroidSpellCheckerService extends SpellCheckerService // Filter contents final int length = text.length(); int letterCount = 0; for (int i = 0; i < length; ++i) { for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) { final int codePoint = text.codePointAt(i); // Any word containing a '@' is probably an e-mail address // Any word containing a '/' is probably either an ad-hoc combination of two // words or a URI - in either case we don't want to spell check that if ('@' == codePoint || '/' == codePoint) return true; if ('@' == codePoint || '/' == codePoint) return true; if (isLetterCheckableByLanguage(codePoint, script)) ++letterCount; } // Guestimate heuristic: perform spell checking if at least 3/4 of the characters Loading Loading @@ -570,7 +569,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService suggestionsLimit); final WordComposer composer = new WordComposer(); final int length = text.length(); for (int i = 0; i < length; ++i) { for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) { final int character = text.codePointAt(i); final int proximityIndex = SpellCheckerProximityInfo.getIndexOfCodeForScript(character, mScript); Loading tests/src/com/android/inputmethod/latin/InputLogicTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { } private void type(final String stringToType) { for (int i = 0; i < stringToType.length(); ++i) { for (int i = 0; i < stringToType.length(); i = stringToType.offsetByCodePoints(i, 1)) { type(stringToType.codePointAt(i)); } } Loading Loading
java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +4 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ class BinaryDictionaryGetter { // This assumes '%' is fully available as a non-separator, normal // character in a file name. This is probably true for all file systems. final StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); ++i) { final int nameLength = name.length(); for (int i = 0; i < nameLength; i = name.offsetByCodePoints(i, 1)) { final int codePoint = name.codePointAt(i); if (isFileNameCharacter(codePoint)) { sb.appendCodePoint(codePoint); Loading @@ -92,7 +93,8 @@ class BinaryDictionaryGetter { */ private static String getWordListIdFromFileName(final String fname) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < fname.length(); ++i) { final int fnameLength = fname.length(); for (int i = 0; i < fnameLength; i = fname.offsetByCodePoints(i, 1)) { final int codePoint = fname.codePointAt(i); if ('%' != codePoint) { sb.appendCodePoint(codePoint); Loading
java/src/com/android/inputmethod/latin/SettingsValues.java +4 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,8 @@ public class SettingsValues { mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols); mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols); if (LatinImeLogger.sDBG) { for (int i = 0; i < mMagicSpaceStrippers.length(); ++i) { final int length = mMagicSpaceStrippers.length(); for (int i = 0; i < length; i = mMagicSpaceStrippers.offsetByCodePoints(i, 1)) { if (isMagicSpaceSwapper(mMagicSpaceStrippers.codePointAt(i))) { throw new RuntimeException("Char code " + mMagicSpaceStrippers.codePointAt(i) + " is both a magic space swapper and stripper."); Loading Loading @@ -234,10 +235,12 @@ public class SettingsValues { } public boolean isMagicSpaceStripper(int code) { // TODO: this does not work if the code does not fit in a char return mMagicSpaceStrippers.contains(String.valueOf((char)code)); } public boolean isMagicSpaceSwapper(int code) { // TODO: this does not work if the code does not fit in a char return mMagicSpaceSwappers.contains(String.valueOf((char)code)); } Loading
java/src/com/android/inputmethod/latin/WordComposer.java +2 −1 Original line number Diff line number Diff line Loading @@ -221,7 +221,8 @@ public class WordComposer { if (mTrailingSingleQuotesCount > 0) { --mTrailingSingleQuotesCount; } else { for (int i = mTypedWord.length() - 1; i >= 0; --i) { for (int i = mTypedWord.offsetByCodePoints(mTypedWord.length(), -1); i >= 0; i = mTypedWord.offsetByCodePoints(i, -1)) { if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break; ++mTrailingSingleQuotesCount; } Loading
java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +5 −6 Original line number Diff line number Diff line Loading @@ -431,9 +431,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService // If the first char is not uppercase, then the word is either all lower case, // and in either case we return CAPITALIZE_NONE. if (!Character.isUpperCase(text.codePointAt(0))) return CAPITALIZE_NONE; final int len = text.codePointCount(0, text.length()); final int len = text.length(); int capsCount = 1; for (int i = 1; i < len; ++i) { for (int i = 1; i < len; i = text.offsetByCodePoints(i, 1)) { if (1 != capsCount && i != capsCount) break; if (Character.isUpperCase(text.codePointAt(i))) ++capsCount; } Loading Loading @@ -522,13 +522,12 @@ public class AndroidSpellCheckerService extends SpellCheckerService // Filter contents final int length = text.length(); int letterCount = 0; for (int i = 0; i < length; ++i) { for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) { final int codePoint = text.codePointAt(i); // Any word containing a '@' is probably an e-mail address // Any word containing a '/' is probably either an ad-hoc combination of two // words or a URI - in either case we don't want to spell check that if ('@' == codePoint || '/' == codePoint) return true; if ('@' == codePoint || '/' == codePoint) return true; if (isLetterCheckableByLanguage(codePoint, script)) ++letterCount; } // Guestimate heuristic: perform spell checking if at least 3/4 of the characters Loading Loading @@ -570,7 +569,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService suggestionsLimit); final WordComposer composer = new WordComposer(); final int length = text.length(); for (int i = 0; i < length; ++i) { for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) { final int character = text.codePointAt(i); final int proximityIndex = SpellCheckerProximityInfo.getIndexOfCodeForScript(character, mScript); Loading
tests/src/com/android/inputmethod/latin/InputLogicTests.java +1 −1 Original line number Diff line number Diff line Loading @@ -133,7 +133,7 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { } private void type(final String stringToType) { for (int i = 0; i < stringToType.length(); ++i) { for (int i = 0; i < stringToType.length(); i = stringToType.offsetByCodePoints(i, 1)) { type(stringToType.codePointAt(i)); } } Loading