summaryrefslogtreecommitdiffstats
path: root/core/java/android/text/method
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-04-05 14:27:59 -0700
committerKenny Root <kroot@google.com>2010-04-05 14:48:44 -0700
commit8cdb684163051c12f37e8a5f9031f17efd9d0fa4 (patch)
treeb5fbaca51660e742398250149e38134aef81c6fd /core/java/android/text/method
parent5923c9718390bf6d50c52661263f15c1f863012b (diff)
downloadframeworks_base-8cdb684163051c12f37e8a5f9031f17efd9d0fa4.zip
frameworks_base-8cdb684163051c12f37e8a5f9031f17efd9d0fa4.tar.gz
frameworks_base-8cdb684163051c12f37e8a5f9031f17efd9d0fa4.tar.bz2
Revert to previous text selection behavior
There was a new behavior that starting "Select text" would allow you to swipe from beginning to end and immediately copy that. This change reverts to the previous behavior that "Select text" will start where your cursor is currently and any tap will extend the selection from that origin to the point of the tap. Change-Id: Ib955cc8d62a652f518435953da2f54e810d9dfb0
Diffstat (limited to 'core/java/android/text/method')
-rw-r--r--core/java/android/text/method/ArrowKeyMovementMethod.java54
1 files changed, 31 insertions, 23 deletions
diff --git a/core/java/android/text/method/ArrowKeyMovementMethod.java b/core/java/android/text/method/ArrowKeyMovementMethod.java
index 7b307f8..9af42cc 100644
--- a/core/java/android/text/method/ArrowKeyMovementMethod.java
+++ b/core/java/android/text/method/ArrowKeyMovementMethod.java
@@ -252,7 +252,6 @@ implements MovementMethod
int offset = getOffset(x, y, widget);
if (cap) {
-
buffer.setSpan(LAST_TAP_DOWN, offset, offset,
Spannable.SPAN_POINT_POINT);
@@ -286,13 +285,13 @@ implements MovementMethod
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
}
}
- } else if (event.getAction() == MotionEvent.ACTION_MOVE ) {
+ } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
boolean cap = (MetaKeyKeyListener.getMetaState(buffer,
KeyEvent.META_SHIFT_ON) == 1) ||
(MetaKeyKeyListener.getMetaState(buffer,
MetaKeyKeyListener.META_SELECTING) != 0);
- if (cap & handled) {
+ if (cap && handled) {
// Before selecting, make sure we've moved out of the "slop".
// handled will be true, if we're in select mode AND we're
// OUT of the slop
@@ -308,28 +307,35 @@ implements MovementMethod
int y = (int) event.getY();
int offset = getOffset(x, y, widget);
- // Get the last down touch position (the position at which the
- // user started the selection)
- int lastDownOffset = buffer.getSpanStart(LAST_TAP_DOWN);
-
- // Compute the selection boundaries
- int spanstart;
- int spanend;
- if (offset >= lastDownOffset) {
- // Expand from word start of the original tap to new word
- // end, since we are selecting "forwards"
- spanstart = findWordStart(buffer, lastDownOffset);
- spanend = findWordEnd(buffer, offset);
+ final OnePointFiveTapState[] tap = buffer.getSpans(0, buffer.length(),
+ OnePointFiveTapState.class);
+
+ if (tap.length > 0 && tap[0].active) {
+ // Get the last down touch position (the position at which the
+ // user started the selection)
+ int lastDownOffset = buffer.getSpanStart(LAST_TAP_DOWN);
+
+ // Compute the selection boundaries
+ int spanstart;
+ int spanend;
+ if (offset >= lastDownOffset) {
+ // Expand from word start of the original tap to new word
+ // end, since we are selecting "forwards"
+ spanstart = findWordStart(buffer, lastDownOffset);
+ spanend = findWordEnd(buffer, offset);
+ } else {
+ // Expand to from new word start to word end of the original
+ // tap since we are selecting "backwards".
+ // The spanend will always need to be associated with the touch
+ // up position, so that refining the selection with the
+ // trackball will work as expected.
+ spanstart = findWordEnd(buffer, lastDownOffset);
+ spanend = findWordStart(buffer, offset);
+ }
+ Selection.setSelection(buffer, spanstart, spanend);
} else {
- // Expand to from new word start to word end of the original
- // tap since we are selecting "backwards".
- // The spanend will always need to be associated with the touch
- // up position, so that refining the selection with the
- // trackball will work as expected.
- spanstart = findWordEnd(buffer, lastDownOffset);
- spanend = findWordStart(buffer, offset);
+ Selection.extendSelection(buffer, offset);
}
- Selection.setSelection(buffer, spanstart, spanend);
return true;
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
@@ -393,6 +399,8 @@ implements MovementMethod
// If we selecting something with the onepointfivetap-and
// swipe gesture, stop it on finger up.
MetaKeyKeyListener.stopSelecting(widget, buffer);
+ } else {
+ Selection.extendSelection(buffer, off);
}
} else if (doubletap) {
Selection.setSelection(buffer,