diff --git a/java/res/values-xlarge/bools.xml b/java/res/values-xlarge/bools.xml index 2ac5fc624..3079133dd 100644 --- a/java/res/values-xlarge/bools.xml +++ b/java/res/values-xlarge/bools.xml @@ -22,5 +22,4 @@ false false false - false diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 208711504..7de41f0a0 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -149,7 +149,8 @@ - - + + + diff --git a/java/res/values/bools.xml b/java/res/values/bools.xml index 0497a6aed..5d932a693 100644 --- a/java/res/values/bools.xml +++ b/java/res/values/bools.xml @@ -32,5 +32,4 @@ true true true - true diff --git a/java/res/values/keycodes.xml b/java/res/values/keycodes.xml index c5d5b3cd1..cbfe89690 100644 --- a/java/res/values/keycodes.xml +++ b/java/res/values/keycodes.xml @@ -28,5 +28,4 @@ -100 -102 - -103 diff --git a/java/res/xml/kbd_qwerty_black_f1.xml b/java/res/xml/kbd_qwerty_black_f1.xml new file mode 100644 index 000000000..296d8a06a --- /dev/null +++ b/java/res/xml/kbd_qwerty_black_f1.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_qwerty_black_row4.xml b/java/res/xml/kbd_qwerty_black_row4.xml index 2b9ef7f90..c6e25b444 100644 --- a/java/res/xml/kbd_qwerty_black_row4.xml +++ b/java/res/xml/kbd_qwerty_black_row4.xml @@ -27,15 +27,12 @@ > - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_qwerty_f1.xml b/java/res/xml/kbd_qwerty_f1.xml new file mode 100644 index 000000000..23e494cc5 --- /dev/null +++ b/java/res/xml/kbd_qwerty_f1.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_qwerty_row4.xml b/java/res/xml/kbd_qwerty_row4.xml index 2e2b32e3f..a5113ea76 100644 --- a/java/res/xml/kbd_qwerty_row4.xml +++ b/java/res/xml/kbd_qwerty_row4.xml @@ -27,17 +27,12 @@ > - - + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_symbols_black_f1.xml b/java/res/xml/kbd_symbols_black_f1.xml new file mode 100644 index 000000000..353b007ad --- /dev/null +++ b/java/res/xml/kbd_symbols_black_f1.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_symbols_black_row4.xml b/java/res/xml/kbd_symbols_black_row4.xml index d1ed52717..a50f8c05d 100644 --- a/java/res/xml/kbd_symbols_black_row4.xml +++ b/java/res/xml/kbd_symbols_black_row4.xml @@ -26,15 +26,15 @@ > - + - + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_symbols_row4.xml b/java/res/xml/kbd_symbols_row4.xml index 4b3dd9071..f012a4d25 100644 --- a/java/res/xml/kbd_symbols_row4.xml +++ b/java/res/xml/kbd_symbols_row4.xml @@ -26,7 +26,7 @@ > - + - + keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseKeyboardContent", keys == null); int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { @@ -214,12 +210,10 @@ public class BaseKeyboardParser { } } } - if (DEBUG_PARSER) debugLeaveMethod("parseKeyboardContent", keys == null); } private void parseRowContent(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseRowContent", keys == null); int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { @@ -252,12 +246,10 @@ public class BaseKeyboardParser { } } } - if (DEBUG_PARSER) debugLeaveMethod("parseRowContent", keys == null); } private void parseKey(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseKey", keys == null); if (keys == null) { checkEndTag(TAG_KEY, parser); } else { @@ -272,7 +264,6 @@ public class BaseKeyboardParser { private void parseSpacer(XmlResourceParser parser, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseSpacer", keys == null); if (keys == null) { checkEndTag(TAG_SPACER, parser); } else { @@ -288,16 +279,12 @@ public class BaseKeyboardParser { private void parseIncludeKeyboardContent(XmlResourceParser parser, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseIncludeKeyboardContent", keys == null); parseIncludeInternal(parser, null, keys); - if (DEBUG_PARSER) debugLeaveMethod("parseIncludeKeyboardContent", keys == null); } private void parseIncludeRowContent(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseIncludeRowContent", keys == null); parseIncludeInternal(parser, row, keys); - if (DEBUG_PARSER) debugLeaveMethod("parseIncludeRowContent", keys == null); } private void parseIncludeInternal(XmlResourceParser parser, Row row, List keys) @@ -320,7 +307,6 @@ public class BaseKeyboardParser { private void parseMerge(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseMerge", keys == null); int event; while ((event = parser.next()) != XmlResourceParser.END_DOCUMENT) { if (event == XmlResourceParser.START_TAG) { @@ -339,21 +325,16 @@ public class BaseKeyboardParser { } } } - if (DEBUG_PARSER) debugLeaveMethod("parseMerge", keys == null); } private void parseSwitchKeyboardContent(XmlResourceParser parser, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseSwitchKeyboardContent", keys == null); parseSwitchInternal(parser, null, keys); - if (DEBUG_PARSER) debugLeaveMethod("parseSwitchKeyboardContent", keys == null); } private void parseSwitchRowContent(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseSwitchRowContent", keys == null); parseSwitchInternal(parser, row, keys); - if (DEBUG_PARSER) debugLeaveMethod("parseSwitchRowContent", keys == null); } private void parseSwitchInternal(XmlResourceParser parser, Row row, List keys) @@ -386,7 +367,6 @@ public class BaseKeyboardParser { private boolean parseCase(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseCase", keys == null); final boolean selected = parseCaseCondition(parser); if (row == null) { // Processing Rows. @@ -395,46 +375,67 @@ public class BaseKeyboardParser { // Processing Keys. parseRowContent(parser, row, selected ? keys : null); } - if (DEBUG_PARSER) debugLeaveMethod("parseCase", keys == null || !selected); return selected; } private boolean parseCaseCondition(XmlResourceParser parser) { - final BaseKeyboard keyboard = mKeyboard; - final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser), - R.styleable.BaseKeyboard_Case); - final int mode = a.getInt(R.styleable.BaseKeyboard_Case_mode, -1); - final String settingsKey = a.getString(R.styleable.BaseKeyboard_Case_settingsKey); - final String voiceKey = a.getString(R.styleable.BaseKeyboard_Case_voiceKey); - a.recycle(); - - final KeyboardId id = keyboard.mId; + final KeyboardId id = mKeyboard.mId; if (id == null) return true; - final boolean modeMatched = (mode == -1 || id.mMode == mode); - final boolean settingsKeyMatched = (settingsKey == null - || id.mHasSettingsKey == Boolean.parseBoolean(settingsKey)); - final boolean voiceKeyMatched = (voiceKey == null - || id.mHasVoiceKey == Boolean.parseBoolean(voiceKey)); - final boolean selected = modeMatched && settingsKeyMatched && voiceKeyMatched; - if (DEBUG_TAG) { + + final TypedArray a = mResources.obtainAttributes(Xml.asAttributeSet(parser), + R.styleable.BaseKeyboard_Case); + try { + final boolean modeMatched = matchInteger( + a, R.styleable.BaseKeyboard_Case_mode, id.mMode); + final boolean settingsKeyMatched = matchBoolean( + a, R.styleable.BaseKeyboard_Case_hasSettingsKey, id.mHasSettingsKey); + final boolean voiceEnabledMatched = matchBoolean( + a, R.styleable.BaseKeyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled); + final boolean voiceKeyMatched = matchBoolean( + a, R.styleable.BaseKeyboard_Case_hasVoiceKey, id.mHasVoiceKey); + + final boolean selected = modeMatched && settingsKeyMatched + && voiceEnabledMatched && voiceKeyMatched; + + if (DEBUG_TAG) { Log.d(TAG, "parseCaseCondition: " + Boolean.toString(selected).toUpperCase() - + (mode != -1 ? " mode=" + mode : "") - + (settingsKey != null ? " settingsKey="+settingsKey : "") - + (voiceKey != null ? " voiceKey=" + voiceKey : "")); + + debugInteger(a, + R.styleable.BaseKeyboard_Case_mode, "mode") + + debugBoolean(a, + R.styleable.BaseKeyboard_Case_hasSettingsKey, "hasSettingsKey") + + debugBoolean(a, + R.styleable.BaseKeyboard_Case_voiceKeyEnabled, "voiceKeyEnabled") + + debugBoolean(a, + R.styleable.BaseKeyboard_Case_hasVoiceKey, "hasVoiceKey") + ); + } + + return selected; + } finally { + a.recycle(); } - return selected; + } + + private static boolean matchInteger(TypedArray a, int index, int value) { + // If does not have "index" attribute, that means this is wild-card for the + // attribute. + return !a.hasValue(index) || a.getInt(index, 0) == value; + } + + private static boolean matchBoolean(TypedArray a, int index, boolean value) { + // If does not have "index" attribute, that means this is wild-card for the + // attribute. + return !a.hasValue(index) || a.getBoolean(index, false) == value; } private boolean parseDefault(XmlResourceParser parser, Row row, List keys) throws XmlPullParserException, IOException { - if (DEBUG_PARSER) debugEnterMethod("parseDefault", keys == null); if (row == null) { parseKeyboardContent(parser, keys); } else { parseRowContent(parser, row, keys); } - if (DEBUG_PARSER) debugLeaveMethod("parseDefault", keys == null); return true; } @@ -512,14 +513,6 @@ public class BaseKeyboardParser { } } - private static void debugEnterMethod(String title, boolean skip) { - Log.d(TAG, title + ": enter" + (skip ? " skip" : "")); - } - - private static void debugLeaveMethod(String title, boolean skip) { - Log.d(TAG, title + ": leave" + (skip ? " skip" : "")); - } - private static void debugStartTag(String title, String tag, boolean skip) { Log.d(TAG, title + ": <" + tag + ">" + (skip ? " skip" : "")); } @@ -527,4 +520,12 @@ public class BaseKeyboardParser { private static void debugEndTag(String title, String tag, boolean skip) { Log.d(TAG, title + ": " + (skip ? " skip" : "")); } - } + + private static String debugInteger(TypedArray a, int index, String name) { + return a.hasValue(index) ? name + "=" + a.getInt(index, 0) : ""; + } + + private static String debugBoolean(TypedArray a, int index, String name) { + return a.hasValue(index) ? name + "=" + a.getBoolean(index, false) : ""; + } +} diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index 7ae597f75..08ff41b6f 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -98,7 +98,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha /** mIsAutoCompletionActive indicates that auto completed word will be input instead of * what user actually typed. */ private boolean mIsAutoCompletionActive; - private boolean mVoiceButtonEnabled; + private boolean mVoiceKeyEnabled; private boolean mVoiceButtonOnPrimary; private int mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; @@ -139,12 +139,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final int mode = mMode; final int colorScheme = getCharColorId(); final boolean hasSettingsKey = mHasSettingsKey; - final boolean hasVoiceKey = mVoiceButtonEnabled && !mVoiceButtonOnPrimary; + final boolean voiceKeyEnabled = mVoiceKeyEnabled; + final boolean hasVoiceKey = voiceKeyEnabled && !mVoiceButtonOnPrimary; final int imeOptions = mImeOptions; - mSymbolsId = new KeyboardId(locale, orientation, mode, - KBD_SYMBOLS, colorScheme, hasSettingsKey, hasVoiceKey, imeOptions, true); - mSymbolsShiftedId = new KeyboardId(locale, orientation, mode, - KBD_SYMBOLS_SHIFT, colorScheme, hasSettingsKey, hasVoiceKey, imeOptions, true); + mSymbolsId = new KeyboardId(locale, orientation, mode, KBD_SYMBOLS, + colorScheme, hasSettingsKey, voiceKeyEnabled, hasVoiceKey, imeOptions, true); + mSymbolsShiftedId = new KeyboardId(locale, orientation, mode, KBD_SYMBOLS_SHIFT, + colorScheme, hasSettingsKey, voiceKeyEnabled, hasVoiceKey, imeOptions, true); } /** @@ -158,6 +159,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha public final int[] mXmlArray; public final int mColorScheme; public final boolean mHasSettingsKey; + public final boolean mVoiceKeyEnabled; public final boolean mHasVoiceKey; public final int mImeOptions; public final boolean mEnableShiftLock; @@ -165,14 +167,15 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private final int mHashCode; public KeyboardId(Locale locale, int orientation, int mode, - int[] xmlArray, int colorScheme, boolean hasSettingsKey, boolean hasVoiceKey, - int imeOptions, boolean enableShiftLock) { + int[] xmlArray, int colorScheme, boolean hasSettingsKey, boolean voiceKeyEnabled, + boolean hasVoiceKey, int imeOptions, boolean enableShiftLock) { this.mLocale = locale; this.mOrientation = orientation; this.mMode = mode; this.mXmlArray = xmlArray; this.mColorScheme = colorScheme; this.mHasSettingsKey = hasSettingsKey; + this.mVoiceKeyEnabled = voiceKeyEnabled; this.mHasVoiceKey = hasVoiceKey; this.mImeOptions = imeOptions; this.mEnableShiftLock = enableShiftLock; @@ -184,6 +187,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha xmlArray, colorScheme, hasSettingsKey, + voiceKeyEnabled, hasVoiceKey, imeOptions, enableShiftLock, @@ -210,6 +214,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha && other.mXmlArray == this.mXmlArray && other.mColorScheme == this.mColorScheme && other.mHasSettingsKey == this.mHasSettingsKey + && other.mVoiceKeyEnabled == this.mVoiceKeyEnabled && other.mHasVoiceKey == this.mHasVoiceKey && other.mImeOptions == this.mImeOptions && other.mEnableShiftLock == this.mEnableShiftLock; @@ -222,7 +227,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha @Override public String toString() { - return String.format("[%s %s %5s imeOptions=0x%08x xml=0x%08x %s%s%s%s]", + return String.format("[%s %s %5s imeOptions=0x%08x xml=0x%08x %s%s%s%s%s]", mLocale, (mOrientation == 1 ? "port" : "land"), modeName(mMode), @@ -230,6 +235,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mXmlArray[0], (mColorScheme == CHAR_THEME_COLOR_WHITE ? "white" : "black"), (mHasSettingsKey ? " hasSettingsKey" : ""), + (mVoiceKeyEnabled ? " voiceKeyEnabled" : ""), (mHasVoiceKey ? " hasVoiceKey" : ""), (mEnableShiftLock ? " enableShiftLock" : "")); } @@ -248,14 +254,14 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private boolean hasVoiceKey(boolean isSymbols) { - return mVoiceButtonEnabled && (isSymbols != mVoiceButtonOnPrimary); + return mVoiceKeyEnabled && (isSymbols != mVoiceButtonOnPrimary); } - public void loadKeyboard(int mode, int imeOptions, boolean voiceButtonEnabled, + public void loadKeyboard(int mode, int imeOptions, boolean voiceKeyEnabled, boolean voiceButtonOnPrimary) { mSymbolsModeState = SYMBOLS_MODE_STATE_NONE; try { - loadKeyboardInternal(mode, imeOptions, voiceButtonEnabled, voiceButtonOnPrimary, + loadKeyboardInternal(mode, imeOptions, voiceKeyEnabled, voiceButtonOnPrimary, false); } catch (RuntimeException e) { Log.w(TAG, e); @@ -270,7 +276,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mMode = mode; mImeOptions = imeOptions; - mVoiceButtonEnabled = voiceButtonEnabled; + mVoiceKeyEnabled = voiceButtonEnabled; mVoiceButtonOnPrimary = voiceButtonOnPrimary; mIsSymbols = isSymbols; // Update the settings key state because number of enabled IMEs could have been changed @@ -298,11 +304,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final Locale savedLocale = mSubtypeSwitcher.changeSystemLocale( mSubtypeSwitcher.getInputLocale()); - final int xml = id.getXmlId(); keyboard = new LatinKeyboard(mInputMethodService, id); - keyboard.setVoiceMode( - hasVoiceKey(xml == R.xml.kbd_symbols || xml == R.xml.kbd_symbols_black), - mVoiceButtonEnabled); keyboard.setImeOptions(res, id.mMode, id.mImeOptions); keyboard.setColorOfSymbolIcons(isBlackSym(id.mColorScheme)); @@ -340,8 +342,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } final int orientation = mInputMethodService.getResources().getConfiguration().orientation; final Locale locale = mSubtypeSwitcher.getInputLocale(); - return new KeyboardId(locale, orientation, mode, xmlArray, - charColorId, mHasSettingsKey, hasVoiceKey, imeOptions, enableShiftLock); + return new KeyboardId(locale, orientation, mode, xmlArray, charColorId, + mHasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, imeOptions, enableShiftLock); } public int getKeyboardMode() { @@ -605,7 +607,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } private void toggleKeyboardMode() { - loadKeyboardInternal(mMode, mImeOptions, mVoiceButtonEnabled, mVoiceButtonOnPrimary, + loadKeyboardInternal(mMode, mImeOptions, mVoiceKeyEnabled, mVoiceButtonOnPrimary, !mIsSymbols); if (mIsSymbols) { mSymbolsModeState = SYMBOLS_MODE_STATE_BEGIN; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e24bc0e6d..9c7af3557 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -200,7 +200,7 @@ public class LatinIME extends InputMethodService private boolean mLocaleSupportedForVoiceInput; private boolean mIsShowingHint; private int mCorrectionMode; - private boolean mVoiceButtonEnabled; + private boolean mVoiceKeyEnabled; private boolean mVoiceButtonOnPrimary; private int mOrientation; private List mSuggestPuncList; @@ -531,7 +531,7 @@ public class LatinIME extends InputMethodService final int mode = mKeyboardSwitcher.getKeyboardMode(); final EditorInfo attribute = getCurrentInputEditorInfo(); final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; - mKeyboardSwitcher.loadKeyboard(mode, imeOptions, mVoiceButtonEnabled, + mKeyboardSwitcher.loadKeyboard(mode, imeOptions, mVoiceKeyEnabled, mVoiceButtonOnPrimary); } @@ -679,8 +679,7 @@ public class LatinIME extends InputMethodService mJustAddedAutoSpace = false; loadSettings(attribute); - switcher.loadKeyboard(mode, attribute.imeOptions, mVoiceButtonEnabled, - mVoiceButtonOnPrimary); + switcher.loadKeyboard(mode, attribute.imeOptions, mVoiceKeyEnabled, mVoiceButtonOnPrimary); switcher.updateShiftState(); setCandidatesViewShownInternal(isCandidateStripVisible(), @@ -2222,7 +2221,7 @@ public class LatinIME extends InputMethodService final int mode = switcher.getKeyboardMode(); final EditorInfo attribute = getCurrentInputEditorInfo(); final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; - switcher.loadKeyboard(mode, imeOptions, mVoiceButtonEnabled, + switcher.loadKeyboard(mode, imeOptions, mVoiceKeyEnabled, mVoiceButtonOnPrimary); initSuggest(); switcher.updateShiftState(); @@ -2468,7 +2467,7 @@ public class LatinIME extends InputMethodService if (VOICE_INSTALLED) { final String voiceMode = sp.getString(PREF_VOICE_MODE, getString(R.string.voice_mode_main)); - mVoiceButtonEnabled = !voiceMode.equals(getString(R.string.voice_mode_off)) + mVoiceKeyEnabled = !voiceMode.equals(getString(R.string.voice_mode_off)) && shouldShowVoiceButton(makeFieldContext(), attribute); mVoiceButtonOnPrimary = voiceMode.equals(getString(R.string.voice_mode_main)); } diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 6fcea227d..1242818d8 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -52,29 +52,16 @@ public class LatinKeyboard extends BaseKeyboard { private Drawable mSpaceIcon; private Drawable mSpaceAutoCompletionIndicator; private Drawable mSpacePreviewIcon; - private Drawable mMicIcon; - private Drawable mMicPreviewIcon; - private Drawable m123MicIcon; - private Drawable m123MicPreviewIcon; private final Drawable mButtonArrowLeftIcon; private final Drawable mButtonArrowRightIcon; private Key mEnterKey; - private Key mF1Key; - private final Drawable mHintIcon; private Key mSpaceKey; - private Key m123Key; private int mSpaceKeyIndex = -1; private int mSpaceDragStartX; private int mSpaceDragLastDiff; private final Resources mRes; private final Context mContext; - private int mMode; // TODO: remove this and use the corresponding mode in the parent class - // Whether this keyboard has voice icon on it - private boolean mHasVoiceButton; - // Whether voice icon is enabled at all - private boolean mVoiceEnabled; private final boolean mIsAlphaKeyboard; - private CharSequence m123Label; private boolean mCurrentlyInSpace; private SlidingLocaleDrawable mSlidingLocaleIcon; private int[] mPrefLetterFrequencies; @@ -112,22 +99,14 @@ public class LatinKeyboard extends BaseKeyboard { final Resources res = context.getResources(); mContext = context; mRes = res; - mMode = id.mMode; mShiftedIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); setDefaultBounds(mShiftLockPreviewIcon); mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space); mSpaceAutoCompletionIndicator = res.getDrawable(R.drawable.sym_keyboard_space_led); mSpacePreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_space); - mMicIcon = res.getDrawable(R.drawable.sym_keyboard_mic); - mMicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_mic); - setDefaultBounds(mMicPreviewIcon); mButtonArrowLeftIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_left); mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right); - m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); - m123MicPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_123_mic); - mHintIcon = res.getDrawable(R.drawable.hint_popup); - setDefaultBounds(m123MicPreviewIcon); sSpacebarVerticalCorrection = res.getDimensionPixelOffset( R.dimen.spacebar_vertical_correction); final int xmlLayoutResId = id.getXmlId(); @@ -154,16 +133,9 @@ public class LatinKeyboard extends BaseKeyboard { case LatinIME.KEYCODE_ENTER: mEnterKey = key; break; - case LatinKeyboardView.KEYCODE_F1: - mF1Key = key; - break; case LatinIME.KEYCODE_SPACE: mSpaceKey = key; break; - case KEYCODE_MODE_CHANGE: - m123Key = key; - m123Label = key.label; - break; } return key; @@ -180,7 +152,6 @@ public class LatinKeyboard extends BaseKeyboard { } public void setImeOptions(Resources res, int mode, int options) { - mMode = mode; if (mEnterKey == null) return; final boolean configDynamicKeyTopEnterKey = res.getBoolean( @@ -290,87 +261,10 @@ public class LatinKeyboard extends BaseKeyboard { if (isBlack) { mShiftedIcon = res.getDrawable(R.drawable.sym_bkeyboard_shift_locked); mSpaceIcon = res.getDrawable(R.drawable.sym_bkeyboard_space); - mMicIcon = res.getDrawable(R.drawable.sym_bkeyboard_mic); - m123MicIcon = res.getDrawable(R.drawable.sym_bkeyboard_123_mic); } else { mShiftedIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mSpaceIcon = res.getDrawable(R.drawable.sym_keyboard_space); - mMicIcon = res.getDrawable(R.drawable.sym_keyboard_mic); - m123MicIcon = res.getDrawable(R.drawable.sym_keyboard_123_mic); } - updateDynamicKeys(); - } - - public void setVoiceMode(boolean hasVoiceButton, boolean hasVoice) { - mHasVoiceButton = hasVoiceButton; - mVoiceEnabled = hasVoice; - updateDynamicKeys(); - } - - private void updateDynamicKeys() { - update123Key(); - updateF1Key(); - } - - private void update123Key() { - final boolean configDynamicKeyTopSymbolKey = mRes.getBoolean( - R.bool.config_dynamic_key_top_symbol_key); - // Update KEYCODE_MODE_CHANGE key only on alphabet mode, not on symbol mode. - if (m123Key != null && mIsAlphaKeyboard) { - if (configDynamicKeyTopSymbolKey && mVoiceEnabled && !mHasVoiceButton) { - m123Key.icon = m123MicIcon; - m123Key.iconPreview = m123MicPreviewIcon; - m123Key.label = null; - } else { - m123Key.icon = null; - m123Key.iconPreview = null; - m123Key.label = m123Label; - } - } - } - - private void updateF1Key() { - // Update KEYCODE_F1 key. Please note that some keyboard layouts have no F1 key. - if (mF1Key == null) - return; - - if (mIsAlphaKeyboard) { - if (mMode == KeyboardSwitcher.MODE_URL) { - setNonMicF1Key(mF1Key, "/", R.xml.popup_slash); - } else if (mMode == KeyboardSwitcher.MODE_EMAIL) { - setNonMicF1Key(mF1Key, "@", R.xml.popup_at); - } else { - if (mVoiceEnabled && mHasVoiceButton) { - setMicF1Key(mF1Key); - } else { - setNonMicF1Key(mF1Key, ",", R.xml.popup_comma); - } - } - } else { // Symbols keyboard - if (mVoiceEnabled && mHasVoiceButton) { - setMicF1Key(mF1Key); - } else { - setNonMicF1Key(mF1Key, ",", R.xml.popup_comma); - } - } - } - - private void setMicF1Key(Key key) { - key.label = null; - key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; - key.popupResId = R.xml.popup_mic; - key.icon = mMicIcon; - key.hintIcon = mHintIcon; - key.iconPreview = mMicPreviewIcon; - } - - private void setNonMicF1Key(Key key, String label, int popupResId) { - key.label = label; - key.codes = new int[] { label.charAt(0) }; - key.popupResId = popupResId; - key.icon = null; - key.hintIcon = mHintIcon; - key.iconPreview = null; } /** diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java index a215621d1..fb8b69ed0 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboardView.java @@ -34,8 +34,8 @@ public class LatinKeyboardView extends BaseKeyboardView { public static final int KEYCODE_OPTIONS = -100; public static final int KEYCODE_OPTIONS_LONGPRESS = -101; + // TODO: remove this once LatinIME stops referring to this. public static final int KEYCODE_VOICE = -102; - public static final int KEYCODE_F1 = -103; public static final int KEYCODE_NEXT_LANGUAGE = -104; public static final int KEYCODE_PREV_LANGUAGE = -105; public static final int KEYCODE_CAPSLOCK = -106;