diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index c63ecbe1a..a015d6b71 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -178,9 +178,17 @@ - - - + + + + + + + + + + + diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml index cd4262458..082c374e8 100644 --- a/java/res/xml-sw600dp/kbd_key_styles.xml +++ b/java/res/xml-sw600dp/kbd_key_styles.xml @@ -37,6 +37,23 @@ latin:styleName="functionalKeyStyle" /> + + + + + + + + + - - - - - - - - + + - - - - - - - - + + - - + latin:keyWidth="0dp" /> + @@ -182,11 +181,11 @@ latin:keyLabel="0" /> - + latin:keyWidth="0dp" /> + diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml index b80442584..220c4b882 100644 --- a/java/res/xml-sw600dp/kbd_phone.xml +++ b/java/res/xml-sw600dp/kbd_phone.xml @@ -121,10 +121,10 @@ latin:keyStyle="num0KeyStyle" /> - + latin:keyWidth="0dp" /> + diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml index f84ebd578..43c4f6d7f 100644 --- a/java/res/xml-sw600dp/kbd_phone_symbols.xml +++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml @@ -131,10 +131,10 @@ latin:keyStyle="num0KeyStyle" /> - + latin:keyWidth="0dp" /> + diff --git a/java/res/xml-sw600dp/kbd_qwerty_f2.xml b/java/res/xml-sw600dp/kbd_qwerty_f2.xml new file mode 100644 index 000000000..e6c57f8f7 --- /dev/null +++ b/java/res/xml-sw600dp/kbd_qwerty_f2.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml-sw600dp/kbd_qwerty_row4.xml b/java/res/xml-sw600dp/kbd_qwerty_row4.xml index 56aca137e..6378ea414 100644 --- a/java/res/xml-sw600dp/kbd_qwerty_row4.xml +++ b/java/res/xml-sw600dp/kbd_qwerty_row4.xml @@ -161,10 +161,10 @@ - + + diff --git a/java/res/xml-sw600dp/kbd_symbols.xml b/java/res/xml-sw600dp/kbd_symbols.xml index 4eb493a6e..3f555aa85 100644 --- a/java/res/xml-sw600dp/kbd_symbols.xml +++ b/java/res/xml-sw600dp/kbd_symbols.xml @@ -216,10 +216,10 @@ latin:keyWidth="9.750%p" /> - + + diff --git a/java/res/xml-sw600dp/kbd_symbols_shift.xml b/java/res/xml-sw600dp/kbd_symbols_shift.xml index cfbf75648..7ad7afc17 100644 --- a/java/res/xml-sw600dp/kbd_symbols_shift.xml +++ b/java/res/xml-sw600dp/kbd_symbols_shift.xml @@ -154,10 +154,10 @@ latin:keyStyle="spaceKeyStyle" latin:keyXPos="30.750%p" latin:keyWidth="39.750%p" /> - + + diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml index 160e85daa..28869a87d 100644 --- a/java/res/xml/kbd_key_styles.xml +++ b/java/res/xml/kbd_key_styles.xml @@ -40,7 +40,7 @@ %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( a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"), textAttr(KeyboardId.colorSchemeName( @@ -468,6 +472,10 @@ public class KeyboardParser { booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), 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_hasVoiceKey, "hasVoiceKey"), textAttr(KeyboardId.imeOptionsName( diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 6f6355d53..5d3ec526a 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -36,8 +36,8 @@ import java.util.HashMap; import java.util.Locale; public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener { - private static final String TAG = "KeyboardSwitcher"; - private static final boolean DEBUG = false; + private static final String TAG = KeyboardSwitcher.class.getSimpleName(); + private static final boolean DEBUG = LatinImeLogger.sDBG; public static final boolean DEBUG_STATE = false; private static String sConfigDefaultKeyboardThemeId; @@ -238,12 +238,17 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } 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 int orientation = res.getConfiguration().orientation; final Locale locale = mSubtypeSwitcher.getInputLocale(); return new KeyboardId( 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) { @@ -253,6 +258,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final int colorScheme = getColorScheme(); final boolean hasVoiceKey = mVoiceKeyEnabled && !mVoiceButtonOnPrimary; 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. // 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, @@ -263,10 +272,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha 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); + attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, 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); + attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, mVoiceKeyEnabled, + hasVoiceKey, true); } public int getKeyboardMode() { @@ -745,16 +756,16 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private static boolean getSettingsKeyMode(SharedPreferences prefs, Context context) { - Resources resources = context.getResources(); - final boolean showSettingsKeyOption = resources.getBoolean( + final Resources res = context.getResources(); + final boolean showSettingsKeyOption = res.getBoolean( R.bool.config_enable_show_settings_key_option); if (showSettingsKeyOption) { 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 // 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)) - || (settingsKeyMode.equals(resources.getString(SETTINGS_KEY_MODE_AUTO)) + if (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_ALWAYS_SHOW)) + || (settingsKeyMode.equals(res.getString(SETTINGS_KEY_MODE_AUTO)) && Utils.hasMultipleEnabledIMEsOrSubtypes( ((InputMethodManager) context.getSystemService( 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. 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; + } + } } diff --git a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java index 64f26743e..48d169f6a 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java @@ -42,7 +42,7 @@ public class SuggestTestsBase extends AndroidTestCase { return new KeyboardId(locale.toString() + " keyboard", com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE, 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) {