From 3889462439357fd76c0b82dfd52e1ca6e0bafd2d Mon Sep 17 00:00:00 2001 From: Ken Wakasa Date: Thu, 4 Aug 2011 00:23:17 +0900 Subject: [PATCH] Handle non word separators correctly even for the initial letter of a word bug: 5101114 Change-Id: I0d804c9a500ff000dc06cadad46a2c6c6b8088b2 --- java/res/values-fr/donottranslate.xml | 2 +- java/res/values-it/donottranslate.xml | 2 +- java/res/values/donottranslate.xml | 4 ++-- .../com/android/inputmethod/latin/LatinIME.java | 3 ++- .../com/android/inputmethod/latin/Settings.java | 14 +++++++++++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/java/res/values-fr/donottranslate.xml b/java/res/values-fr/donottranslate.xml index 09c37e31a..695750f32 100644 --- a/java/res/values-fr/donottranslate.xml +++ b/java/res/values-fr/donottranslate.xml @@ -25,5 +25,5 @@ ;:!?([*&@{<>+=| - \u0027 + \u0027 diff --git a/java/res/values-it/donottranslate.xml b/java/res/values-it/donottranslate.xml index adb2a9a9d..58e94361b 100644 --- a/java/res/values-it/donottranslate.xml +++ b/java/res/values-it/donottranslate.xml @@ -19,5 +19,5 @@ --> - + diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 0d18d907d..9727746e7 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -27,10 +27,10 @@ ([*&@{<>+=| - \u0027- + \u0027- + magic_space_neutral_symbols \ symbols_excluded_from_word_separators --> = \\ < diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index cbfc90017..5c0b38c42 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1374,7 +1374,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } int code = primaryCode; - if (isAlphabet(code) && isSuggestionsRequested() && !isCursorTouchingWord()) { + if ((isAlphabet(code) || mSettingsValues.isSymbolExcludedFromWordSeparators(code)) + && isSuggestionsRequested() && !isCursorTouchingWord()) { if (!mHasUncommittedTypedChars) { mHasUncommittedTypedChars = true; mComposingStringBuilder.setLength(0); diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java index 84751264a..4c2627be3 100644 --- a/java/src/com/android/inputmethod/latin/Settings.java +++ b/java/src/com/android/inputmethod/latin/Settings.java @@ -103,6 +103,7 @@ public class Settings extends InputMethodSettingsActivity public final String mMagicSpaceSwappers; public final String mSuggestPuncs; public final SuggestedWords mSuggestPuncList; + private final String mSymbolsExcludedFromWordSeparators; // From preferences: public final boolean mSoundOn; // Sound setting private to Latin IME (see mSilentModeOn) @@ -152,10 +153,13 @@ public class Settings extends InputMethodSettingsActivity mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols); String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers + res.getString(R.string.magic_space_promoting_symbols); - final String notWordSeparators = res.getString(R.string.non_word_separator_symbols); - for (int i = notWordSeparators.length() - 1; i >= 0; --i) { - wordSeparators = wordSeparators.replace(notWordSeparators.substring(i, i + 1), ""); + final String symbolsExcludedFromWordSeparators = + res.getString(R.string.symbols_excluded_from_word_separators); + for (int i = symbolsExcludedFromWordSeparators.length() - 1; i >= 0; --i) { + wordSeparators = wordSeparators.replace( + symbolsExcludedFromWordSeparators.substring(i, i + 1), ""); } + mSymbolsExcludedFromWordSeparators = symbolsExcludedFromWordSeparators; mWordSeparators = wordSeparators; mSuggestPuncs = res.getString(R.string.suggested_punctuations); // TODO: it would be nice not to recreate this each time we change the configuration @@ -197,6 +201,10 @@ public class Settings extends InputMethodSettingsActivity return mWordSeparators.contains(String.valueOf((char)code)); } + public boolean isSymbolExcludedFromWordSeparators(int code) { + return mSymbolsExcludedFromWordSeparators.contains(String.valueOf((char)code)); + } + public boolean isMagicSpaceStripper(int code) { return mMagicSpaceStrippers.contains(String.valueOf((char)code)); }