diff options
| author | Richard Ledley <rledley@google.com> | 2017-12-21 10:11:34 +0000 |
|---|---|---|
| committer | Richard Ledley <rledley@google.com> | 2018-01-11 14:16:14 +0000 |
| commit | 724eff9a3da8cea2d0356186982caa8dd8da33fd (patch) | |
| tree | 6b46491ad47325f424d121419e8359a88040979a /core/java/android/widget/SelectionActionModeHelper.java | |
| parent | 2647c5f22f721b27af40979af092a0a1dc23bc4e (diff) | |
Make Linkify links clickable in nonselectable text.
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest\#testToolbarAppearsAfterLinkClickedNonselectable
Bug: b/67629726
Change-Id: I94452116453fff1a36f5d567b3a686e92e97a34f
Diffstat (limited to 'core/java/android/widget/SelectionActionModeHelper.java')
| -rw-r--r-- | core/java/android/widget/SelectionActionModeHelper.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java index 2c6466cd1b9b..3bfa520cd942 100644 --- a/core/java/android/widget/SelectionActionModeHelper.java +++ b/core/java/android/widget/SelectionActionModeHelper.java @@ -235,10 +235,13 @@ public final class SelectionActionModeHelper { @Editor.TextActionMode int actionMode, @Nullable SelectionResult result) { final CharSequence text = getText(mTextView); if (result != null && text instanceof Spannable - && (mTextView.isTextSelectable() || mTextView.isTextEditable())) { + && (mTextView.isTextSelectable() + || mTextView.isTextEditable() + || actionMode == Editor.TextActionMode.TEXT_LINK)) { // Do not change the selection if TextClassifier should be dark launched. if (!mTextView.getTextClassifier().getSettings().isDarkLaunch()) { Selection.setSelection((Spannable) text, result.mStart, result.mEnd); + mTextView.invalidate(); } mTextClassification = result.mClassification; } else { @@ -250,8 +253,17 @@ public final class SelectionActionModeHelper { && (mTextView.isTextSelectable() || mTextView.isTextEditable())) { controller.show(); } - if (result != null && actionMode == Editor.TextActionMode.SELECTION) { - mSelectionTracker.onSmartSelection(result); + if (result != null) { + switch (actionMode) { + case Editor.TextActionMode.SELECTION: + mSelectionTracker.onSmartSelection(result); + break; + case Editor.TextActionMode.TEXT_LINK: + mSelectionTracker.onLinkSelected(result); + break; + default: + break; + } } } mEditor.setRestartActionModeOnNextRefresh(false); @@ -486,12 +498,24 @@ public final class SelectionActionModeHelper { * Called when selection action mode is started and the results come from a classifier. */ public void onSmartSelection(SelectionResult result) { + onClassifiedSelection(result); + mLogger.logSelectionModified( + result.mStart, result.mEnd, result.mClassification, result.mSelection); + } + + /** + * Called when link action mode is started and the classification comes from a classifier. + */ + public void onLinkSelected(SelectionResult result) { + onClassifiedSelection(result); + // TODO: log (b/70246800) + } + + private void onClassifiedSelection(SelectionResult result) { if (isSelectionStarted()) { mSelectionStart = result.mStart; mSelectionEnd = result.mEnd; mAllowReset = mSelectionStart != mOriginalStart || mSelectionEnd != mOriginalEnd; - mLogger.logSelectionModified( - result.mStart, result.mEnd, result.mClassification, result.mSelection); } } |
