am 10aa8f12: am 9dcb764f: Fix "Show settings key" option on 7" device (DO NOT MERGE)

* commit '10aa8f127ae4e1f9e09f26e4e54770855ff24440':
  Fix "Show settings key" option on 7" device (DO NOT MERGE)
main
Tadashi G. Takaoka 2011-06-10 15:20:52 -07:00 committed by Android Git Automerger
commit 89dfebe7af
14 changed files with 242 additions and 98 deletions

View File

@ -178,9 +178,17 @@
</attr> </attr>
<attr name="webInput" format="boolean" /> <attr name="webInput" format="boolean" />
<attr name="passwordInput" format="boolean" /> <attr name="passwordInput" format="boolean" />
<attr name="hasSettingsKey" format="string" /> <attr name="hasSettingsKey" format="boolean" />
<attr name="voiceKeyEnabled" format="string" /> <!-- This should be aligned with KeyboardID.F2KEY_MODE_* -->
<attr name="hasVoiceKey" format="string" /> <attr name="f2KeyMode" format="enum">
<enum name="none" value="0" />
<enum name="settings" value="1" />
<enum name="shortcutIme" value="2" />
<enum name="shortcutImeOrSettings" value="3" />
</attr>
<attr name="clobberSettingsKey" format="boolean" />
<attr name="voiceKeyEnabled" format="boolean" />
<attr name="hasVoiceKey" format="boolean" />
<attr name="imeAction"> <attr name="imeAction">
<!-- This should be aligned with EditorInfo.IME_ACTION_* --> <!-- This should be aligned with EditorInfo.IME_ACTION_* -->
<flag name="actionUnspecified" value="0" /> <flag name="actionUnspecified" value="0" />

View File

@ -37,6 +37,23 @@
latin:styleName="functionalKeyStyle" /> latin:styleName="functionalKeyStyle" />
</case> </case>
</switch> </switch>
<!-- Base key style for the key which may have settings key as popup key -->
<switch>
<case
latin:clobberSettingsKey="true"
>
<key-style
latin:styleName="settingsPopupStyle"
latin:parentStyle="functionalKeyStyle" />
</case>
<default>
<key-style
latin:styleName="settingsPopupStyle"
latin:keyHintIcon="@drawable/hint_popup_holo"
latin:popupCharacters="\@drawable/sym_keyboard_settings_holo|\@integer/key_settings"
latin:parentStyle="functionalKeyStyle" />
</default>
</switch>
<!-- Functional key styles --> <!-- Functional key styles -->
<switch> <switch>
<case <case
@ -78,28 +95,18 @@
latin:keyHintIcon="@drawable/hint_popup_holo" latin:keyHintIcon="@drawable/hint_popup_holo"
latin:popupCharacters="@string/alternates_for_smiley" latin:popupCharacters="@string/alternates_for_smiley"
latin:maxPopupKeyboardColumn="5" /> latin:maxPopupKeyboardColumn="5" />
<switch>
<case
latin:voiceKeyEnabled="true"
>
<key-style <key-style
latin:styleName="micOrSettingsKeyStyle" latin:styleName="micKeyStyle"
latin:code="@integer/key_voice" latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_keyboard_voice_holo" latin:keyIcon="@drawable/sym_keyboard_voice_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic" latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:keyHintIcon="@drawable/hint_popup_holo" latin:parentStyle="settingsPopupStyle" />
latin:popupCharacters="\@drawable/sym_keyboard_settings|\@integer/key_settings"
latin:parentStyle="functionalKeyStyle" />
</case>
<default>
<key-style <key-style
latin:styleName="micOrSettingsKeyStyle" latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings" latin:code="@integer/key_settings"
latin:keyIcon="@drawable/sym_keyboard_settings_holo" latin:keyIcon="@drawable/sym_keyboard_settings_holo"
latin:iconPreview="@drawable/sym_keyboard_feedback_settings" latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
latin:parentStyle="functionalKeyStyle" /> latin:parentStyle="functionalKeyStyle" />
</default>
</switch>
</case> </case>
<case <case
latin:colorScheme="black" latin:colorScheme="black"
@ -140,28 +147,18 @@
latin:keyHintIcon="@drawable/hint_popup_holo" latin:keyHintIcon="@drawable/hint_popup_holo"
latin:popupCharacters="@string/alternates_for_smiley" latin:popupCharacters="@string/alternates_for_smiley"
latin:maxPopupKeyboardColumn="5" /> latin:maxPopupKeyboardColumn="5" />
<switch>
<case
latin:voiceKeyEnabled="true"
>
<key-style <key-style
latin:styleName="micOrSettingsKeyStyle" latin:styleName="micKeyStyle"
latin:code="@integer/key_voice" latin:code="@integer/key_voice"
latin:keyIcon="@drawable/sym_bkeyboard_mic" latin:keyIcon="@drawable/sym_bkeyboard_mic"
latin:iconPreview="@drawable/sym_keyboard_feedback_mic" latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
latin:keyHintIcon="@drawable/hint_popup_holo" latin:parentStyle="settingsPopupStyle" />
latin:popupCharacters="\@drawable/sym_keyboard_settings|\@integer/key_settings"
latin:parentStyle="functionalKeyStyle" />
</case>
<default>
<key-style <key-style
latin:styleName="micOrSettingsKeyStyle" latin:styleName="settingsKeyStyle"
latin:code="@integer/key_settings" latin:code="@integer/key_settings"
latin:keyIcon="@drawable/sym_bkeyboard_settings" latin:keyIcon="@drawable/sym_bkeyboard_settings"
latin:iconPreview="@drawable/sym_keyboard_feedback_settings" latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
latin:parentStyle="functionalKeyStyle" /> latin:parentStyle="functionalKeyStyle" />
</default>
</switch>
</case> </case>
</switch> </switch>
<key-style <key-style

View File

@ -85,12 +85,11 @@
latin:keyXPos="24.875%p" /> latin:keyXPos="24.875%p" />
<Key <Key
latin:keyStyle="num0KeyStyle" /> latin:keyStyle="num0KeyStyle" />
<Spacer /> <Spacer
<Key
latin:keyStyle="micOrSettingsKeyStyle"
latin:keyXPos="-11.00%p" latin:keyXPos="-11.00%p"
latin:keyWidth="0%p" latin:keyWidth="0dp" />
latin:keyEdgeFlags="right" /> <include
latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</case> </case>
<!-- latin:passwordInput="false" --> <!-- latin:passwordInput="false" -->
@ -182,11 +181,11 @@
latin:keyLabel="0" /> latin:keyLabel="0" />
<Key <Key
latin:keyLabel="#" /> latin:keyLabel="#" />
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle"
latin:keyXPos="-11.00%p" latin:keyXPos="-11.00%p"
latin:keyWidth="-11.00%p" latin:keyWidth="0dp" />
latin:keyEdgeFlags="right" /> <include
latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</default> </default>
</switch> </switch>

View File

@ -121,10 +121,10 @@
latin:keyStyle="num0KeyStyle" /> latin:keyStyle="num0KeyStyle" />
<Key <Key
latin:keyStyle="numPoundKeyStyle" /> latin:keyStyle="numPoundKeyStyle" />
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle"
latin:keyXPos="-11.00%p" latin:keyXPos="-11.00%p"
latin:keyWidth="-11.00%p" latin:keyWidth="0dp" />
latin:keyEdgeFlags="right" /> <include
latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -131,10 +131,10 @@
latin:keyStyle="num0KeyStyle" /> latin:keyStyle="num0KeyStyle" />
<Key <Key
latin:keyStyle="numPoundKeyStyle" /> latin:keyStyle="numPoundKeyStyle" />
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle"
latin:keyXPos="-11.00%p" latin:keyXPos="-11.00%p"
latin:keyWidth="-11.00%p" latin:keyWidth="0dp" />
latin:keyEdgeFlags="right" /> <include
latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, 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.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
<switch>
<case
latin:f2KeyMode="settings"
>
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="0%p"
latin:keyEdgeFlags="right" />
</case>
<case
latin:f2KeyMode="shortcutIme"
>
<switch>
<case
latin:voiceKeyEnabled="true"
>
<Key
latin:keyStyle="micKeyStyle"
latin:keyWidth="0%p"
latin:keyEdgeFlags="right" />
</case>
<!-- voiceKeyEnabled="false" -->
<default>
<Spacer />
</default>
</switch>
</case>
<case
latin:f2KeyMode="shortcutImeOrSettings"
>
<switch>
<case
latin:voiceKeyEnabled="true"
>
<Key
latin:keyStyle="micKeyStyle"
latin:keyWidth="0%p"
latin:keyEdgeFlags="right" />
</case>
<!-- voiceKeyEnabled="false" -->
<default>
<Key
latin:keyStyle="settingsKeyStyle"
latin:keyWidth="0%p"
latin:keyEdgeFlags="right" />
</default>
</switch>
</case>
<!-- f2KeyMode="none" -->
<default>
<Spacer />
</default>
</switch>
</merge>

View File

@ -161,10 +161,10 @@
</switch> </switch>
</default> </default>
</switch> </switch>
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle" latin:keyXPos="-10.00%p"
latin:keyXPos="-10.0%p" latin:keyWidth="0dp" />
latin:keyWidth="0%p" <include
latin:keyEdgeFlags="right" /> latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</merge> </merge>

View File

@ -216,10 +216,10 @@
latin:keyWidth="9.750%p" /> latin:keyWidth="9.750%p" />
</default> </default>
</switch> </switch>
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle" latin:keyXPos="-10.00%p"
latin:keyXPos="-10.0%p" latin:keyWidth="0dp" />
latin:keyWidth="0%p" <include
latin:keyEdgeFlags="right" /> latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -154,10 +154,10 @@
latin:keyStyle="spaceKeyStyle" latin:keyStyle="spaceKeyStyle"
latin:keyXPos="30.750%p" latin:keyXPos="30.750%p"
latin:keyWidth="39.750%p" /> latin:keyWidth="39.750%p" />
<Key <Spacer
latin:keyStyle="micOrSettingsKeyStyle" latin:keyXPos="-10.00%p"
latin:keyXPos="-10.0%p" latin:keyWidth="0dp" />
latin:keyWidth="0.0%p" <include
latin:keyEdgeFlags="right" /> latin:keyboardLayout="@xml/kbd_qwerty_f2" />
</Row> </Row>
</Keyboard> </Keyboard>

View File

@ -40,7 +40,7 @@
<!-- Base key style for the key which may have settings key as popup key --> <!-- Base key style for the key which may have settings key as popup key -->
<switch> <switch>
<case <case
latin:hasSettingsKey="true" latin:clobberSettingsKey="true"
> >
<key-style <key-style
latin:styleName="settingsPopupStyle" latin:styleName="settingsPopupStyle"

View File

@ -36,6 +36,11 @@ public class KeyboardId {
public static final int MODE_PHONE = 4; public static final int MODE_PHONE = 4;
public static final int MODE_NUMBER = 5; public static final int MODE_NUMBER = 5;
public static final int F2KEY_MODE_NONE = 0;
public static final int F2KEY_MODE_SETTINGS = 1;
public static final int F2KEY_MODE_SHORTCUT_IME = 2;
public static final int F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS = 3;
public final Locale mLocale; public final Locale mLocale;
public final int mOrientation; public final int mOrientation;
public final int mMode; public final int mMode;
@ -43,7 +48,10 @@ public class KeyboardId {
public final int mColorScheme; public final int mColorScheme;
public final boolean mWebInput; public final boolean mWebInput;
public final boolean mPasswordInput; public final boolean mPasswordInput;
// TODO: Clean up these booleans and modes.
public final boolean mHasSettingsKey; public final boolean mHasSettingsKey;
public final int mF2KeyMode;
public final boolean mClobberSettingsKey;
public final boolean mVoiceKeyEnabled; public final boolean mVoiceKeyEnabled;
public final boolean mHasVoiceKey; public final boolean mHasVoiceKey;
public final int mImeAction; public final int mImeAction;
@ -53,8 +61,9 @@ public class KeyboardId {
private final int mHashCode; private final int mHashCode;
public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation, public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation,
int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled, int mode, EditorInfo attribute, boolean hasSettingsKey, int f2KeyMode,
boolean hasVoiceKey, boolean enableShiftLock) { boolean clobberSettingsKey, boolean voiceKeyEnabled, boolean hasVoiceKey,
boolean enableShiftLock) {
final int inputType = (attribute != null) ? attribute.inputType : 0; final int inputType = (attribute != null) ? attribute.inputType : 0;
final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
this.mLocale = locale; this.mLocale = locale;
@ -66,6 +75,8 @@ public class KeyboardId {
this.mPasswordInput = Utils.isPasswordInputType(inputType) this.mPasswordInput = Utils.isPasswordInputType(inputType)
|| Utils.isVisiblePasswordInputType(inputType); || Utils.isVisiblePasswordInputType(inputType);
this.mHasSettingsKey = hasSettingsKey; this.mHasSettingsKey = hasSettingsKey;
this.mF2KeyMode = f2KeyMode;
this.mClobberSettingsKey = clobberSettingsKey;
this.mVoiceKeyEnabled = voiceKeyEnabled; this.mVoiceKeyEnabled = voiceKeyEnabled;
this.mHasVoiceKey = hasVoiceKey; this.mHasVoiceKey = hasVoiceKey;
// We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and // We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
@ -84,6 +95,8 @@ public class KeyboardId {
mWebInput, mWebInput,
mPasswordInput, mPasswordInput,
hasSettingsKey, hasSettingsKey,
f2KeyMode,
clobberSettingsKey,
voiceKeyEnabled, voiceKeyEnabled,
hasVoiceKey, hasVoiceKey,
mImeAction, mImeAction,
@ -125,6 +138,8 @@ public class KeyboardId {
&& other.mWebInput == this.mWebInput && other.mWebInput == this.mWebInput
&& other.mPasswordInput == this.mPasswordInput && other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey && other.mHasSettingsKey == this.mHasSettingsKey
&& other.mF2KeyMode == this.mF2KeyMode
&& other.mClobberSettingsKey == this.mClobberSettingsKey
&& other.mVoiceKeyEnabled == this.mVoiceKeyEnabled && other.mVoiceKeyEnabled == this.mVoiceKeyEnabled
&& other.mHasVoiceKey == this.mHasVoiceKey && other.mHasVoiceKey == this.mHasVoiceKey
&& other.mImeAction == this.mImeAction && other.mImeAction == this.mImeAction
@ -138,13 +153,15 @@ public class KeyboardId {
@Override @Override
public String toString() { public String toString() {
return String.format("[%s.xml %s %s %s %s %s%s%s%s%s%s%s]", return String.format("[%s.xml %s %s %s %s %s %s%s%s%s%s%s%s%s]",
mXmlName, mXmlName,
mLocale, mLocale,
(mOrientation == 1 ? "port" : "land"), (mOrientation == 1 ? "port" : "land"),
modeName(mMode), modeName(mMode),
imeOptionsName(mImeAction), imeOptionsName(mImeAction),
colorSchemeName(mColorScheme), colorSchemeName(mColorScheme),
f2KeyModeName(mF2KeyMode),
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
(mWebInput ? " webInput" : ""), (mWebInput ? " webInput" : ""),
(mPasswordInput ? " passwordInput" : ""), (mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""),
@ -195,5 +212,15 @@ public class KeyboardId {
return action; return action;
} }
} }
public static String f2KeyModeName(int f2KeyMode) {
switch (f2KeyMode) {
case F2KEY_MODE_NONE: return "none";
case F2KEY_MODE_SETTINGS: return "settings";
case F2KEY_MODE_SHORTCUT_IME: return "shortcutIme";
case F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS: return "shortcutImeOrSettings";
}
return null;
}
} }

View File

@ -438,6 +438,10 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput); R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput);
final boolean settingsKeyMatched = matchBoolean(a, final boolean settingsKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_hasSettingsKey, id.mHasSettingsKey); R.styleable.Keyboard_Case_hasSettingsKey, id.mHasSettingsKey);
final boolean f2KeyModeMatched = matchInteger(a,
R.styleable.Keyboard_Case_f2KeyMode, id.mF2KeyMode);
final boolean clobberSettingsKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
final boolean voiceEnabledMatched = matchBoolean(a, final boolean voiceEnabledMatched = matchBoolean(a,
R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled); R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled);
final boolean voiceKeyMatched = matchBoolean(a, final boolean voiceKeyMatched = matchBoolean(a,
@ -455,11 +459,11 @@ public class KeyboardParser {
final boolean countryCodeMatched = matchString(a, final boolean countryCodeMatched = matchString(a,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = modeMatched && webInputMatched && passwordInputMatched final boolean selected = modeMatched && webInputMatched && passwordInputMatched
&& settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched && settingsKeyMatched && f2KeyModeMatched && clobberSettingsKeyMatched
&& colorSchemeMatched && imeActionMatched && languageCodeMatched && voiceEnabledMatched && voiceKeyMatched && colorSchemeMatched
&& countryCodeMatched; && imeActionMatched && languageCodeMatched && countryCodeMatched;
if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
textAttr(KeyboardId.modeName( textAttr(KeyboardId.modeName(
a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"), a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"),
textAttr(KeyboardId.colorSchemeName( textAttr(KeyboardId.colorSchemeName(
@ -468,6 +472,10 @@ public class KeyboardParser {
booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"), booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"), booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
textAttr(KeyboardId.f2KeyModeName(
a.getInt(R.styleable.Keyboard_Case_f2KeyMode, -1)), "f2KeyMode"),
booleanAttr(a, R.styleable.Keyboard_Case_clobberSettingsKey,
"clobberSettingsKey"),
booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"), booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"),
booleanAttr(a, R.styleable.Keyboard_Case_hasVoiceKey, "hasVoiceKey"), booleanAttr(a, R.styleable.Keyboard_Case_hasVoiceKey, "hasVoiceKey"),
textAttr(KeyboardId.imeOptionsName( textAttr(KeyboardId.imeOptionsName(

View File

@ -36,8 +36,8 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener { public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "KeyboardSwitcher"; private static final String TAG = KeyboardSwitcher.class.getSimpleName();
private static final boolean DEBUG = false; private static final boolean DEBUG = LatinImeLogger.sDBG;
public static final boolean DEBUG_STATE = false; public static final boolean DEBUG_STATE = false;
private static String sConfigDefaultKeyboardThemeId; private static String sConfigDefaultKeyboardThemeId;
@ -238,12 +238,17 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
} }
final boolean hasSettingsKey = hasSettingsKey(attribute); final boolean hasSettingsKey = hasSettingsKey(attribute);
final int f2KeyMode = getF2KeyMode(mPrefs, mInputMethodService, attribute);
final boolean clobberSettingsKey = Utils.inPrivateImeOptions(
mInputMethodService.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY,
attribute);
final Resources res = mInputMethodService.getResources(); final Resources res = mInputMethodService.getResources();
final int orientation = res.getConfiguration().orientation; final int orientation = res.getConfiguration().orientation;
final Locale locale = mSubtypeSwitcher.getInputLocale(); final Locale locale = mSubtypeSwitcher.getInputLocale();
return new KeyboardId( return new KeyboardId(
res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, mode, res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation, mode,
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock); attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled,
hasVoiceKey, enableShiftLock);
} }
private void makeSymbolsKeyboardIds(final int mode, EditorInfo attribute) { private void makeSymbolsKeyboardIds(final int mode, EditorInfo attribute) {
@ -253,6 +258,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final int colorScheme = getColorScheme(); final int colorScheme = getColorScheme();
final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary; final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary;
final boolean hasSettingsKey = hasSettingsKey(attribute); final boolean hasSettingsKey = hasSettingsKey(attribute);
final int f2KeyMode = getF2KeyMode(mPrefs, mInputMethodService, attribute);
final boolean clobberSettingsKey = Utils.inPrivateImeOptions(
mInputMethodService.getPackageName(), LatinIME.IME_OPTION_NO_SETTINGS_KEY,
attribute);
// Note: This comment is only applied for phone number keyboard layout. // 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 // 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, // between "phone keyboard" and "phone symbols keyboard". But on xlarge device,
@ -263,10 +272,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols; int xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone : R.xml.kbd_symbols;
final String xmlName = res.getResourceEntryName(xmlId); final String xmlName = res.getResourceEntryName(xmlId);
mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, mSymbolsId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled,
hasVoiceKey, true);
xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift; xmlId = mode == KeyboardId.MODE_PHONE ? R.xml.kbd_phone_symbols : R.xml.kbd_symbols_shift;
mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode, mSymbolsShiftedId = new KeyboardId(xmlName, xmlId, colorScheme, locale, orientation, mode,
attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, true); attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled,
hasVoiceKey, true);
} }
public int getKeyboardMode() { public int getKeyboardMode() {
@ -745,16 +756,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} }
private static boolean getSettingsKeyMode(SharedPreferences prefs, Context context) { private static boolean getSettingsKeyMode(SharedPreferences prefs, Context context) {
Resources resources = context.getResources(); final Resources res = context.getResources();
final boolean showSettingsKeyOption = resources.getBoolean( final boolean showSettingsKeyOption = res.getBoolean(
R.bool.config_enable_show_settings_key_option); R.bool.config_enable_show_settings_key_option);
if (showSettingsKeyOption) { if (showSettingsKeyOption) {
final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY, final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
resources.getString(DEFAULT_SETTINGS_KEY_MODE)); res.getString(DEFAULT_SETTINGS_KEY_MODE));
// We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or // We show the settings key when 1) SETTINGS_KEY_MODE_ALWAYS_SHOW or
// 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system // 2) SETTINGS_KEY_MODE_AUTO and there are two or more enabled IMEs on the system
if (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))
|| (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO)) || (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))
&& Utils.hasMultipleEnabledIMEsOrSubtypes( && Utils.hasMultipleEnabledIMEsOrSubtypes(
((InputMethodManager) context.getSystemService( ((InputMethodManager) context.getSystemService(
Context.INPUT_METHOD_SERVICE))))) { Context.INPUT_METHOD_SERVICE))))) {
@ -765,4 +776,21 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// If the show settings key option is disabled, we always try showing the settings key. // If the show settings key option is disabled, we always try showing the settings key.
return true; return true;
} }
private static int getF2KeyMode(SharedPreferences prefs, Context context,
EditorInfo attribute) {
final boolean clobberSettingsKey = Utils.inPrivateImeOptions(context.getPackageName(),
LatinIME.IME_OPTION_NO_SETTINGS_KEY, attribute);
final Resources res = context.getResources();
final String settingsKeyMode = prefs.getString(Settings.PREF_SETTINGS_KEY,
res.getString(DEFAULT_SETTINGS_KEY_MODE));
if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO))) {
return clobberSettingsKey ? KeyboardId.F2KEY_MODE_SHORTCUT_IME
: KeyboardId.F2KEY_MODE_SHORTCUT_IME_OR_SETTINGS;
} else if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW))) {
return clobberSettingsKey ? KeyboardId.F2KEY_MODE_NONE : KeyboardId.F2KEY_MODE_SETTINGS;
} else { // SETTINGS_KEY_MODE_ALWAYS_HIDE
return KeyboardId.F2KEY_MODE_SHORTCUT_IME;
}
}
} }

View File

@ -42,7 +42,7 @@ public class SuggestTestsBase extends AndroidTestCase {
return new KeyboardId(locale.toString() + " keyboard", return new KeyboardId(locale.toString() + " keyboard",
com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE, com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE,
locale, Configuration.ORIENTATION_LANDSCAPE, KeyboardId.MODE_TEXT, locale, Configuration.ORIENTATION_LANDSCAPE, KeyboardId.MODE_TEXT,
new EditorInfo(), false, false, false, false); new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false, false);
} }
protected InputStream openTestRawResource(int resIdInTest) { protected InputStream openTestRawResource(int resIdInTest) {