mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
couple SaveAs dialog related fixes
This commit is contained in:
parent
0148465e75
commit
0b5005e0d0
2 changed files with 9 additions and 9 deletions
|
@ -47,7 +47,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.19.14'
|
||||
implementation 'com.simplemobiletools:commons:3.19.15'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||
import java.io.File
|
||||
|
||||
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
|
||||
|
||||
|
@ -15,7 +14,7 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
|||
var realPath = path.getParentPath()
|
||||
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
||||
save_as_path.text = activity.humanizePath(realPath)
|
||||
save_as_path.text = "${activity.humanizePath(realPath).trimEnd('/')}/"
|
||||
|
||||
val fullName = path.getFilenameFromPath()
|
||||
val dotAt = fullName.lastIndexOf(".")
|
||||
|
@ -60,20 +59,21 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val newFile = File(realPath, "$filename.$extension")
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
val newFilename = "$filename.$extension"
|
||||
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
||||
if (!newFilename.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (newFile.exists()) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
||||
if (activity.getDoesFilePathExist(newPath)) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
||||
ConfirmationDialog(activity, title) {
|
||||
callback(newFile.absolutePath)
|
||||
callback(newPath)
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
callback(newFile.absolutePath)
|
||||
callback(newPath)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue