aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-11-15 20:15:03 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-11-15 20:15:03 +0000
commitbe1aa63ff081c1cd9bb86a8592b8f61c960ec6f7 (patch)
tree3802314df711677eea9b56e8530629541d84a3fd
parent27c79417296d3f0c2ce9fa0b1ea71e78e85757ea (diff)
parentf8a247d99656c1841fadf74bb713b4018c5fa6d2 (diff)
downloadandroid_packages_apps_CMFileManager-be1aa63ff081c1cd9bb86a8592b8f61c960ec6f7.tar.gz
android_packages_apps_CMFileManager-be1aa63ff081c1cd9bb86a8592b8f61c960ec6f7.tar.bz2
android_packages_apps_CMFileManager-be1aa63ff081c1cd9bb86a8592b8f61c960ec6f7.zip
Merge "CMFM: Remove orphan bookmarks" into cm-10.2
-rw-r--r--src/com/cyanogenmod/filemanager/preferences/Bookmarks.java27
-rw-r--r--src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java8
-rw-r--r--src/com/cyanogenmod/filemanager/ui/policy/DeleteActionPolicy.java9
3 files changed, 43 insertions, 1 deletions
diff --git a/src/com/cyanogenmod/filemanager/preferences/Bookmarks.java b/src/com/cyanogenmod/filemanager/preferences/Bookmarks.java
index 998b7153..0c76a23b 100644
--- a/src/com/cyanogenmod/filemanager/preferences/Bookmarks.java
+++ b/src/com/cyanogenmod/filemanager/preferences/Bookmarks.java
@@ -152,6 +152,33 @@ public class Bookmarks {
}
/**
+ * Method that remove all orphan bookmarks derived from "path"
+ *
+ * @param ctx The current context
+ * @param path The path to check
+ */
+ public static void deleteOrphanBookmarks(Context ctx, String path) {
+ ContentResolver cr = ctx.getContentResolver();
+ Cursor cursor = Bookmarks.getAllBookmarks(cr);
+ try {
+ if (cursor != null && cursor.moveToFirst()) {
+ do {
+ Bookmark bm = new Bookmark(cursor);
+ if (bm.mPath.startsWith(path)) {
+ removeBookmark(ctx, bm);
+ }
+ } while (cursor.moveToNext());
+ }
+ } finally {
+ try {
+ if (cursor != null) {
+ cursor.close();
+ }
+ } catch (Exception e) {/**NON BLOCK**/}
+ }
+ }
+
+ /**
* Method that create the {@link ContentValues} from the bookmark
*
* @param bookmark The bookmark
diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java
index 1f583e96..c2923f3e 100644
--- a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java
+++ b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java
@@ -28,6 +28,7 @@ import com.cyanogenmod.filemanager.console.RelaunchableException;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
import com.cyanogenmod.filemanager.listeners.OnSelectionListener;
import com.cyanogenmod.filemanager.model.FileSystemObject;
+import com.cyanogenmod.filemanager.preferences.Bookmarks;
import com.cyanogenmod.filemanager.util.CommandHelper;
import com.cyanogenmod.filemanager.util.DialogHelper;
import com.cyanogenmod.filemanager.util.ExceptionUtil;
@@ -302,6 +303,13 @@ public final class CopyMoveActionPolicy extends ActionsPolicy {
@Override
public void onSuccess() {
+ // Remove orphan bookmark paths
+ if (files != null) {
+ for (LinkedResource linkedFiles : files) {
+ Bookmarks.deleteOrphanBookmarks(ctx, linkedFiles.mSrc.getAbsolutePath());
+ }
+ }
+
//Operation complete. Refresh
if (this.mOnRequestRefreshListener != null) {
// The reference is not the same, so refresh the complete navigation view
diff --git a/src/com/cyanogenmod/filemanager/ui/policy/DeleteActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/DeleteActionPolicy.java
index 039f4fe8..843afe24 100644
--- a/src/com/cyanogenmod/filemanager/ui/policy/DeleteActionPolicy.java
+++ b/src/com/cyanogenmod/filemanager/ui/policy/DeleteActionPolicy.java
@@ -28,6 +28,7 @@ import com.cyanogenmod.filemanager.console.RelaunchableException;
import com.cyanogenmod.filemanager.listeners.OnRequestRefreshListener;
import com.cyanogenmod.filemanager.listeners.OnSelectionListener;
import com.cyanogenmod.filemanager.model.FileSystemObject;
+import com.cyanogenmod.filemanager.preferences.Bookmarks;
import com.cyanogenmod.filemanager.ui.widgets.FlingerListView.OnItemFlingerResponder;
import com.cyanogenmod.filemanager.util.CommandHelper;
import com.cyanogenmod.filemanager.util.DialogHelper;
@@ -192,6 +193,13 @@ public final class DeleteActionPolicy extends ActionsPolicy {
onItemFlingerResponder.accept();
}
+ // Remove orphan bookmark paths
+ if (files != null) {
+ for (FileSystemObject fso : files) {
+ Bookmarks.deleteOrphanBookmarks(ctx, fso.getFullPath());
+ }
+ }
+
// Refresh
if (this.mOnRequestRefreshListener != null) {
// The reference is not the same, so refresh the complete navigation view
@@ -232,7 +240,6 @@ public final class DeleteActionPolicy extends ActionsPolicy {
* @param ctx The current context
* @param fso The file or folder to be deleted
*/
- @SuppressWarnings("hiding")
private void doOperation(
final Context ctx, final FileSystemObject fso) throws Throwable {
try {