Handle non word separators correctly even for the initial letter of a word

bug: 5101114
Change-Id: I0d804c9a500ff000dc06cadad46a2c6c6b8088b2
main
Ken Wakasa 2011-08-04 00:23:17 +09:00
parent bb12dc455b
commit 3889462439
5 changed files with 17 additions and 8 deletions

View File

@ -25,5 +25,5 @@
<!-- Symbols that should promote magic spaces into real space --> <!-- Symbols that should promote magic spaces into real space -->
<string name="magic_space_promoting_symbols">;:!?([*&amp;@{&lt;&gt;+=|</string> <string name="magic_space_promoting_symbols">;:!?([*&amp;@{&lt;&gt;+=|</string>
<!-- Symbols that do NOT separate words --> <!-- Symbols that do NOT separate words -->
<string name="non_word_separator_symbols">\u0027</string> <string name="symbols_excluded_from_word_separators">\u0027</string>
</resources> </resources>

View File

@ -19,5 +19,5 @@
--> -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Symbols that do NOT separate words --> <!-- Symbols that do NOT separate words -->
<string name="non_word_separator_symbols"></string> <string name="symbols_excluded_from_word_separators"></string>
</resources> </resources>

View File

@ -27,10 +27,10 @@
<!-- Symbols that should convert magic spaces into real space --> <!-- Symbols that should convert magic spaces into real space -->
<string name="magic_space_promoting_symbols">([*&amp;@{&lt;&gt;+=|</string> <string name="magic_space_promoting_symbols">([*&amp;@{&lt;&gt;+=|</string>
<!-- Symbols that do NOT separate words --> <!-- Symbols that do NOT separate words -->
<string name="non_word_separator_symbols">\u0027-</string> <string name="symbols_excluded_from_word_separators">\u0027-</string>
<!-- Word separator list is the union of all symbols except those that are not separators: <!-- Word separator list is the union of all symbols except those that are not separators:
magic_space_swapping_symbols | magic_space_stripping_symbols | magic_space_swapping_symbols | magic_space_stripping_symbols |
magic_space_neutral_symbols \ non_word_separator_symbols --> magic_space_neutral_symbols \ symbols_excluded_from_word_separators -->
<!-- Label for "switch to more symbol" modifier key. Must be short to fit on key! --> <!-- Label for "switch to more symbol" modifier key. Must be short to fit on key! -->
<string name="label_to_more_symbol_key">= \\ &lt;</string> <string name="label_to_more_symbol_key">= \\ &lt;</string>

View File

@ -1374,7 +1374,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
int code = primaryCode; int code = primaryCode;
if (isAlphabet(code) && isSuggestionsRequested() && !isCursorTouchingWord()) { if ((isAlphabet(code) || mSettingsValues.isSymbolExcludedFromWordSeparators(code))
&& isSuggestionsRequested() && !isCursorTouchingWord()) {
if (!mHasUncommittedTypedChars) { if (!mHasUncommittedTypedChars) {
mHasUncommittedTypedChars = true; mHasUncommittedTypedChars = true;
mComposingStringBuilder.setLength(0); mComposingStringBuilder.setLength(0);

View File

@ -103,6 +103,7 @@ public class Settings extends InputMethodSettingsActivity
public final String mMagicSpaceSwappers; public final String mMagicSpaceSwappers;
public final String mSuggestPuncs; public final String mSuggestPuncs;
public final SuggestedWords mSuggestPuncList; public final SuggestedWords mSuggestPuncList;
private final String mSymbolsExcludedFromWordSeparators;
// From preferences: // From preferences:
public final boolean mSoundOn; // Sound setting private to Latin IME (see mSilentModeOn) 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); mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols);
String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers
+ res.getString(R.string.magic_space_promoting_symbols); + res.getString(R.string.magic_space_promoting_symbols);
final String notWordSeparators = res.getString(R.string.non_word_separator_symbols); final String symbolsExcludedFromWordSeparators =
for (int i = notWordSeparators.length() - 1; i >= 0; --i) { res.getString(R.string.symbols_excluded_from_word_separators);
wordSeparators = wordSeparators.replace(notWordSeparators.substring(i, i + 1), ""); for (int i = symbolsExcludedFromWordSeparators.length() - 1; i >= 0; --i) {
wordSeparators = wordSeparators.replace(
symbolsExcludedFromWordSeparators.substring(i, i + 1), "");
} }
mSymbolsExcludedFromWordSeparators = symbolsExcludedFromWordSeparators;
mWordSeparators = wordSeparators; mWordSeparators = wordSeparators;
mSuggestPuncs = res.getString(R.string.suggested_punctuations); mSuggestPuncs = res.getString(R.string.suggested_punctuations);
// TODO: it would be nice not to recreate this each time we change the configuration // 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)); return mWordSeparators.contains(String.valueOf((char)code));
} }
public boolean isSymbolExcludedFromWordSeparators(int code) {
return mSymbolsExcludedFromWordSeparators.contains(String.valueOf((char)code));
}
public boolean isMagicSpaceStripper(int code) { public boolean isMagicSpaceStripper(int code) {
return mMagicSpaceStrippers.contains(String.valueOf((char)code)); return mMagicSpaceStrippers.contains(String.valueOf((char)code));
} }