Move a settings method to SettingsValues (B3)

Change-Id: Ibfa27bd919c92be219c4d107b3ace008ca80a19f
This commit is contained in:
Jean Chalard 2012-06-12 10:00:07 +09:00
parent 8b538807a3
commit fe53e5c060
2 changed files with 16 additions and 18 deletions

View file

@ -828,7 +828,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/ */
@Override @Override
public void onExtractedTextClicked() { public void onExtractedTextClicked() {
if (isSuggestionsRequested()) return; if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) return;
super.onExtractedTextClicked(); super.onExtractedTextClicked();
} }
@ -844,7 +844,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/ */
@Override @Override
public void onExtractedCursorMovement(int dx, int dy) { public void onExtractedCursorMovement(int dx, int dy) {
if (isSuggestionsRequested()) return; if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) return;
super.onExtractedCursorMovement(dx, dy); super.onExtractedCursorMovement(dx, dy);
} }
@ -1449,7 +1449,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
} }
} }
if (isSuggestionsRequested()) { if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(); restartSuggestionsOnWordBeforeCursorIfAtEndOfWord();
} }
} }
@ -1494,7 +1494,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// thread here. // thread here.
if (!isComposingWord && (isAlphabet(primaryCode) if (!isComposingWord && (isAlphabet(primaryCode)
|| mCurrentSettings.isSymbolExcludedFromWordSeparators(primaryCode)) || mCurrentSettings.isSymbolExcludedFromWordSeparators(primaryCode))
&& isSuggestionsRequested() && && mCurrentSettings.isSuggestionsRequested(mDisplayOrientation) &&
!mConnection.isCursorTouchingWord(mCurrentSettings)) { !mConnection.isCursorTouchingWord(mCurrentSettings)) {
// Reset entirely the composing state anyway, then start composing a new word unless // Reset entirely the composing state anyway, then start composing a new word unless
// the character is a single quote. The idea here is, single quote is not a // the character is a single quote. The idea here is, single quote is not a
@ -1576,7 +1576,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
sendKeyCodePoint(primaryCode); sendKeyCodePoint(primaryCode);
if (Keyboard.CODE_SPACE == primaryCode) { if (Keyboard.CODE_SPACE == primaryCode) {
if (isSuggestionsRequested()) { if (mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) {
if (maybeDoubleSpace()) { if (maybeDoubleSpace()) {
mSpaceState = SPACE_STATE_DOUBLE; mSpaceState = SPACE_STATE_DOUBLE;
} else if (!isShowingPunctuationList()) { } else if (!isShowingPunctuationList()) {
@ -1627,13 +1627,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
inputView.closing(); inputView.closing();
} }
public boolean isSuggestionsRequested() {
// TODO: move this method to mCurrentSettings
return mCurrentSettings.isSuggestionStripRequestedByTextField()
&& (mCurrentSettings.isCorrectionOn()
|| mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation));
}
public boolean isShowingPunctuationList() { public boolean isShowingPunctuationList() {
if (mSuggestionsView == null) return false; if (mSuggestionsView == null) return false;
return mCurrentSettings.mSuggestPuncList == mSuggestionsView.getSuggestions(); return mCurrentSettings.mSuggestPuncList == mSuggestionsView.getSuggestions();
@ -1648,7 +1641,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return false; return false;
if (mCurrentSettings.isApplicationSpecifiedCompletionsOn()) if (mCurrentSettings.isApplicationSpecifiedCompletionsOn())
return true; return true;
return isSuggestionsRequested(); return mCurrentSettings.isSuggestionsRequested(mDisplayOrientation);
} }
public void switchToKeyboardView() { public void switchToKeyboardView() {
@ -1697,7 +1690,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void updateSuggestions() { public void updateSuggestions() {
// Check if we have a suggestion engine attached. // Check if we have a suggestion engine attached.
if ((mSuggest == null || !isSuggestionsRequested())) { if ((mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation))) {
if (mWordComposer.isComposingWord()) { if (mWordComposer.isComposingWord()) {
Log.w(TAG, "Called updateSuggestions but suggestions were not requested!"); Log.w(TAG, "Called updateSuggestions but suggestions were not requested!");
mWordComposer.setAutoCorrection(mWordComposer.getTypedWord()); mWordComposer.setAutoCorrection(mWordComposer.getTypedWord());
@ -1926,7 +1919,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
public void updateBigramPredictions() { public void updateBigramPredictions() {
if (mSuggest == null || !isSuggestionsRequested()) if (mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation))
return; return;
if (!mCurrentSettings.mBigramPredictionEnabled) { if (!mCurrentSettings.mBigramPredictionEnabled) {
@ -2225,8 +2218,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard(); final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1; final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
p.println(" Keyboard mode = " + keyboardMode); p.println(" Keyboard mode = " + keyboardMode);
p.println(" mIsSuggestionsStripRequestedByTextField = " p.println(" mIsSuggestionsSuggestionsRequested = "
+ mCurrentSettings.isSuggestionStripRequestedByTextField()); + mCurrentSettings.isSuggestionsRequested(mDisplayOrientation));
p.println(" mCorrectionMode=" + mCurrentSettings.mCorrectionMode); p.println(" mCorrectionMode=" + mCurrentSettings.mCorrectionMode);
p.println(" isComposingWord=" + mWordComposer.isComposingWord()); p.println(" isComposingWord=" + mWordComposer.isComposingWord());
p.println(" isCorrectionOn=" + mCurrentSettings.isCorrectionOn()); p.println(" isCorrectionOn=" + mCurrentSettings.isCorrectionOn());

View file

@ -238,10 +238,15 @@ public class SettingsValues {
return mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT; return mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT;
} }
public boolean isSuggestionStripRequestedByTextField() { private boolean isSuggestionStripRequestedByTextField() {
return mInputAttributes.mIsSettingsSuggestionStripOn; return mInputAttributes.mIsSettingsSuggestionStripOn;
} }
public boolean isSuggestionsRequested(final int displayOrientation) {
return isSuggestionStripRequestedByTextField()
&& (isCorrectionOn() || isSuggestionStripVisibleInOrientation(displayOrientation));
}
public boolean isCorrectionOn() { public boolean isCorrectionOn() {
return mCorrectionMode == Suggest.CORRECTION_FULL return mCorrectionMode == Suggest.CORRECTION_FULL
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM; || mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM;