properly handle locked folders and third party intents
This commit is contained in:
parent
3b2d9322fd
commit
9809930390
5 changed files with 98 additions and 57 deletions
|
@ -61,7 +61,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.14.9'
|
implementation 'com.simplemobiletools:commons:5.14.11'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -769,10 +769,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun itemClicked(path: String) {
|
private fun itemClicked(path: String) {
|
||||||
handleLockedFolderOpening(path) {
|
handleLockedFolderOpening(path) { success ->
|
||||||
Intent(this, MediaActivity::class.java).apply {
|
if (success) {
|
||||||
putExtra(DIRECTORY, path)
|
Intent(this, MediaActivity::class.java).apply {
|
||||||
handleMediaIntent(this)
|
putExtra(DIRECTORY, path)
|
||||||
|
handleMediaIntent(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
if (realPath != null && File(realPath).exists()) {
|
if (realPath != null && File(realPath).exists()) {
|
||||||
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
||||||
if (isFileTypeVisible(realPath)) {
|
if (isFileTypeVisible(realPath)) {
|
||||||
sendViewPagerIntent(realPath)
|
bottom_actions.beGone()
|
||||||
finish()
|
handleLockedFolderOpening(realPath.getParentPath()) { success ->
|
||||||
|
if (success) {
|
||||||
|
sendViewPagerIntent(realPath)
|
||||||
|
}
|
||||||
|
finish()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,18 +115,28 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
|
|
||||||
if (mUri!!.scheme == "file") {
|
if (mUri!!.scheme == "file") {
|
||||||
if (filename.contains('.')) {
|
if (filename.contains('.')) {
|
||||||
rescanPaths(arrayListOf(mUri!!.path))
|
bottom_actions.beGone()
|
||||||
sendViewPagerIntent(mUri!!.path)
|
handleLockedFolderOpening(mUri!!.path.getParentPath()) { success ->
|
||||||
finish()
|
if (success) {
|
||||||
return
|
rescanPaths(arrayListOf(mUri!!.path))
|
||||||
|
sendViewPagerIntent(mUri!!.path)
|
||||||
|
}
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
|
val path = applicationContext.getRealPathFromURI(mUri!!) ?: ""
|
||||||
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) {
|
if (path != mUri.toString() && path.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && File(path).exists()) {
|
||||||
if (isFileTypeVisible(path)) {
|
if (isFileTypeVisible(path)) {
|
||||||
rescanPaths(arrayListOf(mUri!!.path))
|
bottom_actions.beGone()
|
||||||
sendViewPagerIntent(path)
|
handleLockedFolderOpening(path.getParentPath()) { success ->
|
||||||
finish()
|
if (success) {
|
||||||
|
rescanPaths(arrayListOf(mUri!!.path))
|
||||||
|
sendViewPagerIntent(path)
|
||||||
|
}
|
||||||
|
finish()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,8 +159,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
if (selectedKeys.size <= 1) {
|
if (selectedKeys.size <= 1) {
|
||||||
val path = getFirstSelectedItemPath() ?: return
|
val path = getFirstSelectedItemPath() ?: return
|
||||||
if (path != FAVORITES && path != RECYCLE_BIN) {
|
if (path != FAVORITES && path != RECYCLE_BIN) {
|
||||||
activity.handleLockedFolderOpening(path) {
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
PropertiesDialog(activity, path, config.shouldShowHidden)
|
if (success) {
|
||||||
|
PropertiesDialog(activity, path, config.shouldShowHidden)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,18 +182,20 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.handleLockedFolderOpening(sourcePath) {
|
activity.handleLockedFolderOpening(sourcePath) { success ->
|
||||||
RenameItemDialog(activity, dir.absolutePath) {
|
if (success) {
|
||||||
activity.runOnUiThread {
|
RenameItemDialog(activity, dir.absolutePath) {
|
||||||
firstDir.apply {
|
activity.runOnUiThread {
|
||||||
path = it
|
firstDir.apply {
|
||||||
name = it.getFilenameFromPath()
|
path = it
|
||||||
tmb = File(it, tmb.getFilenameFromPath()).absolutePath
|
name = it.getFilenameFromPath()
|
||||||
}
|
tmb = File(it, tmb.getFilenameFromPath()).absolutePath
|
||||||
updateDirs(dirs)
|
}
|
||||||
ensureBackgroundThread {
|
updateDirs(dirs)
|
||||||
activity.galleryDB.DirectoryDao().updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath)
|
ensureBackgroundThread {
|
||||||
listener?.refreshItems()
|
activity.galleryDB.DirectoryDao().updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath)
|
||||||
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,26 +222,32 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
val path = it
|
val path = it
|
||||||
if (hide) {
|
if (hide) {
|
||||||
if (config.wasHideFolderTooltipShown) {
|
if (config.wasHideFolderTooltipShown) {
|
||||||
activity.handleLockedFolderOpening(path) {
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
hideFolder(path)
|
if (success) {
|
||||||
|
hideFolder(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config.wasHideFolderTooltipShown = true
|
config.wasHideFolderTooltipShown = true
|
||||||
ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) {
|
ConfirmationDialog(activity, activity.getString(R.string.hide_folder_description)) {
|
||||||
activity.handleLockedFolderOpening(path) {
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
hideFolder(path)
|
if (success) {
|
||||||
|
hideFolder(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activity.handleLockedFolderOpening(path) {
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
activity.removeNoMedia(path) {
|
if (success) {
|
||||||
if (activity.config.shouldShowHidden) {
|
activity.removeNoMedia(path) {
|
||||||
updateFolderNames()
|
if (activity.config.shouldShowHidden) {
|
||||||
} else {
|
updateFolderNames()
|
||||||
activity.runOnUiThread {
|
} else {
|
||||||
listener?.refreshItems()
|
activity.runOnUiThread {
|
||||||
finishActMode()
|
listener?.refreshItems()
|
||||||
|
finishActMode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,18 +267,22 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emptyRecycleBin() {
|
private fun emptyRecycleBin() {
|
||||||
activity.handleLockedFolderOpening(RECYCLE_BIN) {
|
activity.handleLockedFolderOpening(RECYCLE_BIN) { success ->
|
||||||
activity.emptyTheRecycleBin {
|
if (success) {
|
||||||
listener?.refreshItems()
|
activity.emptyTheRecycleBin {
|
||||||
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emptyAndDisableRecycleBin() {
|
private fun emptyAndDisableRecycleBin() {
|
||||||
activity.handleLockedFolderOpening(RECYCLE_BIN) {
|
activity.handleLockedFolderOpening(RECYCLE_BIN) { success ->
|
||||||
activity.showRecycleBinEmptyingDialog {
|
if (success) {
|
||||||
activity.emptyAndDisableTheRecycleBin {
|
activity.showRecycleBinEmptyingDialog {
|
||||||
listener?.refreshItems()
|
activity.emptyAndDisableTheRecycleBin {
|
||||||
|
listener?.refreshItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,8 +438,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryCreateShortcut() {
|
private fun tryCreateShortcut() {
|
||||||
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") {
|
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success ->
|
||||||
createShortcut()
|
if (success) {
|
||||||
|
createShortcut()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,8 +540,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foldersToDelete.size == 1) {
|
if (foldersToDelete.size == 1) {
|
||||||
activity.handleLockedFolderOpening(foldersToDelete.first().absolutePath) {
|
activity.handleLockedFolderOpening(foldersToDelete.first().absolutePath) { success ->
|
||||||
listener?.deleteFolders(foldersToDelete)
|
if (success) {
|
||||||
|
listener?.deleteFolders(foldersToDelete)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foldersToDelete = foldersToDelete.filter { !activity.config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File>
|
foldersToDelete = foldersToDelete.filter { !activity.config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File>
|
||||||
|
@ -535,8 +553,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryChangeAlbumCover(useDefault: Boolean) {
|
private fun tryChangeAlbumCover(useDefault: Boolean) {
|
||||||
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") {
|
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success ->
|
||||||
changeAlbumCover(useDefault)
|
if (success) {
|
||||||
|
changeAlbumCover(useDefault)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,10 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri
|
||||||
|
|
||||||
private fun showOtherFolder() {
|
private fun showOtherFolder() {
|
||||||
FilePickerDialog(activity, sourcePath, false, showHidden, true, true) {
|
FilePickerDialog(activity, sourcePath, false, showHidden, true, true) {
|
||||||
activity.handleLockedFolderOpening(it) {
|
activity.handleLockedFolderOpening(it) { success ->
|
||||||
callback(it)
|
if (success) {
|
||||||
|
callback(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,8 +104,10 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri
|
||||||
activity.toast(R.string.source_and_destination_same)
|
activity.toast(R.string.source_and_destination_same)
|
||||||
return@DirectoryAdapter
|
return@DirectoryAdapter
|
||||||
} else {
|
} else {
|
||||||
activity.handleLockedFolderOpening(path) {
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
callback(path)
|
if (success) {
|
||||||
|
callback(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue