[IL24] Move mDisplayOrientation to SettingsValues.

Bug: 8636060
Change-Id: Id57ced0cca9dc9e5e85c3a53683588feb28c1402
This commit is contained in:
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 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.
private BroadcastReceiver mDictionaryPackInstallReceiver =
new DictionaryPackInstallBroadcastReceiver(this);
@ -485,7 +481,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.getInstance().init(this, mKeyboardSwitcher, mInputLogic.mSuggest);
}
mDisplayOrientation = getResources().getConfiguration().orientation;
// Register to receive ringer mode change and network state change.
// Also receive installation and removal of a dictionary pack.
@ -609,8 +604,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onConfigurationChanged(final Configuration conf) {
// If orientation changed while predicting, commit the change
if (mDisplayOrientation != conf.orientation) {
mDisplayOrientation = conf.orientation;
final SettingsValues settingsValues = mSettings.getCurrent();
if (settingsValues.mDisplayOrientation != conf.orientation) {
mHandler.startOrientationChanging();
mInputLogic.mConnection.beginBatchEdit();
mInputLogic.commitTyped(mSettings.getCurrent(), LastComposedWord.NOT_A_SEPARATOR);
@ -789,9 +784,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
canReachInputConnection = true;
}
if (isDifferentTextField ||
!currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
loadSettings();
}
if (isDifferentTextField) {
mainKeyboardView.closing();
loadSettings();
currentSettingsValues = mSettings.getCurrent();
if (suggest != null && currentSettingsValues.mCorrectionEnabled) {
@ -1040,7 +1038,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/
@Override
public void onExtractedTextClicked() {
if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) return;
if (mSettings.getCurrent().isSuggestionsRequested()) {
return;
}
super.onExtractedTextClicked();
}
@ -1056,7 +1056,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
*/
@Override
public void onExtractedCursorMovement(final int dx, final int dy) {
if (mSettings.getCurrent().isSuggestionsRequested(mDisplayOrientation)) return;
if (mSettings.getCurrent().isSuggestionsRequested()) {
return;
}
super.onExtractedCursorMovement(dx, dy);
}
@ -1634,11 +1636,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return true;
if (null == currentSettings)
return false;
if (!currentSettings.isSuggestionStripVisibleInOrientation(mDisplayOrientation))
if (!currentSettings.isSuggestionStripVisible())
return false;
if (currentSettings.isApplicationSpecifiedCompletionsOn())
return true;
return currentSettings.isSuggestionsRequested(mDisplayOrientation);
return currentSettings.isSuggestionsRequested();
}
public void dismissAddToDictionaryHint() {
@ -2278,8 +2280,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final int keyboardMode = keyboard != null ? keyboard.mId.mMode : -1;
p.println(" Keyboard mode = " + keyboardMode);
final SettingsValues settingsValues = mSettings.getCurrent();
p.println(" mIsSuggestionsRequested = "
+ settingsValues.isSuggestionsRequested(mDisplayOrientation));
p.println(" mIsSuggestionsRequested = " + settingsValues.isSuggestionsRequested());
p.println(" mCorrectionEnabled=" + settingsValues.mCorrectionEnabled);
p.println(" isComposingWord=" + mInputLogic.mWordComposer.isComposingWord());
p.println(" mSoundOn=" + settingsValues.mSoundOn);

View file

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

View file

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