From 0ade1ec5793ea3c4bb4b31fb565cbd0b19ec500e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 6 Nov 2016 20:49:47 +0100 Subject: [PATCH] check write permissions before starting the deletion --- .../simplemobiletools/gallery/activities/MainActivity.java | 6 ++++++ .../simplemobiletools/gallery/activities/MediaActivity.java | 3 +++ .../gallery/activities/ViewPagerActivity.java | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 5855f9afa..e282f46e8 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -196,6 +196,12 @@ public class MainActivity extends SimpleActivity } } + for (String path : mToBeDeleted) { + if (Utils.Companion.isShowingWritePermissions(this, new File(path))) { + return; + } + } + notifyDeletion(deletedCnt); } diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index a8442a056..2245cc570 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -293,6 +293,9 @@ public class MediaActivity extends SimpleActivity } private void prepareForDeleting() { + if (Utils.Companion.isShowingWritePermissions(this, new File(mPath))) + return; + Utils.Companion.showToast(this, R.string.deleting); final SparseBooleanArray items = mGridView.getCheckedItemPositions(); final int cnt = items.size(); diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 71ed7b3b6..89b83366b 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -242,8 +242,10 @@ public class ViewPagerActivity extends SimpleActivity } private void notifyDeletion() { - mToBeDeleted = getCurrentFile().getAbsolutePath(); + if (Utils.Companion.isShowingWritePermissions(this, new File(mPath))) + return; + mToBeDeleted = getCurrentFile().getAbsolutePath(); if (mMedia.size() <= 1) { deleteFile(); } else {