From a12074b0c657f3cd5f88e213e6fa89519e6a3252 Mon Sep 17 00:00:00 2001 From: Michael Beyeler Date: Wed, 31 Jan 2018 15:18:07 -0800 Subject: [PATCH 1/3] display date in human-readable format remove invalid : character change YYYY to yyyy --- .../com/simplemobiletools/draw/dialogs/SaveImageDialog.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt index a0c11a9..bfc3f0e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt @@ -14,6 +14,9 @@ import com.simplemobiletools.draw.views.MyCanvas import kotlinx.android.synthetic.main.dialog_save_image.view.* import java.io.File import java.io.OutputStream +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.Date class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: String, val curPath: String, val canvas: MyCanvas, callback: (path: String, extension: String) -> Unit) { @@ -104,7 +107,10 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri } private fun getInitialFilename(): String { - val defaultFilename = "image_${System.currentTimeMillis() / 1000}" + // Display date and time in human readable format: + val sdf = SimpleDateFormat("yyyy-MM-dd_HH-mm") + val defaultFilename = "image_${sdf.format(Date(System.currentTimeMillis()))}" + return if (curPath.isEmpty()) defaultFilename else curPath.getFilenameFromPath().substring(0, curPath.getFilenameFromPath().lastIndexOf(".")) } } From f1e38febcd4987b279dbfdb959d3f8ad2b48405c Mon Sep 17 00:00:00 2001 From: Michael Beyeler Date: Wed, 7 Feb 2018 14:22:44 -0800 Subject: [PATCH 2/3] rename sdf to simpleDateFormat, formatted --- .../com/simplemobiletools/draw/dialogs/SaveImageDialog.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt index bfc3f0e..06ba6db 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt @@ -107,9 +107,9 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri } private fun getInitialFilename(): String { - // Display date and time in human readable format: - val sdf = SimpleDateFormat("yyyy-MM-dd_HH-mm") - val defaultFilename = "image_${sdf.format(Date(System.currentTimeMillis()))}" + val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH-mm") + val formatted = simpleDateFormat.format(Date(System.currentTimeMillis())) + val defaultFilename = "image_${formatted}" return if (curPath.isEmpty()) defaultFilename else curPath.getFilenameFromPath().substring(0, curPath.getFilenameFromPath().lastIndexOf(".")) } From 1d90587429c93e775a59f55d81e0e03d93b78aee Mon Sep 17 00:00:00 2001 From: Michael Beyeler Date: Wed, 7 Feb 2018 14:24:53 -0800 Subject: [PATCH 3/3] remove curly braces from format string --- .../com/simplemobiletools/draw/dialogs/SaveImageDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt index 06ba6db..ceeba3a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/dialogs/SaveImageDialog.kt @@ -109,7 +109,7 @@ class SaveImageDialog(val activity: SimpleActivity, val suggestedExtension: Stri private fun getInitialFilename(): String { val simpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH-mm") val formatted = simpleDateFormat.format(Date(System.currentTimeMillis())) - val defaultFilename = "image_${formatted}" + val defaultFilename = "image_$formatted" return if (curPath.isEmpty()) defaultFilename else curPath.getFilenameFromPath().substring(0, curPath.getFilenameFromPath().lastIndexOf(".")) }