Move two methods in a more appropriate place
Change-Id: I512b04e23490413a44b1ca0517102fe2d9138df3
This commit is contained in:
parent
a32eb27213
commit
2010aad741
3 changed files with 33 additions and 31 deletions
|
@ -1401,7 +1401,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
} else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
||||||
if (revertSwapPunctuation()) {
|
if (mConnection.revertSwapPunctuation()) {
|
||||||
// Likewise
|
// Likewise
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1975,10 +1975,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be
|
// Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be
|
||||||
// adding words in situations where the user or application really didn't
|
// adding words in situations where the user or application really didn't
|
||||||
// want corrections enabled or learned.
|
// want corrections enabled or learned.
|
||||||
if (!(mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_FULL
|
if (!mCurrentSettings.isCorrectionOn()) return null;
|
||||||
|| mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mUserHistoryDictionary != null) {
|
if (mUserHistoryDictionary != null) {
|
||||||
final CharSequence prevWord
|
final CharSequence prevWord
|
||||||
|
@ -2075,32 +2072,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean revertSwapPunctuation() {
|
|
||||||
// Here we test whether we indeed have a space and something else before us. This should not
|
|
||||||
// be needed, but it's there just in case something went wrong.
|
|
||||||
final CharSequence textBeforeCursor = mConnection.getTextBeforeCursor(2, 0);
|
|
||||||
// NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to
|
|
||||||
// enter surrogate pairs this code will have been removed.
|
|
||||||
if (TextUtils.isEmpty(textBeforeCursor)
|
|
||||||
|| (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) {
|
|
||||||
// We may only come here if the application is changing the text while we are typing.
|
|
||||||
// This is quite a broken case, but not logically impossible, so we shouldn't crash,
|
|
||||||
// but some debugging log may be in order.
|
|
||||||
Log.d(TAG, "Tried to revert a swap of punctuation but we didn't "
|
|
||||||
+ "find a space just before the cursor.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mConnection.deleteSurroundingText(2, 0);
|
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
||||||
ResearchLogger.latinIME_deleteSurroundingText(2);
|
|
||||||
}
|
|
||||||
mConnection.commitText(" " + textBeforeCursor.subSequence(0, 1), 1);
|
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
||||||
ResearchLogger.latinIME_revertSwapPunctuation();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWordSeparator(int code) {
|
public boolean isWordSeparator(int code) {
|
||||||
return mCurrentSettings.isWordSeparator(code);
|
return mCurrentSettings.isWordSeparator(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,4 +393,30 @@ public class RichInputConnection {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean revertSwapPunctuation() {
|
||||||
|
// Here we test whether we indeed have a space and something else before us. This should not
|
||||||
|
// be needed, but it's there just in case something went wrong.
|
||||||
|
final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0);
|
||||||
|
// NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to
|
||||||
|
// enter surrogate pairs this code will have been removed.
|
||||||
|
if (TextUtils.isEmpty(textBeforeCursor)
|
||||||
|
|| (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) {
|
||||||
|
// We may only come here if the application is changing the text while we are typing.
|
||||||
|
// This is quite a broken case, but not logically impossible, so we shouldn't crash,
|
||||||
|
// but some debugging log may be in order.
|
||||||
|
Log.d(TAG, "Tried to revert a swap of punctuation but we didn't "
|
||||||
|
+ "find a space just before the cursor.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
deleteSurroundingText(2, 0);
|
||||||
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
ResearchLogger.latinIME_deleteSurroundingText(2);
|
||||||
|
}
|
||||||
|
commitText(" " + textBeforeCursor.subSequence(0, 1), 1);
|
||||||
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
|
ResearchLogger.latinIME_revertSwapPunctuation();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,11 @@ public class SettingsValues {
|
||||||
res.getBoolean(R.bool.config_default_vibration_enabled));
|
res.getBoolean(R.bool.config_default_vibration_enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCorrectionOn() {
|
||||||
|
return mCorrectionMode == Suggest.CORRECTION_FULL
|
||||||
|
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSuggestionStripVisibleInOrientation(final int orientation) {
|
public boolean isSuggestionStripVisibleInOrientation(final int orientation) {
|
||||||
return (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_VALUE)
|
return (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_VALUE)
|
||||||
|| (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_ONLY_PORTRAIT_VALUE
|
|| (mSuggestionVisibility == SUGGESTION_VISIBILITY_SHOW_ONLY_PORTRAIT_VALUE
|
||||||
|
|
Loading…
Reference in a new issue