diff options
author | Gilles Debunne <debunne@google.com> | 2010-12-21 16:10:20 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-12-21 16:10:20 -0800 |
commit | 68e8ed38feffb8608858a6bfc3a14d183bf5a166 (patch) | |
tree | 3b894974cebae03380d307e87dec246786bb2b7b | |
parent | 1528d8f47cc6f0e0d5c9f905f82d15a35ce1bafb (diff) | |
parent | f3895edf4b21e1083b58cdb36b93223ecaa98ca8 (diff) | |
download | frameworks_base-68e8ed38feffb8608858a6bfc3a14d183bf5a166.zip frameworks_base-68e8ed38feffb8608858a6bfc3a14d183bf5a166.tar.gz frameworks_base-68e8ed38feffb8608858a6bfc3a14d183bf5a166.tar.bz2 |
Merge "Links are clickable in TextView when textIsSelectable."
-rw-r--r-- | core/java/android/widget/TextView.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 052760f..0699ac2 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -81,6 +81,7 @@ import android.text.method.SingleLineTransformationMethod; import android.text.method.TextKeyListener; import android.text.method.TimeKeyListener; import android.text.method.TransformationMethod; +import android.text.style.ClickableSpan; import android.text.style.ParagraphStyle; import android.text.style.URLSpan; import android.text.style.UpdateAppearance; @@ -7238,6 +7239,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener handled |= mMovement.onTouchEvent(this, (Spannable) mText, event); } + if (mLinksClickable && mAutoLinkMask != 0 && mTextIsSelectable && + action == MotionEvent.ACTION_UP && !mIgnoreActionUpEvent && isFocused()) { + // The LinkMovementMethod which should handle taps on links has not been installed + // to support text selection. We reproduce its behavior here to open links. + ClickableSpan[] links = ((Spannable) mText).getSpans(getSelectionStart(), + getSelectionEnd(), ClickableSpan.class); + + if (links.length != 0) { + links[0].onClick(this); + handled = true; + } + } + if (isTextEditable() || mTextIsSelectable) { if (mScrollX != oldScrollX || mScrollY != oldScrollY) { // Hide insertion anchor while scrolling. Leave selection. |