summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/BookmarkUtils.java
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2013-07-29 15:22:13 +0800
committerkaiyiz <kaiyiz@codeaurora.org>2013-07-29 15:22:27 +0800
commitbf7043ddceae7e580508262b9db93cde338bbccc (patch)
tree8ad6aa4dbeb1943e312cf435278acf55dd1f2704 /src/com/android/browser/BookmarkUtils.java
parentd8119b148cfc2943fe84c9b3a9765460e21b34f1 (diff)
downloadandroid_packages_apps_Gello-bf7043ddceae7e580508262b9db93cde338bbccc.tar.gz
android_packages_apps_Gello-bf7043ddceae7e580508262b9db93cde338bbccc.tar.bz2
android_packages_apps_Gello-bf7043ddceae7e580508262b9db93cde338bbccc.zip
Browser: Fix bug still display sub folder in add-to list if folder removed
If current bookmark folder contains sub folders, when we delete the current folder, the sub folders are not removed together. To fix this problem, we query all the sub folders and bookmarks under the current folder, and delete them all. CRs-Fixed: 502058 Change-Id: I08dbfa9cc41bc3aa11395d84593afc671d990b69
Diffstat (limited to 'src/com/android/browser/BookmarkUtils.java')
-rw-r--r--src/com/android/browser/BookmarkUtils.java38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java
index f0c01f7d..26e20722 100644
--- a/src/com/android/browser/BookmarkUtils.java
+++ b/src/com/android/browser/BookmarkUtils.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
+import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -39,6 +40,7 @@ import android.net.Uri;
import android.os.Message;
import android.provider.Browser;
import android.provider.BrowserContract;
+import android.provider.BrowserContract.Bookmarks;
public class BookmarkUtils {
private final static String LOGTAG = "BookmarkUtils";
@@ -247,10 +249,7 @@ public class BookmarkUtils {
Runnable runnable = new Runnable(){
@Override
public void run() {
- Uri uri = ContentUris.withAppendedId(
- BrowserContract.Bookmarks.CONTENT_URI,
- id);
- context.getContentResolver().delete(uri, null, null);
+ removeBookmarkOrFolder(context, id);
}
};
new Thread(runnable).start();
@@ -259,4 +258,35 @@ public class BookmarkUtils {
.setNegativeButton(R.string.cancel, null)
.show();
}
+
+ /**
+ * Remove the bookmark or folder.Remove all sub folders and bookmarks under current folder.
+ * @param context Package Context for strings, dialog, ContentResolver.
+ * @param id Id of the bookmark to remove.
+ */
+ private static void removeBookmarkOrFolder(Context context, long id) {
+ Cursor cursor = context.getContentResolver().query(Bookmarks.CONTENT_URI,
+ new String[] {Bookmarks._ID},
+ Bookmarks.PARENT + "=?",
+ new String[] {Long.toString(id)},
+ null);
+
+ if (cursor != null) {
+ try {
+ if (cursor.moveToFirst()) {
+ do {
+ removeBookmarkOrFolder(context,
+ cursor.getLong(cursor.getColumnIndex(Bookmarks._ID)));
+ } while (cursor.moveToNext());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ cursor.close();
+ }
+ }
+
+ context.getContentResolver().delete(
+ ContentUris.withAppendedId(Bookmarks.CONTENT_URI, id), null, null);
+ }
}