OSDN Git Service

Add search suggestions for just bookmarks+history.
authorBjorn Bringert <bringert@android.com>
Wed, 29 Apr 2009 20:41:47 +0000 (21:41 +0100)
committerBjorn Bringert <bringert@android.com>
Wed, 29 Apr 2009 20:41:47 +0000 (21:41 +0100)
The browser returns bookmarks+history, and pads with
google search suggest, when search suggestions are
requested using content://browser/search_suggest_query
This patch adds a new URI
content://browser/bookmarks/search_suggest_query
that only returns bookmarks+history.

src/com/android/browser/BrowserProvider.java

index c189248..6633a36 100644 (file)
@@ -97,6 +97,7 @@ public class BrowserProvider extends ContentProvider {
     private static final int URI_MATCH_SEARCHES_ID = 11;
     //
     private static final int URI_MATCH_SUGGEST = 20;
+    private static final int URI_MATCH_BOOKMARKS_SUGGEST = 21;
 
     private static final UriMatcher URI_MATCHER;
 
@@ -112,6 +113,9 @@ public class BrowserProvider extends ContentProvider {
                 URI_MATCH_SEARCHES_ID);
         URI_MATCHER.addURI("browser", SearchManager.SUGGEST_URI_PATH_QUERY,
                 URI_MATCH_SUGGEST);
+        URI_MATCHER.addURI("browser",
+                TABLE_NAMES[URI_MATCH_BOOKMARKS] + "/" + SearchManager.SUGGEST_URI_PATH_QUERY,
+                URI_MATCH_BOOKMARKS_SUGGEST);
     }
 
     // 1 -> 2 add cache table
@@ -473,7 +477,7 @@ public class BrowserProvider extends ContentProvider {
             throw new IllegalArgumentException("Unknown URL");
         }
 
-        if (match == URI_MATCH_SUGGEST) {
+        if (match == URI_MATCH_SUGGEST || match == URI_MATCH_BOOKMARKS_SUGGEST) {
             String suggestSelection;
             String [] myArgs;
             if (selectionArgs[0] == null || selectionArgs[0].equals("")) {
@@ -500,7 +504,8 @@ public class BrowserProvider extends ContentProvider {
                     ORDER_BY,
                     (new Integer(MAX_SUGGESTION_LONG_ENTRIES)).toString());
 
-            if (Regex.WEB_URL_PATTERN.matcher(selectionArgs[0]).matches()) {
+            if (match == URI_MATCH_BOOKMARKS_SUGGEST
+                    || Regex.WEB_URL_PATTERN.matcher(selectionArgs[0]).matches()) {
                 return new MySuggestionCursor(c, null, "");
             } else {
                 // get Google suggest if there is still space in the list