Snap back to the previous keyboard when sliding input is canceled
Bug: 3316517 Change-Id: Iffaad1eb93b6a014d8445f3e27b0e24c20967dafmain
parent
2912c654b4
commit
5f922caff8
|
@ -20,7 +20,7 @@ public interface KeyboardActionListener {
|
|||
|
||||
/**
|
||||
* Called when the user presses a key. This is sent before the
|
||||
* {@link #onKey} is called. For keys that repeat, this is only
|
||||
* {@link #onCodeInput} is called. For keys that repeat, this is only
|
||||
* called once.
|
||||
*
|
||||
* @param primaryCode
|
||||
|
@ -31,7 +31,7 @@ public interface KeyboardActionListener {
|
|||
|
||||
/**
|
||||
* Called when the user releases a key. This is sent after the
|
||||
* {@link #onKey} is called. For keys that repeat, this is only
|
||||
* {@link #onCodeInput} is called. For keys that repeat, this is only
|
||||
* called once.
|
||||
*
|
||||
* @param primaryCode
|
||||
|
@ -54,11 +54,11 @@ public interface KeyboardActionListener {
|
|||
* accidental presses of a key adjacent to the intended
|
||||
* key.
|
||||
* @param x
|
||||
* x-coordinate pixel of touched event. If onKey is not called by onTouchEvent,
|
||||
* the value should be NOT_A_TOUCH_COORDINATE.
|
||||
* x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
||||
* onTouchEvent, the value should be NOT_A_TOUCH_COORDINATE.
|
||||
* @param y
|
||||
* y-coordinate pixel of touched event. If onKey is not called by onTouchEvent,
|
||||
* the value should be NOT_A_TOUCH_COORDINATE.
|
||||
* y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
|
||||
* onTouchEvent, the value should be NOT_A_TOUCH_COORDINATE.
|
||||
*/
|
||||
void onCodeInput(int primaryCode, int[] keyCodes, int x, int y);
|
||||
|
||||
|
|
|
@ -505,6 +505,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
mSymbolKeyState.onOtherKeyPressed();
|
||||
}
|
||||
|
||||
public void onCancelInput() {
|
||||
// Snap back to the previous keyboard mode if the user cancels sliding input.
|
||||
if (mAutoModeSwitchState == AUTO_MODE_SWITCH_STATE_MOMENTARY && getPointerCount() == 1)
|
||||
changeKeyboardMode();
|
||||
}
|
||||
|
||||
private void toggleShiftInSymbol() {
|
||||
if (isAlphabetMode())
|
||||
return;
|
||||
|
@ -563,11 +569,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
switch (mAutoModeSwitchState) {
|
||||
case AUTO_MODE_SWITCH_STATE_MOMENTARY:
|
||||
// Only distinct multi touch devices can be in this state.
|
||||
// On non-distinct multi touch devices, mode change key is handled by {@link onKey},
|
||||
// not by {@link onPress} and {@link onRelease}. So, on such devices,
|
||||
// {@link mAutoModeSwitchState} starts from {@link AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN},
|
||||
// or {@link AUTO_MODE_SWITCH_STATE_ALPHA}, not from
|
||||
// {@link AUTO_MODE_SWITCH_STATE_MOMENTARY}.
|
||||
// On non-distinct multi touch devices, mode change key is handled by
|
||||
// {@link LatinIME#onCodeInput}, not by {@link LatinIME#onPress} and
|
||||
// {@link LatinIME#onRelease}. So, on such devices, {@link #mAutoModeSwitchState} starts
|
||||
// from {@link #AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN}, or
|
||||
// {@link #AUTO_MODE_SWITCH_STATE_ALPHA}, not from
|
||||
// {@link #AUTO_MODE_SWITCH_STATE_MOMENTARY}.
|
||||
if (key == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
|
||||
// Detected only the mode change key has been pressed, and then released.
|
||||
if (mIsSymbols) {
|
||||
|
@ -578,6 +585,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
|||
} else if (getPointerCount() == 1) {
|
||||
// Snap back to the previous keyboard mode if the user pressed the mode change key
|
||||
// and slid to other key, then released the finger.
|
||||
// If the user cancels the sliding input, snapping back to the previous keyboard
|
||||
// mode is handled by {@link #onCancelInput}.
|
||||
changeKeyboardMode();
|
||||
} else {
|
||||
// Chording input is being started. The keyboard mode will be snapped back to the
|
||||
|
|
|
@ -550,7 +550,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
}
|
||||
|
||||
/**
|
||||
* When enabled, calls to {@link KeyboardActionListener#onKey} will include key
|
||||
* When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
|
||||
* codes for adjacent keys. When disabled, only the primary key code will be
|
||||
* reported.
|
||||
* @param enabled whether or not the proximity correction is enabled
|
||||
|
@ -1106,6 +1106,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
|||
|
||||
@Override
|
||||
public void onCancelInput() {
|
||||
mKeyboardActionListener.onCancelInput();
|
||||
dismissPopupKeyboard();
|
||||
}
|
||||
|
||||
|
|
|
@ -1048,8 +1048,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
return mOptionsDialog != null && mOptionsDialog.isShowing();
|
||||
}
|
||||
|
||||
// Implementation of KeyboardViewListener
|
||||
|
||||
// Implementation of {@link KeyboardActionListener}.
|
||||
@Override
|
||||
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
|
||||
long when = SystemClock.uptimeMillis();
|
||||
|
@ -1132,7 +1131,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
ic.commitText(text, 1);
|
||||
ic.endBatchEdit();
|
||||
mKeyboardSwitcher.updateShiftState();
|
||||
mKeyboardSwitcher.onKey(0); // dummy key code.
|
||||
mKeyboardSwitcher.onKey(Keyboard.CODE_DUMMY);
|
||||
mJustReverted = false;
|
||||
mJustAddedAutoSpace = false;
|
||||
mEnteredText = text;
|
||||
|
@ -1141,6 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
@Override
|
||||
public void onCancelInput() {
|
||||
// User released a finger outside any key
|
||||
mKeyboardSwitcher.onCancelInput();
|
||||
}
|
||||
|
||||
private void handleBackspace() {
|
||||
|
@ -1836,7 +1836,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private void sendSpace() {
|
||||
sendKeyChar((char)Keyboard.CODE_SPACE);
|
||||
mKeyboardSwitcher.updateShiftState();
|
||||
//onKey(KEY_SPACE[0], KEY_SPACE);
|
||||
}
|
||||
|
||||
public boolean preferCapitalization() {
|
||||
|
|
Loading…
Reference in New Issue