Rename resources to reflect current usage
Bug: 6010403 Change-Id: Ia02ff31007296fdf6901504f238dfd9e4621f658main
parent
8a3d369840
commit
b141c9cd3f
|
@ -20,17 +20,17 @@
|
|||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<!-- Symbols that are suggested between words -->
|
||||
<string name="suggested_punctuations">!,?,\\,,:,;,\",(,),\',-,/,@,_</string>
|
||||
<!-- Symbols that should be swapped with a magic space -->
|
||||
<string name="magic_space_swapping_symbols">.,;:!?)]}\"</string>
|
||||
<!-- Symbols that should strip a magic space -->
|
||||
<string name="magic_space_stripping_symbols">"	 \n/_\'-"</string>
|
||||
<!-- Symbols that should convert magic spaces into real space -->
|
||||
<string name="magic_space_promoting_symbols">([*&@{<>+=|</string>
|
||||
<!-- Symbols that should be swapped with a weak space -->
|
||||
<string name="weak_space_swapping_symbols">.,;:!?)]}\"</string>
|
||||
<!-- Symbols that should strip a weak space -->
|
||||
<string name="weak_space_stripping_symbols">"	 \n/_\'-"</string>
|
||||
<!-- Symbols that should convert weak spaces into real space -->
|
||||
<string name="weak_space_promoting_symbols">([*&@{<>+=|</string>
|
||||
<!-- Symbols that do NOT separate words -->
|
||||
<string name="symbols_excluded_from_word_separators">\'-</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 \ symbols_excluded_from_word_separators -->
|
||||
weak_space_swapping_symbols | weak_space_stripping_symbols
|
||||
\ symbols_excluded_from_word_separators -->
|
||||
<!-- Symbol characters list that should switch back to the main layout -->
|
||||
<!-- U+2018: "‘" LEFT SINGLE QUOTATION MARK
|
||||
U+2019: "’" RIGHT SINGLE QUOTATION MARK
|
||||
|
|
|
@ -165,8 +165,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
// Double space: the state where the user pressed space twice quickly, which LatinIME
|
||||
// resolved as period-space. Undoing this converts the period to a space.
|
||||
private static final int SPACE_STATE_DOUBLE = 1;
|
||||
// Swap punctuation: the state where a (weak or magic) space and a punctuation from the
|
||||
// suggestion strip have just been swapped. Undoing this swaps them back.
|
||||
// Swap punctuation: the state where a weak space and a punctuation from the suggestion strip
|
||||
// have just been swapped. Undoing this swaps them back; the space is still considered weak.
|
||||
private static final int SPACE_STATE_SWAP_PUNCTUATION = 2;
|
||||
// Weak space: a space that should be swapped only by suggestion strip punctuation. Weak
|
||||
// spaces happen when the user presses space, accepting the current suggestion (whether
|
||||
|
@ -1527,10 +1527,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
} else if ((SPACE_STATE_WEAK == spaceState
|
||||
|| SPACE_STATE_SWAP_PUNCTUATION == spaceState)
|
||||
&& isFromSuggestionStrip) {
|
||||
if (mSettingsValues.isMagicSpaceSwapper(code)) {
|
||||
if (mSettingsValues.isWeakSpaceSwapper(code)) {
|
||||
return true;
|
||||
} else {
|
||||
if (mSettingsValues.isMagicSpaceStripper(code)) {
|
||||
if (mSettingsValues.isWeakSpaceStripper(code)) {
|
||||
removeTrailingSpaceWhileInBatchEdit(ic);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -35,8 +35,8 @@ public class SettingsValues {
|
|||
|
||||
// From resources:
|
||||
public final int mDelayUpdateOldSuggestions;
|
||||
public final String mMagicSpaceStrippers;
|
||||
public final String mMagicSpaceSwappers;
|
||||
public final String mWeakSpaceStrippers;
|
||||
public final String mWeakSpaceSwappers;
|
||||
private final String mSuggestPuncs;
|
||||
public final SuggestedWords mSuggestPuncList;
|
||||
public final SuggestedWords mSuggestPuncOutputTextList;
|
||||
|
@ -89,14 +89,14 @@ public class SettingsValues {
|
|||
|
||||
// Get the resources
|
||||
mDelayUpdateOldSuggestions = res.getInteger(R.integer.config_delay_update_old_suggestions);
|
||||
mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols);
|
||||
mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols);
|
||||
mWeakSpaceStrippers = res.getString(R.string.weak_space_stripping_symbols);
|
||||
mWeakSpaceSwappers = res.getString(R.string.weak_space_swapping_symbols);
|
||||
if (LatinImeLogger.sDBG) {
|
||||
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.");
|
||||
final int length = mWeakSpaceStrippers.length();
|
||||
for (int i = 0; i < length; i = mWeakSpaceStrippers.offsetByCodePoints(i, 1)) {
|
||||
if (isWeakSpaceSwapper(mWeakSpaceStrippers.codePointAt(i))) {
|
||||
throw new RuntimeException("Char code " + mWeakSpaceStrippers.codePointAt(i)
|
||||
+ " is both a weak space swapper and stripper.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class SettingsValues {
|
|||
mSuggestPuncOutputTextList = createSuggestPuncOutputTextList(suggestPuncsSpec);
|
||||
mSymbolsExcludedFromWordSeparators =
|
||||
res.getString(R.string.symbols_excluded_from_word_separators);
|
||||
mWordSeparators = createWordSeparators(mMagicSpaceStrippers, mMagicSpaceSwappers,
|
||||
mWordSeparators = createWordSeparators(mWeakSpaceStrippers, mWeakSpaceSwappers,
|
||||
mSymbolsExcludedFromWordSeparators, res);
|
||||
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
||||
|
||||
|
@ -188,11 +188,11 @@ public class SettingsValues {
|
|||
return builder.setIsPunctuationSuggestions().build();
|
||||
}
|
||||
|
||||
private static String createWordSeparators(final String magicSpaceStrippers,
|
||||
final String magicSpaceSwappers, final String symbolsExcludedFromWordSeparators,
|
||||
private static String createWordSeparators(final String weakSpaceStrippers,
|
||||
final String weakSpaceSwappers, final String symbolsExcludedFromWordSeparators,
|
||||
final Resources res) {
|
||||
String wordSeparators = magicSpaceStrippers + magicSpaceSwappers
|
||||
+ res.getString(R.string.magic_space_promoting_symbols);
|
||||
String wordSeparators = weakSpaceStrippers + weakSpaceSwappers
|
||||
+ res.getString(R.string.weak_space_promoting_symbols);
|
||||
for (int i = symbolsExcludedFromWordSeparators.length() - 1; i >= 0; --i) {
|
||||
wordSeparators = wordSeparators.replace(
|
||||
symbolsExcludedFromWordSeparators.substring(i, i + 1), "");
|
||||
|
@ -215,14 +215,14 @@ public class SettingsValues {
|
|||
return mSymbolsExcludedFromWordSeparators.contains(String.valueOf((char)code));
|
||||
}
|
||||
|
||||
public boolean isMagicSpaceStripper(int code) {
|
||||
public boolean isWeakSpaceStripper(int code) {
|
||||
// TODO: this does not work if the code does not fit in a char
|
||||
return mMagicSpaceStrippers.contains(String.valueOf((char)code));
|
||||
return mWeakSpaceStrippers.contains(String.valueOf((char)code));
|
||||
}
|
||||
|
||||
public boolean isMagicSpaceSwapper(int code) {
|
||||
public boolean isWeakSpaceSwapper(int code) {
|
||||
// TODO: this does not work if the code does not fit in a char
|
||||
return mMagicSpaceSwappers.contains(String.valueOf((char)code));
|
||||
return mWeakSpaceSwappers.contains(String.valueOf((char)code));
|
||||
}
|
||||
|
||||
private static boolean isAutoCorrectEnabled(final Resources resources,
|
||||
|
|
Loading…
Reference in New Issue