mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +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 {
|
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.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
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.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
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) {
|
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()
|
var realPath = path.getParentPath()
|
||||||
|
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
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 fullName = path.getFilenameFromPath()
|
||||||
val dotAt = fullName.lastIndexOf(".")
|
val dotAt = fullName.lastIndexOf(".")
|
||||||
|
@ -60,20 +59,21 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFile = File(realPath, "$filename.$extension")
|
val newFilename = "$filename.$extension"
|
||||||
if (!newFile.name.isAValidFilename()) {
|
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
||||||
|
if (!newFilename.isAValidFilename()) {
|
||||||
activity.toast(R.string.filename_invalid_characters)
|
activity.toast(R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newFile.exists()) {
|
if (activity.getDoesFilePathExist(newPath)) {
|
||||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
||||||
ConfirmationDialog(activity, title) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newFile.absolutePath)
|
callback(newPath)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callback(newFile.absolutePath)
|
callback(newPath)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue