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, 2242893main
parent
9468335a06
commit
1ca2267119
|
@ -178,12 +178,13 @@ public class KeyboardSwitcher {
|
||||||
mPreferSymbols);
|
mPreferSymbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setKeyboardMode(int mode, int imeOptions,
|
void setKeyboardMode(int mode, int imeOptions, boolean enableVoice, boolean isSymbols) {
|
||||||
boolean enableVoice, boolean isSymbols) {
|
|
||||||
if (mInputView == null) return;
|
if (mInputView == null) return;
|
||||||
mMode = mode;
|
mMode = mode;
|
||||||
mImeOptions = imeOptions;
|
mImeOptions = imeOptions;
|
||||||
mHasVoice = enableVoice;
|
if (enableVoice != mHasVoice) {
|
||||||
|
setVoiceMode(mHasVoice, mVoiceOnPrimary);
|
||||||
|
}
|
||||||
mIsSymbols = isSymbols;
|
mIsSymbols = isSymbols;
|
||||||
|
|
||||||
mInputView.setPreviewEnabled(true);
|
mInputView.setPreviewEnabled(true);
|
||||||
|
@ -211,7 +212,8 @@ public class KeyboardSwitcher {
|
||||||
conf.locale = mInputLocale;
|
conf.locale = mInputLocale;
|
||||||
orig.updateConfiguration(conf, null);
|
orig.updateConfiguration(conf, null);
|
||||||
LatinKeyboard keyboard = new LatinKeyboard(
|
LatinKeyboard keyboard = new LatinKeyboard(
|
||||||
mContext, id.mXml, id.mKeyboardMode, id.mHasVoice);
|
mContext, id.mXml, id.mKeyboardMode);
|
||||||
|
keyboard.setVoiceMode(hasVoiceButton(id.mXml == R.xml.kbd_symbols), mHasVoice);
|
||||||
keyboard.setLanguageSwitcher(mLanguageSwitcher);
|
keyboard.setLanguageSwitcher(mLanguageSwitcher);
|
||||||
if (id.mKeyboardMode == KEYBOARDMODE_NORMAL
|
if (id.mKeyboardMode == KEYBOARDMODE_NORMAL
|
||||||
|| id.mKeyboardMode == KEYBOARDMODE_URL
|
|| id.mKeyboardMode == KEYBOARDMODE_URL
|
||||||
|
|
|
@ -790,7 +790,7 @@ public class LatinIME extends InputMethodService
|
||||||
}
|
}
|
||||||
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
|
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
|
||||||
if (mInputView != null) {
|
if (mInputView != null) {
|
||||||
mKeyboardSwitcher.setVoiceMode(mEnableVoice, mVoiceOnPrimary);
|
mKeyboardSwitcher.setVoiceMode(mEnableVoice && mEnableVoiceButton, mVoiceOnPrimary);
|
||||||
}
|
}
|
||||||
mKeyboardSwitcher.makeKeyboards(true);
|
mKeyboardSwitcher.makeKeyboards(true);
|
||||||
}
|
}
|
||||||
|
@ -1829,8 +1829,10 @@ public class LatinIME extends InputMethodService
|
||||||
mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true);
|
mShowSuggestions = sp.getBoolean(PREF_SHOW_SUGGESTIONS, true);
|
||||||
|
|
||||||
if (VOICE_INSTALLED) {
|
if (VOICE_INSTALLED) {
|
||||||
final String voiceMode = sp.getString(PREF_VOICE_MODE, "");
|
final String voiceMode = sp.getString(PREF_VOICE_MODE,
|
||||||
boolean enableVoice = !voiceMode.equals(getString(R.string.voice_mode_off));
|
getString(R.string.voice_mode_main));
|
||||||
|
boolean enableVoice = !voiceMode.equals(getString(R.string.voice_mode_off))
|
||||||
|
&& mEnableVoiceButton;
|
||||||
boolean voiceOnPrimary = voiceMode.equals(getString(R.string.voice_mode_main));
|
boolean voiceOnPrimary = voiceMode.equals(getString(R.string.voice_mode_main));
|
||||||
if (mKeyboardSwitcher != null &&
|
if (mKeyboardSwitcher != null &&
|
||||||
(enableVoice != mEnableVoice || voiceOnPrimary != mVoiceOnPrimary)) {
|
(enableVoice != mEnableVoice || voiceOnPrimary != mVoiceOnPrimary)) {
|
||||||
|
|
|
@ -69,7 +69,12 @@ public class LatinKeyboard extends Keyboard {
|
||||||
private Resources mRes;
|
private Resources mRes;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private int mMode;
|
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 boolean mCurrentlyInSpace;
|
||||||
private SlidingLocaleDrawable mSlidingLocaleIcon;
|
private SlidingLocaleDrawable mSlidingLocaleIcon;
|
||||||
private Rect mBounds = new Rect();
|
private Rect mBounds = new Rect();
|
||||||
|
@ -95,16 +100,15 @@ public class LatinKeyboard extends Keyboard {
|
||||||
static int sSpacebarVerticalCorrection;
|
static int sSpacebarVerticalCorrection;
|
||||||
|
|
||||||
public LatinKeyboard(Context context, int xmlLayoutResId) {
|
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);
|
super(context, xmlLayoutResId, mode);
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mMode = mode;
|
mMode = mode;
|
||||||
mRes = res;
|
mRes = res;
|
||||||
mHasVoice = hasVoice;
|
|
||||||
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
|
mShiftLockIcon = res.getDrawable(R.drawable.sym_keyboard_shift_locked);
|
||||||
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
|
mShiftLockPreviewIcon = res.getDrawable(R.drawable.sym_keyboard_feedback_shift_locked);
|
||||||
mShiftLockPreviewIcon.setBounds(0, 0,
|
mShiftLockPreviewIcon.setBounds(0, 0,
|
||||||
|
@ -122,7 +126,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
setDefaultBounds(m123MicPreviewIcon);
|
setDefaultBounds(m123MicPreviewIcon);
|
||||||
sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
|
sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
|
||||||
R.dimen.spacebar_vertical_correction);
|
R.dimen.spacebar_vertical_correction);
|
||||||
setF1Key(xmlLayoutResId == R.xml.kbd_qwerty);
|
mIsAlphaKeyboard = xmlLayoutResId == R.xml.kbd_qwerty;
|
||||||
mSpaceKeyIndex = indexOf((int) ' ');
|
mSpaceKeyIndex = indexOf((int) ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +151,7 @@ public class LatinKeyboard extends Keyboard {
|
||||||
break;
|
break;
|
||||||
case KEYCODE_MODE_CHANGE:
|
case KEYCODE_MODE_CHANGE:
|
||||||
m123Key = key;
|
m123Key = key;
|
||||||
|
m123Label = key.label;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
|
@ -284,23 +289,36 @@ public class LatinKeyboard extends Keyboard {
|
||||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
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 (mF1Key == null) return;
|
||||||
if (!mHasVoice) {
|
if (m123Key != null && mIsAlphaKeyboard) {
|
||||||
mF1Key.label = ",";
|
if (mVoiceEnabled && !mHasVoiceButton) {
|
||||||
mF1Key.codes = new int[] { ',' };
|
|
||||||
mF1Key.icon = null;
|
|
||||||
mF1Key.iconPreview = null;
|
|
||||||
if (isAlphaKeyboard && m123Key != null) {
|
|
||||||
m123Key.icon = m123MicIcon;
|
m123Key.icon = m123MicIcon;
|
||||||
m123Key.iconPreview = m123MicPreviewIcon;
|
m123Key.iconPreview = m123MicPreviewIcon;
|
||||||
m123Key.label = null;
|
m123Key.label = null;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
m123Key.icon = null;
|
||||||
|
m123Key.iconPreview = null;
|
||||||
|
m123Key.label = m123Label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHasVoiceButton && mVoiceEnabled) {
|
||||||
mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
|
mF1Key.codes = new int[] { LatinKeyboardView.KEYCODE_VOICE };
|
||||||
mF1Key.label = null;
|
mF1Key.label = null;
|
||||||
mF1Key.icon = mMicIcon;
|
mF1Key.icon = mMicIcon;
|
||||||
mF1Key.iconPreview = mMicPreviewIcon;
|
mF1Key.iconPreview = mMicPreviewIcon;
|
||||||
|
} else {
|
||||||
|
mF1Key.label = ",";
|
||||||
|
mF1Key.codes = new int[] { ',' };
|
||||||
|
mF1Key.icon = null;
|
||||||
|
mF1Key.iconPreview = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue