Loading java/src/com/android/inputmethod/keyboard/PointerTracker.java +21 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private static boolean sGestureHandlingEnabledByInputField = false; private static boolean sGestureHandlingEnabledByUser = false; // TODO: Move this to resource. private static final int SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION = 1000; // msec public interface KeyEventHandler { /** * Get KeyDetector object that is used for this PointerTracker. Loading Loading @@ -165,6 +168,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private boolean mIsDetectingGesture = false; // per PointerTracker. private static boolean sInGesture = false; private static long sGestureFirstDownTime; private static long sLastBatchInputTime; private static long sLastLetterTypingUpTime; private static final InputPointers sAggregratedPointers = new InputPointers( GestureStroke.DEFAULT_CAPACITY); Loading Loading @@ -345,6 +349,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } // Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state. if (key.isEnabled() || altersCode) { sLastBatchInputTime = 0; // reset time if (code == Keyboard.CODE_OUTPUT_TEXT) { mListener.onTextInput(key.getOutputText()); } else if (code != Keyboard.CODE_UNSPECIFIED) { Loading Loading @@ -452,7 +457,15 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } private void setPressedKeyGraphics(final Key key) { private static boolean needsToSuppressKeyPreviewPopup(final long eventTime) { if (!sShouldHandleGesture) return false; if (sLastBatchInputTime == 0) return false; final long elapsedTimeAfterTheLastBatchInput = eventTime - sLastBatchInputTime; return elapsedTimeAfterTheLastBatchInput < SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION; } private void setPressedKeyGraphics(final Key key, final long eventTime) { if (key == null) { return; } Loading @@ -464,7 +477,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } if (!key.noKeyPreview() && !sInGesture) { if (!key.noKeyPreview() && !sInGesture && !needsToSuppressKeyPreviewPopup(eventTime)) { mDrawingProxy.showKeyPreview(this); } updatePressKeyGraphics(key); Loading Loading @@ -579,7 +592,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker); } private void mayEndBatchInput() { private void mayEndBatchInput(final long eventTime) { synchronized (sAggregratedPointers) { mGestureStrokeWithPreviewPoints.appendAllBatchPoints(sAggregratedPointers); mGestureStrokeWithPreviewPoints.reset(); Loading @@ -589,6 +602,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { + sAggregratedPointers.getPointerSize()); } sInGesture = false; sLastBatchInputTime = eventTime; mListener.onEndBatchInput(sAggregratedPointers); clearBatchInputPointsOfAllPointerTrackers(); } Loading Loading @@ -714,7 +728,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { startRepeatKey(key); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } } Loading Loading @@ -792,7 +806,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } onMoveToNewKey(key, x, y); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } else if (isMajorEnoughMoveToBeOnNewKey(x, y, key)) { // The pointer has been slid in to the new key from the previous key, we must call // onRelease() first to notify that the previous key has been released, then call Loading @@ -811,7 +825,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } onMoveToNewKey(key, x, y); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } else { // HACK: On some devices, quick successive touches may be translated to sudden // move by touch panel firmware. This hack detects the case and translates the Loading Loading @@ -922,7 +936,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (currentKey != null) { callListenerOnRelease(currentKey, currentKey.mCode, true); } mayEndBatchInput(); mayEndBatchInput(eventTime); return; } // This event will be recognized as a regular code input. Clear unused possible batch points Loading Loading
java/src/com/android/inputmethod/keyboard/PointerTracker.java +21 −7 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private static boolean sGestureHandlingEnabledByInputField = false; private static boolean sGestureHandlingEnabledByUser = false; // TODO: Move this to resource. private static final int SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION = 1000; // msec public interface KeyEventHandler { /** * Get KeyDetector object that is used for this PointerTracker. Loading Loading @@ -165,6 +168,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private boolean mIsDetectingGesture = false; // per PointerTracker. private static boolean sInGesture = false; private static long sGestureFirstDownTime; private static long sLastBatchInputTime; private static long sLastLetterTypingUpTime; private static final InputPointers sAggregratedPointers = new InputPointers( GestureStroke.DEFAULT_CAPACITY); Loading Loading @@ -345,6 +349,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } // Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state. if (key.isEnabled() || altersCode) { sLastBatchInputTime = 0; // reset time if (code == Keyboard.CODE_OUTPUT_TEXT) { mListener.onTextInput(key.getOutputText()); } else if (code != Keyboard.CODE_UNSPECIFIED) { Loading Loading @@ -452,7 +457,15 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } private void setPressedKeyGraphics(final Key key) { private static boolean needsToSuppressKeyPreviewPopup(final long eventTime) { if (!sShouldHandleGesture) return false; if (sLastBatchInputTime == 0) return false; final long elapsedTimeAfterTheLastBatchInput = eventTime - sLastBatchInputTime; return elapsedTimeAfterTheLastBatchInput < SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION; } private void setPressedKeyGraphics(final Key key, final long eventTime) { if (key == null) { return; } Loading @@ -464,7 +477,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } if (!key.noKeyPreview() && !sInGesture) { if (!key.noKeyPreview() && !sInGesture && !needsToSuppressKeyPreviewPopup(eventTime)) { mDrawingProxy.showKeyPreview(this); } updatePressKeyGraphics(key); Loading Loading @@ -579,7 +592,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mDrawingProxy.showGesturePreviewTrail(this, isOldestTracker); } private void mayEndBatchInput() { private void mayEndBatchInput(final long eventTime) { synchronized (sAggregratedPointers) { mGestureStrokeWithPreviewPoints.appendAllBatchPoints(sAggregratedPointers); mGestureStrokeWithPreviewPoints.reset(); Loading @@ -589,6 +602,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { + sAggregratedPointers.getPointerSize()); } sInGesture = false; sLastBatchInputTime = eventTime; mListener.onEndBatchInput(sAggregratedPointers); clearBatchInputPointsOfAllPointerTrackers(); } Loading Loading @@ -714,7 +728,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { startRepeatKey(key); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } } Loading Loading @@ -792,7 +806,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } onMoveToNewKey(key, x, y); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } else if (isMajorEnoughMoveToBeOnNewKey(x, y, key)) { // The pointer has been slid in to the new key from the previous key, we must call // onRelease() first to notify that the previous key has been released, then call Loading @@ -811,7 +825,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } onMoveToNewKey(key, x, y); startLongPressTimer(key); setPressedKeyGraphics(key); setPressedKeyGraphics(key, eventTime); } else { // HACK: On some devices, quick successive touches may be translated to sudden // move by touch panel firmware. This hack detects the case and translates the Loading Loading @@ -922,7 +936,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (currentKey != null) { callListenerOnRelease(currentKey, currentKey.mCode, true); } mayEndBatchInput(); mayEndBatchInput(eventTime); return; } // This event will be recognized as a regular code input. Clear unused possible batch points Loading