diff options
author | 2010-02-26 11:47:05 -0800 | |
---|---|---|
committer | 2010-02-26 11:47:05 -0800 | |
commit | 1ca22671191f5079a104bd7c73078561a5f48ef6 (patch) | |
tree | dc2bce8ff05a6d97e9afe7d0d1afc225fe8f7fbf /src/com/android/inputmethod/latin/LatinKeyboard.java | |
parent | 9468335a06d2b0e3ef15f4f57f8c1b0857b34ebe (diff) | |
download | latinime-1ca22671191f5079a104bd7c73078561a5f48ef6.tar.gz latinime-1ca22671191f5079a104bd7c73078561a5f48ef6.tar.xz latinime-1ca22671191f5079a104bd7c73078561a5f48ef6.zip |
Fix for microphone icon showing up incorrectly on the ?123 icon.
This also addresses the defaults for voice button on a wiped device.
I think it also addresses mic button showing up when not expected by a specific text field
that has the privateImeOptions of "nm".
Bugs 2417842, 2242893
Diffstat (limited to 'src/com/android/inputmethod/latin/LatinKeyboard.java')
-rw-r--r-- | src/com/android/inputmethod/latin/LatinKeyboard.java | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/com/android/inputmethod/latin/LatinKeyboard.java b/src/com/android/inputmethod/latin/LatinKeyboard.java index 9b742a5f9..58e1dc767 100644 --- a/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -69,7 +69,12 @@ public class LatinKeyboard extends Keyboard { private Resources mRes; private Context mContext; private int mMode; - private boolean mHasVoice; + // Whether this keyboard has voice icon on it + private boolean mHasVoiceButton; + // Whether voice icon is enabled at all + private boolean mVoiceEnabled; + private boolean mIsAlphaKeyboard; + private CharSequence m123Label; private boolean mCurrentlyInSpace; private SlidingLocaleDrawable mSlidingLocaleIcon; private Rect mBounds = new Rect(); @@ -95,16 +100,15 @@ public class LatinKeyboard extends Keyboard { static int sSpacebarVerticalCorrection; public LatinKeyboard(Context context, int xmlLayoutResId) { - this(context, xmlLayoutResId, 0, false); + this(context, xmlLayoutResId, 0); } - public LatinKeyboard(Context context, int xmlLayoutResId, int mode, boolean hasVoice) { + public LatinKeyboard(Context context, int xmlLayoutResId, int mode) { super(context, xmlLayoutResId, mode); final Resources res = context.getResources(); mContext = context; mMode = mode; mRes = res; - mHasVoice = hasVoice; mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked); mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked); mShiftLockPreviewIcon.setBounds(0, 0, @@ -122,7 +126,7 @@ public class LatinKeyboard extends Keyboard { setDefaultBounds(m123MicPreviewIcon); sSpacebarVerticalCorrection = res.getDimensionPixelOffset( R.dimen.spacebar_vertical_correction); - setF1Key(xmlLayoutResId == R.xml.kbd_qwerty); + mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty; mSpaceKeyIndex = indexOf((int) ' '); } @@ -147,6 +151,7 @@ public class LatinKeyboard extends Keyboard { break; case KEYCODE_MODE_CHANGE: m123Key = key; + m123Label = key.label; break; } return key; @@ -284,23 +289,36 @@ public class LatinKeyboard extends Keyboard { drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); } - private void setF1Key(boolean isAlphaKeyboard) { + public void setVoiceMode(boolean hasVoiceButton, boolean hasVoice) { + mHasVoiceButton = hasVoiceButton; + mVoiceEnabled = hasVoice; + updateF1Key(); + } + + private void updateF1Key() { if (mF1Key == null) return; - if (!mHasVoice) { - mF1Key.label = ","; - mF1Key.codes = new int[] { ',' }; - mF1Key.icon = null; - mF1Key.iconPreview = null; - if (isAlphaKeyboard && m123Key != null) { + if (m123Key != null && mIsAlphaKeyboard) { + if (mVoiceEnabled && !mHasVoiceButton) { m123Key.icon = m123MicIcon; m123Key.iconPreview = m123MicPreviewIcon; m123Key.label = null; + } else { + m123Key.icon = null; + m123Key.iconPreview = null; + m123Key.label = m123Label; } - } else { + } + + if (mHasVoiceButton && mVoiceEnabled) { mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE }; mF1Key.label = null; mF1Key.icon = mMicIcon; mF1Key.iconPreview = mMicPreviewIcon; + } else { + mF1Key.label = ","; + mF1Key.codes = new int[] { ',' }; + mF1Key.icon = null; + mF1Key.iconPreview = null; } } |