diff options
| author | Andrei Stingaceanu <stg@google.com> | 2017-02-06 17:03:28 +0000 |
|---|---|---|
| committer | Andrei Stingaceanu <stg@google.com> | 2017-02-06 17:03:28 +0000 |
| commit | f0ebee91f86eafc1fb7b4c377f3cd1d6ce3fe38e (patch) | |
| tree | 15932f8a7422f81fc30be7ff3a5027aa6d62c6c8 /core/java | |
| parent | 6c149326d8d1ef0f8bf6dad702ffca399364d0d3 (diff) | |
Clickable spans - trigger onClick onSingleTapUp
Previously (post Android N) we decided to introduce
a gesture detector in textView and trigger the onClick()
over a clickable span when onSingleTapConfirmed was
called. The problem is that onSingleTapConfirmed also
waits for double tap timeout to make sure (to confirm).
This has a chance to break some apps so relax the
rule to only look for onSingleTapUp.
* the bug for which the initial change was made is
still fixed
* slightly amended the ClickableSpan JavaDoc to
specify that the onClick gets triggered if the
span is selected when clicked (note that this
behavior is unchanged since ClickableSpan exists,
added just an extra hint to devs)
Bug: 23692690
Test: in the attached CL (same topic)
Change-Id: Iead434aa558301d61879c27edc48dc4148ca187f
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/text/style/ClickableSpan.java | 2 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/java/android/text/style/ClickableSpan.java b/core/java/android/text/style/ClickableSpan.java index a183427a44d0..b098f16da1ed 100644 --- a/core/java/android/text/style/ClickableSpan.java +++ b/core/java/android/text/style/ClickableSpan.java @@ -22,7 +22,7 @@ import android.view.View; /** * If an object of this type is attached to the text of a TextView * with a movement method of LinkMovementMethod, the affected spans of - * text can be selected. If clicked, the {@link #onClick} method will + * text can be selected. If selected and clicked, the {@link #onClick} method will * be called. */ public abstract class ClickableSpan extends CharacterStyle implements UpdateAppearance { diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 4a8ec94962d1..a5ff29119dc9 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9639,7 +9639,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() { @Override - public boolean onSingleTapConfirmed(MotionEvent e) { + public boolean onSingleTapUp(MotionEvent e) { if (shouldUseClickableSpanOnClickGestureDetector()) { ClickableSpan[] links = ((Spannable) mText).getSpans( getSelectionStart(), getSelectionEnd(), |
