From 7f10f67c7b42771fbcd30176715bef8b710c01d9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 26 Oct 2017 10:10:11 +0200 Subject: [PATCH] fix #386, automatically append "_1" after the filename when saving in editor --- .../simplemobiletools/gallery/activities/EditActivity.kt | 4 ++-- .../gallery/activities/ViewPagerActivity.kt | 2 +- .../com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index dc09ee11e..61359be9e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -141,13 +141,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener setResult(RESULT_OK) finish() } else if (uri.scheme == "file") { - SaveAsDialog(this, uri.path) { + SaveAsDialog(this, uri.path, true) { saveBitmapToFile(result.bitmap, it) } } else if (uri.scheme == "content") { val newPath = applicationContext.getRealPathFromURI(uri) ?: "" if (!newPath.isEmpty()) { - SaveAsDialog(this, newPath) { + SaveAsDialog(this, newPath, true) { saveBitmapToFile(result.bitmap, it) } } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index e9af326b0..c56d37d31 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -446,7 +446,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun saveImageAs() { val currPath = getCurrentPath() - SaveAsDialog(this, currPath) { + SaveAsDialog(this, currPath, false) { Thread({ toast(R.string.saving) val selectedFile = File(it) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index 503e0f741..f97e2fb99 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -11,7 +11,7 @@ import com.simplemobiletools.gallery.activities.SimpleActivity import kotlinx.android.synthetic.main.dialog_save_as.view.* 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 { 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) } + if (appendFilename) { + name += "_1" + } + save_as_name.setText(name) save_as_path.setOnClickListener { FilePickerDialog(activity, realPath, false, false, true) {