summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-11-22 10:46:05 -0500
committerCary Clark <cary@android.com>2010-11-22 12:48:59 -0500
commit8974d281fa5c96bf50d5f5bac665cae44568f6e8 (patch)
tree529e4ed4e256149d6c5e91a87452b752f54db082 /src
parent77df4568331d527f993f4d69168218ddf5acddda (diff)
downloadpackages_apps_Browser-8974d281fa5c96bf50d5f5bac665cae44568f6e8.zip
packages_apps_Browser-8974d281fa5c96bf50d5f5bac665cae44568f6e8.tar.gz
packages_apps_Browser-8974d281fa5c96bf50d5f5bac665cae44568f6e8.tar.bz2
add select text to context menu
Long pressing near a link may select the link even if the intent was to select text. Add an entry to the context menu to permit selecting text when the hit is an non-image anchor or a synthetic link. depends on companion change to frameworks/base bug:3214410 Change-Id: Ib444cc95c513aa474c289e22687bf6579a7207e8
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index aabdb26..83bbc63 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1193,7 +1193,15 @@ public class Controller
menu.setGroupVisible(R.id.ANCHOR_MENU,
type == WebView.HitTestResult.SRC_ANCHOR_TYPE
|| type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE);
-
+ boolean hitText = type == WebView.HitTestResult.SRC_ANCHOR_TYPE
+ || type == WebView.HitTestResult.PHONE_TYPE
+ || type == WebView.HitTestResult.EMAIL_TYPE
+ || type == WebView.HitTestResult.GEO_TYPE;
+ menu.setGroupVisible(R.id.SELECT_TEXT_MENU, hitText);
+ if (hitText) {
+ menu.findItem(R.id.select_text_menu_id)
+ .setOnMenuItemClickListener(new SelectText(webview));
+ }
// Setup custom handling depending on the type
switch (type) {
case WebView.HitTestResult.PHONE_TYPE:
@@ -1884,6 +1892,22 @@ public class Controller
}
}
+ private static class SelectText implements OnMenuItemClickListener {
+ private WebView mWebView;
+
+ public boolean onMenuItemClick(MenuItem item) {
+ if (mWebView != null) {
+ return mWebView.selectText();
+ }
+ return false;
+ }
+
+ public SelectText(WebView webView) {
+ mWebView = webView;
+ }
+
+ }
+
/********************** TODO: UI stuff *****************************/
// these methods have been copied, they still need to be cleaned up