From a12074b0c657f3cd5f88e213e6fa89519e6a3252 Mon Sep 17 00:00:00 2001 From: Michael Beyeler Date: Wed, 31 Jan 2018 15:18:07 -0800 Subject: [PATCH] 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(".")) } }