зеркало из https://github.com/mozilla/gecko-dev.git
Bug 786029: Fennec should integrate with Android's search. [f=mfinkle, r=lucasr]
This commit is contained in:
Родитель
f489e4717d
Коммит
fa96289660
|
@ -112,6 +112,13 @@
|
|||
<data android:scheme="https" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
|
||||
<!-- For debugging -->
|
||||
<intent-filter>
|
||||
<action android:name="org.mozilla.gecko.DEBUG" />
|
||||
|
@ -219,7 +226,12 @@
|
|||
|
||||
<provider android:name="@ANDROID_PACKAGE_NAME@.db.BrowserProvider"
|
||||
android:authorities="@ANDROID_PACKAGE_NAME@.db.browser"
|
||||
android:permission="@ANDROID_PACKAGE_NAME@.permissions.BROWSER_PROVIDER"/>
|
||||
android:permission="@ANDROID_PACKAGE_NAME@.permissions.BROWSER_PROVIDER">
|
||||
|
||||
<path-permission android:pathPrefix="/search_suggest_query"
|
||||
android:readPermission="android.permission.GLOBAL_SEARCH" />
|
||||
|
||||
</provider>
|
||||
|
||||
<!--
|
||||
Ensure that passwords provider runs in its own process. (Bug 718760.)
|
||||
|
|
|
@ -1941,6 +1941,10 @@ abstract public class GeckoApp
|
|||
String uri = getURIFromIntent(intent);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBookmarkLoadEvent(uri));
|
||||
}
|
||||
else if (Intent.ACTION_SEARCH.equals(action)) {
|
||||
String uri = getURIFromIntent(intent);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(uri));
|
||||
}
|
||||
else if (ACTION_ALERT_CALLBACK.equals(action)) {
|
||||
String alertName = "";
|
||||
String alertCookie = "";
|
||||
|
|
|
@ -213,6 +213,7 @@ FENNEC_PP_XML_FILES = \
|
|||
res/layout-xlarge-v11/awesomebar_search.xml \
|
||||
res/layout-xlarge-v11/gecko_app.xml \
|
||||
res/xml/preferences.xml \
|
||||
res/xml/searchable.xml \
|
||||
res/menu/browser_app_menu.xml \
|
||||
res/menu-v11/browser_app_menu.xml \
|
||||
res/menu-large-v11/browser_app_menu.xml \
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.mozilla.gecko.ProfileMigrator;
|
|||
import org.mozilla.gecko.sync.Utils;
|
||||
import org.mozilla.gecko.util.GeckoBackgroundThread;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
|
@ -117,6 +118,9 @@ public class BrowserProvider extends ContentProvider {
|
|||
// Control matches
|
||||
static final int CONTROL = 600;
|
||||
|
||||
// Search Suggest matches
|
||||
static final int SEARCH_SUGGEST = 700;
|
||||
|
||||
static final String DEFAULT_BOOKMARKS_SORT_ORDER = Bookmarks.TYPE
|
||||
+ " ASC, " + Bookmarks.POSITION + " ASC, " + Bookmarks._ID
|
||||
+ " ASC";
|
||||
|
@ -138,6 +142,7 @@ public class BrowserProvider extends ContentProvider {
|
|||
static final Map<String, String> IMAGES_PROJECTION_MAP;
|
||||
static final Map<String, String> COMBINED_PROJECTION_MAP;
|
||||
static final Map<String, String> SCHEMA_PROJECTION_MAP;
|
||||
static final Map<String, String> SEARCH_SUGGEST_PROJECTION_MAP;
|
||||
|
||||
static {
|
||||
// We will reuse this.
|
||||
|
@ -228,6 +233,18 @@ public class BrowserProvider extends ContentProvider {
|
|||
|
||||
// Control
|
||||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, "control", CONTROL);
|
||||
|
||||
// Search Suggest
|
||||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST);
|
||||
|
||||
map = new HashMap<String, String>();
|
||||
map.put(SearchManager.SUGGEST_COLUMN_TEXT_1,
|
||||
Combined.TITLE + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_1);
|
||||
map.put(SearchManager.SUGGEST_COLUMN_TEXT_2_URL,
|
||||
Combined.URL + " AS " + SearchManager.SUGGEST_COLUMN_TEXT_2_URL);
|
||||
map.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA,
|
||||
Combined.URL + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA);
|
||||
SEARCH_SUGGEST_PROJECTION_MAP = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
private HashMap<String, DatabaseHelper> mDatabasePerProfile;
|
||||
|
@ -1374,6 +1391,9 @@ public class BrowserProvider extends ContentProvider {
|
|||
case HISTORY_ID:
|
||||
trace("URI is HISTORY_ID: " + uri);
|
||||
return History.CONTENT_ITEM_TYPE;
|
||||
case SEARCH_SUGGEST:
|
||||
trace("URI is SEARCH_SUGGEST: " + uri);
|
||||
return SearchManager.SUGGEST_MIME_TYPE;
|
||||
}
|
||||
|
||||
debug("URI has unrecognized type: " + uri);
|
||||
|
@ -1861,6 +1881,28 @@ public class BrowserProvider extends ContentProvider {
|
|||
return controlCursor;
|
||||
}
|
||||
|
||||
case SEARCH_SUGGEST: {
|
||||
debug("Query is on search suggest: " + uri);
|
||||
selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " +
|
||||
Combined.TITLE + " LIKE ?)");
|
||||
|
||||
String keyword = uri.getLastPathSegment();
|
||||
if (keyword == null)
|
||||
keyword = "";
|
||||
|
||||
selectionArgs = DBUtils.appendSelectionArgs(selectionArgs,
|
||||
new String[] { "%" + keyword + "%",
|
||||
"%" + keyword + "%" });
|
||||
|
||||
if (TextUtils.isEmpty(sortOrder))
|
||||
sortOrder = DEFAULT_HISTORY_SORT_ORDER;
|
||||
|
||||
qb.setProjectionMap(SEARCH_SUGGEST_PROJECTION_MAP);
|
||||
qb.setTables(VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown query URI " + uri);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ $(dir-strings-xml)/strings.xml: $(strings-xml-preqs)
|
|||
-DSTRINGSPATH="$(STRINGSPATH)" \
|
||||
-DSYNCSTRINGSPATH="$(SYNCSTRINGSPATH)" \
|
||||
-DBOOKMARKSPATH="$(BOOKMARKSPATH)" \
|
||||
-DMOZ_APP_DISPLAYNAME="@MOZ_APP_DISPLAYNAME@" \
|
||||
$< \
|
||||
> $@
|
||||
|
||||
|
|
|
@ -231,6 +231,8 @@ just addresses the organization to follow, e.g. "This site is run by " -->
|
|||
|
||||
<!ENTITY webapp_generic_name "App">
|
||||
|
||||
<!ENTITY searchable_description "Bookmarks and history">
|
||||
|
||||
<!-- Updater notifications -->
|
||||
<!ENTITY updater_start_title "Update available for &brandShortName;">
|
||||
<!ENTITY updater_start_select "Touch to download">
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#filter substitution
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:label="@string/moz_app_displayname"
|
||||
android:searchSuggestAuthority="@ANDROID_PACKAGE_NAME@.db.browser"
|
||||
android:searchSuggestIntentAction="android.intent.action.SEARCH"
|
||||
android:searchSettingsDescription="@string/searchable_description"
|
||||
android:includeInGlobalSearch="true"/>
|
|
@ -11,6 +11,7 @@
|
|||
]>
|
||||
#includesubst @BOOKMARKSPATH@
|
||||
<resources>
|
||||
<string name="moz_app_displayname">@MOZ_APP_DISPLAYNAME@</string>
|
||||
#include ../sync/strings.xml.in
|
||||
<string name="splash_settingup">&splash_settingup;</string>
|
||||
<string name="splash_bookmarks_history">&splash_bookmarks_history;</string>
|
||||
|
@ -217,6 +218,8 @@
|
|||
|
||||
<string name="webapp_generic_name">&webapp_generic_name;</string>
|
||||
|
||||
<string name="searchable_description">&searchable_description;</string>
|
||||
|
||||
<!-- Updater notifications -->
|
||||
<string name="updater_start_title">&updater_start_title;</string>
|
||||
<string name="updater_start_select">&updater_start_select;</string>
|
||||
|
|
Загрузка…
Ссылка в новой задаче