Fix a bug where mic/emoji key wouldn't work.
Bug: 17272902 Bug: 17269948 Change-Id: I561609fa84a6265f8148db7d2411bc1fd38dd163main
parent
9cf69a45b2
commit
e38043849e
|
@ -28,6 +28,7 @@ import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
||||||
|
import com.android.inputmethod.event.Event;
|
||||||
import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException;
|
import com.android.inputmethod.keyboard.KeyboardLayoutSet.KeyboardLayoutSetException;
|
||||||
import com.android.inputmethod.keyboard.emoji.EmojiPalettesView;
|
import com.android.inputmethod.keyboard.emoji.EmojiPalettesView;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardState;
|
import com.android.inputmethod.keyboard.internal.KeyboardState;
|
||||||
|
@ -311,9 +312,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
/**
|
/**
|
||||||
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
* Updates state machine to figure out when to automatically switch back to the previous mode.
|
||||||
*/
|
*/
|
||||||
public void onCodeInput(final int code, final int currentAutoCapsState,
|
public void onEvent(final Event event, final int currentAutoCapsState,
|
||||||
final int currentRecapitalizeState) {
|
final int currentRecapitalizeState) {
|
||||||
mState.onCodeInput(code, currentAutoCapsState, currentRecapitalizeState);
|
mState.onEvent(event, currentAutoCapsState, currentRecapitalizeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingEmojiPalettes() {
|
public boolean isShowingEmojiPalettes() {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.inputmethod.event.Event;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
*
|
*
|
||||||
* The input events are {@link #onLoadKeyboard(int, int)}, {@link #onSaveKeyboardState()},
|
* The input events are {@link #onLoadKeyboard(int, int)}, {@link #onSaveKeyboardState()},
|
||||||
* {@link #onPressKey(int,boolean,int,int)}, {@link #onReleaseKey(int,boolean,int,int)},
|
* {@link #onPressKey(int,boolean,int,int)}, {@link #onReleaseKey(int,boolean,int,int)},
|
||||||
* {@link #onCodeInput(int,int,int)}, {@link #onFinishSlidingInput(int,int)},
|
* {@link #onEvent(Event,int,int)}, {@link #onFinishSlidingInput(int,int)},
|
||||||
* {@link #onUpdateShiftState(int,int)}, {@link #onResetKeyboardStateToAlphabet(int,int)}.
|
* {@link #onUpdateShiftState(int,int)}, {@link #onResetKeyboardStateToAlphabet(int,int)}.
|
||||||
*
|
*
|
||||||
* The actions are {@link SwitchActions}'s methods.
|
* The actions are {@link SwitchActions}'s methods.
|
||||||
|
@ -610,10 +611,11 @@ public final class KeyboardState {
|
||||||
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCodeInput(final int code, final int currentAutoCapsState,
|
public void onEvent(final Event event, final int currentAutoCapsState,
|
||||||
final int currentRecapitalizeState) {
|
final int currentRecapitalizeState) {
|
||||||
|
final int code = event.isFunctionalKeyEvent() ? event.mKeyCode : event.mCodePoint;
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code)
|
Log.d(TAG, "onEvent: code=" + Constants.printableCode(code)
|
||||||
+ " autoCaps=" + currentAutoCapsState + " " + this);
|
+ " autoCaps=" + currentAutoCapsState + " " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// code) needs the coordinates in the keyboard frame.
|
// code) needs the coordinates in the keyboard frame.
|
||||||
// TODO: We should reconsider which coordinate system should be used to represent
|
// TODO: We should reconsider which coordinate system should be used to represent
|
||||||
// keyboard event. Also we should pull this up -- LatinIME has no business doing
|
// keyboard event. Also we should pull this up -- LatinIME has no business doing
|
||||||
// this transformation, it should be done already before calling onCodeInput.
|
// this transformation, it should be done already before calling onEvent.
|
||||||
final int keyX = mainKeyboardView.getKeyX(x);
|
final int keyX = mainKeyboardView.getKeyX(x);
|
||||||
final int keyY = mainKeyboardView.getKeyY(y);
|
final int keyY = mainKeyboardView.getKeyY(y);
|
||||||
final Event event = createSoftwareKeypressEvent(getCodePointForKeyboard(codePoint),
|
final Event event = createSoftwareKeypressEvent(getCodePointForKeyboard(codePoint),
|
||||||
|
@ -1308,7 +1308,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
// This method is public for testability of LatinIME, but also in the future it should
|
// This method is public for testability of LatinIME, but also in the future it should
|
||||||
// completely replace #onCodeInput.
|
// completely replace #onCodeInput.
|
||||||
public void onEvent(final Event event) {
|
public void onEvent(final Event event) {
|
||||||
if (Constants.CODE_SHORTCUT == event.mCodePoint) {
|
if (Constants.CODE_SHORTCUT == event.mKeyCode) {
|
||||||
mSubtypeSwitcher.switchToShortcutIME(this);
|
mSubtypeSwitcher.switchToShortcutIME(this);
|
||||||
}
|
}
|
||||||
final InputTransaction completeInputTransaction =
|
final InputTransaction completeInputTransaction =
|
||||||
|
@ -1316,8 +1316,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
mKeyboardSwitcher.getKeyboardShiftMode(),
|
mKeyboardSwitcher.getKeyboardShiftMode(),
|
||||||
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
|
mKeyboardSwitcher.getCurrentKeyboardScriptId(), mHandler);
|
||||||
updateStateAfterInputTransaction(completeInputTransaction);
|
updateStateAfterInputTransaction(completeInputTransaction);
|
||||||
mKeyboardSwitcher.onCodeInput(event.mCodePoint, getCurrentAutoCapsState(),
|
mKeyboardSwitcher.onEvent(event, getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
getCurrentRecapitalizeState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper method to split the code point and the key code. Ultimately, they should not be
|
// A helper method to split the code point and the key code. Ultimately, they should not be
|
||||||
|
@ -1341,13 +1340,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
@Override
|
@Override
|
||||||
public void onTextInput(final String rawText) {
|
public void onTextInput(final String rawText) {
|
||||||
// TODO: have the keyboard pass the correct key code when we need it.
|
// TODO: have the keyboard pass the correct key code when we need it.
|
||||||
final Event event = Event.createSoftwareTextEvent(rawText, Event.NOT_A_KEY_CODE);
|
final Event event = Event.createSoftwareTextEvent(rawText, Constants.CODE_OUTPUT_TEXT);
|
||||||
final InputTransaction completeInputTransaction =
|
final InputTransaction completeInputTransaction =
|
||||||
mInputLogic.onTextInput(mSettings.getCurrent(), event,
|
mInputLogic.onTextInput(mSettings.getCurrent(), event,
|
||||||
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
mKeyboardSwitcher.getKeyboardShiftMode(), mHandler);
|
||||||
updateStateAfterInputTransaction(completeInputTransaction);
|
updateStateAfterInputTransaction(completeInputTransaction);
|
||||||
mKeyboardSwitcher.onCodeInput(Constants.CODE_OUTPUT_TEXT, getCurrentAutoCapsState(),
|
mKeyboardSwitcher.onEvent(event, getCurrentAutoCapsState(), getCurrentRecapitalizeState());
|
||||||
getCurrentRecapitalizeState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -644,7 +644,7 @@ public final class InputLogic {
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_CAPSLOCK:
|
case Constants.CODE_CAPSLOCK:
|
||||||
// Note: Changing keyboard to shift lock state is handled in
|
// Note: Changing keyboard to shift lock state is handled in
|
||||||
// {@link KeyboardSwitcher#onCodeInput(int)}.
|
// {@link KeyboardSwitcher#onEvent(Event)}.
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_SYMBOL_SHIFT:
|
case Constants.CODE_SYMBOL_SHIFT:
|
||||||
// Note: Calling back to the keyboard on the symbol Shift key is handled in
|
// Note: Calling back to the keyboard on the symbol Shift key is handled in
|
||||||
|
@ -672,11 +672,11 @@ public final class InputLogic {
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_EMOJI:
|
case Constants.CODE_EMOJI:
|
||||||
// Note: Switching emoji keyboard is being handled in
|
// Note: Switching emoji keyboard is being handled in
|
||||||
// {@link KeyboardState#onCodeInput(int,int)}.
|
// {@link KeyboardState#onEvent(Event,int)}.
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_ALPHA_FROM_EMOJI:
|
case Constants.CODE_ALPHA_FROM_EMOJI:
|
||||||
// Note: Switching back from Emoji keyboard to the main keyboard is being
|
// Note: Switching back from Emoji keyboard to the main keyboard is being
|
||||||
// handled in {@link KeyboardState#onCodeInput(int,int)}.
|
// handled in {@link KeyboardState#onEvent(Event,int)}.
|
||||||
break;
|
break;
|
||||||
case Constants.CODE_SHIFT_ENTER:
|
case Constants.CODE_SHIFT_ENTER:
|
||||||
// TODO: remove this object
|
// TODO: remove this object
|
||||||
|
|
|
@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard.internal;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.android.inputmethod.event.Event;
|
||||||
import com.android.inputmethod.latin.Constants;
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
|
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
|
||||||
public static final boolean NOT_SLIDING = false;
|
public static final boolean NOT_SLIDING = false;
|
||||||
public static final boolean SLIDING = true;
|
public static final boolean SLIDING = true;
|
||||||
// Argument for {@link KeyboardState#onCodeInput}.
|
// Argument for {@link KeyboardState#onEvent}.
|
||||||
public static final boolean SINGLE = true;
|
public static final boolean SINGLE = true;
|
||||||
public static final boolean MULTI = false;
|
public static final boolean MULTI = false;
|
||||||
public static final int CAP_MODE_OFF = Constants.TextUtils.CAP_MODE_OFF;
|
public static final int CAP_MODE_OFF = Constants.TextUtils.CAP_MODE_OFF;
|
||||||
|
@ -183,7 +184,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
} else {
|
} else {
|
||||||
mAutoCapsState = mAutoCapsMode;
|
mAutoCapsState = mAutoCapsMode;
|
||||||
}
|
}
|
||||||
mState.onCodeInput(code, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
final Event event =
|
||||||
|
Event.createSoftwareKeypressEvent(code /* codePoint */, code /* keyCode */,
|
||||||
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
|
||||||
|
false /* isKeyRepeat */);
|
||||||
|
mState.onEvent(event, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFinishSlidingInput() {
|
public void onFinishSlidingInput() {
|
||||||
|
|
Loading…
Reference in New Issue