[IL24] Move mDisplayOrientation to SettingsValues.

Bug: 8636060
Change-Id: Id57ced0cca9dc9e5e85c3a53683588feb28c1402
main
Jean Chalard 2013-12-20 16:34:38 +09:00
parent a22a63f3b1
commit aa161eb371
3 changed files with 30 additions and 25 deletions

View File

@ -137,10 +137,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mUseOnlyPersonalizationDictionaryForDebug = false; private boolean mUseOnlyPersonalizationDictionaryForDebug = false;
private boolean mBoostPersonalizationDictionaryForDebug = false; private boolean mBoostPersonalizationDictionaryForDebug = false;
// Member variable for remembering the current device orientation.
// TODO[IL]: Move this to SettingsValues.
public int mDisplayOrientation;
// Object for reacting to adding/removing a dictionary pack. // Object for reacting to adding/removing a dictionary pack.
private BroadcastReceiver mDictionaryPackInstallReceiver = private BroadcastReceiver mDictionaryPackInstallReceiver =
new DictionaryPackInstallBroadcastReceiver(this); new DictionaryPackInstallBroadcastReceiver(this);
@ -485,7 +481,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.getInstance().init(this, mKeyboardSwitcher, mInputLogic.mSuggest); ResearchLogger.getInstance().init(this, mKeyboardSwitcher, mInputLogic.mSuggest);
} }
mDisplayOrientation = getResources().getConfiguration().orientation;
// Register to receive ringer mode change and network state change. // Register to receive ringer mode change and network state change.
// Also receive installation and removal of a dictionary pack. // Also receive installation and removal of a dictionary pack.
@ -609,8 +604,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override @Override
public void onConfigurationChanged(final Configuration conf) { public void onConfigurationChanged(final Configuration conf) {
// If orientation changed while predicting, commit the change // If orientation changed while predicting, commit the change
if (mDisplayOrientation != conf.orientation) { final SettingsValues settingsValues = mSettings.getCurrent();
mDisplayOrientation = conf.orientation; if (settingsValues.mDisplayOrientation != conf.orientation) {
mHandler.startOrientationChanging(); mHandler.startOrientationChanging();
mInputLogic.mConnection.beginBatchEdit(); mInputLogic.mConnection.beginBatchEdit();
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR); mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
@ -789,9 +784,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
canReachInputConnection = true; canReachInputConnection = true;
} }
if (isDifferentTextField ||
!currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
loadSettings();
}
if (isDifferentTextField) { if (isDifferentTextField) {
mainKeyboardView.closing(); mainKeyboardView.closing();
loadSettings();
currentSettingsValues = mSettings.getCurrent(); currentSettingsValues = mSettings.getCurrent();
if (suggest != null && currentSettingsValues.mCorrectionEnabled) { if (suggest != null && currentSettingsValues.mCorrectionEnabled) {
@ -1040,7 +1038,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/ */
@Override @Override
public void onExtractedTextClicked() { public void onExtractedTextClicked() {
if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) return; if (mSettings.getCurrent().isSuggestionsRequested()) {
return;
}
super.onExtractedTextClicked(); super.onExtractedTextClicked();
} }
@ -1056,7 +1056,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/ */
@Override @Override
public void onExtractedCursorMovement(final int dx, final int dy) { public void onExtractedCursorMovement(final int dx, final int dy) {
if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) return; if (mSettings.getCurrent().isSuggestionsRequested()) {
return;
}
super.onExtractedCursorMovement(dx, dy); super.onExtractedCursorMovement(dx, dy);
} }
@ -1634,11 +1636,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return true; return true;
if (null == currentSettings) if (null == currentSettings)
return false; return false;
if (!currentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation)) if (!currentSettings.isSuggestionStripVisible())
return false; return false;
if (currentSettings.isApplicationSpecifiedCompletionsOn()) if (currentSettings.isApplicationSpecifiedCompletionsOn())
return true; return true;
return currentSettings.isSuggestionsRequested(mDisplayOrientation); return currentSettings.isSuggestionsRequested();
} }
public void dismissAddToDictionaryHint() { public void dismissAddToDictionaryHint() {
@ -2278,8 +2280,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
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);
final SettingsValues settingsValues = mSettings.getCurrent(); final SettingsValues settingsValues = mSettings.getCurrent();
p.println(" mIsSuggestionsRequested = " p.println(" mIsSuggestionsRequested = " + settingsValues.isSuggestionsRequested());
+ settingsValues.isSuggestionsRequested(mDisplayOrientation));
p.println(" mCorrectionEnabled=" + settingsValues.mCorrectionEnabled); p.println(" mCorrectionEnabled=" + settingsValues.mCorrectionEnabled);
p.println(" isComposingWord=" + mInputLogic.mWordComposer.isComposingWord()); p.println(" isComposingWord=" + mInputLogic.mWordComposer.isComposingWord());
p.println(" mSoundOn=" + settingsValues.mSoundOn); p.println(" mSoundOn=" + settingsValues.mSoundOn);

View File

@ -389,7 +389,7 @@ public final class InputLogic {
// a letter or a word connector. // a letter or a word connector.
&& settingsValues.isWordCodePoint(codePoint) && settingsValues.isWordCodePoint(codePoint)
// We never go into composing state if suggestions are not requested. // We never go into composing state if suggestions are not requested.
&& settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation) && && settingsValues.isSuggestionsRequested() &&
// In languages with spaces, we only start composing a word when we are not already // In languages with spaces, we only start composing a word when we are not already
// touching a word. In languages without spaces, the above conditions are sufficient. // touching a word. In languages without spaces, the above conditions are sufficient.
(!mConnection.isCursorTouchingWord(settingsValues) (!mConnection.isCursorTouchingWord(settingsValues)
@ -493,7 +493,7 @@ public final class InputLogic {
} }
if (Constants.CODE_SPACE == codePoint) { if (Constants.CODE_SPACE == codePoint) {
if (settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)) { if (settingsValues.isSuggestionsRequested()) {
if (maybeDoubleSpacePeriod(settingsValues, keyboardSwitcher, handler)) { if (maybeDoubleSpacePeriod(settingsValues, keyboardSwitcher, handler)) {
mSpaceState = SpaceState.DOUBLE; mSpaceState = SpaceState.DOUBLE;
} else if (!mLatinIME.isShowingPunctuationList()) { } else if (!mLatinIME.isShowingPunctuationList()) {
@ -674,8 +674,7 @@ public final class InputLogic {
} }
} }
} }
// TODO: move mDisplayOrientation to CurrentSettings. if (settingsValues.isSuggestionsRequested()
if (settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)
&& settingsValues.mCurrentLanguageHasSpaces) { && settingsValues.mCurrentLanguageHasSpaces) {
restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(settingsValues, keyboardSwitcher, restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(settingsValues, keyboardSwitcher,
handler); handler);
@ -893,8 +892,7 @@ public final class InputLogic {
handler.cancelUpdateSuggestionStrip(); handler.cancelUpdateSuggestionStrip();
// Check if we have a suggestion engine attached. // Check if we have a suggestion engine attached.
if (mSuggest == null if (mSuggest == null || !settingsValues.isSuggestionsRequested()) {
|| !settingsValues.isSuggestionsRequested(mLatinIME.mDisplayOrientation)) {
if (mWordComposer.isComposingWord()) { if (mWordComposer.isComposingWord()) {
Log.w(TAG, "Called updateSuggestionsOrPredictions but suggestions were not " Log.w(TAG, "Called updateSuggestionsOrPredictions but suggestions were not "
+ "requested!"); + "requested!");

View File

@ -101,6 +101,7 @@ public final class SettingsValues {
public final int mSuggestionVisibility; public final int mSuggestionVisibility;
public final boolean mBoostPersonalizationDictionaryForDebug; public final boolean mBoostPersonalizationDictionaryForDebug;
public final boolean mUseOnlyPersonalizationDictionaryForDebug; public final boolean mUseOnlyPersonalizationDictionaryForDebug;
public final int mDisplayOrientation;
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds; private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
// Setting values for additional features // Setting values for additional features
@ -184,6 +185,7 @@ public final class SettingsValues {
Settings.readBoostPersonalizationDictionaryForDebug(prefs); Settings.readBoostPersonalizationDictionaryForDebug(prefs);
mUseOnlyPersonalizationDictionaryForDebug = mUseOnlyPersonalizationDictionaryForDebug =
Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs); Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
mDisplayOrientation = res.getConfiguration().orientation;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>(); mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo( final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
mInputAttributes.mTargetApplicationPackageName); mInputAttributes.mTargetApplicationPackageName);
@ -241,6 +243,7 @@ public final class SettingsValues {
mIsInternal = false; mIsInternal = false;
mBoostPersonalizationDictionaryForDebug = false; mBoostPersonalizationDictionaryForDebug = false;
mUseOnlyPersonalizationDictionaryForDebug = false; mUseOnlyPersonalizationDictionaryForDebug = false;
mDisplayOrientation = Configuration.ORIENTATION_PORTRAIT;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>(); mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>();
mAppWorkarounds.set(null); mAppWorkarounds.set(null);
} }
@ -254,16 +257,15 @@ public final class SettingsValues {
return mInputAttributes.mApplicationSpecifiedCompletionOn; return mInputAttributes.mApplicationSpecifiedCompletionOn;
} }
public boolean isSuggestionsRequested(final int displayOrientation) { public boolean isSuggestionsRequested() {
return mInputAttributes.mIsSettingsSuggestionStripOn return mInputAttributes.mIsSettingsSuggestionStripOn
&& (mCorrectionEnabled && (mCorrectionEnabled || isSuggestionStripVisible());
|| isSuggestionStripVisibleInOrientation(displayOrientation));
} }
public boolean isSuggestionStripVisibleInOrientation(final int orientation) { public boolean isSuggestionStripVisible() {
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
&& orientation == Configuration.ORIENTATION_PORTRAIT); && mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT);
} }
public boolean isWordSeparator(final int code) { public boolean isWordSeparator(final int code) {
@ -306,6 +308,10 @@ public final class SettingsValues {
return mInputAttributes.isSameInputType(editorInfo); return mInputAttributes.isSameInputType(editorInfo);
} }
public boolean hasSameOrientation(final Configuration configuration) {
return mDisplayOrientation == configuration.orientation;
}
public boolean isBeforeJellyBean() { public boolean isBeforeJellyBean() {
final AppWorkaroundsUtils appWorkaroundUtils final AppWorkaroundsUtils appWorkaroundUtils
= mAppWorkarounds.get(null, TIMEOUT_TO_GET_TARGET_PACKAGE); = mAppWorkarounds.get(null, TIMEOUT_TO_GET_TARGET_PACKAGE);