Merge pull request #79 from VisCog/fix-date

Add human readable date
This commit is contained in:
Tibor Kaputa 2018-02-07 23:34:07 +01:00 committed by GitHub
commit a1782dfb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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}"
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("."))
}
}