bug 710392 - exclude about:home from top sites on about:home r=lucasr

This commit is contained in:
Brad Lassey 2012-01-04 21:34:06 -08:00
parent 2ddf4b722d
commit 6cb042919a
4 changed files with 16 additions and 8 deletions

View File

@ -168,7 +168,7 @@ public class AboutHomeContent extends ScrollView {
activity.stopManagingCursor(mCursor);
ContentResolver resolver = GeckoApp.mAppContext.getContentResolver();
mCursor = BrowserDB.filter(resolver, "", NUMBER_OF_TOP_SITES_PORTRAIT);
mCursor = BrowserDB.filter(resolver, "", NUMBER_OF_TOP_SITES_PORTRAIT, "about:%");
activity.startManagingCursor(mCursor);
mTopSitesAdapter = new TopSitesCursorAdapter(activity,

View File

@ -61,7 +61,7 @@ public class AndroidBrowserDB implements BrowserDB.BrowserDBIface {
private static final Uri BOOKMARKS_CONTENT_URI_POST_11 = Uri.parse("content://com.android.browser/bookmarks");
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit, CharSequence urlFilter) {
Cursor c = cr.query(Browser.BOOKMARKS_URI,
new String[] { URL_COLUMN_ID,
BookmarkColumns.URL,
@ -70,9 +70,11 @@ public class AndroidBrowserDB implements BrowserDB.BrowserDBIface {
URL_COLUMN_THUMBNAIL },
// The length restriction on URL is for the same reason as in the general bookmark query
// (see comment earlier in this file).
(urlFilter != null ? "(" + Browser.BookmarkColumns.URL + " NOT LIKE ? ) AND " : "" ) +
"(" + Browser.BookmarkColumns.URL + " LIKE ? OR " + Browser.BookmarkColumns.TITLE + " LIKE ?)"
+ " AND LENGTH(" + Browser.BookmarkColumns.URL + ") > 0",
new String[] {"%" + constraint.toString() + "%", "%" + constraint.toString() + "%",},
urlFilter == null ? new String[] {"%" + constraint.toString() + "%", "%" + constraint.toString() + "%"} :
new String[] {urlFilter.toString(), "%" + constraint.toString() + "%", "%" + constraint.toString() + "%"},
// ORDER BY is number of visits times a multiplier from 1 - 120 of how recently the site
// was accessed with a site accessed today getting 120 and a site accessed 119 or more
// days ago getting 1

View File

@ -53,7 +53,7 @@ public class BrowserDB {
private static BrowserDBIface sDb;
public interface BrowserDBIface {
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit);
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit, CharSequence urlFilter);
public void updateVisitedHistory(ContentResolver cr, String uri);
@ -88,8 +88,12 @@ public class BrowserDB {
sDb = new AndroidBrowserDB();
}
public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit, CharSequence urlFilter) {
return sDb.filter(cr, constraint, limit, urlFilter);
}
public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
return sDb.filter(cr, constraint, limit);
return sDb.filter(cr, constraint, limit, null);
}
public static void updateVisitedHistory(ContentResolver cr, String uri) {
@ -143,4 +147,4 @@ public class BrowserDB {
public static void updateThumbnailForUrl(ContentResolver cr, String uri, BitmapDrawable thumbnail) {
sDb.updateThumbnailForUrl(cr, uri, thumbnail);
}
}
}

View File

@ -81,15 +81,17 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE, mProfile).build();
}
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit, CharSequence urlFilter) {
Cursor c = cr.query(appendProfileAndLimit(History.CONTENT_URI, limit),
new String[] { History._ID,
History.URL,
History.TITLE,
History.FAVICON,
History.THUMBNAIL },
(urlFilter != null ? "(" + History.URL + " NOT LIKE ? )" : "" )+
"(" + History.URL + " LIKE ? OR " + History.TITLE + " LIKE ?)",
new String[] {"%" + constraint.toString() + "%", "%" + constraint.toString() + "%"},
urlFilter == null ? new String[] {"%" + constraint.toString() + "%", "%" + constraint.toString() + "%"} :
new String[] {urlFilter.toString(), "%" + constraint.toString() + "%", "%" + constraint.toString() + "%"},
// ORDER BY is number of visits times a multiplier from 1 - 120 of how recently the site
// was accessed with a site accessed today getting 120 and a site accessed 119 or more
// days ago getting 1