mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
adding password protection to file move and deleting
This commit is contained in:
parent
5c3d4f3e8d
commit
9e6ccbe67c
4 changed files with 52 additions and 22 deletions
|
@ -48,7 +48,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.2.17'
|
||||
implementation 'com.simplemobiletools:commons:5.2.18'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||
implementation 'androidx.multidex:multidex:2.0.0'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
|
|
@ -202,7 +202,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
R.id.menu_set_as -> setAs(getCurrentPath())
|
||||
R.id.menu_slideshow -> initSlideshow()
|
||||
R.id.menu_copy_to -> copyMoveTo(true)
|
||||
R.id.menu_move_to -> copyMoveTo(false)
|
||||
R.id.menu_move_to -> moveFileTo()
|
||||
R.id.menu_open_with -> openPath(getCurrentPath(), true)
|
||||
R.id.menu_hide -> toggleFileVisibility(true)
|
||||
R.id.menu_unhide -> toggleFileVisibility(false)
|
||||
|
@ -523,6 +523,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
}
|
||||
|
||||
private fun moveFileTo() {
|
||||
handleDeletePasswordProtection {
|
||||
copyMoveTo(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val currPath = getCurrentPath()
|
||||
if (!isCopyOperation && currPath.startsWith(recycleBinPath)) {
|
||||
|
@ -918,7 +924,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
return
|
||||
}
|
||||
|
||||
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||
if (config.isDeletePasswordProtectionOn) {
|
||||
handleDeletePasswordProtection {
|
||||
deleteConfirmed()
|
||||
}
|
||||
} else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||
deleteConfirmed()
|
||||
} else {
|
||||
askConfirmDelete()
|
||||
|
|
|
@ -96,7 +96,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
R.id.cab_unhide -> toggleFoldersVisibility(false)
|
||||
R.id.cab_exclude -> tryExcludeFolder()
|
||||
R.id.cab_copy_to -> copyMoveTo(true)
|
||||
R.id.cab_move_to -> copyMoveTo(false)
|
||||
R.id.cab_move_to -> moveFilesTo()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
R.id.cab_select_photo -> changeAlbumCover(false)
|
||||
|
@ -310,6 +310,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
listener?.recheckPinnedFolders()
|
||||
}
|
||||
|
||||
private fun moveFilesTo() {
|
||||
activity.handleDeletePasswordProtection {
|
||||
copyMoveTo(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val paths = ArrayList<String>()
|
||||
val showHidden = activity.config.shouldShowHidden
|
||||
|
@ -343,24 +349,28 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
if (config.skipDeleteConfirmation) {
|
||||
deleteFolders()
|
||||
} else {
|
||||
val itemsCnt = selectedKeys.size
|
||||
val items = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||
val fileDirItem = getFirstSelectedItem() ?: return
|
||||
val baseString = if (!config.useRecycleBin || (isOneItemSelected() && fileDirItem.isRecycleBin()) || (isOneItemSelected() && fileDirItem.areFavorites())) {
|
||||
R.string.deletion_confirmation
|
||||
} else {
|
||||
R.string.move_to_recycle_bin_confirmation
|
||||
}
|
||||
|
||||
var question = String.format(resources.getString(baseString), items)
|
||||
val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt)
|
||||
question += "\n\n$warning"
|
||||
ConfirmationDialog(activity, question) {
|
||||
when {
|
||||
config.isDeletePasswordProtectionOn -> activity.handleDeletePasswordProtection {
|
||||
deleteFolders()
|
||||
}
|
||||
config.skipDeleteConfirmation -> deleteFolders()
|
||||
else -> {
|
||||
val itemsCnt = selectedKeys.size
|
||||
val items = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||
val fileDirItem = getFirstSelectedItem() ?: return
|
||||
val baseString = if (!config.useRecycleBin || (isOneItemSelected() && fileDirItem.isRecycleBin()) || (isOneItemSelected() && fileDirItem.areFavorites())) {
|
||||
R.string.deletion_confirmation
|
||||
} else {
|
||||
R.string.move_to_recycle_bin_confirmation
|
||||
}
|
||||
|
||||
var question = String.format(resources.getString(baseString), items)
|
||||
val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt)
|
||||
question += "\n\n$warning"
|
||||
ConfirmationDialog(activity, question) {
|
||||
deleteFolders()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
R.id.cab_restore_recycle_bin_files -> restoreFiles()
|
||||
R.id.cab_share -> shareMedia()
|
||||
R.id.cab_copy_to -> copyMoveTo(true)
|
||||
R.id.cab_move_to -> copyMoveTo(false)
|
||||
R.id.cab_move_to -> moveFilesTo()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
R.id.cab_open_with -> openPath()
|
||||
R.id.cab_fix_date_taken -> fixDateTaken()
|
||||
|
@ -275,6 +275,12 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
}
|
||||
}
|
||||
|
||||
private fun moveFilesTo() {
|
||||
activity.handleDeletePasswordProtection {
|
||||
copyMoveTo(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val paths = getSelectedPaths()
|
||||
|
||||
|
@ -351,7 +357,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
|||
}
|
||||
|
||||
private fun checkDeleteConfirmation() {
|
||||
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||
if (config.isDeletePasswordProtectionOn) {
|
||||
activity.handleDeletePasswordProtection {
|
||||
deleteFiles()
|
||||
}
|
||||
} else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||
deleteFiles()
|
||||
} else {
|
||||
askConfirmDelete()
|
||||
|
|
Loading…
Reference in a new issue