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