From 3641813e9b8256c94f48916d8c902f98069214b1 Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Mon, 2 Apr 2012 11:56:48 -0700 Subject: [PATCH] Bug 738961 - Awesomebar filter should treat space-separated words as separate filters. r=lucasr --- mobile/android/base/db/LocalBrowserDB.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mobile/android/base/db/LocalBrowserDB.java b/mobile/android/base/db/LocalBrowserDB.java index e0dc8b78eb7f..497583fa463d 100644 --- a/mobile/android/base/db/LocalBrowserDB.java +++ b/mobile/android/base/db/LocalBrowserDB.java @@ -143,13 +143,19 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface { private Cursor filterAllSites(ContentResolver cr, String[] projection, CharSequence constraint, int limit, CharSequence urlFilter) { - // The combined history/bookmarks selection queries for sites with a url or title - // containing the constraint string - String selection = "(" + Combined.URL + " LIKE ? OR " + - Combined.TITLE + " LIKE ?)"; + String selection = ""; + String[] selectionArgs = null; - final String historySelectionArg = "%" + constraint.toString() + "%"; - String[] selectionArgs = new String[] { historySelectionArg, historySelectionArg }; + // The combined history/bookmarks selection queries for sites with a url or title containing + // the constraint string(s), treating space-separated words as separate constraints + String[] constraintWords = constraint.toString().split(" "); + for (int i = 0; i < constraintWords.length; i++) { + selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " + + Combined.TITLE + " LIKE ?)"); + String constraintWord = "%" + constraintWords[i] + "%"; + selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, + new String[] { constraintWord, constraintWord }); + } if (urlFilter != null) { selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " NOT LIKE ?)");