@@ -86,6 +86,7 @@ public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {
8686 // Parameters for pointer handling.
8787 private static PointerTrackerParams sParams ;
8888 private static int sPointerStep ;
89+ private static int sPointerWordStep ;
8990 private static GestureStrokeRecognitionParams sGestureStrokeRecognitionParams ;
9091 private static GestureStrokeDrawingParams sGestureStrokeDrawingParams ;
9192 private static boolean sNeedsPhantomSuddenMoveEventHack ;
@@ -129,11 +130,12 @@ public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {
129130 private int mLastX ;
130131 private int mLastY ;
131132
132- // For spacebar slide tracking.
133+ // For spacebar/backspace slide tracking.
133134 private int mStartX ;
134135 private int mStartY ;
135136 private long mStartTime ;
136137 private boolean mSlidOnSpaceBar = false ;
138+ private boolean mSlidOnBackspace = false ;
137139
138140 // true if keyboard layout has been changed.
139141 private boolean mKeyboardLayoutHasBeenChanged ;
@@ -164,6 +166,7 @@ public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy
164166 final DrawingProxy drawingProxy ) {
165167 sParams = new PointerTrackerParams (mainKeyboardViewAttr );
166168 sPointerStep = (int )(10.0 * Resources .getSystem ().getDisplayMetrics ().density );
169+ sPointerWordStep = (int )(20.0 * Resources .getSystem ().getDisplayMetrics ().density );
167170 sGestureStrokeRecognitionParams = new GestureStrokeRecognitionParams (mainKeyboardViewAttr );
168171 sGestureStrokeDrawingParams = new GestureStrokeDrawingParams (mainKeyboardViewAttr );
169172 sTypingTimeRecorder = new TypingTimeRecorder (
@@ -296,6 +299,9 @@ private void callListenerOnCodeInput(final Key key, final int primaryCode, final
296299 if (ignoreModifierKey ) {
297300 return ;
298301 }
302+ if (mSlidOnBackspace && code == Constants .CODE_DELETE ) {
303+ return ;
304+ }
299305 // Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
300306 if (key .isEnabled () || altersCode ) {
301307 sTypingTimeRecorder .onCodeInput (code , eventTime );
@@ -925,6 +931,20 @@ private void onMoveEventInternal(final int x, final int y, final long eventTime)
925931 return ;
926932 }
927933
934+ // Backspace slider
935+ if (oldKey != null && oldKey .getCode () == Constants .CODE_DELETE
936+ && Settings .getInstance ().getCurrent ().mBackspaceTrackpadEnabled ) {
937+ int steps = (x - mStartX ) / sPointerWordStep ;
938+ if (steps != 0
939+ && mStartTime + Settings .getInstance ().getCurrent ().mKeyLongpressTimeout
940+ < System .currentTimeMillis ()) {
941+ mSlidOnBackspace = true ;
942+ mStartX += steps * sPointerWordStep ;
943+ sListener .onBackspaceSlide (steps );
944+ }
945+ return ;
946+ }
947+
928948 if (sGestureEnabler .shouldHandleGesture ()) {
929949 // Register move event on gesture tracker.
930950 onGestureMoveEvent (x , y , eventTime , true /* isMajorEvent */ , newKey );
@@ -1012,6 +1032,12 @@ private void onUpEventInternal(final int x, final int y, final long eventTime) {
10121032 return ;
10131033 }
10141034
1035+ if (mSlidOnBackspace ) {
1036+ sListener .onBackspaceSlideFinished ();
1037+ mSlidOnBackspace = false ;
1038+ return ;
1039+ }
1040+
10151041 if (sInGesture ) {
10161042 if (currentKey != null ) {
10171043 callListenerOnRelease (currentKey , currentKey .getCode (), true /* withSliding */ );
@@ -1057,6 +1083,9 @@ public void onLongPressed() {
10571083 if (mSlidOnSpaceBar ) {
10581084 return ;
10591085 }
1086+ if (mSlidOnBackspace ) {
1087+ return ;
1088+ }
10601089 final Key key = getKey ();
10611090 if (key == null ) {
10621091 return ;
0 commit comments