2010-08-31 15:27:04 +00:00
|
|
|
/*
|
2011-05-20 03:09:57 +00:00
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
2010-08-31 15:27:04 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
* use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations under
|
|
|
|
* the License.
|
|
|
|
*/
|
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
package com.android.inputmethod.keyboard;
|
2010-08-31 15:27:04 +00:00
|
|
|
|
2012-07-19 08:20:54 +00:00
|
|
|
import android.graphics.Canvas;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.graphics.Rect;
|
2011-10-26 11:54:35 +00:00
|
|
|
import android.os.SystemClock;
|
2011-06-21 14:38:42 +00:00
|
|
|
import android.util.Log;
|
2011-09-06 06:25:58 +00:00
|
|
|
import android.view.MotionEvent;
|
2012-06-04 06:23:53 +00:00
|
|
|
import android.view.View;
|
2011-07-25 21:05:02 +00:00
|
|
|
import android.widget.TextView;
|
2011-06-21 14:38:42 +00:00
|
|
|
|
2012-07-19 03:33:51 +00:00
|
|
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
2012-07-18 05:27:51 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.GestureStroke;
|
2011-06-22 02:53:02 +00:00
|
|
|
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
2012-07-18 05:27:51 +00:00
|
|
|
import com.android.inputmethod.latin.InputPointers;
|
2011-01-28 03:40:27 +00:00
|
|
|
import com.android.inputmethod.latin.LatinImeLogger;
|
2012-03-30 20:15:46 +00:00
|
|
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
2012-07-20 18:02:39 +00:00
|
|
|
import com.android.inputmethod.research.ResearchLogger;
|
2010-08-31 15:27:04 +00:00
|
|
|
|
2011-07-11 22:24:01 +00:00
|
|
|
import java.util.ArrayList;
|
2010-12-18 11:04:44 +00:00
|
|
|
|
2010-08-31 15:27:04 +00:00
|
|
|
public class PointerTracker {
|
2010-12-18 11:04:44 +00:00
|
|
|
private static final String TAG = PointerTracker.class.getSimpleName();
|
|
|
|
private static final boolean DEBUG_EVENT = false;
|
|
|
|
private static final boolean DEBUG_MOVE_EVENT = false;
|
|
|
|
private static final boolean DEBUG_LISTENER = false;
|
2011-01-28 03:40:27 +00:00
|
|
|
private static boolean DEBUG_MODE = LatinImeLogger.sDBG;
|
2010-09-01 16:35:24 +00:00
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
// TODO: There should be an option to turn on/off the gesture input.
|
2012-07-19 03:33:51 +00:00
|
|
|
private static boolean sIsGestureEnabled = true;
|
|
|
|
|
2012-07-19 05:47:55 +00:00
|
|
|
private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
|
2012-07-18 08:56:30 +00:00
|
|
|
|
2011-07-11 02:31:02 +00:00
|
|
|
public interface KeyEventHandler {
|
|
|
|
/**
|
|
|
|
* Get KeyDetector object that is used for this PointerTracker.
|
|
|
|
* @return the KeyDetector object that is used for this PointerTracker
|
|
|
|
*/
|
|
|
|
public KeyDetector getKeyDetector();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get KeyboardActionListener object that is used to register key code and so on.
|
|
|
|
* @return the KeyboardActionListner for this PointerTracker
|
|
|
|
*/
|
|
|
|
public KeyboardActionListener getKeyboardActionListener();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get DrawingProxy object that is used for this PointerTracker.
|
|
|
|
* @return the DrawingProxy object that is used for this PointerTracker
|
|
|
|
*/
|
|
|
|
public DrawingProxy getDrawingProxy();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get TimerProxy object that handles key repeat and long press timer event for this
|
|
|
|
* PointerTracker.
|
|
|
|
* @return the TimerProxy object that handles key repeat and long press timer event.
|
|
|
|
*/
|
|
|
|
public TimerProxy getTimerProxy();
|
|
|
|
}
|
|
|
|
|
2011-08-31 06:26:32 +00:00
|
|
|
public interface DrawingProxy extends MoreKeysPanel.Controller {
|
2010-08-31 15:27:04 +00:00
|
|
|
public void invalidateKey(Key key);
|
2011-07-25 21:05:02 +00:00
|
|
|
public TextView inflateKeyPreviewText();
|
2011-11-29 07:56:27 +00:00
|
|
|
public void showKeyPreview(PointerTracker tracker);
|
2011-04-19 06:18:20 +00:00
|
|
|
public void dismissKeyPreview(PointerTracker tracker);
|
2012-07-19 08:20:54 +00:00
|
|
|
public void showGestureTrail(PointerTracker tracker);
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2011-07-09 01:35:58 +00:00
|
|
|
public interface TimerProxy {
|
2012-03-14 05:46:22 +00:00
|
|
|
public void startTypingStateTimer();
|
|
|
|
public boolean isTypingState();
|
2012-02-01 06:07:25 +00:00
|
|
|
public void startKeyRepeatTimer(PointerTracker tracker);
|
|
|
|
public void startLongPressTimer(PointerTracker tracker);
|
|
|
|
public void startLongPressTimer(int code);
|
2011-07-17 21:37:30 +00:00
|
|
|
public void cancelLongPressTimer();
|
2012-01-31 06:54:48 +00:00
|
|
|
public void startDoubleTapTimer();
|
2012-02-16 19:45:35 +00:00
|
|
|
public void cancelDoubleTapTimer();
|
2012-01-31 06:54:48 +00:00
|
|
|
public boolean isInDoubleTapTimeout();
|
2011-07-09 01:35:58 +00:00
|
|
|
public void cancelKeyTimers();
|
2011-08-24 05:44:46 +00:00
|
|
|
|
|
|
|
public static class Adapter implements TimerProxy {
|
2011-11-22 00:41:01 +00:00
|
|
|
@Override
|
2012-03-14 05:46:22 +00:00
|
|
|
public void startTypingStateTimer() {}
|
2011-11-22 00:41:01 +00:00
|
|
|
@Override
|
2012-03-14 05:46:22 +00:00
|
|
|
public boolean isTypingState() { return false; }
|
2011-08-24 05:44:46 +00:00
|
|
|
@Override
|
2012-02-01 06:07:25 +00:00
|
|
|
public void startKeyRepeatTimer(PointerTracker tracker) {}
|
2011-08-24 05:44:46 +00:00
|
|
|
@Override
|
2012-02-01 06:07:25 +00:00
|
|
|
public void startLongPressTimer(PointerTracker tracker) {}
|
|
|
|
@Override
|
|
|
|
public void startLongPressTimer(int code) {}
|
2011-08-24 05:44:46 +00:00
|
|
|
@Override
|
|
|
|
public void cancelLongPressTimer() {}
|
|
|
|
@Override
|
2012-01-31 06:54:48 +00:00
|
|
|
public void startDoubleTapTimer() {}
|
|
|
|
@Override
|
2012-02-16 19:45:35 +00:00
|
|
|
public void cancelDoubleTapTimer() {}
|
|
|
|
@Override
|
2012-01-31 06:54:48 +00:00
|
|
|
public boolean isInDoubleTapTimeout() { return false; }
|
|
|
|
@Override
|
2011-08-24 05:44:46 +00:00
|
|
|
public void cancelKeyTimers() {}
|
|
|
|
}
|
2011-07-09 01:35:58 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 11:14:39 +00:00
|
|
|
// Parameters for pointer handling.
|
2012-07-23 01:27:14 +00:00
|
|
|
private static MainKeyboardView.PointerTrackerParams sParams;
|
2011-07-11 22:24:01 +00:00
|
|
|
private static int sTouchNoiseThresholdDistanceSquared;
|
2012-05-30 10:29:57 +00:00
|
|
|
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
2011-07-11 22:24:01 +00:00
|
|
|
|
2012-03-13 11:53:15 +00:00
|
|
|
private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
|
2012-07-19 12:53:42 +00:00
|
|
|
private static final InputPointers sAggregratedPointers = new InputPointers(
|
|
|
|
GestureStroke.DEFAULT_CAPACITY);
|
2011-07-11 22:24:01 +00:00
|
|
|
private static PointerTrackerQueue sPointerTrackerQueue;
|
2012-07-19 05:47:55 +00:00
|
|
|
// HACK: Change gesture detection criteria depending on this variable.
|
|
|
|
// TODO: Find more comprehensive ways to detect a gesture start.
|
|
|
|
// True when the previous user input was a gesture input, not a typing input.
|
|
|
|
private static boolean sWasInGesture;
|
2011-07-11 22:24:01 +00:00
|
|
|
|
|
|
|
public final int mPointerId;
|
2010-08-31 15:27:04 +00:00
|
|
|
|
2011-07-09 04:26:29 +00:00
|
|
|
private DrawingProxy mDrawingProxy;
|
|
|
|
private TimerProxy mTimerProxy;
|
2011-07-04 10:59:57 +00:00
|
|
|
private KeyDetector mKeyDetector;
|
2010-12-18 11:04:44 +00:00
|
|
|
private KeyboardActionListener mListener = EMPTY_LISTENER;
|
2010-12-17 05:13:01 +00:00
|
|
|
|
2010-12-02 09:46:21 +00:00
|
|
|
private Keyboard mKeyboard;
|
2011-01-28 03:40:27 +00:00
|
|
|
private int mKeyQuarterWidthSquared;
|
2011-07-25 21:05:02 +00:00
|
|
|
private final TextView mKeyPreviewText;
|
2010-08-31 15:27:04 +00:00
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
private boolean mIsAlphabetKeyboard;
|
|
|
|
private boolean mIsPossibleGesture = false;
|
|
|
|
private boolean mInGesture = false;
|
|
|
|
|
2012-07-19 05:47:55 +00:00
|
|
|
// TODO: Remove these variables
|
2012-07-18 08:56:30 +00:00
|
|
|
private int mLastRecognitionPointSize = 0;
|
|
|
|
private long mLastRecognitionTime = 0;
|
|
|
|
|
2011-07-08 23:19:19 +00:00
|
|
|
// The position and time at which first down event occurred.
|
|
|
|
private long mDownTime;
|
|
|
|
private long mUpTime;
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
// The current key where this pointer is.
|
|
|
|
private Key mCurrentKey = null;
|
|
|
|
// The position where the current key was recognized for the first time.
|
2011-07-08 23:19:19 +00:00
|
|
|
private int mKeyX;
|
|
|
|
private int mKeyY;
|
|
|
|
|
|
|
|
// Last pointer position.
|
|
|
|
private int mLastX;
|
|
|
|
private int mLastY;
|
2010-08-31 15:27:04 +00:00
|
|
|
|
2010-12-30 07:51:36 +00:00
|
|
|
// true if keyboard layout has been changed.
|
|
|
|
private boolean mKeyboardLayoutHasBeenChanged;
|
|
|
|
|
2011-07-23 08:16:56 +00:00
|
|
|
// true if event is already translated to a key action.
|
2010-09-03 03:51:03 +00:00
|
|
|
private boolean mKeyAlreadyProcessed;
|
|
|
|
|
2011-08-31 06:26:32 +00:00
|
|
|
// true if this pointer has been long-pressed and is showing a more keys panel.
|
|
|
|
private boolean mIsShowingMoreKeysPanel;
|
2011-07-23 08:16:56 +00:00
|
|
|
|
2010-12-20 07:21:54 +00:00
|
|
|
// true if this pointer is in sliding key input
|
2011-07-11 22:24:01 +00:00
|
|
|
boolean mIsInSlidingKeyInput;
|
2010-12-20 07:21:54 +00:00
|
|
|
|
2010-12-18 09:48:32 +00:00
|
|
|
// true if sliding key is allowed.
|
|
|
|
private boolean mIsAllowedSlidingKeyInput;
|
|
|
|
|
2011-04-07 08:16:30 +00:00
|
|
|
// ignore modifier key if true
|
|
|
|
private boolean mIgnoreModifierKey;
|
|
|
|
|
2010-12-18 11:04:44 +00:00
|
|
|
// Empty {@link KeyboardActionListener}
|
2011-08-29 10:09:56 +00:00
|
|
|
private static final KeyboardActionListener EMPTY_LISTENER =
|
|
|
|
new KeyboardActionListener.Adapter();
|
2010-09-24 11:45:24 +00:00
|
|
|
|
2012-07-18 05:27:51 +00:00
|
|
|
private final GestureStroke mGestureStroke;
|
|
|
|
|
2012-05-30 10:29:57 +00:00
|
|
|
public static void init(boolean hasDistinctMultitouch,
|
2012-07-20 08:49:06 +00:00
|
|
|
boolean needsPhantomSuddenMoveEventHack) {
|
2011-07-11 22:24:01 +00:00
|
|
|
if (hasDistinctMultitouch) {
|
|
|
|
sPointerTrackerQueue = new PointerTrackerQueue();
|
|
|
|
} else {
|
|
|
|
sPointerTrackerQueue = null;
|
|
|
|
}
|
2012-05-30 10:29:57 +00:00
|
|
|
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
2011-07-11 22:24:01 +00:00
|
|
|
|
2012-07-23 01:27:14 +00:00
|
|
|
setParameters(MainKeyboardView.PointerTrackerParams.DEFAULT);
|
2012-07-20 08:49:06 +00:00
|
|
|
updateGestureInputEnabledState(null, false /* gestureInputEnabled */);
|
2012-01-25 11:14:39 +00:00
|
|
|
}
|
2011-11-22 00:41:01 +00:00
|
|
|
|
2012-07-23 01:27:14 +00:00
|
|
|
public static void setParameters(MainKeyboardView.PointerTrackerParams params) {
|
2012-01-25 11:14:39 +00:00
|
|
|
sParams = params;
|
2011-07-11 22:24:01 +00:00
|
|
|
sTouchNoiseThresholdDistanceSquared = (int)(
|
2012-01-25 11:14:39 +00:00
|
|
|
params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance);
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2012-07-20 08:49:06 +00:00
|
|
|
private static void updateGestureInputEnabledState(Keyboard keyboard,
|
|
|
|
boolean gestureInputEnabled) {
|
|
|
|
if (!gestureInputEnabled
|
2012-07-19 03:33:51 +00:00
|
|
|
|| AccessibilityUtils.getInstance().isTouchExplorationEnabled()
|
|
|
|
|| (keyboard != null && keyboard.mId.passwordInput())) {
|
|
|
|
sIsGestureEnabled = false;
|
|
|
|
} else {
|
|
|
|
sIsGestureEnabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-11 22:24:01 +00:00
|
|
|
public static PointerTracker getPointerTracker(final int id, KeyEventHandler handler) {
|
2012-03-13 11:53:15 +00:00
|
|
|
final ArrayList<PointerTracker> trackers = sTrackers;
|
2011-07-11 22:24:01 +00:00
|
|
|
|
|
|
|
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
|
|
|
for (int i = trackers.size(); i <= id; i++) {
|
|
|
|
final PointerTracker tracker = new PointerTracker(i, handler);
|
|
|
|
trackers.add(tracker);
|
|
|
|
}
|
|
|
|
|
|
|
|
return trackers.get(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isAnyInSlidingKeyInput() {
|
|
|
|
return sPointerTrackerQueue != null ? sPointerTrackerQueue.isAnyInSlidingKeyInput() : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setKeyboardActionListener(KeyboardActionListener listener) {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2011-07-11 22:24:01 +00:00
|
|
|
tracker.mListener = listener;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 08:49:06 +00:00
|
|
|
public static void setKeyDetector(KeyDetector keyDetector, boolean gestureInputEnabledByUser) {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2011-07-11 22:24:01 +00:00
|
|
|
tracker.setKeyDetectorInner(keyDetector);
|
|
|
|
// Mark that keyboard layout has been changed.
|
|
|
|
tracker.mKeyboardLayoutHasBeenChanged = true;
|
|
|
|
}
|
2012-07-19 03:33:51 +00:00
|
|
|
final Keyboard keyboard = keyDetector.getKeyboard();
|
2012-07-20 08:49:06 +00:00
|
|
|
updateGestureInputEnabledState(keyboard, gestureInputEnabledByUser);
|
2011-07-11 22:24:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void dismissAllKeyPreviews() {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2012-06-04 06:23:53 +00:00
|
|
|
tracker.getKeyPreviewText().setVisibility(View.INVISIBLE);
|
2011-11-29 07:56:27 +00:00
|
|
|
tracker.setReleasedKeyGraphics(tracker.mCurrentKey);
|
2011-07-11 22:24:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
// TODO: To handle multi-touch gestures we may want to move this method to
|
|
|
|
// {@link PointerTrackerQueue}.
|
|
|
|
private static InputPointers getIncrementalBatchPoints() {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2012-07-19 12:53:42 +00:00
|
|
|
tracker.mGestureStroke.appendIncrementalBatchPoints(sAggregratedPointers);
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
2012-07-19 12:53:42 +00:00
|
|
|
return sAggregratedPointers;
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
// TODO: To handle multi-touch gestures we may want to move this method to
|
|
|
|
// {@link PointerTrackerQueue}.
|
|
|
|
private static InputPointers getAllBatchPoints() {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2012-07-19 12:53:42 +00:00
|
|
|
tracker.mGestureStroke.appendAllBatchPoints(sAggregratedPointers);
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
2012-07-19 12:53:42 +00:00
|
|
|
return sAggregratedPointers;
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
// TODO: To handle multi-touch gestures we may want to move this method to
|
|
|
|
// {@link PointerTrackerQueue}.
|
2012-07-19 05:47:55 +00:00
|
|
|
public static void clearBatchInputPointsOfAllPointerTrackers() {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2012-07-18 08:56:30 +00:00
|
|
|
tracker.mGestureStroke.reset();
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
2012-07-19 12:53:42 +00:00
|
|
|
sAggregratedPointers.reset();
|
2012-07-18 05:27:51 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:20:54 +00:00
|
|
|
// TODO: To handle multi-touch gestures we may want to move this method to
|
|
|
|
// {@link PointerTrackerQueue}.
|
|
|
|
public static void drawGestureTrailForAllPointerTrackers(Canvas canvas, Paint paint) {
|
2012-07-20 08:51:52 +00:00
|
|
|
final int trackersSize = sTrackers.size();
|
|
|
|
for (int i = 0; i < trackersSize; ++i) {
|
|
|
|
final PointerTracker tracker = sTrackers.get(i);
|
2012-07-19 08:20:54 +00:00
|
|
|
tracker.mGestureStroke.drawGestureTrail(canvas, paint, tracker.getLastX(),
|
|
|
|
tracker.getLastY());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-18 05:27:51 +00:00
|
|
|
private PointerTracker(int id, KeyEventHandler handler) {
|
2011-07-11 22:24:01 +00:00
|
|
|
if (handler == null)
|
|
|
|
throw new NullPointerException();
|
|
|
|
mPointerId = id;
|
2012-07-18 05:27:51 +00:00
|
|
|
mGestureStroke = new GestureStroke(id);
|
2011-07-11 22:24:01 +00:00
|
|
|
setKeyDetectorInner(handler.getKeyDetector());
|
|
|
|
mListener = handler.getKeyboardActionListener();
|
|
|
|
mDrawingProxy = handler.getDrawingProxy();
|
|
|
|
mTimerProxy = handler.getTimerProxy();
|
2011-07-25 21:05:02 +00:00
|
|
|
mKeyPreviewText = mDrawingProxy.inflateKeyPreviewText();
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextView getKeyPreviewText() {
|
|
|
|
return mKeyPreviewText;
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2010-12-30 07:51:36 +00:00
|
|
|
// Returns true if keyboard has been changed by this callback.
|
2012-01-17 08:08:26 +00:00
|
|
|
private boolean callListenerOnPressAndCheckKeyboardLayoutChange(Key key) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (mInGesture) {
|
2012-06-12 10:40:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-11-29 07:56:27 +00:00
|
|
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
2011-12-01 07:34:23 +00:00
|
|
|
if (DEBUG_LISTENER) {
|
2011-12-12 04:08:41 +00:00
|
|
|
Log.d(TAG, "onPress : " + KeyDetector.printableCode(key)
|
2012-01-17 08:08:26 +00:00
|
|
|
+ " ignoreModifier=" + ignoreModifierKey
|
2011-12-01 07:34:23 +00:00
|
|
|
+ " enabled=" + key.isEnabled());
|
|
|
|
}
|
2011-11-22 00:41:01 +00:00
|
|
|
if (ignoreModifierKey) {
|
2011-04-07 08:16:30 +00:00
|
|
|
return false;
|
2011-11-22 00:41:01 +00:00
|
|
|
}
|
2011-06-23 12:23:44 +00:00
|
|
|
if (key.isEnabled()) {
|
2012-01-17 08:08:26 +00:00
|
|
|
mListener.onPressKey(key.mCode);
|
2011-02-20 07:50:46 +00:00
|
|
|
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
|
|
|
mKeyboardLayoutHasBeenChanged = false;
|
2012-04-12 08:51:57 +00:00
|
|
|
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
|
|
|
mTimerProxy.startTypingStateTimer();
|
|
|
|
}
|
2011-02-20 07:50:46 +00:00
|
|
|
return keyboardLayoutHasBeenChanged;
|
|
|
|
}
|
|
|
|
return false;
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
|
|
|
|
2011-02-20 07:50:46 +00:00
|
|
|
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
|
|
|
// primaryCode is different from {@link Key#mCode}.
|
2012-03-06 05:56:46 +00:00
|
|
|
private void callListenerOnCodeInput(Key key, int primaryCode, int x, int y) {
|
2011-11-29 07:56:27 +00:00
|
|
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
2012-03-14 10:49:13 +00:00
|
|
|
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
|
|
|
final int code = altersCode ? key.mAltCode : primaryCode;
|
2011-11-30 08:54:58 +00:00
|
|
|
if (DEBUG_LISTENER) {
|
2012-01-10 08:24:00 +00:00
|
|
|
Log.d(TAG, "onCodeInput: " + Keyboard.printableCode(code) + " text=" + key.mOutputText
|
2012-03-06 05:56:46 +00:00
|
|
|
+ " x=" + x + " y=" + y
|
2012-03-14 10:49:13 +00:00
|
|
|
+ " ignoreModifier=" + ignoreModifierKey + " altersCode=" + altersCode
|
2011-12-01 07:34:23 +00:00
|
|
|
+ " enabled=" + key.isEnabled());
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.pointerTracker_callListenerOnCodeInput(key, x, y, ignoreModifierKey,
|
|
|
|
altersCode, code);
|
|
|
|
}
|
2011-11-29 07:56:27 +00:00
|
|
|
if (ignoreModifierKey) {
|
2011-04-07 08:16:30 +00:00
|
|
|
return;
|
2011-11-29 07:56:27 +00:00
|
|
|
}
|
2012-03-14 10:49:13 +00:00
|
|
|
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
|
|
|
if (key.isEnabled() || altersCode) {
|
2012-01-10 08:24:00 +00:00
|
|
|
if (code == Keyboard.CODE_OUTPUT_TEXT) {
|
|
|
|
mListener.onTextInput(key.mOutputText);
|
|
|
|
} else if (code != Keyboard.CODE_UNSPECIFIED) {
|
2012-03-06 05:56:46 +00:00
|
|
|
mListener.onCodeInput(code, x, y);
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
2011-11-22 00:41:01 +00:00
|
|
|
}
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
|
|
|
|
2011-02-20 07:50:46 +00:00
|
|
|
// Note that we need primaryCode argument because the keyboard may in shifted state and the
|
|
|
|
// primaryCode is different from {@link Key#mCode}.
|
2011-03-02 19:43:13 +00:00
|
|
|
private void callListenerOnRelease(Key key, int primaryCode, boolean withSliding) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (mInGesture) {
|
2012-06-12 10:40:37 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-11-29 07:56:27 +00:00
|
|
|
final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier();
|
2011-12-01 07:34:23 +00:00
|
|
|
if (DEBUG_LISTENER) {
|
2011-12-12 04:08:41 +00:00
|
|
|
Log.d(TAG, "onRelease : " + Keyboard.printableCode(primaryCode)
|
2011-12-01 07:34:23 +00:00
|
|
|
+ " sliding=" + withSliding + " ignoreModifier=" + ignoreModifierKey
|
|
|
|
+ " enabled="+ key.isEnabled());
|
|
|
|
}
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.pointerTracker_callListenerOnRelease(key, primaryCode, withSliding,
|
|
|
|
ignoreModifierKey);
|
|
|
|
}
|
2011-11-29 07:56:27 +00:00
|
|
|
if (ignoreModifierKey) {
|
2011-04-07 08:16:30 +00:00
|
|
|
return;
|
2011-11-29 07:56:27 +00:00
|
|
|
}
|
2011-11-22 00:41:01 +00:00
|
|
|
if (key.isEnabled()) {
|
2012-01-17 08:08:26 +00:00
|
|
|
mListener.onReleaseKey(primaryCode, withSliding);
|
2011-11-22 00:41:01 +00:00
|
|
|
}
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 07:13:57 +00:00
|
|
|
private void callListenerOnCancelInput() {
|
2010-12-18 11:04:44 +00:00
|
|
|
if (DEBUG_LISTENER)
|
2010-12-20 07:13:57 +00:00
|
|
|
Log.d(TAG, "onCancelInput");
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.pointerTracker_callListenerOnCancelInput();
|
|
|
|
}
|
2010-12-20 07:13:57 +00:00
|
|
|
mListener.onCancelInput();
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
|
|
|
|
2011-08-29 09:36:26 +00:00
|
|
|
private void setKeyDetectorInner(KeyDetector keyDetector) {
|
2011-07-04 10:59:57 +00:00
|
|
|
mKeyDetector = keyDetector;
|
2011-07-08 05:31:29 +00:00
|
|
|
mKeyboard = keyDetector.getKeyboard();
|
2012-07-18 08:56:30 +00:00
|
|
|
mIsAlphabetKeyboard = mKeyboard.mId.isAlphabetKeyboard();
|
2012-07-18 05:27:51 +00:00
|
|
|
mGestureStroke.setGestureSampleLength(
|
|
|
|
mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
|
2012-06-25 07:33:06 +00:00
|
|
|
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
|
|
|
if (newKey != mCurrentKey) {
|
|
|
|
if (mDrawingProxy != null) {
|
|
|
|
setReleasedKeyGraphics(mCurrentKey);
|
|
|
|
}
|
|
|
|
mCurrentKey = newKey;
|
|
|
|
}
|
2011-07-29 00:05:40 +00:00
|
|
|
final int keyQuarterWidth = mKeyboard.mMostCommonKeyWidth / 4;
|
2011-01-28 03:40:27 +00:00
|
|
|
mKeyQuarterWidthSquared = keyQuarterWidth * keyQuarterWidth;
|
2011-07-08 05:31:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-20 07:21:54 +00:00
|
|
|
public boolean isInSlidingKeyInput() {
|
|
|
|
return mIsInSlidingKeyInput;
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
public Key getKey() {
|
|
|
|
return mCurrentKey;
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 06:02:29 +00:00
|
|
|
public boolean isModifier() {
|
2011-11-29 07:56:27 +00:00
|
|
|
return mCurrentKey != null && mCurrentKey.isModifier();
|
2010-09-15 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
public Key getKeyOn(int x, int y) {
|
2012-03-15 10:44:43 +00:00
|
|
|
return mKeyDetector.detectHitKey(x, y);
|
2010-09-15 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private void setReleasedKeyGraphics(Key key) {
|
2011-07-23 08:27:49 +00:00
|
|
|
mDrawingProxy.dismissKeyPreview(this);
|
2012-03-14 10:49:13 +00:00
|
|
|
if (key == null) {
|
2012-03-13 08:15:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-14 10:49:13 +00:00
|
|
|
// Even if the key is disabled, update the key release graphics just in case.
|
2012-03-13 08:15:05 +00:00
|
|
|
updateReleaseKeyGraphics(key);
|
|
|
|
|
|
|
|
if (key.isShift()) {
|
|
|
|
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
|
|
|
if (shiftKey != key) {
|
|
|
|
updateReleaseKeyGraphics(shiftKey);
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-13 08:15:05 +00:00
|
|
|
}
|
2011-11-30 08:54:58 +00:00
|
|
|
|
2012-03-13 08:15:05 +00:00
|
|
|
if (key.altCodeWhileTyping()) {
|
|
|
|
final int altCode = key.mAltCode;
|
|
|
|
final Key altKey = mKeyboard.getKey(altCode);
|
|
|
|
if (altKey != null) {
|
|
|
|
updateReleaseKeyGraphics(altKey);
|
|
|
|
}
|
|
|
|
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
|
|
|
|
if (k != key && k.mAltCode == altCode) {
|
|
|
|
updateReleaseKeyGraphics(k);
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private void setPressedKeyGraphics(Key key) {
|
2012-03-14 10:49:13 +00:00
|
|
|
if (key == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
|
|
|
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
|
|
|
final boolean needsToUpdateGraphics = key.isEnabled() || altersCode;
|
|
|
|
if (!needsToUpdateGraphics) {
|
2012-03-13 08:15:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
if (!key.noKeyPreview() && !mInGesture) {
|
2012-03-13 08:15:05 +00:00
|
|
|
mDrawingProxy.showKeyPreview(this);
|
|
|
|
}
|
|
|
|
updatePressKeyGraphics(key);
|
|
|
|
|
|
|
|
if (key.isShift()) {
|
|
|
|
for (final Key shiftKey : mKeyboard.mShiftKeys) {
|
|
|
|
if (shiftKey != key) {
|
|
|
|
updatePressKeyGraphics(shiftKey);
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-13 08:15:05 +00:00
|
|
|
}
|
2011-11-30 08:54:58 +00:00
|
|
|
|
2012-03-14 05:46:22 +00:00
|
|
|
if (key.altCodeWhileTyping() && mTimerProxy.isTypingState()) {
|
2012-03-13 08:15:05 +00:00
|
|
|
final int altCode = key.mAltCode;
|
|
|
|
final Key altKey = mKeyboard.getKey(altCode);
|
|
|
|
if (altKey != null) {
|
|
|
|
updatePressKeyGraphics(altKey);
|
|
|
|
}
|
|
|
|
for (final Key k : mKeyboard.mAltCodeKeysWhileTyping) {
|
|
|
|
if (k != key && k.mAltCode == altCode) {
|
|
|
|
updatePressKeyGraphics(k);
|
2011-11-30 08:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-18 10:07:20 +00:00
|
|
|
}
|
2010-09-03 03:51:03 +00:00
|
|
|
}
|
|
|
|
|
2012-03-13 08:15:05 +00:00
|
|
|
private void updateReleaseKeyGraphics(Key key) {
|
|
|
|
key.onReleased();
|
|
|
|
mDrawingProxy.invalidateKey(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePressKeyGraphics(Key key) {
|
|
|
|
key.onPressed();
|
|
|
|
mDrawingProxy.invalidateKey(key);
|
|
|
|
}
|
|
|
|
|
2011-07-08 23:19:19 +00:00
|
|
|
public int getLastX() {
|
|
|
|
return mLastX;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLastY() {
|
|
|
|
return mLastY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getDownTime() {
|
|
|
|
return mDownTime;
|
|
|
|
}
|
2012-07-21 23:36:13 +00:00
|
|
|
public Rect getBoundingBox() {
|
|
|
|
return mGestureStroke.getBoundingBox();
|
2012-07-19 08:20:54 +00:00
|
|
|
}
|
2011-07-08 23:19:19 +00:00
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private Key onDownKey(int x, int y, long eventTime) {
|
2011-07-08 23:19:19 +00:00
|
|
|
mDownTime = eventTime;
|
|
|
|
return onMoveToNewKey(onMoveKeyInternal(x, y), x, y);
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private Key onMoveKeyInternal(int x, int y) {
|
2011-07-08 23:19:19 +00:00
|
|
|
mLastX = x;
|
|
|
|
mLastY = y;
|
2012-03-15 10:44:43 +00:00
|
|
|
return mKeyDetector.detectHitKey(x, y);
|
2011-07-08 23:19:19 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private Key onMoveKey(int x, int y) {
|
2011-07-08 23:19:19 +00:00
|
|
|
return onMoveKeyInternal(x, y);
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private Key onMoveToNewKey(Key newKey, int x, int y) {
|
|
|
|
mCurrentKey = newKey;
|
2011-07-08 23:19:19 +00:00
|
|
|
mKeyX = x;
|
|
|
|
mKeyY = y;
|
2011-11-29 07:56:27 +00:00
|
|
|
return newKey;
|
2011-07-08 23:19:19 +00:00
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
private void startBatchInput() {
|
|
|
|
if (DEBUG_LISTENER) {
|
|
|
|
Log.d(TAG, "onStartBatchInput");
|
|
|
|
}
|
|
|
|
mInGesture = true;
|
|
|
|
mListener.onStartBatchInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateBatchInput(InputPointers batchPoints) {
|
|
|
|
if (DEBUG_LISTENER) {
|
|
|
|
Log.d(TAG, "onUpdateBatchInput: batchPoints=" + batchPoints.getPointerSize());
|
|
|
|
}
|
|
|
|
mListener.onUpdateBatchInput(batchPoints);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void endBatchInput(InputPointers batchPoints) {
|
|
|
|
if (DEBUG_LISTENER) {
|
|
|
|
Log.d(TAG, "onEndBatchInput: batchPoints=" + batchPoints.getPointerSize());
|
|
|
|
}
|
|
|
|
mListener.onEndBatchInput(batchPoints);
|
2012-07-19 05:47:55 +00:00
|
|
|
clearBatchInputRecognitionStateOfThisPointerTracker();
|
|
|
|
clearBatchInputPointsOfAllPointerTrackers();
|
|
|
|
sWasInGesture = true;
|
2012-07-18 08:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void abortBatchInput() {
|
2012-07-19 05:47:55 +00:00
|
|
|
clearBatchInputRecognitionStateOfThisPointerTracker();
|
|
|
|
clearBatchInputPointsOfAllPointerTrackers();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void clearBatchInputRecognitionStateOfThisPointerTracker() {
|
2012-07-18 08:56:30 +00:00
|
|
|
mIsPossibleGesture = false;
|
|
|
|
mInGesture = false;
|
2012-07-19 05:47:55 +00:00
|
|
|
mLastRecognitionPointSize = 0;
|
|
|
|
mLastRecognitionTime = 0;
|
2012-07-18 08:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean updateBatchInputRecognitionState(long eventTime, int size) {
|
|
|
|
if (size > mLastRecognitionPointSize
|
2012-07-19 05:47:55 +00:00
|
|
|
&& eventTime > mLastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME) {
|
2012-07-18 08:56:30 +00:00
|
|
|
mLastRecognitionPointSize = size;
|
|
|
|
mLastRecognitionTime = eventTime;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-06 06:25:58 +00:00
|
|
|
public void processMotionEvent(int action, int x, int y, long eventTime,
|
|
|
|
KeyEventHandler handler) {
|
|
|
|
switch (action) {
|
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
|
case MotionEvent.ACTION_POINTER_DOWN:
|
|
|
|
onDownEvent(x, y, eventTime, handler);
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_UP:
|
|
|
|
case MotionEvent.ACTION_POINTER_UP:
|
|
|
|
onUpEvent(x, y, eventTime);
|
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_MOVE:
|
2012-06-26 08:34:04 +00:00
|
|
|
onMoveEvent(x, y, eventTime, null);
|
2011-09-06 06:25:58 +00:00
|
|
|
break;
|
|
|
|
case MotionEvent.ACTION_CANCEL:
|
|
|
|
onCancelEvent(x, y, eventTime);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-11 02:31:02 +00:00
|
|
|
public void onDownEvent(int x, int y, long eventTime, KeyEventHandler handler) {
|
2010-12-18 11:04:44 +00:00
|
|
|
if (DEBUG_EVENT)
|
|
|
|
printTouchEvent("onDownEvent:", x, y, eventTime);
|
2010-12-21 05:01:13 +00:00
|
|
|
|
2011-07-11 02:31:02 +00:00
|
|
|
mDrawingProxy = handler.getDrawingProxy();
|
2011-07-11 01:09:15 +00:00
|
|
|
mTimerProxy = handler.getTimerProxy();
|
2011-07-11 02:31:02 +00:00
|
|
|
setKeyboardActionListener(handler.getKeyboardActionListener());
|
|
|
|
setKeyDetectorInner(handler.getKeyDetector());
|
2010-12-17 05:13:01 +00:00
|
|
|
// Naive up-to-down noise filter.
|
2011-07-08 23:19:19 +00:00
|
|
|
final long deltaT = eventTime - mUpTime;
|
2012-01-25 11:14:39 +00:00
|
|
|
if (deltaT < sParams.mTouchNoiseThresholdTime) {
|
2011-07-08 23:19:19 +00:00
|
|
|
final int dx = x - mLastX;
|
|
|
|
final int dy = y - mLastY;
|
2010-12-17 05:13:01 +00:00
|
|
|
final int distanceSquared = (dx * dx + dy * dy);
|
2011-07-11 22:24:01 +00:00
|
|
|
if (distanceSquared < sTouchNoiseThresholdDistanceSquared) {
|
2011-01-28 03:40:27 +00:00
|
|
|
if (DEBUG_MODE)
|
|
|
|
Log.w(TAG, "onDownEvent: ignore potential noise: time=" + deltaT
|
|
|
|
+ " distance=" + distanceSquared);
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.pointerTracker_onDownEvent(deltaT, distanceSquared);
|
|
|
|
}
|
2011-04-18 10:07:20 +00:00
|
|
|
mKeyAlreadyProcessed = true;
|
2010-12-17 05:13:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-11 22:24:01 +00:00
|
|
|
final PointerTrackerQueue queue = sPointerTrackerQueue;
|
2012-06-12 10:40:37 +00:00
|
|
|
final Key key = getKeyOn(x, y);
|
2010-12-21 05:01:13 +00:00
|
|
|
if (queue != null) {
|
2011-11-29 07:56:27 +00:00
|
|
|
if (key != null && key.isModifier()) {
|
2010-12-21 05:01:13 +00:00
|
|
|
// Before processing a down event of modifier key, all pointers already being
|
|
|
|
// tracked should be released.
|
|
|
|
queue.releaseAllPointers(eventTime);
|
|
|
|
}
|
|
|
|
queue.add(this);
|
|
|
|
}
|
|
|
|
onDownEventInternal(x, y, eventTime);
|
2012-06-12 10:40:37 +00:00
|
|
|
if (queue != null && queue.size() == 1) {
|
2012-07-18 08:56:30 +00:00
|
|
|
mIsPossibleGesture = false;
|
|
|
|
// A gesture should start only from the letter key.
|
2012-07-20 09:40:31 +00:00
|
|
|
if (sIsGestureEnabled && mIsAlphabetKeyboard && !mIsShowingMoreKeysPanel && key != null
|
2012-07-18 08:56:30 +00:00
|
|
|
&& Keyboard.isLetterCode(key.mCode)) {
|
|
|
|
mIsPossibleGesture = true;
|
2012-07-19 12:53:42 +00:00
|
|
|
// TODO: pointer times should be relative to first down even in entire batch input
|
|
|
|
// instead of resetting to 0 for each new down event.
|
2012-07-18 08:56:30 +00:00
|
|
|
mGestureStroke.addPoint(x, y, 0, false);
|
|
|
|
}
|
2012-06-12 10:40:37 +00:00
|
|
|
}
|
2010-12-21 05:01:13 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 05:13:01 +00:00
|
|
|
private void onDownEventInternal(int x, int y, long eventTime) {
|
2011-11-29 07:56:27 +00:00
|
|
|
Key key = onDownKey(x, y, eventTime);
|
2010-12-18 09:48:32 +00:00
|
|
|
// Sliding key is allowed when 1) enabled by configuration, 2) this pointer starts sliding
|
2011-08-23 03:08:36 +00:00
|
|
|
// from modifier key, or 3) this pointer's KeyDetector always allows sliding input.
|
2012-01-25 11:14:39 +00:00
|
|
|
mIsAllowedSlidingKeyInput = sParams.mSlidingKeyInputEnabled
|
2011-12-01 07:26:09 +00:00
|
|
|
|| (key != null && key.isModifier())
|
2011-08-23 03:08:36 +00:00
|
|
|
|| mKeyDetector.alwaysAllowsSlidingInput();
|
2010-12-30 07:51:36 +00:00
|
|
|
mKeyboardLayoutHasBeenChanged = false;
|
2010-09-03 03:51:03 +00:00
|
|
|
mKeyAlreadyProcessed = false;
|
2010-12-20 07:21:54 +00:00
|
|
|
mIsInSlidingKeyInput = false;
|
2011-04-07 08:16:30 +00:00
|
|
|
mIgnoreModifierKey = false;
|
2011-11-29 07:56:27 +00:00
|
|
|
if (key != null) {
|
2010-12-30 07:51:36 +00:00
|
|
|
// This onPress call may have changed keyboard layout. Those cases are detected at
|
2011-11-29 07:56:27 +00:00
|
|
|
// {@link #setKeyboard}. In those cases, we should update key according to the new
|
2010-12-30 07:51:36 +00:00
|
|
|
// keyboard layout.
|
2012-01-17 08:08:26 +00:00
|
|
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
2011-11-29 07:56:27 +00:00
|
|
|
key = onDownKey(x, y, eventTime);
|
|
|
|
}
|
2011-04-07 08:16:30 +00:00
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
startRepeatKey(key);
|
|
|
|
startLongPressTimer(key);
|
|
|
|
setPressedKeyGraphics(key);
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-07 08:16:30 +00:00
|
|
|
private void startSlidingKeyInput(Key key) {
|
2011-11-29 07:56:27 +00:00
|
|
|
if (!mIsInSlidingKeyInput) {
|
|
|
|
mIgnoreModifierKey = key.isModifier();
|
|
|
|
}
|
2011-04-07 08:16:30 +00:00
|
|
|
mIsInSlidingKeyInput = true;
|
|
|
|
}
|
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
private void onGestureMoveEvent(PointerTracker tracker, int x, int y, long eventTime,
|
|
|
|
boolean isHistorical, Key key) {
|
|
|
|
final int gestureTime = (int)(eventTime - tracker.getDownTime());
|
2012-07-19 03:33:51 +00:00
|
|
|
if (sIsGestureEnabled && mIsPossibleGesture) {
|
2012-07-18 08:56:30 +00:00
|
|
|
final GestureStroke stroke = mGestureStroke;
|
|
|
|
stroke.addPoint(x, y, gestureTime, isHistorical);
|
2012-07-19 05:47:55 +00:00
|
|
|
if (!mInGesture && stroke.isStartOfAGesture(gestureTime, sWasInGesture)) {
|
2012-07-18 08:56:30 +00:00
|
|
|
startBatchInput();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key != null && mInGesture) {
|
|
|
|
final InputPointers batchPoints = getIncrementalBatchPoints();
|
2012-07-19 08:20:54 +00:00
|
|
|
mDrawingProxy.showGestureTrail(this);
|
2012-07-18 08:56:30 +00:00
|
|
|
if (updateBatchInputRecognitionState(eventTime, batchPoints.getPointerSize())) {
|
|
|
|
updateBatchInput(batchPoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-26 08:34:04 +00:00
|
|
|
public void onMoveEvent(int x, int y, long eventTime, MotionEvent me) {
|
2010-12-18 11:04:44 +00:00
|
|
|
if (DEBUG_MOVE_EVENT)
|
|
|
|
printTouchEvent("onMoveEvent:", x, y, eventTime);
|
2010-09-03 08:54:37 +00:00
|
|
|
if (mKeyAlreadyProcessed)
|
|
|
|
return;
|
2010-12-17 05:13:01 +00:00
|
|
|
|
2012-06-12 10:40:37 +00:00
|
|
|
if (me != null) {
|
|
|
|
// Add historical points to gesture path.
|
|
|
|
final int pointerIndex = me.findPointerIndex(mPointerId);
|
|
|
|
final int historicalSize = me.getHistorySize();
|
|
|
|
for (int h = 0; h < historicalSize; h++) {
|
|
|
|
final int historicalX = (int)me.getHistoricalX(pointerIndex, h);
|
|
|
|
final int historicalY = (int)me.getHistoricalY(pointerIndex, h);
|
|
|
|
final long historicalTime = me.getHistoricalEventTime(h);
|
2012-07-18 08:56:30 +00:00
|
|
|
onGestureMoveEvent(this, historicalX, historicalY, historicalTime,
|
2012-06-12 10:40:37 +00:00
|
|
|
true /* isHistorical */, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-08 23:19:19 +00:00
|
|
|
final int lastX = mLastX;
|
|
|
|
final int lastY = mLastY;
|
2011-11-29 07:56:27 +00:00
|
|
|
final Key oldKey = mCurrentKey;
|
|
|
|
Key key = onMoveKey(x, y);
|
2012-06-12 10:40:37 +00:00
|
|
|
|
|
|
|
// Register move event on gesture tracker.
|
2012-07-18 08:56:30 +00:00
|
|
|
onGestureMoveEvent(this, x, y, eventTime, false /* isHistorical */, key);
|
|
|
|
if (mInGesture) {
|
2012-06-12 10:40:37 +00:00
|
|
|
mIgnoreModifierKey = true;
|
|
|
|
mTimerProxy.cancelLongPressTimer();
|
|
|
|
mIsInSlidingKeyInput = true;
|
|
|
|
mCurrentKey = null;
|
|
|
|
setReleasedKeyGraphics(oldKey);
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
if (key != null) {
|
2010-11-09 19:57:41 +00:00
|
|
|
if (oldKey == null) {
|
2010-12-17 07:56:15 +00:00
|
|
|
// The pointer has been slid in to the new key, but the finger was not on any keys.
|
|
|
|
// In this case, we must call onPress() to notify that the new key is being pressed.
|
2010-12-30 07:51:36 +00:00
|
|
|
// This onPress call may have changed keyboard layout. Those cases are detected at
|
2011-11-29 07:56:27 +00:00
|
|
|
// {@link #setKeyboard}. In those cases, we should update key according to the
|
2010-12-30 07:51:36 +00:00
|
|
|
// new keyboard layout.
|
2012-01-17 08:08:26 +00:00
|
|
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
2011-11-29 07:56:27 +00:00
|
|
|
key = onMoveKey(x, y);
|
|
|
|
}
|
|
|
|
onMoveToNewKey(key, x, y);
|
|
|
|
startLongPressTimer(key);
|
|
|
|
setPressedKeyGraphics(key);
|
|
|
|
} else if (isMajorEnoughMoveToBeOnNewKey(x, y, key)) {
|
2010-12-17 07:56:15 +00:00
|
|
|
// 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
|
|
|
|
// onPress() to notify that the new key is being pressed.
|
2011-11-29 07:56:27 +00:00
|
|
|
setReleasedKeyGraphics(oldKey);
|
2011-03-02 19:43:13 +00:00
|
|
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
2011-04-07 08:16:30 +00:00
|
|
|
startSlidingKeyInput(oldKey);
|
2011-07-09 01:35:58 +00:00
|
|
|
mTimerProxy.cancelKeyTimers();
|
2011-11-29 07:56:27 +00:00
|
|
|
startRepeatKey(key);
|
2010-12-18 09:48:32 +00:00
|
|
|
if (mIsAllowedSlidingKeyInput) {
|
2010-12-30 07:51:36 +00:00
|
|
|
// This onPress call may have changed keyboard layout. Those cases are detected
|
2011-11-29 07:56:27 +00:00
|
|
|
// at {@link #setKeyboard}. In those cases, we should update key according
|
2010-12-30 07:51:36 +00:00
|
|
|
// to the new keyboard layout.
|
2012-01-17 08:08:26 +00:00
|
|
|
if (callListenerOnPressAndCheckKeyboardLayoutChange(key)) {
|
2011-11-29 07:56:27 +00:00
|
|
|
key = onMoveKey(x, y);
|
|
|
|
}
|
|
|
|
onMoveToNewKey(key, x, y);
|
|
|
|
startLongPressTimer(key);
|
|
|
|
setPressedKeyGraphics(key);
|
2010-12-18 09:48:32 +00:00
|
|
|
} else {
|
2011-01-28 03:40:27 +00:00
|
|
|
// 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
|
|
|
|
// move event to successive up and down events.
|
|
|
|
final int dx = x - lastX;
|
|
|
|
final int dy = y - lastY;
|
|
|
|
final int lastMoveSquared = dx * dx + dy * dy;
|
2012-05-30 10:29:57 +00:00
|
|
|
if (sNeedsPhantomSuddenMoveEventHack
|
|
|
|
&& lastMoveSquared >= mKeyQuarterWidthSquared) {
|
|
|
|
if (DEBUG_MODE) {
|
|
|
|
Log.w(TAG, String.format("onMoveEvent:"
|
|
|
|
+ " phantom sudden move event is translated to "
|
2011-01-28 03:40:27 +00:00
|
|
|
+ "up[%d,%d]/down[%d,%d] events", lastX, lastY, x, y));
|
2012-05-30 10:29:57 +00:00
|
|
|
}
|
2012-03-30 20:15:46 +00:00
|
|
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
|
|
|
ResearchLogger.pointerTracker_onMoveEvent(x, y, lastX, lastY);
|
|
|
|
}
|
2012-06-12 10:40:37 +00:00
|
|
|
onUpEventInternal(x, y, eventTime);
|
2011-01-28 03:40:27 +00:00
|
|
|
onDownEventInternal(x, y, eventTime);
|
|
|
|
} else {
|
2012-06-27 00:47:59 +00:00
|
|
|
// HACK: If there are currently multiple touches, register the key even if
|
|
|
|
// the finger slides off the key. This defends against noise from some
|
|
|
|
// touch panels when there are close multiple touches.
|
|
|
|
// Caveat: When in chording input mode with a modifier key, we don't use
|
|
|
|
// this hack.
|
|
|
|
if (me != null && me.getPointerCount() > 1
|
|
|
|
&& !sPointerTrackerQueue.hasModifierKeyOlderThan(this)) {
|
2012-06-12 10:40:37 +00:00
|
|
|
onUpEventInternal(x, y, eventTime);
|
2012-06-27 00:47:59 +00:00
|
|
|
}
|
2011-04-18 10:07:20 +00:00
|
|
|
mKeyAlreadyProcessed = true;
|
2011-11-29 07:56:27 +00:00
|
|
|
setReleasedKeyGraphics(oldKey);
|
2011-01-28 03:40:27 +00:00
|
|
|
}
|
2010-12-18 09:48:32 +00:00
|
|
|
}
|
2011-04-22 02:09:48 +00:00
|
|
|
}
|
2010-08-31 15:27:04 +00:00
|
|
|
} else {
|
2011-11-29 07:56:27 +00:00
|
|
|
if (oldKey != null && isMajorEnoughMoveToBeOnNewKey(x, y, key)) {
|
2010-12-17 07:56:15 +00:00
|
|
|
// The pointer has been slid out from the previous key, we must call onRelease() to
|
|
|
|
// notify that the previous key has been released.
|
2011-11-29 07:56:27 +00:00
|
|
|
setReleasedKeyGraphics(oldKey);
|
2011-03-02 19:43:13 +00:00
|
|
|
callListenerOnRelease(oldKey, oldKey.mCode, true);
|
2011-04-07 08:16:30 +00:00
|
|
|
startSlidingKeyInput(oldKey);
|
2011-07-17 21:37:30 +00:00
|
|
|
mTimerProxy.cancelLongPressTimer();
|
2010-12-18 09:48:32 +00:00
|
|
|
if (mIsAllowedSlidingKeyInput) {
|
2011-11-29 07:56:27 +00:00
|
|
|
onMoveToNewKey(key, x, y);
|
2010-12-18 09:48:32 +00:00
|
|
|
} else {
|
2011-04-18 10:07:20 +00:00
|
|
|
mKeyAlreadyProcessed = true;
|
2010-12-18 09:48:32 +00:00
|
|
|
}
|
2010-09-02 15:48:16 +00:00
|
|
|
}
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-06 23:11:30 +00:00
|
|
|
public void onUpEvent(int x, int y, long eventTime) {
|
2010-12-18 11:04:44 +00:00
|
|
|
if (DEBUG_EVENT)
|
|
|
|
printTouchEvent("onUpEvent :", x, y, eventTime);
|
2010-12-21 05:01:13 +00:00
|
|
|
|
2011-07-11 22:24:01 +00:00
|
|
|
final PointerTrackerQueue queue = sPointerTrackerQueue;
|
2010-12-21 05:01:13 +00:00
|
|
|
if (queue != null) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (!mInGesture) {
|
2012-06-12 10:40:37 +00:00
|
|
|
if (mCurrentKey != null && mCurrentKey.isModifier()) {
|
|
|
|
// Before processing an up event of modifier key, all pointers already being
|
|
|
|
// tracked should be released.
|
|
|
|
queue.releaseAllPointersExcept(this, eventTime);
|
|
|
|
} else {
|
|
|
|
queue.releaseAllPointersOlderThan(this, eventTime);
|
|
|
|
}
|
2010-12-21 05:01:13 +00:00
|
|
|
}
|
|
|
|
queue.remove(this);
|
|
|
|
}
|
2012-06-12 10:40:37 +00:00
|
|
|
onUpEventInternal(x, y, eventTime);
|
2010-12-21 05:01:13 +00:00
|
|
|
}
|
|
|
|
|
2011-04-19 06:18:20 +00:00
|
|
|
// Let this pointer tracker know that one of newer-than-this pointer trackers got an up event.
|
|
|
|
// This pointer tracker needs to keep the key top graphics "pressed", but needs to get a
|
|
|
|
// "virtual" up event.
|
2011-07-23 08:27:49 +00:00
|
|
|
public void onPhantomUpEvent(int x, int y, long eventTime) {
|
2011-04-22 02:09:48 +00:00
|
|
|
if (DEBUG_EVENT)
|
|
|
|
printTouchEvent("onPhntEvent:", x, y, eventTime);
|
2012-06-12 10:40:37 +00:00
|
|
|
onUpEventInternal(x, y, eventTime);
|
2011-04-18 10:07:20 +00:00
|
|
|
mKeyAlreadyProcessed = true;
|
2010-12-21 05:01:13 +00:00
|
|
|
}
|
|
|
|
|
2012-06-12 10:40:37 +00:00
|
|
|
private void onUpEventInternal(int x, int y, long eventTime) {
|
2011-07-09 01:35:58 +00:00
|
|
|
mTimerProxy.cancelKeyTimers();
|
2010-12-20 07:21:54 +00:00
|
|
|
mIsInSlidingKeyInput = false;
|
2012-05-09 09:49:03 +00:00
|
|
|
// Release the last pressed key.
|
|
|
|
setReleasedKeyGraphics(mCurrentKey);
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mIsShowingMoreKeysPanel) {
|
|
|
|
mDrawingProxy.dismissMoreKeysPanel();
|
|
|
|
mIsShowingMoreKeysPanel = false;
|
2011-07-23 08:16:56 +00:00
|
|
|
}
|
2012-06-12 10:40:37 +00:00
|
|
|
|
2012-07-18 08:56:30 +00:00
|
|
|
if (mInGesture) {
|
2012-06-12 10:40:37 +00:00
|
|
|
// Register up event on gesture tracker.
|
2012-07-18 08:56:30 +00:00
|
|
|
// TODO: Figure out how to deal with multiple fingers that are in gesture, sliding,
|
|
|
|
// and/or tapping mode?
|
|
|
|
endBatchInput(getAllBatchPoints());
|
2012-06-12 10:40:37 +00:00
|
|
|
if (mCurrentKey != null) {
|
|
|
|
callListenerOnRelease(mCurrentKey, mCurrentKey.mCode, true);
|
2012-07-18 08:56:30 +00:00
|
|
|
mCurrentKey = null;
|
2012-06-12 10:40:37 +00:00
|
|
|
}
|
2012-07-19 08:20:54 +00:00
|
|
|
mDrawingProxy.showGestureTrail(this);
|
2012-06-12 10:40:37 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-07-19 12:53:42 +00:00
|
|
|
// This event will be recognized as a regular code input. Clear unused batch points so they
|
|
|
|
// are not mistakenly included in the next batch event.
|
|
|
|
clearBatchInputPointsOfAllPointerTrackers();
|
2011-04-18 10:07:20 +00:00
|
|
|
if (mKeyAlreadyProcessed)
|
|
|
|
return;
|
2012-06-26 10:01:59 +00:00
|
|
|
if (mCurrentKey != null && !mCurrentKey.isRepeatable()) {
|
2012-05-09 09:49:03 +00:00
|
|
|
detectAndSendKey(mCurrentKey, mKeyX, mKeyY);
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-26 11:54:35 +00:00
|
|
|
public void onShowMoreKeysPanel(int x, int y, KeyEventHandler handler) {
|
2012-07-19 05:47:55 +00:00
|
|
|
abortBatchInput();
|
2011-07-23 08:16:56 +00:00
|
|
|
onLongPressed();
|
2011-08-31 06:26:32 +00:00
|
|
|
mIsShowingMoreKeysPanel = true;
|
2012-07-20 09:40:31 +00:00
|
|
|
onDownEvent(x, y, SystemClock.uptimeMillis(), handler);
|
2011-07-23 08:16:56 +00:00
|
|
|
}
|
|
|
|
|
2011-07-06 23:11:30 +00:00
|
|
|
public void onLongPressed() {
|
2011-04-18 10:07:20 +00:00
|
|
|
mKeyAlreadyProcessed = true;
|
2011-11-29 07:56:27 +00:00
|
|
|
setReleasedKeyGraphics(mCurrentKey);
|
2011-07-11 22:24:01 +00:00
|
|
|
final PointerTrackerQueue queue = sPointerTrackerQueue;
|
2011-06-08 07:58:08 +00:00
|
|
|
if (queue != null) {
|
2011-04-22 08:33:24 +00:00
|
|
|
queue.remove(this);
|
2011-06-08 07:58:08 +00:00
|
|
|
}
|
2011-04-18 10:07:20 +00:00
|
|
|
}
|
|
|
|
|
2011-07-06 23:11:30 +00:00
|
|
|
public void onCancelEvent(int x, int y, long eventTime) {
|
2010-12-18 11:04:44 +00:00
|
|
|
if (DEBUG_EVENT)
|
|
|
|
printTouchEvent("onCancelEvt:", x, y, eventTime);
|
2010-12-21 05:01:13 +00:00
|
|
|
|
2011-07-11 22:24:01 +00:00
|
|
|
final PointerTrackerQueue queue = sPointerTrackerQueue;
|
2011-04-22 02:09:48 +00:00
|
|
|
if (queue != null) {
|
2011-07-23 08:27:49 +00:00
|
|
|
queue.releaseAllPointersExcept(this, eventTime);
|
2010-12-21 05:01:13 +00:00
|
|
|
queue.remove(this);
|
2011-04-22 02:09:48 +00:00
|
|
|
}
|
2010-12-17 05:13:01 +00:00
|
|
|
onCancelEventInternal();
|
2010-12-21 05:01:13 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 05:13:01 +00:00
|
|
|
private void onCancelEventInternal() {
|
2011-07-09 01:35:58 +00:00
|
|
|
mTimerProxy.cancelKeyTimers();
|
2011-11-29 07:56:27 +00:00
|
|
|
setReleasedKeyGraphics(mCurrentKey);
|
2010-12-20 07:21:54 +00:00
|
|
|
mIsInSlidingKeyInput = false;
|
2011-08-31 06:26:32 +00:00
|
|
|
if (mIsShowingMoreKeysPanel) {
|
|
|
|
mDrawingProxy.dismissMoreKeysPanel();
|
|
|
|
mIsShowingMoreKeysPanel = false;
|
2011-07-23 08:16:56 +00:00
|
|
|
}
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private void startRepeatKey(Key key) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (key != null && key.isRepeatable() && !mInGesture) {
|
2012-05-10 18:33:31 +00:00
|
|
|
onRegisterKey(key);
|
2012-02-01 06:07:25 +00:00
|
|
|
mTimerProxy.startKeyRepeatTimer(this);
|
2011-04-22 12:05:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-10 18:33:31 +00:00
|
|
|
public void onRegisterKey(Key key) {
|
2010-09-01 08:50:24 +00:00
|
|
|
if (key != null) {
|
2011-11-29 07:56:27 +00:00
|
|
|
detectAndSendKey(key, key.mX, key.mY);
|
2012-04-12 08:51:57 +00:00
|
|
|
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
|
|
|
mTimerProxy.startTypingStateTimer();
|
|
|
|
}
|
2010-09-01 08:50:24 +00:00
|
|
|
}
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private boolean isMajorEnoughMoveToBeOnNewKey(int x, int y, Key newKey) {
|
2012-03-13 11:53:15 +00:00
|
|
|
if (mKeyDetector == null)
|
2011-07-04 10:59:57 +00:00
|
|
|
throw new NullPointerException("keyboard and/or key detector not set");
|
2011-11-29 07:56:27 +00:00
|
|
|
Key curKey = mCurrentKey;
|
2010-08-31 15:27:04 +00:00
|
|
|
if (newKey == curKey) {
|
2011-04-21 03:22:00 +00:00
|
|
|
return false;
|
2011-11-29 07:56:27 +00:00
|
|
|
} else if (curKey != null) {
|
|
|
|
return curKey.squaredDistanceToEdge(x, y)
|
2011-07-04 10:59:57 +00:00
|
|
|
>= mKeyDetector.getKeyHysteresisDistanceSquared();
|
2010-08-31 15:27:04 +00:00
|
|
|
} else {
|
2011-04-21 03:22:00 +00:00
|
|
|
return true;
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private void startLongPressTimer(Key key) {
|
2012-07-18 08:56:30 +00:00
|
|
|
if (key != null && key.isLongPressEnabled() && !mInGesture) {
|
2012-02-01 06:07:25 +00:00
|
|
|
mTimerProxy.startLongPressTimer(this);
|
2010-10-22 10:35:23 +00:00
|
|
|
}
|
2010-10-02 06:17:27 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 07:56:27 +00:00
|
|
|
private void detectAndSendKey(Key key, int x, int y) {
|
2010-09-07 06:37:59 +00:00
|
|
|
if (key == null) {
|
2010-12-20 07:13:57 +00:00
|
|
|
callListenerOnCancelInput();
|
2010-12-18 11:04:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-10-02 06:17:27 +00:00
|
|
|
|
2011-11-30 08:54:58 +00:00
|
|
|
int code = key.mCode;
|
2012-03-06 05:56:46 +00:00
|
|
|
callListenerOnCodeInput(key, code, x, y);
|
2011-11-30 08:54:58 +00:00
|
|
|
callListenerOnRelease(key, code, false);
|
2012-07-19 05:47:55 +00:00
|
|
|
sWasInGesture = false;
|
2010-08-31 15:27:04 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 11:04:44 +00:00
|
|
|
private void printTouchEvent(String title, int x, int y, long eventTime) {
|
2012-03-15 10:44:43 +00:00
|
|
|
final Key key = mKeyDetector.detectHitKey(x, y);
|
2011-12-01 07:34:23 +00:00
|
|
|
final String code = KeyDetector.printableCode(key);
|
2011-11-29 07:56:27 +00:00
|
|
|
Log.d(TAG, String.format("%s%s[%d] %4d %4d %5d %s", title,
|
2012-06-26 09:36:30 +00:00
|
|
|
(mKeyAlreadyProcessed ? "-" : " "), mPointerId, x, y, eventTime, code));
|
2010-12-18 11:04:44 +00:00
|
|
|
}
|
2010-09-24 11:45:24 +00:00
|
|
|
}
|