diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 76000f091..96688e463 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -238,7 +238,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View when (item.itemId) { R.id.menu_set_as -> setAs(getCurrentPath()) R.id.menu_slideshow -> initSlideshow() - R.id.menu_copy_to -> copyMoveTo(true) + R.id.menu_copy_to -> checkMediaManagementAndCopy(true) R.id.menu_move_to -> moveFileTo() R.id.menu_open_with -> openPath(getCurrentPath(), true) R.id.menu_hide -> toggleFileVisibility(true) @@ -642,7 +642,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun moveFileTo() { handleDeletePasswordProtection { - copyMoveTo(false) + checkMediaManagementAndCopy(false) + } + } + + private fun checkMediaManagementAndCopy(isCopyOperation: Boolean) { + handleMediaManagementPrompt { + copyMoveTo(isCopyOperation) } } @@ -882,6 +888,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View bottom_toggle_file_visibility.setOnLongClickListener { toast(if (currentMedium?.isHidden() == true) R.string.unhide else R.string.hide); true } + bottom_toggle_file_visibility.setOnClickListener { currentMedium?.apply { toggleFileVisibility(!isHidden()) { @@ -905,7 +912,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View bottom_copy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0) bottom_copy.setOnLongClickListener { toast(R.string.copy); true } bottom_copy.setOnClickListener { - copyMoveTo(true) + checkMediaManagementAndCopy(true) } bottom_move.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_MOVE != 0) @@ -1078,14 +1085,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return } - if (config.isDeletePasswordProtectionOn) { - handleDeletePasswordProtection { + handleMediaManagementPrompt { + if (config.isDeletePasswordProtectionOn) { + handleDeletePasswordProtection { + deleteConfirmed() + } + } else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) { deleteConfirmed() + } else { + askConfirmDelete() } - } else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) { - deleteConfirmed() - } else { - askConfirmDelete() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 891e67e03..47227f7ab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -172,7 +172,7 @@ class MediaAdapter( R.id.cab_rotate_right -> rotateSelection(90) R.id.cab_rotate_left -> rotateSelection(270) R.id.cab_rotate_one_eighty -> rotateSelection(180) - R.id.cab_copy_to -> copyMoveTo(true) + R.id.cab_copy_to -> checkMediaManagementAndCopy(true) R.id.cab_move_to -> moveFilesTo() R.id.cab_create_shortcut -> createShortcut() R.id.cab_select_all -> selectAll() @@ -356,7 +356,13 @@ class MediaAdapter( private fun moveFilesTo() { activity.handleDeletePasswordProtection { - copyMoveTo(false) + checkMediaManagementAndCopy(false) + } + } + + private fun checkMediaManagementAndCopy(isCopyOperation: Boolean) { + activity.handleMediaManagementPrompt { + copyMoveTo(isCopyOperation) } } @@ -434,14 +440,16 @@ class MediaAdapter( } private fun checkDeleteConfirmation() { - if (config.isDeletePasswordProtectionOn) { - activity.handleDeletePasswordProtection { + activity.handleMediaManagementPrompt { + if (config.isDeletePasswordProtectionOn) { + activity.handleDeletePasswordProtection { + deleteFiles() + } + } else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) { deleteFiles() + } else { + askConfirmDelete() } - } else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) { - deleteFiles() - } else { - askConfirmDelete() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index f662f4212..bf9eda2b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -126,14 +126,14 @@ fun SimpleActivity.launchAbout() { } @RequiresApi(Build.VERSION_CODES.S) -fun SimpleActivity.launchMediaManagementIntent() { +fun AppCompatActivity.launchMediaManagementIntent() { Intent(Settings.ACTION_REQUEST_MANAGE_MEDIA).apply { data = Uri.parse("package:$packageName") startActivity(this) } } -fun SimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { +fun AppCompatActivity.handleMediaManagementPrompt(callback: () -> Unit) { if (isSPlus() && !MediaStore.canManageMedia(this)) { ConfirmationDialog(this, "", R.string.media_management_prompt, R.string.ok, 0) { launchMediaManagementIntent()