From 1e9815d4c4864790fde2ad1e216058f922060c92 Mon Sep 17 00:00:00 2001 From: John Reck Date: Mon, 8 Aug 2011 17:45:05 -0700 Subject: Move local bookmarks to end of Bookmark page Bug: 5136280 Also hide empty accounts in the bookmark page Change-Id: I39067b5325d24c7ebf41df88c6231c411983fc57 --- .../android/browser/provider/BrowserProvider2.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/com/android/browser/provider') diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 0c1fd42..7e4ac0d 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -69,6 +69,7 @@ import java.util.HashMap; public class BrowserProvider2 extends SQLiteContentProvider { public static final String PARAM_GROUP_BY = "groupBy"; + public static final String PARAM_ALLOW_EMPTY_ACCOUNTS = "allowEmptyAccounts"; public static final String LEGACY_AUTHORITY = "browser"; static final Uri LEGACY_AUTHORITY_URI = new Uri.Builder() @@ -114,6 +115,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { "ON history.url = images.url_key"; static final String DEFAULT_SORT_HISTORY = History.DATE_LAST_VISITED + " DESC"; + static final String DEFAULT_SORT_ACCOUNTS = + Accounts.ACCOUNT_NAME + " IS NOT NULL DESC, " + + Accounts.ACCOUNT_NAME + " ASC"; private static final String[] SUGGEST_PROJECTION = new String[] { Bookmarks._ID, @@ -844,6 +848,14 @@ public class BrowserProvider2 extends SQLiteContentProvider { case ACCOUNTS: { qb.setTables(VIEW_ACCOUNTS); qb.setProjectionMap(ACCOUNTS_PROJECTION_MAP); + String allowEmpty = uri.getQueryParameter(PARAM_ALLOW_EMPTY_ACCOUNTS); + if ("false".equals(allowEmpty)) { + selection = DatabaseUtils.concatenateWhere(selection, + SQL_WHERE_ACCOUNT_HAS_BOOKMARKS); + } + if (sortOrder == null) { + sortOrder = DEFAULT_SORT_ACCOUNTS; + } break; } @@ -2114,4 +2126,19 @@ public class BrowserProvider2 extends SQLiteContentProvider { + " WHERE url NOT IN (SELECT url FROM bookmarks" + " WHERE deleted = 0 AND folder = 0) " + " ORDER BY bookmark DESC, visits DESC, date DESC "; + + private static final String SQL_WHERE_ACCOUNT_HAS_BOOKMARKS = + "0 < ( " + + "SELECT count(*) " + + "FROM bookmarks " + + "WHERE deleted = 0 AND folder = 0 " + + " AND ( " + + " v_accounts.account_name = bookmarks.account_name " + + " OR (v_accounts.account_name IS NULL AND bookmarks.account_name IS NULL) " + + " ) " + + " AND ( " + + " v_accounts.account_type = bookmarks.account_type " + + " OR (v_accounts.account_type IS NULL AND bookmarks.account_type IS NULL) " + + " ) " + + ")"; } -- cgit v1.1