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 {
|
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 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.0'
|
implementation 'androidx.multidex:multidex:2.0.0'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
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_set_as -> setAs(getCurrentPath())
|
||||||
R.id.menu_slideshow -> initSlideshow()
|
R.id.menu_slideshow -> initSlideshow()
|
||||||
R.id.menu_copy_to -> copyMoveTo(true)
|
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_open_with -> openPath(getCurrentPath(), true)
|
||||||
R.id.menu_hide -> toggleFileVisibility(true)
|
R.id.menu_hide -> toggleFileVisibility(true)
|
||||||
R.id.menu_unhide -> toggleFileVisibility(false)
|
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) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val currPath = getCurrentPath()
|
val currPath = getCurrentPath()
|
||||||
if (!isCopyOperation && currPath.startsWith(recycleBinPath)) {
|
if (!isCopyOperation && currPath.startsWith(recycleBinPath)) {
|
||||||
|
@ -918,7 +924,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
if (config.isDeletePasswordProtectionOn) {
|
||||||
|
handleDeletePasswordProtection {
|
||||||
|
deleteConfirmed()
|
||||||
|
}
|
||||||
|
} else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||||
deleteConfirmed()
|
deleteConfirmed()
|
||||||
} else {
|
} else {
|
||||||
askConfirmDelete()
|
askConfirmDelete()
|
||||||
|
|
|
@ -96,7 +96,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
R.id.cab_unhide -> toggleFoldersVisibility(false)
|
R.id.cab_unhide -> toggleFoldersVisibility(false)
|
||||||
R.id.cab_exclude -> tryExcludeFolder()
|
R.id.cab_exclude -> tryExcludeFolder()
|
||||||
R.id.cab_copy_to -> copyMoveTo(true)
|
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_select_all -> selectAll()
|
||||||
R.id.cab_delete -> askConfirmDelete()
|
R.id.cab_delete -> askConfirmDelete()
|
||||||
R.id.cab_select_photo -> changeAlbumCover(false)
|
R.id.cab_select_photo -> changeAlbumCover(false)
|
||||||
|
@ -310,6 +310,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
listener?.recheckPinnedFolders()
|
listener?.recheckPinnedFolders()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun moveFilesTo() {
|
||||||
|
activity.handleDeletePasswordProtection {
|
||||||
|
copyMoveTo(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val paths = ArrayList<String>()
|
val paths = ArrayList<String>()
|
||||||
val showHidden = activity.config.shouldShowHidden
|
val showHidden = activity.config.shouldShowHidden
|
||||||
|
@ -343,9 +349,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
if (config.skipDeleteConfirmation) {
|
when {
|
||||||
|
config.isDeletePasswordProtectionOn -> activity.handleDeletePasswordProtection {
|
||||||
deleteFolders()
|
deleteFolders()
|
||||||
} else {
|
}
|
||||||
|
config.skipDeleteConfirmation -> deleteFolders()
|
||||||
|
else -> {
|
||||||
val itemsCnt = selectedKeys.size
|
val itemsCnt = selectedKeys.size
|
||||||
val items = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
val items = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||||
val fileDirItem = getFirstSelectedItem() ?: return
|
val fileDirItem = getFirstSelectedItem() ?: return
|
||||||
|
@ -363,6 +372,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun deleteFolders() {
|
private fun deleteFolders() {
|
||||||
if (selectedKeys.isEmpty()) {
|
if (selectedKeys.isEmpty()) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
R.id.cab_restore_recycle_bin_files -> restoreFiles()
|
R.id.cab_restore_recycle_bin_files -> restoreFiles()
|
||||||
R.id.cab_share -> shareMedia()
|
R.id.cab_share -> shareMedia()
|
||||||
R.id.cab_copy_to -> copyMoveTo(true)
|
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_select_all -> selectAll()
|
||||||
R.id.cab_open_with -> openPath()
|
R.id.cab_open_with -> openPath()
|
||||||
R.id.cab_fix_date_taken -> fixDateTaken()
|
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) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val paths = getSelectedPaths()
|
val paths = getSelectedPaths()
|
||||||
|
|
||||||
|
@ -351,7 +357,11 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDeleteConfirmation() {
|
private fun checkDeleteConfirmation() {
|
||||||
if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
if (config.isDeletePasswordProtectionOn) {
|
||||||
|
activity.handleDeletePasswordProtection {
|
||||||
|
deleteFiles()
|
||||||
|
}
|
||||||
|
} else if (config.tempSkipDeleteConfirmation || config.skipDeleteConfirmation) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
} else {
|
} else {
|
||||||
askConfirmDelete()
|
askConfirmDelete()
|
||||||
|
|
Loading…
Reference in a new issue