summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/provider
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-12-10 10:12:58 -0800
committerJohn Reck <jreck@google.com>2010-12-10 10:49:21 -0800
commitbe9a94742befec3b82f96ef33f20ede73d546a2b (patch)
treed7b940a99b11c1fadc507cbfe042c67d8c62a464 /src/com/android/browser/provider
parent0ebd3ac69a76ec76d9caab65a1947f971242994e (diff)
downloadpackages_apps_Browser-be9a94742befec3b82f96ef33f20ede73d546a2b.zip
packages_apps_Browser-be9a94742befec3b82f96ef33f20ede73d546a2b.tar.gz
packages_apps_Browser-be9a94742befec3b82f96ef33f20ede73d546a2b.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: I2b6c6c47c2f7b42d64acff13d991869a7dc2d9b3
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r--src/com/android/browser/provider/BrowserProvider2.java54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 0f51695..8137d55 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,49 @@ 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);
+ where, 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);