summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-03-14 12:57:01 -0700
committerGilles Debunne <debunne@google.com>2011-03-14 12:57:01 -0700
commit816dd3d443108b473965f97123eef7300f53615f (patch)
treef579f49872f12f8f1d5fb93186159e969046a64b /core/java/android/widget/TextView.java
parent206c62ed34dc8a48fd6c907d95456226949f42dd (diff)
parent9c06c0ffc9fe24c7b8bbeca53bce76aca9d1ac4f (diff)
resolved conflicts for merge of 9c06c0ff to gingerbread-plus-aosp
Change-Id: I7f9c71eeb9fc5e01856f764930c6f168741cc9da
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 97b05af0aae2..68600cf90a59 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -301,6 +301,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Set when this TextView gained focus with some text selected. Will start selection mode.
private boolean mCreatedWithASelection = false;
+ private boolean mNoContextMenuOnUp = false;
+
/*
* Kick-start the font cache for the zygote process (to pay the cost of
* initializing freetype for our default font only once).
@@ -6798,8 +6800,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Restore previous selection
Selection.setSelection((Spannable)mText, prevStart, prevEnd);
- // Tapping inside the selection displays the cut/copy/paste context menu
- showContextMenu();
+ // Tapping inside the selection displays the cut/copy/paste context menu, unless
+ // this is a double tap that should simply trigger text selection mode.
+ if (!mNoContextMenuOnUp) showContextMenu();
} else {
// Tapping outside stops selection mode, if any
stopTextSelectionMode();
@@ -6857,7 +6860,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mScrolled = false;
}
- final boolean superResult = super.onTouchEvent(event);
+ boolean result = super.onTouchEvent(event);
/*
* Don't handle the release after a long press, because it will
@@ -6866,11 +6869,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
*/
if (mEatTouchRelease && action == MotionEvent.ACTION_UP) {
mEatTouchRelease = false;
- return superResult;
- }
-
- if ((mMovement != null || onCheckIsTextEditor()) && isEnabled() &&
- mText instanceof Spannable && mLayout != null) {
+ } else if ((mMovement != null || onCheckIsTextEditor()) && mText instanceof Spannable &&
+ mLayout != null) {
boolean handled = false;
// Save previous selection, in case this event is used to show the IME.
@@ -6911,12 +6911,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
- if (handled) {
- return true;
- }
+ if (handled) result = true;
+ }
+
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
+ mNoContextMenuOnUp = false;
}
- return superResult;
+ return result;
}
private void prepareCursorControllers() {
@@ -8200,9 +8202,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final int slopSquared = doubleTapSlop * doubleTapSlop;
if (distanceSquared < slopSquared) {
startTextSelectionMode();
- // Hacky: onTapUpEvent will open a context menu with cut/copy
- // Prevent this by hiding handles which will be revived instead.
- hide();
+ // prevents onTapUpEvent from opening a context menu with cut/copy
+ mNoContextMenuOnUp = true;
}
}
mPreviousTapPositionX = x;