Handle non word separators correctly even for the initial letter of a word
bug: 5101114 Change-Id: I0d804c9a500ff000dc06cadad46a2c6c6b8088b2main
parent
bb12dc455b
commit
3889462439
|
@ -25,5 +25,5 @@
|
|||
<!-- Symbols that should promote magic spaces into real space -->
|
||||
<string name="magic_space_promoting_symbols">;:!?([*&@{<>+=|</string>
|
||||
<!-- Symbols that do NOT separate words -->
|
||||
<string name="non_word_separator_symbols">\u0027</string>
|
||||
<string name="symbols_excluded_from_word_separators">\u0027</string>
|
||||
</resources>
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<!-- Symbols that do NOT separate words -->
|
||||
<string name="non_word_separator_symbols"></string>
|
||||
<string name="symbols_excluded_from_word_separators"></string>
|
||||
</resources>
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
<!-- Symbols that should convert magic spaces into real space -->
|
||||
<string name="magic_space_promoting_symbols">([*&@{<>+=|</string>
|
||||
<!-- 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:
|
||||
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! -->
|
||||
<string name="label_to_more_symbol_key">= \\ <</string>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue