* commit '653546a618126ed6cdf154b68cc2faf000789d61': Resolve an old TODO.
This commit is contained in:
commit
51ca9f9aca
4 changed files with 37 additions and 30 deletions
|
@ -39,6 +39,7 @@ import com.android.inputmethod.latin.R;
|
|||
import com.android.inputmethod.latin.RichInputMethodManager;
|
||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||
import com.android.inputmethod.latin.WordComposer;
|
||||
import com.android.inputmethod.latin.settings.Settings;
|
||||
import com.android.inputmethod.latin.settings.SettingsValues;
|
||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||
import com.android.inputmethod.latin.utils.ScriptUtils;
|
||||
|
@ -61,7 +62,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
private KeyboardLayoutSet mKeyboardLayoutSet;
|
||||
// TODO: The following {@link KeyboardTextsSet} should be in {@link KeyboardLayoutSet}.
|
||||
private final KeyboardTextsSet mKeyboardTextsSet = new KeyboardTextsSet();
|
||||
private SettingsValues mCurrentSettingsValues;
|
||||
|
||||
private KeyboardTheme mKeyboardTheme;
|
||||
private Context mThemeContext;
|
||||
|
@ -121,7 +121,6 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
|
||||
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
|
||||
mKeyboardLayoutSet = builder.build();
|
||||
mCurrentSettingsValues = settingsValues;
|
||||
try {
|
||||
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState);
|
||||
mKeyboardTextsSet.setLocale(mSubtypeSwitcher.getCurrentSubtypeLocale(), mThemeContext);
|
||||
|
@ -145,22 +144,24 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
|
||||
private void setKeyboard(final Keyboard keyboard) {
|
||||
// Make {@link MainKeyboardView} visible and hide {@link EmojiPalettesView}.
|
||||
setMainKeyboardFrame();
|
||||
final SettingsValues currentSettingsValues = Settings.getInstance().getCurrent();
|
||||
setMainKeyboardFrame(currentSettingsValues);
|
||||
// TODO: pass this object to setKeyboard instead of getting the current values.
|
||||
final MainKeyboardView keyboardView = mKeyboardView;
|
||||
final Keyboard oldKeyboard = keyboardView.getKeyboard();
|
||||
keyboardView.setKeyboard(keyboard);
|
||||
mCurrentInputView.setKeyboardTopPadding(keyboard.mTopPadding);
|
||||
keyboardView.setKeyPreviewPopupEnabled(
|
||||
mCurrentSettingsValues.mKeyPreviewPopupOn,
|
||||
mCurrentSettingsValues.mKeyPreviewPopupDismissDelay);
|
||||
currentSettingsValues.mKeyPreviewPopupOn,
|
||||
currentSettingsValues.mKeyPreviewPopupDismissDelay);
|
||||
keyboardView.setKeyPreviewAnimationParams(
|
||||
mCurrentSettingsValues.mHasCustomKeyPreviewAnimationParams,
|
||||
mCurrentSettingsValues.mKeyPreviewShowUpStartXScale,
|
||||
mCurrentSettingsValues.mKeyPreviewShowUpStartYScale,
|
||||
mCurrentSettingsValues.mKeyPreviewShowUpDuration,
|
||||
mCurrentSettingsValues.mKeyPreviewDismissEndXScale,
|
||||
mCurrentSettingsValues.mKeyPreviewDismissEndYScale,
|
||||
mCurrentSettingsValues.mKeyPreviewDismissDuration);
|
||||
currentSettingsValues.mHasCustomKeyPreviewAnimationParams,
|
||||
currentSettingsValues.mKeyPreviewShowUpStartXScale,
|
||||
currentSettingsValues.mKeyPreviewShowUpStartYScale,
|
||||
currentSettingsValues.mKeyPreviewShowUpDuration,
|
||||
currentSettingsValues.mKeyPreviewDismissEndXScale,
|
||||
currentSettingsValues.mKeyPreviewDismissEndYScale,
|
||||
currentSettingsValues.mKeyPreviewDismissDuration);
|
||||
keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
|
||||
final boolean subtypeChanged = (oldKeyboard == null)
|
||||
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
|
||||
|
@ -237,22 +238,13 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
setKeyboard(mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_SYMBOLS));
|
||||
}
|
||||
|
||||
private void setMainKeyboardFrame() {
|
||||
mMainKeyboardFrame.setVisibility(hasHardwareKeyboard() ? View.GONE : View.VISIBLE);
|
||||
private void setMainKeyboardFrame(final SettingsValues settingsValues) {
|
||||
mMainKeyboardFrame.setVisibility(
|
||||
settingsValues.mHasHardwareKeyboard ? View.GONE : View.VISIBLE);
|
||||
mEmojiPalettesView.setVisibility(View.GONE);
|
||||
mEmojiPalettesView.stopEmojiPalettes();
|
||||
}
|
||||
|
||||
// TODO: Move this boolean to a member of {@link SettingsValues} and reset it
|
||||
// at {@link LatinIME#onConfigurationChanged(Configuration)}.
|
||||
public boolean hasHardwareKeyboard() {
|
||||
// Copied from {@link InputMethodServce#onEvaluateInputViewShown()}.
|
||||
final Configuration config = mLatinIME.getResources().getConfiguration();
|
||||
final boolean noHardwareKeyboard = config.keyboard == Configuration.KEYBOARD_NOKEYS
|
||||
|| config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
|
||||
return !noHardwareKeyboard;
|
||||
}
|
||||
|
||||
// Implements {@link KeyboardState.SwitchActions}.
|
||||
@Override
|
||||
public void setEmojiKeyboard() {
|
||||
|
|
|
@ -1075,12 +1075,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
@Override
|
||||
public void onComputeInsets(final InputMethodService.Insets outInsets) {
|
||||
super.onComputeInsets(outInsets);
|
||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||
final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
|
||||
if (visibleKeyboardView == null || !hasSuggestionStripView()) {
|
||||
return;
|
||||
}
|
||||
final int inputHeight = mInputView.getHeight();
|
||||
final boolean hasHardwareKeyboard = mKeyboardSwitcher.hasHardwareKeyboard();
|
||||
final boolean hasHardwareKeyboard = settingsValues.mHasHardwareKeyboard;
|
||||
if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) {
|
||||
// If there is a hardware keyboard and a visible software keyboard view has been hidden,
|
||||
// no visual element will be shown on the screen.
|
||||
|
@ -1116,7 +1117,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
@Override
|
||||
public boolean onShowInputRequested(final int flags, final boolean configChange) {
|
||||
if ((flags & InputMethod.SHOW_EXPLICIT) == 0 && mKeyboardSwitcher.hasHardwareKeyboard()) {
|
||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||
if ((flags & InputMethod.SHOW_EXPLICIT) == 0 && settingsValues.mHasHardwareKeyboard) {
|
||||
// Even when IME is implicitly shown and physical keyboard is connected, we should
|
||||
// show {@link InputView}.
|
||||
// See {@link InputMethodService#onShowInputRequested(int,boolean)}.
|
||||
|
@ -1127,7 +1129,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
|
||||
@Override
|
||||
public boolean onEvaluateFullscreenMode() {
|
||||
if (mKeyboardSwitcher.hasHardwareKeyboard()) {
|
||||
final SettingsValues settingsValues = mSettings.getCurrent();
|
||||
if (settingsValues.mHasHardwareKeyboard) {
|
||||
// If there is a hardware keyboard, disable full screen mode.
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.latin.settings;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -368,6 +369,15 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false);
|
||||
}
|
||||
|
||||
public static boolean readHasHardwareKeyboard(final Configuration conf) {
|
||||
// The standard way of finding out whether we have a hardware keyboard. This code is taken
|
||||
// from InputMethodService#onEvaluateInputShown, which canonically determines this.
|
||||
// In a nutshell, we have a keyboard if the configuration says the type of hardware keyboard
|
||||
// is NOKEYS and if it's not hidden (e.g. folded inside the device).
|
||||
return conf.keyboard != Configuration.KEYBOARD_NOKEYS
|
||||
&& conf.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES;
|
||||
}
|
||||
|
||||
public static boolean isInternal(final SharedPreferences prefs) {
|
||||
return prefs.getBoolean(PREF_KEY_IS_INTERNAL, false);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,10 @@ public class SettingsValues {
|
|||
public final SpacingAndPunctuations mSpacingAndPunctuations;
|
||||
public final int mDelayInMillisecondsToUpdateOldSuggestions;
|
||||
public final long mDoubleSpacePeriodTimeout;
|
||||
|
||||
// From configuration:
|
||||
public final Locale mLocale;
|
||||
public final boolean mHasHardwareKeyboard;
|
||||
public final int mDisplayOrientation;
|
||||
// From preferences, in the same order as xml/prefs.xml:
|
||||
public final boolean mAutoCap;
|
||||
public final boolean mVibrateOn;
|
||||
|
@ -74,7 +77,6 @@ public class SettingsValues {
|
|||
public final boolean mSlidingKeyInputPreviewEnabled;
|
||||
public final boolean mPhraseGestureEnabled;
|
||||
public final int mKeyLongpressTimeout;
|
||||
public final Locale mLocale;
|
||||
public final boolean mEnableMetricsLogging;
|
||||
public final boolean mShouldShowUiToAcceptTypedWord;
|
||||
|
||||
|
@ -89,7 +91,6 @@ public class SettingsValues {
|
|||
public final float mAutoCorrectionThreshold;
|
||||
public final boolean mAutoCorrectionEnabledPerUserSettings;
|
||||
private final boolean mSuggestionsEnabledPerUserSettings;
|
||||
public final int mDisplayOrientation;
|
||||
private final AsyncResultHolder<AppWorkaroundsUtils> mAppWorkarounds;
|
||||
|
||||
// Setting values for additional features
|
||||
|
@ -153,6 +154,7 @@ public class SettingsValues {
|
|||
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
|
||||
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
|
||||
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
|
||||
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());
|
||||
mEnableMetricsLogging = prefs.getBoolean(Settings.PREF_ENABLE_METRICS_LOGGING, true);
|
||||
mShouldShowUiToAcceptTypedWord = Settings.HAS_UI_TO_ACCEPT_TYPED_WORD
|
||||
&& prefs.getBoolean(DebugSettings.PREF_SHOW_UI_TO_ACCEPT_TYPED_WORD, true);
|
||||
|
|
Loading…
Reference in a new issue