summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/provider
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-08-08 17:45:05 -0700
committerJohn Reck <jreck@google.com>2011-08-08 17:45:05 -0700
commit1e9815d4c4864790fde2ad1e216058f922060c92 (patch)
tree517138f7f52b174f85aebcc786160a03db7fd1d0 /src/com/android/browser/provider
parente28b347fcc1df6e6bd41cb294d521a4f1e7c5c75 (diff)
downloadpackages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.zip
packages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.tar.gz
packages_apps_Browser-1e9815d4c4864790fde2ad1e216058f922060c92.tar.bz2
Move local bookmarks to end of Bookmark page
Bug: 5136280 Also hide empty accounts in the bookmark page Change-Id: I39067b5325d24c7ebf41df88c6231c411983fc57
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r--src/com/android/browser/provider/BrowserProvider2.java27
1 files changed, 27 insertions, 0 deletions
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) "
+ + " ) "
+ + ")";
}