fix issue with sliding input when showing moreKeys

This commit is contained in:
Helium314 2024-01-01 22:33:21 +01:00
parent 58ddee786e
commit 0872f786c8

View file

@ -227,7 +227,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int trackersSize = sTrackers.size(); final int trackersSize = sTrackers.size();
for (int i = 0; i < trackersSize; ++i) { for (int i = 0; i < trackersSize; ++i) {
final PointerTracker tracker = sTrackers.get(i); final PointerTracker tracker = sTrackers.get(i);
tracker.setReleasedKeyGraphics(tracker.getKey(), true /* withAnimation */); tracker.setReleasedKeyGraphics(tracker.getKey(), true);
} }
} }
@ -302,8 +302,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (mKeyboard.hasProximityCharsCorrection(code)) { if (mKeyboard.hasProximityCharsCorrection(code)) {
sListener.onCodeInput(code, x, y, isKeyRepeat); sListener.onCodeInput(code, x, y, isKeyRepeat);
} else { } else {
sListener.onCodeInput(code, sListener.onCodeInput(code, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, isKeyRepeat);
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, isKeyRepeat);
} }
} }
} }
@ -402,7 +401,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (key.isShift()) { if (key.isShift()) {
for (final Key shiftKey : mKeyboard.mShiftKeys) { for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (shiftKey != key) { if (shiftKey != key) {
sDrawingProxy.onKeyReleased(shiftKey, false /* withAnimation */); sDrawingProxy.onKeyReleased(shiftKey, false);
} }
} }
} }
@ -411,11 +410,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int altCode = key.getAltCode(); final int altCode = key.getAltCode();
final Key altKey = mKeyboard.getKey(altCode); final Key altKey = mKeyboard.getKey(altCode);
if (altKey != null) { if (altKey != null) {
sDrawingProxy.onKeyReleased(altKey, false /* withAnimation */); sDrawingProxy.onKeyReleased(altKey, false);
} }
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) { for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
if (k != key && k.getAltCode() == altCode) { if (k != key && k.getAltCode() == altCode) {
sDrawingProxy.onKeyReleased(k, false /* withAnimation */); sDrawingProxy.onKeyReleased(k, false);
} }
} }
} }
@ -444,7 +443,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (key.isShift()) { if (key.isShift()) {
for (final Key shiftKey : mKeyboard.mShiftKeys) { for (final Key shiftKey : mKeyboard.mShiftKeys) {
if (shiftKey != key) { if (shiftKey != key) {
sDrawingProxy.onKeyPressed(shiftKey, false /* withPreview */); sDrawingProxy.onKeyPressed(shiftKey, false);
} }
} }
} }
@ -453,11 +452,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int altCode = key.getAltCode(); final int altCode = key.getAltCode();
final Key altKey = mKeyboard.getKey(altCode); final Key altKey = mKeyboard.getKey(altCode);
if (altKey != null) { if (altKey != null) {
sDrawingProxy.onKeyPressed(altKey, false /* withPreview */); sDrawingProxy.onKeyPressed(altKey, false);
} }
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) { for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
if (k != key && k.getAltCode() == altCode) { if (k != key && k.getAltCode() == altCode) {
sDrawingProxy.onKeyPressed(k, false /* withPreview */); sDrawingProxy.onKeyPressed(k, false);
} }
} }
} }
@ -532,8 +531,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
return; return;
} }
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen. // A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
sDrawingProxy.showGestureTrail( sDrawingProxy.showGestureTrail(this, isOldestTrackerInQueue());
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
} }
public void updateBatchInputByTimer(final long syntheticMoveEventTime) { public void updateBatchInputByTimer(final long syntheticMoveEventTime) {
@ -692,7 +690,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// {@link #setKeyboard}. In those cases, we should update key according to the new // {@link #setKeyboard}. In those cases, we should update key according to the new
// keyboard layout. // keyboard layout.
// Also height difference between keyboards needs to be considered. // Also height difference between keyboards needs to be considered.
if (callListenerOnPressAndCheckKeyboardLayoutChange(key, 0 /* repeatCount */)) { if (callListenerOnPressAndCheckKeyboardLayoutChange(key, 0)) {
final int yOffset = keyboardChangeOccupiedHeightDifference; final int yOffset = keyboardChangeOccupiedHeightDifference;
keyboardChangeOccupiedHeightDifference = 0; keyboardChangeOccupiedHeightDifference = 0;
CoordinateUtils.set(mDownCoordinates, x, y + yOffset); CoordinateUtils.set(mDownCoordinates, x, y + yOffset);
@ -719,7 +717,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private void resetKeySelectionByDraggingFinger() { private void resetKeySelectionByDraggingFinger() {
mIsInDraggingFinger = false; mIsInDraggingFinger = false;
mIsInSlidingKeyInput = false; mIsInSlidingKeyInput = false;
sDrawingProxy.showSlidingKeyInputPreview(null /* tracker */); sDrawingProxy.showSlidingKeyInputPreview(null);
} }
private void onGestureMoveEvent(final int x, final int y, final long eventTime, private void onGestureMoveEvent(final int x, final int y, final long eventTime,
@ -769,8 +767,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int historicalX = (int)me.getHistoricalX(pointerIndex, h); final int historicalX = (int)me.getHistoricalX(pointerIndex, h);
final int historicalY = (int)me.getHistoricalY(pointerIndex, h); final int historicalY = (int)me.getHistoricalY(pointerIndex, h);
final long historicalTime = me.getHistoricalEventTime(h); final long historicalTime = me.getHistoricalEventTime(h);
onGestureMoveEvent(historicalX, historicalY, historicalTime, onGestureMoveEvent(historicalX, historicalY, historicalTime, false, null);
false /* isMajorEvent */, null);
} }
} }
@ -793,7 +790,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// at {@link #setKeyboard}. In those cases, we should update key according // at {@link #setKeyboard}. In those cases, we should update key according
// to the new keyboard layout. // to the new keyboard layout.
Key key = newKey; Key key = newKey;
if (callListenerOnPressAndCheckKeyboardLayoutChange(key, 0 /* repeatCount */)) { if (callListenerOnPressAndCheckKeyboardLayoutChange(key, 0)) {
key = onMoveKey(x, y); key = onMoveKey(x, y);
} }
onMoveToNewKey(key, x, y); onMoveToNewKey(key, x, y);
@ -838,8 +835,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
} }
private void processDraggingFingerOutFromOldKey(final Key oldKey) { private void processDraggingFingerOutFromOldKey(final Key oldKey) {
setReleasedKeyGraphics(oldKey, true /* withAnimation */); setReleasedKeyGraphics(oldKey, true);
callListenerOnRelease(oldKey, oldKey.getCode(), true /* withSliding */); callListenerOnRelease(oldKey, oldKey.getCode(), true);
startKeySelectionByDraggingFinger(oldKey); startKeySelectionByDraggingFinger(oldKey);
sTimerProxy.cancelKeyTimersOf(this); sTimerProxy.cancelKeyTimersOf(this);
} }
@ -881,12 +878,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
} }
onUpEvent(x, y, eventTime); onUpEvent(x, y, eventTime);
cancelTrackingForAction(); cancelTrackingForAction();
setReleasedKeyGraphics(oldKey, true /* withAnimation */); setReleasedKeyGraphics(oldKey, true);
} else { } else {
if (!mIsDetectingGesture) { if (!mIsDetectingGesture) {
cancelTrackingForAction(); cancelTrackingForAction();
} }
setReleasedKeyGraphics(oldKey, true /* withAnimation */); setReleasedKeyGraphics(oldKey, true);
} }
} }
@ -957,10 +954,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (sGestureEnabler.shouldHandleGesture()) { if (sGestureEnabler.shouldHandleGesture()) {
// Register move event on gesture tracker. // Register move event on gesture tracker.
onGestureMoveEvent(x, y, eventTime, true /* isMajorEvent */, newKey); onGestureMoveEvent(x, y, eventTime, true, newKey);
if (sInGesture) { if (sInGesture) {
mCurrentKey = null; mCurrentKey = null;
setReleasedKeyGraphics(oldKey, true /* withAnimation */); setReleasedKeyGraphics(oldKey, true);
return; return;
} }
} }
@ -1025,7 +1022,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int currentRepeatingKeyCode = mCurrentRepeatingKeyCode; final int currentRepeatingKeyCode = mCurrentRepeatingKeyCode;
mCurrentRepeatingKeyCode = Constants.NOT_A_CODE; mCurrentRepeatingKeyCode = Constants.NOT_A_CODE;
// Release the last pressed key. // Release the last pressed key.
setReleasedKeyGraphics(currentKey, true /* withAnimation */); setReleasedKeyGraphics(currentKey, true);
if(mCursorMoved && currentKey.getCode() == Constants.CODE_DELETE) { if(mCursorMoved && currentKey.getCode() == Constants.CODE_DELETE) {
sListener.onUpWithDeletePointerActive(); sListener.onUpWithDeletePointerActive();
@ -1038,6 +1035,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
mMoreKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime); mMoreKeysPanel.onUpEvent(translatedX, translatedY, mPointerId, eventTime);
} }
dismissMoreKeysPanel(); dismissMoreKeysPanel();
if (isInSlidingKeyInput)
callListenerOnFinishSlidingInput();
return; return;
} }
@ -1049,7 +1048,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (sInGesture) { if (sInGesture) {
if (currentKey != null) { if (currentKey != null) {
callListenerOnRelease(currentKey, currentKey.getCode(), true /* withSliding */); callListenerOnRelease(currentKey, currentKey.getCode(), true);
} }
if (mBatchInputArbiter.mayEndBatchInput( if (mBatchInputArbiter.mayEndBatchInput(
eventTime, getActivePointerTrackerCount(), this)) { eventTime, getActivePointerTrackerCount(), this)) {
@ -1099,10 +1098,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (key.hasNoPanelAutoMoreKey()) { if (key.hasNoPanelAutoMoreKey()) {
cancelKeyTracking(); cancelKeyTracking();
final int moreKeyCode = key.getMoreKeys()[0].mCode; final int moreKeyCode = key.getMoreKeys()[0].mCode;
sListener.onPressKey(moreKeyCode, 0 /* repeatCont */, true /* isSinglePointer */); sListener.onPressKey(moreKeyCode, 0, true);
sListener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, sListener.onCodeInput(moreKeyCode, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false);
Constants.NOT_A_COORDINATE, false /* isKeyRepeat */); sListener.onReleaseKey(moreKeyCode, false);
sListener.onReleaseKey(moreKeyCode, false /* withSliding */);
return; return;
} }
final int code = key.getCode(); final int code = key.getCode();
@ -1110,7 +1108,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// Long pressing the space key invokes IME switcher dialog. // Long pressing the space key invokes IME switcher dialog.
if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) { if (sListener.onCustomRequest(Constants.CUSTOM_CODE_SHOW_INPUT_METHOD_PICKER)) {
cancelKeyTracking(); cancelKeyTracking();
sListener.onReleaseKey(code, false /* withSliding */); sListener.onReleaseKey(code, false);
return; return;
} }
} }
@ -1129,7 +1127,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private void cancelKeyTracking() { private void cancelKeyTracking() {
resetKeySelectionByDraggingFinger(); resetKeySelectionByDraggingFinger();
cancelTrackingForAction(); cancelTrackingForAction();
setReleasedKeyGraphics(mCurrentKey, true /* withAnimation */); setReleasedKeyGraphics(mCurrentKey, true);
sPointerTrackerQueue.remove(this); sPointerTrackerQueue.remove(this);
} }
@ -1146,7 +1144,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
private void onCancelEventInternal() { private void onCancelEventInternal() {
sTimerProxy.cancelKeyTimersOf(this); sTimerProxy.cancelKeyTimersOf(this);
setReleasedKeyGraphics(mCurrentKey, true /* withAnimation */); setReleasedKeyGraphics(mCurrentKey, true);
resetKeySelectionByDraggingFinger(); resetKeySelectionByDraggingFinger();
dismissMoreKeysPanel(); dismissMoreKeysPanel();
} }
@ -1175,12 +1173,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
if (!mIsAllowedDraggingFinger && sTypingTimeRecorder.isInFastTyping(eventTime) if (!mIsAllowedDraggingFinger && sTypingTimeRecorder.isInFastTyping(eventTime)
&& mBogusMoveEventDetector.hasTraveledLongDistance(x, y)) { && mBogusMoveEventDetector.hasTraveledLongDistance(x, y)) {
if (DEBUG_MODE) { if (DEBUG_MODE) {
final float keyDiagonal = (float)Math.hypot( final float keyDiagonal = (float)Math.hypot(mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
final float lengthFromDownRatio = mBogusMoveEventDetector.getAccumulatedDistanceFromDownKey() / keyDiagonal; final float lengthFromDownRatio = mBogusMoveEventDetector.getAccumulatedDistanceFromDownKey() / keyDiagonal;
Log.d(TAG, String.format(Locale.US, "[%d] isMajorEnoughMoveToBeOnNewKey:" Log.d(TAG, String.format(Locale.US, "[%d] isMajorEnoughMoveToBeOnNewKey:"
+ " %.2f key diagonal from virtual down point", + " %.2f key diagonal from virtual down point", mPointerId, lengthFromDownRatio));
mPointerId, lengthFromDownRatio));
} }
return true; return true;
} }
@ -1225,8 +1221,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
} }
final int code = key.getCode(); final int code = key.getCode();
callListenerOnCodeInput(key, code, x, y, eventTime, false /* isKeyRepeat */); callListenerOnCodeInput(key, code, x, y, eventTime, false);
callListenerOnRelease(key, code, false /* withSliding */); callListenerOnRelease(key, code, false);
} }
private void startRepeatKey(final Key key) { private void startRepeatKey(final Key key) {
@ -1250,8 +1246,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
final int nextRepeatCount = repeatCount + 1; final int nextRepeatCount = repeatCount + 1;
startKeyRepeatTimer(nextRepeatCount); startKeyRepeatTimer(nextRepeatCount);
callListenerOnPressAndCheckKeyboardLayoutChange(key, repeatCount); callListenerOnPressAndCheckKeyboardLayoutChange(key, repeatCount);
callListenerOnCodeInput(key, code, mKeyX, mKeyY, SystemClock.uptimeMillis(), callListenerOnCodeInput(key, code, mKeyX, mKeyY, SystemClock.uptimeMillis(), true);
true /* isKeyRepeat */);
} }
private void startKeyRepeatTimer(final int repeatCount) { private void startKeyRepeatTimer(final int repeatCount) {