Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fa484ac authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Add a "Web Search" option to the WebView select text ActionBar

This change allows selected text in a web view to be used as a search
query.

Bug: 3132422
Change-Id: I9ed2a5913641b37732586f8d8aa8a80c3486b606
parent e627f55b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.webkit;

import android.app.SearchManager;
import android.content.Intent;
import android.provider.Browser;
import android.webkit.WebView;
import android.view.ActionMode;
@@ -74,6 +76,12 @@ class SelectActionModeCallback implements ActionMode.Callback {
                mode.finish();
                mWebView.showFindDialog(sel);
                break;
            case com.android.internal.R.id.websearch:
                mode.finish();
                Intent i = new Intent(Intent.ACTION_WEB_SEARCH);
                i.putExtra(SearchManager.QUERY, mWebView.getSelection());
                mWebView.getContext().startActivity(i);
                break;

            default:
                return false;
+5 −0
Original line number Diff line number Diff line
@@ -34,5 +34,10 @@
        android:title="@string/find"
        android:showAsAction="always|withText"
        />
    <item android:id="@+id/websearch"
        android:icon="@drawable/ic_menu_search"
        android:title="@string/websearch"
        android:showAsAction="always|withText"
        />
</menu>
+2 −0
Original line number Diff line number Diff line
@@ -2622,6 +2622,8 @@
    <string name="share">Share</string>
    <!-- ActionBar action to use the current selection to open the Find on page functionality [CHAR LIMIT=10]-->
    <string name="find">Find</string>
    <!-- ActionBar action to use the current selection to perform a web search [CHAR-LIMIT=16] -->
    <string name="websearch">Web Search</string>

    <!-- Network positioning notification ticker. The name of the user (e.g. John Doe) who sent
         the request is shown as a dynamic string. -->