am 904866c7: Clean up batch input related code a bit
* commit '904866c701cd1708f1a2a31e53dfc262ec3eb2b5': Clean up batch input related code a bitmain
commit
fe13939345
|
@ -576,40 +576,29 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return sPointerTrackerQueue.getOldestElement() == this;
|
return sPointerTrackerQueue.getOldestElement() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mayStartBatchInput(final Key key) {
|
/**
|
||||||
if (sInGesture || !mGestureStrokeWithPreviewPoints.isStartOfAGesture()) {
|
* Determines whether the batch input has started or not.
|
||||||
return;
|
* @return true if the batch input has started successfully.
|
||||||
}
|
*/
|
||||||
if (key == null || !Character.isLetter(key.getCode())) {
|
private boolean mayStartBatchInput() {
|
||||||
return;
|
if (!mGestureStrokeWithPreviewPoints.isStartOfAGesture()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onStartBatchInput", mPointerId));
|
Log.d(TAG, String.format("[%d] onStartBatchInput", mPointerId));
|
||||||
}
|
}
|
||||||
sInGesture = true;
|
|
||||||
synchronized (sAggregatedPointers) {
|
synchronized (sAggregatedPointers) {
|
||||||
sAggregatedPointers.reset();
|
sAggregatedPointers.reset();
|
||||||
sLastRecognitionPointSize = 0;
|
sLastRecognitionPointSize = 0;
|
||||||
sLastRecognitionTime = 0;
|
sLastRecognitionTime = 0;
|
||||||
sListener.onStartBatchInput();
|
sListener.onStartBatchInput();
|
||||||
dismissAllMoreKeysPanels();
|
dismissAllMoreKeysPanels();
|
||||||
|
sTimerProxy.cancelLongPressTimerOf(this);
|
||||||
}
|
}
|
||||||
sTimerProxy.cancelLongPressTimerOf(this);
|
return true;
|
||||||
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
|
||||||
sDrawingProxy.showGestureTrail(
|
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBatchInputByTimer(final long eventTime) {
|
private void showGestureTrail() {
|
||||||
final int gestureTime = (int)(eventTime - sGestureFirstDownTime);
|
|
||||||
mGestureStrokeWithPreviewPoints.duplicateLastPointWith(gestureTime);
|
|
||||||
updateBatchInput(eventTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mayUpdateBatchInput(final long eventTime, final Key key) {
|
|
||||||
if (key != null) {
|
|
||||||
updateBatchInput(eventTime);
|
|
||||||
}
|
|
||||||
if (mIsTrackingForActionDisabled) {
|
if (mIsTrackingForActionDisabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -618,13 +607,19 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBatchInput(final long eventTime) {
|
public void updateBatchInputByTimer(final long syntheticMoveEventTime) {
|
||||||
|
final int gestureTime = (int)(syntheticMoveEventTime - sGestureFirstDownTime);
|
||||||
|
mGestureStrokeWithPreviewPoints.duplicateLastPointWith(gestureTime);
|
||||||
|
updateBatchInput(syntheticMoveEventTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBatchInput(final long moveEventTime) {
|
||||||
synchronized (sAggregatedPointers) {
|
synchronized (sAggregatedPointers) {
|
||||||
final GestureStroke stroke = mGestureStrokeWithPreviewPoints;
|
final GestureStroke stroke = mGestureStrokeWithPreviewPoints;
|
||||||
stroke.appendIncrementalBatchPoints(sAggregatedPointers);
|
stroke.appendIncrementalBatchPoints(sAggregatedPointers);
|
||||||
final int size = sAggregatedPointers.getPointerSize();
|
final int size = sAggregatedPointers.getPointerSize();
|
||||||
if (size > sLastRecognitionPointSize
|
if (size > sLastRecognitionPointSize
|
||||||
&& stroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) {
|
&& stroke.hasRecognitionTimePast(moveEventTime, sLastRecognitionTime)) {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onUpdateBatchInput: batchPoints=%d", mPointerId,
|
Log.d(TAG, String.format("[%d] onUpdateBatchInput: batchPoints=%d", mPointerId,
|
||||||
size));
|
size));
|
||||||
|
@ -634,17 +629,23 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
// The listener may change the size of the pointers (when auto-committing
|
// The listener may change the size of the pointers (when auto-committing
|
||||||
// for example), so we need to get the size from the pointers again.
|
// for example), so we need to get the size from the pointers again.
|
||||||
sLastRecognitionPointSize = sAggregatedPointers.getPointerSize();
|
sLastRecognitionPointSize = sAggregatedPointers.getPointerSize();
|
||||||
sLastRecognitionTime = eventTime;
|
sLastRecognitionTime = moveEventTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mayEndBatchInput(final long eventTime) {
|
/**
|
||||||
|
* Determines whether the batch input has ended successfully or continues.
|
||||||
|
* @param upEventTime the event time of this pointer up.
|
||||||
|
* @return true if the batch input has ended successfully, false if it continues.
|
||||||
|
*/
|
||||||
|
private boolean mayEndBatchInput(final long upEventTime) {
|
||||||
|
boolean hasEndBatchInputSuccessfully = false;
|
||||||
synchronized (sAggregatedPointers) {
|
synchronized (sAggregatedPointers) {
|
||||||
mGestureStrokeWithPreviewPoints.appendAllBatchPoints(sAggregatedPointers);
|
mGestureStrokeWithPreviewPoints.appendAllBatchPoints(sAggregatedPointers);
|
||||||
if (getActivePointerTrackerCount() == 1) {
|
if (getActivePointerTrackerCount() == 1) {
|
||||||
sInGesture = false;
|
hasEndBatchInputSuccessfully = true;
|
||||||
sTypingTimeRecorder.onEndBatchInput(eventTime);
|
sTypingTimeRecorder.onEndBatchInput(upEventTime);
|
||||||
sTimerProxy.cancelAllUpdateBatchInputTimers();
|
sTimerProxy.cancelAllUpdateBatchInputTimers();
|
||||||
if (!mIsTrackingForActionDisabled) {
|
if (!mIsTrackingForActionDisabled) {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
|
@ -655,12 +656,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mIsTrackingForActionDisabled) {
|
return hasEndBatchInputSuccessfully;
|
||||||
return;
|
|
||||||
}
|
|
||||||
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
|
||||||
sDrawingProxy.showGestureTrail(
|
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelBatchInput() {
|
private void cancelBatchInput() {
|
||||||
|
@ -815,28 +811,35 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
|
|
||||||
private void onGestureMoveEvent(final int x, final int y, final long eventTime,
|
private void onGestureMoveEvent(final int x, final int y, final long eventTime,
|
||||||
final boolean isMajorEvent, final Key key) {
|
final boolean isMajorEvent, final Key key) {
|
||||||
|
if (!mIsDetectingGesture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int beforeLength = mGestureStrokeWithPreviewPoints.getLength();
|
||||||
final int gestureTime = (int)(eventTime - sGestureFirstDownTime);
|
final int gestureTime = (int)(eventTime - sGestureFirstDownTime);
|
||||||
if (mIsDetectingGesture) {
|
final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
|
||||||
final int beforeLength = mGestureStrokeWithPreviewPoints.getLength();
|
x, y, gestureTime, isMajorEvent);
|
||||||
final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
|
if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) {
|
||||||
x, y, gestureTime, isMajorEvent);
|
sTimerProxy.startUpdateBatchInputTimer(this);
|
||||||
if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) {
|
}
|
||||||
sTimerProxy.startUpdateBatchInputTimer(this);
|
// If the move event goes out from valid batch input area, cancel batch input.
|
||||||
}
|
if (!onValidArea) {
|
||||||
// If the move event goes out from valid batch input area, cancel batch input.
|
cancelBatchInput();
|
||||||
if (!onValidArea) {
|
return;
|
||||||
cancelBatchInput();
|
}
|
||||||
return;
|
// If the MoreKeysPanel is showing then do not attempt to enter gesture mode. However,
|
||||||
}
|
// the gestured touch points are still being recorded in case the panel is dismissed.
|
||||||
// If the MoreKeysPanel is showing then do not attempt to enter gesture mode. However,
|
if (isShowingMoreKeysPanel()) {
|
||||||
// the gestured touch points are still being recorded in case the panel is dismissed.
|
return;
|
||||||
if (isShowingMoreKeysPanel()) {
|
}
|
||||||
return;
|
if (!sInGesture && key != null && Character.isLetter(key.getCode())
|
||||||
}
|
&& mayStartBatchInput()) {
|
||||||
mayStartBatchInput(key);
|
sInGesture = true;
|
||||||
if (sInGesture) {
|
}
|
||||||
mayUpdateBatchInput(eventTime, key);
|
if (sInGesture) {
|
||||||
|
if (key != null) {
|
||||||
|
updateBatchInput(eventTime);
|
||||||
}
|
}
|
||||||
|
showGestureTrail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1087,7 +1090,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (currentKey != null) {
|
if (currentKey != null) {
|
||||||
callListenerOnRelease(currentKey, currentKey.getCode(), true /* withSliding */);
|
callListenerOnRelease(currentKey, currentKey.getCode(), true /* withSliding */);
|
||||||
}
|
}
|
||||||
mayEndBatchInput(eventTime);
|
if (mayEndBatchInput(eventTime)) {
|
||||||
|
sInGesture = false;
|
||||||
|
}
|
||||||
|
showGestureTrail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue