Loading core/java/android/text/method/ArrowKeyMovementMethod.java +64 −8 Original line number Diff line number Diff line Loading @@ -247,11 +247,12 @@ implements MovementMethod KeyEvent.META_SHIFT_ON) == 1) || (MetaKeyKeyListener.getMetaState(buffer, MetaKeyKeyListener.META_SELECTING) != 0); if (cap) { int x = (int) event.getX(); int y = (int) event.getY(); int offset = getOffset(x, y, widget); if (cap) { buffer.setSpan(LAST_TAP_DOWN, offset, offset, Spannable.SPAN_POINT_POINT); Loading @@ -260,6 +261,30 @@ implements MovementMethod // without this, users would get booted out of select // mode once the view detected it needed to scroll. widget.getParent().requestDisallowInterceptTouchEvent(true); } else { OnePointFiveTapState[] tap = buffer.getSpans(0, buffer.length(), OnePointFiveTapState.class); if (tap.length > 0) { if (event.getEventTime() - tap[0].mWhen <= ViewConfiguration.getDoubleTapTimeout() && sameWord(buffer, offset, Selection.getSelectionEnd(buffer))) { tap[0].active = true; MetaKeyKeyListener.startSelecting(widget, buffer); widget.getParent().requestDisallowInterceptTouchEvent(true); buffer.setSpan(LAST_TAP_DOWN, offset, offset, Spannable.SPAN_POINT_POINT); } tap[0].mWhen = event.getEventTime(); } else { OnePointFiveTapState newtap = new OnePointFiveTapState(); newtap.mWhen = event.getEventTime(); newtap.active = false; buffer.setSpan(newtap, 0, buffer.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } } } else if (event.getAction() == MotionEvent.ACTION_MOVE ) { boolean cap = (MetaKeyKeyListener.getMetaState(buffer, Loading Loading @@ -287,7 +312,7 @@ implements MovementMethod // user started the selection) int lastDownOffset = buffer.getSpanStart(LAST_TAP_DOWN); // Compute the selection boundries // Compute the selection boundaries int spanstart; int spanend; if (offset >= lastDownOffset) { Loading Loading @@ -324,6 +349,19 @@ implements MovementMethod // XXX should do the same adjust for x as we do for the line. OnePointFiveTapState[] onepointfivetap = buffer.getSpans(0, buffer.length(), OnePointFiveTapState.class); if (onepointfivetap.length > 0 && onepointfivetap[0].active && Selection.getSelectionStart(buffer) == Selection.getSelectionEnd(buffer)) { // If we've set select mode, because there was a onepointfivetap, // but there was no ensuing swipe gesture, undo the select mode // and remove reference to the last onepointfivetap. MetaKeyKeyListener.stopSelecting(widget, buffer); for (int i=0; i < onepointfivetap.length; i++) { buffer.removeSpan(onepointfivetap[i]); } buffer.removeSpan(LAST_TAP_DOWN); } boolean cap = (MetaKeyKeyListener.getMetaState(buffer, KeyEvent.META_SHIFT_ON) == 1) || (MetaKeyKeyListener.getMetaState(buffer, Loading @@ -335,11 +373,11 @@ implements MovementMethod if (tap.length > 0) { if (event.getEventTime() - tap[0].mWhen <= ViewConfiguration.getDoubleTapTimeout()) { if (sameWord(buffer, off, Selection.getSelectionEnd(buffer))) { ViewConfiguration.getDoubleTapTimeout() && sameWord(buffer, off, Selection.getSelectionEnd(buffer))) { doubletap = true; } } tap[0].mWhen = event.getEventTime(); } else { Loading @@ -351,6 +389,11 @@ implements MovementMethod if (cap) { buffer.removeSpan(LAST_TAP_DOWN); if (onepointfivetap.length > 0 && onepointfivetap[0].active) { // If we selecting something with the onepointfivetap-and // swipe gesture, stop it on finger up. MetaKeyKeyListener.stopSelecting(widget, buffer); } } else if (doubletap) { Selection.setSelection(buffer, findWordStart(buffer, off), Loading @@ -373,6 +416,19 @@ implements MovementMethod long mWhen; } /* We check for a onepointfive tap. This is similar to * doubletap gesture (where a finger goes down, up, down, up, in a short * time period), except in the onepointfive tap, a users finger only needs * to go down, up, down in a short time period. We detect this type of tap * to implement the onepointfivetap-and-swipe selection gesture. * This gesture allows users to select a segment of text without going * through the "select text" option in the context menu. */ private static class OnePointFiveTapState implements NoCopySpan { long mWhen; boolean active; } private static boolean sameWord(CharSequence text, int one, int two) { int start = findWordStart(text, one); int end = findWordEnd(text, one); Loading Loading
core/java/android/text/method/ArrowKeyMovementMethod.java +64 −8 Original line number Diff line number Diff line Loading @@ -247,11 +247,12 @@ implements MovementMethod KeyEvent.META_SHIFT_ON) == 1) || (MetaKeyKeyListener.getMetaState(buffer, MetaKeyKeyListener.META_SELECTING) != 0); if (cap) { int x = (int) event.getX(); int y = (int) event.getY(); int offset = getOffset(x, y, widget); if (cap) { buffer.setSpan(LAST_TAP_DOWN, offset, offset, Spannable.SPAN_POINT_POINT); Loading @@ -260,6 +261,30 @@ implements MovementMethod // without this, users would get booted out of select // mode once the view detected it needed to scroll. widget.getParent().requestDisallowInterceptTouchEvent(true); } else { OnePointFiveTapState[] tap = buffer.getSpans(0, buffer.length(), OnePointFiveTapState.class); if (tap.length > 0) { if (event.getEventTime() - tap[0].mWhen <= ViewConfiguration.getDoubleTapTimeout() && sameWord(buffer, offset, Selection.getSelectionEnd(buffer))) { tap[0].active = true; MetaKeyKeyListener.startSelecting(widget, buffer); widget.getParent().requestDisallowInterceptTouchEvent(true); buffer.setSpan(LAST_TAP_DOWN, offset, offset, Spannable.SPAN_POINT_POINT); } tap[0].mWhen = event.getEventTime(); } else { OnePointFiveTapState newtap = new OnePointFiveTapState(); newtap.mWhen = event.getEventTime(); newtap.active = false; buffer.setSpan(newtap, 0, buffer.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } } } else if (event.getAction() == MotionEvent.ACTION_MOVE ) { boolean cap = (MetaKeyKeyListener.getMetaState(buffer, Loading Loading @@ -287,7 +312,7 @@ implements MovementMethod // user started the selection) int lastDownOffset = buffer.getSpanStart(LAST_TAP_DOWN); // Compute the selection boundries // Compute the selection boundaries int spanstart; int spanend; if (offset >= lastDownOffset) { Loading Loading @@ -324,6 +349,19 @@ implements MovementMethod // XXX should do the same adjust for x as we do for the line. OnePointFiveTapState[] onepointfivetap = buffer.getSpans(0, buffer.length(), OnePointFiveTapState.class); if (onepointfivetap.length > 0 && onepointfivetap[0].active && Selection.getSelectionStart(buffer) == Selection.getSelectionEnd(buffer)) { // If we've set select mode, because there was a onepointfivetap, // but there was no ensuing swipe gesture, undo the select mode // and remove reference to the last onepointfivetap. MetaKeyKeyListener.stopSelecting(widget, buffer); for (int i=0; i < onepointfivetap.length; i++) { buffer.removeSpan(onepointfivetap[i]); } buffer.removeSpan(LAST_TAP_DOWN); } boolean cap = (MetaKeyKeyListener.getMetaState(buffer, KeyEvent.META_SHIFT_ON) == 1) || (MetaKeyKeyListener.getMetaState(buffer, Loading @@ -335,11 +373,11 @@ implements MovementMethod if (tap.length > 0) { if (event.getEventTime() - tap[0].mWhen <= ViewConfiguration.getDoubleTapTimeout()) { if (sameWord(buffer, off, Selection.getSelectionEnd(buffer))) { ViewConfiguration.getDoubleTapTimeout() && sameWord(buffer, off, Selection.getSelectionEnd(buffer))) { doubletap = true; } } tap[0].mWhen = event.getEventTime(); } else { Loading @@ -351,6 +389,11 @@ implements MovementMethod if (cap) { buffer.removeSpan(LAST_TAP_DOWN); if (onepointfivetap.length > 0 && onepointfivetap[0].active) { // If we selecting something with the onepointfivetap-and // swipe gesture, stop it on finger up. MetaKeyKeyListener.stopSelecting(widget, buffer); } } else if (doubletap) { Selection.setSelection(buffer, findWordStart(buffer, off), Loading @@ -373,6 +416,19 @@ implements MovementMethod long mWhen; } /* We check for a onepointfive tap. This is similar to * doubletap gesture (where a finger goes down, up, down, up, in a short * time period), except in the onepointfive tap, a users finger only needs * to go down, up, down in a short time period. We detect this type of tap * to implement the onepointfivetap-and-swipe selection gesture. * This gesture allows users to select a segment of text without going * through the "select text" option in the context menu. */ private static class OnePointFiveTapState implements NoCopySpan { long mWhen; boolean active; } private static boolean sameWord(CharSequence text, int one, int two) { int start = findWordStart(text, one); int end = findWordEnd(text, one); Loading