fix #386, automatically append "_1" after the filename when saving in editor

This commit is contained in:
tibbi 2017-10-26 10:10:11 +02:00
parent 8e99cd5364
commit 7f10f67c7b
3 changed files with 8 additions and 4 deletions

View file

@ -141,13 +141,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
setResult(RESULT_OK) setResult(RESULT_OK)
finish() finish()
} else if (uri.scheme == "file") { } else if (uri.scheme == "file") {
SaveAsDialog(this, uri.path) { SaveAsDialog(this, uri.path, true) {
saveBitmapToFile(result.bitmap, it) saveBitmapToFile(result.bitmap, it)
} }
} else if (uri.scheme == "content") { } else if (uri.scheme == "content") {
val newPath = applicationContext.getRealPathFromURI(uri) ?: "" val newPath = applicationContext.getRealPathFromURI(uri) ?: ""
if (!newPath.isEmpty()) { if (!newPath.isEmpty()) {
SaveAsDialog(this, newPath) { SaveAsDialog(this, newPath, true) {
saveBitmapToFile(result.bitmap, it) saveBitmapToFile(result.bitmap, it)
} }
} else { } else {

View file

@ -446,7 +446,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun saveImageAs() { private fun saveImageAs() {
val currPath = getCurrentPath() val currPath = getCurrentPath()
SaveAsDialog(this, currPath) { SaveAsDialog(this, currPath, false) {
Thread({ Thread({
toast(R.string.saving) toast(R.string.saving)
val selectedFile = File(it) val selectedFile = File(it)

View file

@ -11,7 +11,7 @@ import com.simplemobiletools.gallery.activities.SimpleActivity
import kotlinx.android.synthetic.main.dialog_save_as.view.* import kotlinx.android.synthetic.main.dialog_save_as.view.*
import java.io.File import java.io.File
class SaveAsDialog(val activity: SimpleActivity, val path: String, val callback: (savePath: String) -> Unit) { class SaveAsDialog(val activity: SimpleActivity, val path: String, val appendFilename: Boolean, val callback: (savePath: String) -> Unit) {
init { init {
var realPath = File(path).parent.trimEnd('/') var realPath = File(path).parent.trimEnd('/')
@ -28,6 +28,10 @@ class SaveAsDialog(val activity: SimpleActivity, val path: String, val callback:
save_as_extension.setText(extension) save_as_extension.setText(extension)
} }
if (appendFilename) {
name += "_1"
}
save_as_name.setText(name) save_as_name.setText(name)
save_as_path.setOnClickListener { save_as_path.setOnClickListener {
FilePickerDialog(activity, realPath, false, false, true) { FilePickerDialog(activity, realPath, false, false, true) {