updating commons to 5.21.0

This commit is contained in:
tibbi 2019-12-17 17:43:52 +01:00
parent 980b57250c
commit 37cb4f2608
7 changed files with 27 additions and 5 deletions

View file

@ -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'

View file

@ -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

View file

@ -544,6 +544,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
}
activity.handleSAFDialog(SAFPath) {
if (!it) {
return@handleSAFDialog
}
var foldersToDelete = ArrayList<File>(selectedKeys.size)
selectedDirs.forEach {
if (it.areFavorites() || it.isRecycleBin()) {

View file

@ -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)

View file

@ -426,6 +426,10 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
val SAFPath = getSelectedPaths().firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
activity.handleSAFDialog(SAFPath) {
if (!it) {
return@handleSAFDialog
}
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
val removeMedia = ArrayList<Medium>(selectedKeys.size)
val positions = getSelectedItemPositions()

View file

@ -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)

View file

@ -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)