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