diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/res/drawable/btn_keyboard_key_popup_action_lxx_dark.xml | 21 | ||||
-rw-r--r-- | java/res/drawable/btn_keyboard_key_popup_action_lxx_light.xml | 21 | ||||
-rw-r--r-- | java/res/layout/more_keys_keyboard_for_action_lxx.xml | 32 | ||||
-rw-r--r-- | java/res/values/attrs.xml | 4 | ||||
-rw-r--r-- | java/res/values/donottranslate-text-decorator.xml | 26 | ||||
-rw-r--r-- | java/res/values/themes-ics.xml | 2 | ||||
-rw-r--r-- | java/res/values/themes-klp.xml | 2 | ||||
-rw-r--r-- | java/res/values/themes-lxx-dark.xml | 10 | ||||
-rw-r--r-- | java/res/values/themes-lxx-light.xml | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/Key.java | 4 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | 40 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/MainKeyboardView.java | 14 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 9 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/settings/Settings.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/settings/SettingsValues.java | 8 |
15 files changed, 164 insertions, 49 deletions
diff --git a/java/res/drawable/btn_keyboard_key_popup_action_lxx_dark.xml b/java/res/drawable/btn_keyboard_key_popup_action_lxx_dark.xml new file mode 100644 index 000000000..8b637f204 --- /dev/null +++ b/java/res/drawable/btn_keyboard_key_popup_action_lxx_dark.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_dark" /> + <item android:drawable="@drawable/btn_keyboard_key_active_lxx_dark" /> +</selector> diff --git a/java/res/drawable/btn_keyboard_key_popup_action_lxx_light.xml b/java/res/drawable/btn_keyboard_key_popup_action_lxx_light.xml new file mode 100644 index 000000000..67fc52144 --- /dev/null +++ b/java/res/drawable/btn_keyboard_key_popup_action_lxx_light.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true" + android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_light" /> + <item android:drawable="@drawable/btn_keyboard_key_active_lxx_light" /> +</selector> diff --git a/java/res/layout/more_keys_keyboard_for_action_lxx.xml b/java/res/layout/more_keys_keyboard_for_action_lxx.xml new file mode 100644 index 000000000..d23faa4f0 --- /dev/null +++ b/java/res/layout/more_keys_keyboard_for_action_lxx.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2014, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" +> + <com.android.inputmethod.keyboard.MoreKeysKeyboardView + android:id="@+id/more_keys_keyboard_view" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + style="?attr/moreKeysKeyboardViewForActionStyle" /> +</LinearLayout> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index fb29e12b8..2e81bdf48 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -32,6 +32,8 @@ <attr name="moreKeysKeyboardStyle" format="reference" /> <!-- MoreKeysKeyboardView style --> <attr name="moreKeysKeyboardViewStyle" format="reference" /> + <!-- MoreKeysKeyboardView style for action key --> + <attr name="moreKeysKeyboardViewForActionStyle" format="reference" /> <!-- Suggestions strip style --> <attr name="suggestionStripViewStyle" format="reference" /> <!-- Suggestion word style --> @@ -119,6 +121,8 @@ <attr name="keyPreviewDismissAnimator" format="reference" /> <!-- Layout resource for more keys keyboard --> <attr name="moreKeysKeyboardLayout" format="reference" /> + <!-- Layout resource for more keys keyboard of action key --> + <attr name="moreKeysKeyboardForActionLayout" format="reference" /> <attr name="backgroundDimAlpha" format="integer" /> <!-- More keys keyboard will shown at touched point. --> <attr name="showMoreKeysKeyboardAtTouchedPoint" format="boolean" /> diff --git a/java/res/values/donottranslate-text-decorator.xml b/java/res/values/donottranslate-text-decorator.xml index a20034930..832610b96 100644 --- a/java/res/values/donottranslate-text-decorator.xml +++ b/java/res/values/donottranslate-text-decorator.xml @@ -61,24 +61,18 @@ <!-- Coordinates of the closed path to be used to render the commit indicator. The format is: X[0], Y[0], X[1], Y[1], ..., X[N-1], Y[N-1] --> <integer-array name="text_decorator_commit_indicator_path"> - <item>240</item> - <item>80</item> - <item>212</item> - <item>108</item> - <item>323</item> - <item>220</item> - <item>80</item> - <item>220</item> - <item>80</item> - <item>260</item> + <item>180</item> <item>323</item> - <item>260</item> - <item>212</item> - <item>372</item> - <item>240</item> - <item>400</item> - <item>400</item> + <item>97</item> <item>240</item> + <item>68</item> + <item>268</item> + <item>180</item> + <item>380</item> + <item>420</item> + <item>140</item> + <item>392</item> + <item>112</item> </integer-array> <!-- Background color to be used to highlight the target text when the add-to-dictionary diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index 42d376ce6..9e656dd74 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -25,7 +25,9 @@ <item name="mainKeyboardViewStyle">@style/MainKeyboardView.ICS</item> <item name="emojiPalettesViewStyle">@style/EmojiPalettesView.ICS</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.ICS</item> + <!-- Note: ICS theme uses the same style for both general more keys and action more keys. --> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.ICS</item> + <item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.ICS</item> <item name="suggestionStripViewStyle">@style/SuggestionStripView.ICS</item> <item name="suggestionWordStyle">@style/SuggestionWord.ICS</item> </style> diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml index a16d643ca..c6319bc4e 100644 --- a/java/res/values/themes-klp.xml +++ b/java/res/values/themes-klp.xml @@ -25,7 +25,9 @@ <item name="mainKeyboardViewStyle">@style/MainKeyboardView.KLP</item> <item name="emojiPalettesViewStyle">@style/EmojiPalettesView.KLP</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.KLP</item> + <!-- Note: KLP theme uses the same style for both general more keys and action more keys. --> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.KLP</item> + <item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.KLP</item> <item name="suggestionStripViewStyle">@style/SuggestionStripView.KLP</item> <item name="suggestionWordStyle">@style/SuggestionWord.KLP</item> </style> diff --git a/java/res/values/themes-lxx-dark.xml b/java/res/values/themes-lxx-dark.xml index a613001ba..76e9d33bf 100644 --- a/java/res/values/themes-lxx-dark.xml +++ b/java/res/values/themes-lxx-dark.xml @@ -26,6 +26,7 @@ <item name="emojiPalettesViewStyle">@style/EmojiPalettesView.LXX_Dark</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.LXX_Dark</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.LXX_Dark</item> + <item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.LXX_Dark.Action</item> <item name="suggestionStripViewStyle">@style/SuggestionStripView.LXX_Dark</item> <item name="suggestionWordStyle">@style/SuggestionWord.LXX_Dark</item> </style> @@ -57,6 +58,7 @@ name="MainKeyboardView.LXX_Dark" parent="KeyboardView.LXX_Dark" > + <item name="moreKeysKeyboardForActionLayout">@layout/more_keys_keyboard_for_action_lxx</item> <item name="keyPreviewBackground">@drawable/keyboard_key_feedback_lxx_dark</item> <item name="keyPreviewOffset">@dimen/config_key_preview_offset_holo</item> <item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item> @@ -106,6 +108,14 @@ <item name="verticalCorrection">@dimen/config_more_keys_keyboard_vertical_correction_holo</item> </style> <style + name="MoreKeysKeyboardView.LXX_Dark.Action" + parent="MoreKeysKeyboardView.LXX_Dark" + > + <item name="android:background">@android:color/transparent</item> + <item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_dark</item> + <item name="divider">@null</item> + </style> + <style name="SuggestionStripView.LXX_Dark" parent="KeyboardView.LXX_Dark" > diff --git a/java/res/values/themes-lxx-light.xml b/java/res/values/themes-lxx-light.xml index 66de27573..5cd84171d 100644 --- a/java/res/values/themes-lxx-light.xml +++ b/java/res/values/themes-lxx-light.xml @@ -26,6 +26,7 @@ <item name="emojiPalettesViewStyle">@style/EmojiPalettesView.LXX_Light</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.LXX_Light</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.LXX_Light</item> + <item name="moreKeysKeyboardViewForActionStyle">@style/MoreKeysKeyboardView.LXX_Light.Action</item> <item name="suggestionStripViewStyle">@style/SuggestionStripView.LXX_Light</item> <item name="suggestionWordStyle">@style/SuggestionWord.LXX_Light</item> </style> @@ -57,6 +58,7 @@ name="MainKeyboardView.LXX_Light" parent="KeyboardView.LXX_Light" > + <item name="moreKeysKeyboardForActionLayout">@layout/more_keys_keyboard_for_action_lxx</item> <item name="keyPreviewBackground">@drawable/keyboard_key_feedback_lxx_light</item> <item name="keyPreviewOffset">@dimen/config_key_preview_offset_holo</item> <item name="keyPreviewShowUpAnimator">@anim/key_preview_show_up_lxx</item> @@ -106,6 +108,14 @@ <item name="verticalCorrection">@dimen/config_more_keys_keyboard_vertical_correction_holo</item> </style> <style + name="MoreKeysKeyboardView.LXX_Light.Action" + parent="MoreKeysKeyboardView.LXX_Light" + > + <item name="android:background">@android:color/transparent</item> + <item name="keyBackground">@drawable/btn_keyboard_key_popup_action_lxx_light</item> + <item name="divider">@null</item> + </style> + <style name="SuggestionStripView.LXX_Light" parent="KeyboardView.LXX_Light" > diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index f7e4d8b10..8548544fd 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -547,6 +547,10 @@ public class Key implements Comparable<Key> { return this instanceof Spacer; } + public final boolean isActionKey() { + return mBackgroundType == BACKGROUND_TYPE_ACTION; + } + public final boolean isShift() { return mCode == CODE_SHIFT; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index ec089f7eb..e4875164a 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -38,6 +38,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; @@ -60,7 +61,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; @@ -120,7 +120,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); @@ -144,22 +143,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); @@ -236,22 +237,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() { diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index c73f08498..6d0b2c2f1 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -89,6 +89,7 @@ import java.util.WeakHashMap; * @attr ref R.styleable#MainKeyboardView_keyPreviewShowUpAnimator * @attr ref R.styleable#MainKeyboardView_keyPreviewDismissAnimator * @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardLayout + * @attr ref R.styleable#MainKeyboardView_moreKeysKeyboardForActionLayout * @attr ref R.styleable#MainKeyboardView_backgroundDimAlpha * @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint * @attr ref R.styleable#MainKeyboardView_gestureFloatingPreviewTextLingerTimeout @@ -148,6 +149,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack private final Paint mBackgroundDimAlphaPaint = new Paint(); private boolean mNeedsToDimEntireKeyboard; private final View mMoreKeysKeyboardContainer; + private final View mMoreKeysKeyboardForActionContainer; private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>(); private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint; // More keys panel (used by both more keys keyboard and more suggestions view) @@ -232,6 +234,9 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack final int moreKeysKeyboardLayoutId = mainKeyboardViewAttr.getResourceId( R.styleable.MainKeyboardView_moreKeysKeyboardLayout, 0); + final int moreKeysKeyboardForActionLayoutId = mainKeyboardViewAttr.getResourceId( + R.styleable.MainKeyboardView_moreKeysKeyboardForActionLayout, + moreKeysKeyboardLayoutId); mConfigShowMoreKeysKeyboardAtTouchedPoint = mainKeyboardViewAttr.getBoolean( R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false); @@ -249,8 +254,10 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack mSlidingKeyInputDrawingPreview.setDrawingView(mDrawingPreviewPlacerView); mainKeyboardViewAttr.recycle(); - mMoreKeysKeyboardContainer = LayoutInflater.from(getContext()) - .inflate(moreKeysKeyboardLayoutId, null); + final LayoutInflater inflater = LayoutInflater.from(getContext()); + mMoreKeysKeyboardContainer = inflater.inflate(moreKeysKeyboardLayoutId, null); + mMoreKeysKeyboardForActionContainer = inflater.inflate( + moreKeysKeyboardForActionLayoutId, null); mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator( languageOnSpacebarFadeoutAnimatorResId, this); mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator( @@ -582,7 +589,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack mMoreKeysKeyboardCache.put(key, moreKeysKeyboard); } - final View container = mMoreKeysKeyboardContainer; + final View container = key.isActionKey() ? mMoreKeysKeyboardForActionContainer + : mMoreKeysKeyboardContainer; final MoreKeysKeyboardView moreKeysKeyboardView = (MoreKeysKeyboardView)container.findViewById(R.id.more_keys_keyboard_view); moreKeysKeyboardView.setKeyboard(moreKeysKeyboard); diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index c348e6cfe..e4f39bb18 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1074,12 +1074,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. @@ -1115,7 +1116,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)}. @@ -1126,7 +1128,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; } diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java index 9d3c27bbe..3c7a99102 100644 --- a/java/src/com/android/inputmethod/latin/settings/Settings.java +++ b/java/src/com/android/inputmethod/latin/settings/Settings.java @@ -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); } diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java index 1da112bf6..308f3b470 100644 --- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java @@ -52,7 +52,10 @@ public final 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; @@ -73,7 +76,6 @@ public final 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; @@ -88,7 +90,6 @@ public final 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 @@ -152,6 +153,7 @@ public final 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); |