Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java

Issue 2387333006: Do not show multiple instance of disambiguation menu for TextViewWithClickableSpans (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java
diff --git a/ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java b/ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java
index d8f5fbf41aee33ee0b1d54f7c006f146c7cfe088..cde93fb738973b0cf9fe12d6972079ab261324e6 100644
--- a/ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java
+++ b/ui/android/java/src/org/chromium/ui/widget/TextViewWithClickableSpans.java
@@ -32,6 +32,7 @@ import org.chromium.base.VisibleForTesting;
*/
public class TextViewWithClickableSpans extends TextView {
private AccessibilityManager mAccessibilityManager;
+ private PopupMenu mDisambiguationMenu;
public TextViewWithClickableSpans(Context context) {
super(context);
@@ -147,11 +148,13 @@ public class TextViewWithClickableSpans extends TextView {
private void openDisambiguationMenu() {
ClickableSpan[] clickableSpans = getClickableSpans();
- if (clickableSpans == null || clickableSpans.length == 0) return;
+ if (clickableSpans == null || clickableSpans.length == 0 || mDisambiguationMenu != null) {
+ return;
+ }
SpannableString spannable = (SpannableString) getText();
- PopupMenu popup = new PopupMenu(getContext(), this);
- Menu menu = popup.getMenu();
+ mDisambiguationMenu = new PopupMenu(getContext(), this);
+ Menu menu = mDisambiguationMenu.getMenu();
for (final ClickableSpan clickableSpan : clickableSpans) {
CharSequence itemText = spannable.subSequence(
spannable.getSpanStart(clickableSpan),
@@ -166,6 +169,12 @@ public class TextViewWithClickableSpans extends TextView {
});
}
- popup.show();
+ mDisambiguationMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
+ @Override
+ public void onDismiss(PopupMenu menu) {
+ mDisambiguationMenu = null;
+ }
+ });
+ mDisambiguationMenu.show();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698