Bug 710330 - Handle updates of bookmark folders and seperators correctly. r=lucasr

This commit is contained in:
Gian-Carlo Pascutto 2012-06-25 15:42:26 +02:00
parent bca2b238f3
commit 5f186bf300

View File

@ -787,14 +787,36 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
// Update or insert
ContentProviderOperation.Builder builder =
ContentProviderOperation.newUpdate(bookmarkUri);
// Bookmarks are defined by their URL and Folder.
builder.withSelection(Bookmarks.URL + " = ? AND "
+ Bookmarks.PARENT + " = ? AND "
+ Bookmarks.PARENT + " != ?",
new String[] { url,
Long.toString(parent),
String.valueOf(Bookmarks.FIXED_READING_LIST_ID)
});
if (url != null) {
// Bookmarks are defined by their URL and Folder.
builder.withSelection(Bookmarks.URL + " = ? AND "
+ Bookmarks.PARENT + " = ? AND "
+ Bookmarks.PARENT + " != ?",
new String[] { url,
Long.toString(parent),
String.valueOf(Bookmarks.FIXED_READING_LIST_ID)
});
} else if (title != null) {
// Or their title and parent folder. (Folders!)
builder.withSelection(Bookmarks.TITLE + " = ? AND "
+ Bookmarks.PARENT + " = ? AND "
+ Bookmarks.PARENT + " != ?",
new String[] { title,
Long.toString(parent),
String.valueOf(Bookmarks.FIXED_READING_LIST_ID)
});
} else if (type == Bookmarks.TYPE_SEPARATOR) {
// Or their their position (seperators)
builder.withSelection(Bookmarks.POSITION + " = ? AND "
+ Bookmarks.PARENT + " = ? AND "
+ Bookmarks.PARENT + " != ?",
new String[] { Long.toString(position),
Long.toString(parent),
String.valueOf(Bookmarks.FIXED_READING_LIST_ID)
});
} else {
Log.e(LOGTAG, "Bookmark entry without url or title and not a seperator, not added.");
}
builder.withValues(values);
// Queue the operation