summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2012-02-28 11:15:54 -0800
committerGilles Debunne <debunne@google.com>2012-02-28 11:15:56 -0800
commit9f102ca592e5bca91140c72e0962277d8731f977 (patch)
treeaa5249d629bfcb191dd2d665c20158e778915b9b /core/java
parentaf2abf5adae93b263381ea70d3a0c1a6f03f795f (diff)
downloadframeworks_base-9f102ca592e5bca91140c72e0962277d8731f977.zip
frameworks_base-9f102ca592e5bca91140c72e0962277d8731f977.tar.gz
frameworks_base-9f102ca592e5bca91140c72e0962277d8731f977.tar.bz2
Vibrate on long press, even out of text
Bug 6073057 Change-Id: I53441f365419aa1ae4d51e03efff46697059d38a
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/TextView.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index f384dc1..36504ca 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8189,24 +8189,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public boolean performLongClick() {
boolean handled = false;
- boolean vibrate = true;
if (super.performLongClick()) {
handled = true;
}
+ if (mEditor == null) {
+ return handled;
+ }
+
// Long press in empty space moves cursor and shows the Paste affordance if available.
- if (!handled && mEditor != null && !isPositionOnText(getEditor().mLastDownPositionX, getEditor().mLastDownPositionY) &&
+ if (!handled && !isPositionOnText(getEditor().mLastDownPositionX, getEditor().mLastDownPositionY) &&
getEditor().mInsertionControllerEnabled) {
final int offset = getOffsetForPosition(getEditor().mLastDownPositionX, getEditor().mLastDownPositionY);
stopSelectionActionMode();
Selection.setSelection((Spannable) mText, offset);
getInsertionController().showWithActionPopup();
handled = true;
- vibrate = false;
}
- if (!handled && mEditor != null && getEditor().mSelectionActionMode != null) {
+ if (!handled && getEditor().mSelectionActionMode != null) {
if (touchPositionIsInSelection()) {
// Start a drag
final int start = getSelectionStart();
@@ -8225,15 +8227,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
// Start a new selection
- if (!handled && mEditor != null) {
- vibrate = handled = startSelectionActionMode();
+ if (!handled) {
+ handled = startSelectionActionMode();
}
- if (vibrate) {
+ if (handled) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
- }
-
- if (handled && mEditor != null) {
getEditor().mDiscardNextActionUp = true;
}