diff --git a/java/res/xml-xlarge/kbd_number.xml b/java/res/xml-xlarge/kbd_number.xml index 152ec8285f794befce7ca6ad9fe8ae540603cb78..ce3277b5df24f2e0b26f22f6a6262a9ff658e1d4 100644 --- a/java/res/xml-xlarge/kbd_number.xml +++ b/java/res/xml-xlarge/kbd_number.xml @@ -187,9 +187,17 @@ left edge key. --> <Spacer latin:horizontalGap="8.362%p" /> - <Key - latin:keyStyle="settingsKeyStyle" - latin:keyWidth="8.042%p" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.042%p" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" latin:keyWidth="24.127%p" /> diff --git a/java/res/xml-xlarge/kbd_phone.xml b/java/res/xml-xlarge/kbd_phone.xml index b9444ad504b582a571ddadf79dd557048abec7a2..9122176a96343a0bae8cc263aa6fee9de6ef9e96 100644 --- a/java/res/xml-xlarge/kbd_phone.xml +++ b/java/res/xml-xlarge/kbd_phone.xml @@ -129,9 +129,17 @@ the touch event on the area, "space" is intentionally not marked as a left edge key. --> <Spacer latin:horizontalGap="12.340%p" /> - <Key - latin:keyStyle="settingsKeyStyle" - latin:keyWidth="8.042%p" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.042%p" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" latin:keyWidth="16.084%p" /> diff --git a/java/res/xml-xlarge/kbd_phone_symbols.xml b/java/res/xml-xlarge/kbd_phone_symbols.xml index 690bcde0c48c4ad522fc9872e8d526d289a5ca59..055c148674631a239d94f34e734213fcd7e3b2bd 100644 --- a/java/res/xml-xlarge/kbd_phone_symbols.xml +++ b/java/res/xml-xlarge/kbd_phone_symbols.xml @@ -141,9 +141,17 @@ the touch event on the area, "space" is intentionally not marked as a left edge key. --> <Spacer latin:horizontalGap="8.362%p" /> - <Key - latin:keyStyle="settingsKeyStyle" - latin:keyWidth="8.042%p" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" + latin:keyWidth="8.042%p" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" latin:keyWidth="24.127%p" /> diff --git a/java/res/xml-xlarge/kbd_qwerty_row4.xml b/java/res/xml-xlarge/kbd_qwerty_row4.xml index 8011064a41f5ece84de3eee8a88a5acccf12f747..f36b61fc744e85e81d973cf8b606e60b63fd67bb 100644 --- a/java/res/xml-xlarge/kbd_qwerty_row4.xml +++ b/java/res/xml-xlarge/kbd_qwerty_row4.xml @@ -27,8 +27,16 @@ > <Spacer latin:horizontalGap="8.362%p" /> - <Key - latin:keyStyle="settingsKeyStyle" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <switch> <case latin:languageCode="ru" diff --git a/java/res/xml-xlarge/kbd_symbols.xml b/java/res/xml-xlarge/kbd_symbols.xml index 640dd090403049607f45adee43dbd773d79e3c0b..ab5adce4a9193f842c13d38cf36277f2ae25ddc5 100644 --- a/java/res/xml-xlarge/kbd_symbols.xml +++ b/java/res/xml-xlarge/kbd_symbols.xml @@ -167,8 +167,16 @@ > <Spacer latin:horizontalGap="8.362%p" /> - <Key - latin:keyStyle="settingsKeyStyle" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <Key latin:keyLabel="/" /> <Key diff --git a/java/res/xml-xlarge/kbd_symbols_shift.xml b/java/res/xml-xlarge/kbd_symbols_shift.xml index 1f5513b83b3f43112a2bd2e5d44ae048fe59608a..8359b757144112ad915e35be4b9b258f5c37a3f7 100644 --- a/java/res/xml-xlarge/kbd_symbols_shift.xml +++ b/java/res/xml-xlarge/kbd_symbols_shift.xml @@ -155,8 +155,16 @@ > <Spacer latin:horizontalGap="24.446%p" /> - <Key - latin:keyStyle="settingsKeyStyle" /> + <switch> + <case latin:hasSettingsKey="true"> + <Key + latin:keyStyle="settingsKeyStyle" /> + </case> + <default> + <Spacer + latin:horizontalGap="8.042%p" /> + </default> + </switch> <Key latin:keyStyle="spaceKeyStyle" latin:keyWidth="37.454%p" /> diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index de5e097e355a43c5e1948570e4881622beb43473..86b4405bdef20b15369ab88f590b87db618d79ce 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -83,8 +83,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private static final int AUTO_MODE_SWITCH_STATE_CHORDING = 4; private int mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA; - // Indicates whether or not we have the settings key - private boolean mHasSettingsKey; + // Indicates whether or not we have the settings key in option of settings + private boolean mSettingsKeyEnabledInSettings; private static final int SETTINGS_KEY_MODE_AUTO = R.string.settings_key_mode_auto; private static final int SETTINGS_KEY_MODE_ALWAYS_SHOW = R.string.settings_key_mode_always_show; @@ -122,32 +122,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha prefs.registerOnSharedPreferenceChangeListener(sInstance); } - private void makeSymbolsKeyboardIds(final int mode) { - final Locale locale = mSubtypeSwitcher.getInputLocale(); - final Resources res = mInputMethodService.getResources(); - final int orientation = res.getConfiguration().orientation; - final int colorScheme = getColorScheme(); - final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary; - // Note: This comment is only applied for phone number keyboard layout. - // On non-xlarge device, "@integer/key_switch_alpha_symbol" key code is used to switch - // between "phone keyboard" and "phone symbols keyboard". But on xlarge device, - // "@integer/key_shift" key code is used for that purpose in order to properly display - // "more" and "locked more" key labels. To achieve these behavior, we should initialize - // mSymbolsId and mSymbolsShiftedId to "phone keyboard" and "phone symbols keyboard" - // respectively here for xlarge device's layout switching. - int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols; - final String xmlName = res.getResourceEntryName(xmlId); - mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, - mAttribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); - xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift; - mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, - mAttribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); - } - - private boolean hasVoiceKey(boolean isSymbols) { - return mVoiceKeyEnabled && (isSymbols != mVoiceButtonOnPrimary); - } - public void loadKeyboard(EditorInfo attribute, boolean voiceKeyEnabled, boolean voiceButtonOnPrimary) { mAutoModeSwitchState = AUTO_MODE_SWITCH_STATE_ALPHA; @@ -170,14 +144,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mVoiceButtonOnPrimary = voiceButtonOnPrimary; mIsSymbols = isSymbols; // Update the settings key state because number of enabled IMEs could have been changed - mHasSettingsKey = getSettingsKeyMode(mPrefs, mInputMethodService); + mSettingsKeyEnabledInSettings = getSettingsKeyMode(mPrefs, mInputMethodService); final KeyboardId id = getKeyboardId(attribute, isSymbols); final Keyboard oldKeyboard = mInputView.getKeyboard(); if (oldKeyboard != null && oldKeyboard.mId.equals(id)) return; - makeSymbolsKeyboardIds(id.mMode); + makeSymbolsKeyboardIds(id.mMode, attribute); mCurrentId = id; mInputView.setPreviewEnabled(mInputMethodService.getPopupOn()); setKeyboard(getKeyboard(id)); @@ -224,6 +198,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return keyboard; } + private boolean hasVoiceKey(boolean isSymbols) { + return mVoiceKeyEnabled && (isSymbols != mVoiceButtonOnPrimary); + } + + private boolean hasSettingsKey(EditorInfo attribute) { + return mSettingsKeyEnabledInSettings + && !Utils.inPrivateImeOptions(mInputMethodService.getPackageName(), + LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute); + } + private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) { final int mode = Utils.getKeyboardMode(attribute); final boolean hasVoiceKey = hasVoiceKey(isSymbols); @@ -253,12 +237,36 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha enableShiftLock = true; } } + final boolean hasSettingsKey = hasSettingsKey(attribute); final Resources res = mInputMethodService.getResources(); final int orientation = res.getConfiguration().orientation; final Locale locale = mSubtypeSwitcher.getInputLocale(); return new KeyboardId( res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, mode, - attribute, mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock); + attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock); + } + + private void makeSymbolsKeyboardIds(final int mode, EditorInfo attribute) { + final Locale locale = mSubtypeSwitcher.getInputLocale(); + final Resources res = mInputMethodService.getResources(); + final int orientation = res.getConfiguration().orientation; + final int colorScheme = getColorScheme(); + final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary; + final boolean hasSettingsKey = hasSettingsKey(attribute); + // Note: This comment is only applied for phone number keyboard layout. + // On non-xlarge device, "@integer/key_switch_alpha_symbol" key code is used to switch + // between "phone keyboard" and "phone symbols keyboard". But on xlarge device, + // "@integer/key_shift" key code is used for that purpose in order to properly display + // "more" and "locked more" key labels. To achieve these behavior, we should initialize + // mSymbolsId and mSymbolsShiftedId to "phone keyboard" and "phone symbols keyboard" + // respectively here for xlarge device's layout switching. + int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols; + final String xmlName = res.getResourceEntryName(xmlId); + mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, + attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); + xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift; + mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, + attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); } public int getKeyboardMode() { @@ -689,7 +697,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha createInputViewInternal(layoutId, false); postSetInputView(); } else if (Settings.PREF_SETTINGS_KEY.equals(key)) { - mHasSettingsKey = getSettingsKeyMode(sharedPreferences, mInputMethodService); + mSettingsKeyEnabledInSettings = getSettingsKeyMode(sharedPreferences, + mInputMethodService); createInputViewInternal(mLayoutId, true); postSetInputView(); } @@ -725,7 +734,9 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha Context.INPUT_METHOD_SERVICE))))) { return true; } + return false; } - return false; + // If the show settings key option is disabled, we always try showing the settings key. + return true; } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 40cebb3952549872ebb7357cf1f5df6434a34d19..786e766d60c7988e0f1f48dd3392cf186d53cef6 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -100,7 +100,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen * shown for a given text field. For instance, this is specified by the * search dialog when the dialog is already showing a voice search button. */ - public static final String IME_OPTION_NO_MICROPHONE = "noMicrophone"; + public static final String IME_OPTION_NO_MICROPHONE = "noMicrophoneKey"; + + /** + * The private IME option used to indicate that no settings key should be + * shown for a given text field. + */ + public static final String IME_OPTION_NO_SETTINGS_KEY = "noSettingsKey"; private static final int DELAY_UPDATE_SUGGESTIONS = 180; private static final int DELAY_UPDATE_OLD_SUGGESTIONS = 300;