Move final attributes to SettingsValues (B2)

Bug: 6675475
Bug: 6677394
Change-Id: I4a26efb9226d3f909f331c4d2e47cd83a05c011e
This commit is contained in:
Jean Chalard 2012-06-12 09:35:51 +09:00
parent 6ebd93951f
commit dca729fddd
2 changed files with 62 additions and 36 deletions

View file

@ -872,7 +872,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions); ResearchLogger.latinIME_onDisplayCompletions(applicationSpecifiedCompletions);
} }
if (null != mInputAttributes && mInputAttributes.mApplicationSpecifiedCompletionOn) { if (!mCurrentSettings.isApplicationSpecifiedCompletionsOn()) return;
mApplicationSpecifiedCompletions = applicationSpecifiedCompletions; mApplicationSpecifiedCompletions = applicationSpecifiedCompletions;
if (applicationSpecifiedCompletions == null) { if (applicationSpecifiedCompletions == null) {
clearSuggestions(); clearSuggestions();
@ -899,7 +899,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mWordComposer.setAutoCorrection(mWordComposer.getTypedWord()); mWordComposer.setAutoCorrection(mWordComposer.getTypedWord());
setSuggestionStripShown(true); setSuggestionStripShown(true);
} }
}
private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) { private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
// TODO: Modify this if we support suggestions with hard keyboard // TODO: Modify this if we support suggestions with hard keyboard
@ -1277,8 +1276,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
break; break;
default: default:
if (primaryCode == Keyboard.CODE_TAB if (primaryCode == Keyboard.CODE_TAB && mCurrentSettings.isEditorActionNext()) {
&& mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT) {
performEditorAction(EditorInfo.IME_ACTION_NEXT); performEditorAction(EditorInfo.IME_ACTION_NEXT);
break; break;
} }
@ -1628,7 +1626,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public boolean isSuggestionsRequested() { public boolean isSuggestionsRequested() {
// TODO: move this method to mCurrentSettings // TODO: move this method to mCurrentSettings
return (null != mInputAttributes && mInputAttributes.mIsSettingsSuggestionStripOn) return mCurrentSettings.isSuggestionStripRequestedByTextField()
&& (mCurrentSettings.isCorrectionOn() && (mCurrentSettings.isCorrectionOn()
|| mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation)); || mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation));
} }
@ -1645,7 +1643,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return true; return true;
if (!mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation)) if (!mCurrentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation))
return false; return false;
if (null != mInputAttributes && mInputAttributes.mApplicationSpecifiedCompletionOn) if (mCurrentSettings.isApplicationSpecifiedCompletionsOn())
return true; return true;
return isSuggestionsRequested(); return isSuggestionsRequested();
} }
@ -1827,7 +1825,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
} }
if ((null != mInputAttributes && mInputAttributes.mApplicationSpecifiedCompletionOn) if (mCurrentSettings.isApplicationSpecifiedCompletionsOn()
&& mApplicationSpecifiedCompletions != null && mApplicationSpecifiedCompletions != null
&& index >= 0 && index < mApplicationSpecifiedCompletions.length) { && index >= 0 && index < mApplicationSpecifiedCompletions.length) {
if (mSuggestionsView != null) { if (mSuggestionsView != null) {
@ -2224,13 +2222,14 @@ 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(" mIsSuggestionsRequested=" + mInputAttributes.mIsSettingsSuggestionStripOn); p.println(" mIsSuggestionsStripRequestedByTextField = "
+ mCurrentSettings.isSuggestionStripRequestedByTextField());
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());
p.println(" mSoundOn=" + mCurrentSettings.mSoundOn); p.println(" mSoundOn=" + mCurrentSettings.mSoundOn);
p.println(" mVibrateOn=" + mCurrentSettings.mVibrateOn); p.println(" mVibrateOn=" + mCurrentSettings.mVibrateOn);
p.println(" mKeyPreviewPopupOn=" + mCurrentSettings.mKeyPreviewPopupOn); p.println(" mKeyPreviewPopupOn=" + mCurrentSettings.mKeyPreviewPopupOn);
p.println(" mInputAttributes=" + mInputAttributes.toString()); p.println(" inputAttributes=" + mCurrentSettings.getInputAttributesDebugString());
} }
} }

View file

@ -87,6 +87,9 @@ public class SettingsValues {
private final float mKeypressSoundVolumeRawValue; private final float mKeypressSoundVolumeRawValue;
private final InputMethodSubtype[] mAdditionalSubtypes; private final InputMethodSubtype[] mAdditionalSubtypes;
// From the input box
private final InputAttributes mInputAttributes;
// Deduced settings // Deduced settings
public final int mKeypressVibrationDuration; public final int mKeypressVibrationDuration;
public final float mFxVolume; public final float mFxVolume;
@ -125,6 +128,13 @@ public class SettingsValues {
mSymbolsExcludedFromWordSeparators, res); mSymbolsExcludedFromWordSeparators, res);
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary); mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
// Store the input attributes
if (null == inputAttributes) {
mInputAttributes = new InputAttributes(null, false /* isFullscreenMode */);
} else {
mInputAttributes = inputAttributes;
}
// Get the settings preferences // Get the settings preferences
mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true); mAutoCap = prefs.getBoolean(Settings.PREF_AUTO_CAP, true);
mVibrateOn = isVibrateOn(context, prefs, res); mVibrateOn = isVibrateOn(context, prefs, res);
@ -167,7 +177,7 @@ public class SettingsValues {
mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain); mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain);
mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray( mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray(
getPrefAdditionalSubtypes(prefs, res)); getPrefAdditionalSubtypes(prefs, res));
mCorrectionMode = createCorrectionMode(inputAttributes); mCorrectionMode = createCorrectionMode();
mSuggestionVisibility = createSuggestionVisibility(res); mSuggestionVisibility = createSuggestionVisibility(res);
} }
@ -202,9 +212,9 @@ public class SettingsValues {
return wordSeparators; return wordSeparators;
} }
private int createCorrectionMode(final InputAttributes inputAttributes) { private int createCorrectionMode() {
final boolean shouldAutoCorrect = mAutoCorrectEnabled final boolean shouldAutoCorrect = mAutoCorrectEnabled
&& (null == inputAttributes || !inputAttributes.mInputTypeNoAutoCorrect); && !mInputAttributes.mInputTypeNoAutoCorrect;
if (mBigramSuggestionEnabled && shouldAutoCorrect) return Suggest.CORRECTION_FULL_BIGRAM; if (mBigramSuggestionEnabled && shouldAutoCorrect) return Suggest.CORRECTION_FULL_BIGRAM;
return shouldAutoCorrect ? Suggest.CORRECTION_FULL : Suggest.CORRECTION_NONE; return shouldAutoCorrect ? Suggest.CORRECTION_FULL : Suggest.CORRECTION_NONE;
} }
@ -226,6 +236,18 @@ public class SettingsValues {
res.getBoolean(R.bool.config_default_vibration_enabled)); res.getBoolean(R.bool.config_default_vibration_enabled));
} }
public boolean isApplicationSpecifiedCompletionsOn() {
return mInputAttributes.mApplicationSpecifiedCompletionOn;
}
public boolean isEditorActionNext() {
return mInputAttributes.mEditorAction == EditorInfo.IME_ACTION_NEXT;
}
public boolean isSuggestionStripRequestedByTextField() {
return mInputAttributes.mIsSettingsSuggestionStripOn;
}
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;
@ -413,4 +435,9 @@ public class SettingsValues {
final String newStr = Utils.localeAndTimeHashMapToStr(map); final String newStr = Utils.localeAndTimeHashMapToStr(map);
prefs.edit().putString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, newStr).apply(); prefs.edit().putString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, newStr).apply();
} }
// For debug.
public String getInputAttributesDebugString() {
return mInputAttributes.toString();
}
} }