summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/provider
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-12-09 14:57:32 -0800
committerJohn Reck <jreck@google.com>2010-12-09 14:57:32 -0800
commit8bb2e844c542df30a109c081700ea829dc427e6d (patch)
treecb2e93d8711a3259f81e8cb241ec0147fb715e7e /src/com/android/browser/provider
parent257cc2c8fcdd7117317e89861d4509955a622be8 (diff)
downloadpackages_apps_Browser-8bb2e844c542df30a109c081700ea829dc427e6d.zip
packages_apps_Browser-8bb2e844c542df30a109c081700ea829dc427e6d.tar.gz
packages_apps_Browser-8bb2e844c542df30a109c081700ea829dc427e6d.tar.bz2
Adds selection support to Bookarks DEFAULT_FOLDER
Bug: 3268145 Adds support for selection and selectionArgs when using Bookmarks.CONTENT_URI_DEFAULT_FOLDER Change-Id: I7732d12875266c205325f5052b931bc214a2067b
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r--src/com/android/browser/provider/BrowserProvider2.java53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 8d9f1fe..eb33e5e 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -622,12 +622,6 @@ public class BrowserProvider2 extends SQLiteContentProvider {
}
case BOOKMARKS_FOLDER: {
- // Don't allow selections to be applied to the default folder
- if (!TextUtils.isEmpty(selection) || selectionArgs != null) {
- throw new UnsupportedOperationException(
- "selections aren't supported on this URI");
- }
-
// Look for an account
boolean useAccount = false;
String accountType = uri.getQueryParameter(Bookmarks.PARAM_ACCOUNT_TYPE);
@@ -649,37 +643,48 @@ public class BrowserProvider2 extends SQLiteContentProvider {
}
if (!useAccount) {
qb.setProjectionMap(BOOKMARKS_PROJECTION_MAP);
- query = qb.buildQuery(projection,
- Bookmarks.PARENT + "=? AND " + Bookmarks.IS_DELETED + "=0",
- null, null, null, sortOrder, null);
-
+ String where = Bookmarks.PARENT + "=? AND " + Bookmarks.IS_DELETED + "=0";
+ where = DatabaseUtils.concatenateWhere(where, selection);
args = new String[] { Long.toString(FIXED_ID_ROOT) };
+ if (selectionArgs != null) {
+ args = DatabaseUtils.appendSelectionArgs(args, selectionArgs);
+ }
+ query = qb.buildQuery(projection, where, null, null, sortOrder, null);
} else {
qb.setProjectionMap(BOOKMARKS_PROJECTION_MAP);
+ String where = Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=? " +
+ "AND parent = " +
+ "(SELECT _id FROM " + TABLE_BOOKMARKS + " WHERE " +
+ ChromeSyncColumns.SERVER_UNIQUE + "=" +
+ "'" + ChromeSyncColumns.FOLDER_NAME_BOOKMARKS_BAR + "' " +
+ "AND account_type = ? AND account_name = ?) " +
+ "AND " + Bookmarks.IS_DELETED + "=0";
+ where = DatabaseUtils.concatenateWhere(where, selection);
String bookmarksBarQuery = qb.buildQuery(projection,
- Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=? " +
- "AND parent = " +
- "(SELECT _id FROM " + TABLE_BOOKMARKS + " WHERE " +
- ChromeSyncColumns.SERVER_UNIQUE + "=" +
- "'" + ChromeSyncColumns.FOLDER_NAME_BOOKMARKS_BAR + "' " +
- "AND account_type = ? AND account_name = ?) " +
- "AND " + Bookmarks.IS_DELETED + "=0",
- null, null, null, null, null);
+ selection, null, null, null, null);
+ args = new String[] {accountType, accountName,
+ accountType, accountName};
+ if (selectionArgs != null) {
+ args = DatabaseUtils.appendSelectionArgs(args, selectionArgs);
+ }
+ where = Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=?" +
+ " AND " + ChromeSyncColumns.SERVER_UNIQUE + "=?";
+ where = DatabaseUtils.concatenateWhere(where, selection);
qb.setProjectionMap(OTHER_BOOKMARKS_PROJECTION_MAP);
String otherBookmarksQuery = qb.buildQuery(projection,
- Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=?" +
- " AND " + ChromeSyncColumns.SERVER_UNIQUE + "=?",
- null, null, null, null, null);
+ where, null, null, null, null);
query = qb.buildUnionQuery(
new String[] { bookmarksBarQuery, otherBookmarksQuery },
sortOrder, limit);
- args = new String[] {
- accountType, accountName, accountType, accountName,
+ args = DatabaseUtils.appendSelectionArgs(args, new String[] {
accountType, accountName, ChromeSyncColumns.FOLDER_NAME_OTHER_BOOKMARKS,
- };
+ });
+ if (selectionArgs != null) {
+ args = DatabaseUtils.appendSelectionArgs(args, selectionArgs);
+ }
}
Cursor cursor = db.rawQuery(query, args);