mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
show the media management prompt at copy/move/delete too
This commit is contained in:
parent
6428836c73
commit
91a71685bd
3 changed files with 36 additions and 19 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue