From 37cb4f2608872024beb8f72ea94717cf43550dc2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 17 Dec 2019 17:43:52 +0100 Subject: [PATCH] updating commons to 5.21.0 --- app/build.gradle | 2 +- .../gallery/pro/activities/ViewPagerActivity.kt | 8 +++++++- .../gallery/pro/adapters/DirectoryAdapter.kt | 4 ++++ .../gallery/pro/adapters/ManageHiddenFoldersAdapter.kt | 4 +++- .../gallery/pro/adapters/MediaAdapter.kt | 4 ++++ .../simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt | 6 ++++-- .../simplemobiletools/gallery/pro/extensions/Activity.kt | 4 ++++ 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7fc2026cd..9e7c390ca 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.20.10' + implementation 'com.simplemobiletools:commons:5.21.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' 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 7f30b2096..0dc77ed6c 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 @@ -633,7 +633,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val currentPath = getCurrentPath() if (needsStupidWritePermissions(currentPath)) { handleSAFDialog(currentPath) { - rotateBy(degrees) + if (it) { + rotateBy(degrees) + } } } else { rotateBy(degrees) @@ -668,6 +670,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View SaveAsDialog(this, currPath, false) { val newPath = it handleSAFDialog(it) { + if (!it) { + return@handleSAFDialog + } + toast(R.string.saving) ensureBackgroundThread { val photoFragment = getCurrentPhotoFragment() ?: return@ensureBackgroundThread diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 4e3d29de4..abc71941e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -544,6 +544,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList(selectedKeys.size) selectedDirs.forEach { if (it.areFavorites() || it.isRecycleBin()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt index a3e2337c8..972d3e7a1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt @@ -81,7 +81,9 @@ class ManageHiddenFoldersAdapter(activity: BaseSimpleActivity, var folders: Arra if (sdCardPaths.isNotEmpty()) { activity.handleSAFDialog(sdCardPaths.first()) { - unhideFolders(removeFolders) + if (it) { + unhideFolders(removeFolders) + } } } else { unhideFolders(removeFolders) 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 743d2127d..298a90def 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 @@ -426,6 +426,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList(selectedKeys.size) val removeMedia = ArrayList(selectedKeys.size) val positions = getSelectedItemPositions() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt index 614fb7bfc..a4dd80712 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt @@ -8,7 +8,8 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R import kotlinx.android.synthetic.main.dialog_save_as.view.* -class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) { +class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null, + val callback: (savePath: String) -> Unit) { init { var realPath = path.getParentPath() @@ -41,7 +42,8 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() } + .setOnCancelListener { cancelCallback?.invoke() } .create().apply { activity.setupDialogStuff(view, this, R.string.save_as) { showKeyboard(view.save_as_name) 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 8d9885c7a..3ece915e3 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 @@ -138,6 +138,10 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) { if (needsStupidWritePermissions(path)) { handleSAFDialog(file.absolutePath) { + if (!it) { + return@handleSAFDialog + } + val fileDocument = getDocumentFile(path) if (fileDocument?.exists() == true && fileDocument.isDirectory) { fileDocument.createFile("", NOMEDIA)