mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 14:02:44 +00:00
add readable timestamp to logs and crash reports (similar to backup files)
This commit is contained in:
parent
912be23900
commit
98640c6b0d
2 changed files with 8 additions and 2 deletions
|
@ -17,6 +17,8 @@ import java.io.File
|
|||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
object DebugFlags {
|
||||
|
@ -63,7 +65,8 @@ ${Log.getLog(100).joinToString("\n")}
|
|||
private fun writeCrashReportToFile(text: String) {
|
||||
try {
|
||||
val dir = appContext.getExternalFilesDir(null) ?: return
|
||||
val crashReportFile = File(dir, "crash_report_${System.currentTimeMillis()}.txt")
|
||||
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Calendar.getInstance().time)
|
||||
val crashReportFile = File(dir, "crash_report_$date.txt")
|
||||
crashReportFile.writeText(text)
|
||||
} catch (ignored: IOException) {
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ import helium314.keyboard.settings.SettingsActivity
|
|||
import helium314.keyboard.settings.Theme
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
|
||||
@Composable
|
||||
fun AboutScreen(
|
||||
|
@ -155,12 +157,13 @@ fun createAboutSettings(context: Context) = listOf(
|
|||
name = setting.title,
|
||||
description = setting.description,
|
||||
onClick = {
|
||||
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Calendar.getInstance().time)
|
||||
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
.putExtra(
|
||||
Intent.EXTRA_TITLE,
|
||||
ctx.getString(R.string.english_ime_name)
|
||||
.replace(" ", "_") + "_log_${System.currentTimeMillis()}.txt"
|
||||
.replace(" ", "_") + "_log_$date.txt"
|
||||
)
|
||||
.setType("text/plain")
|
||||
launcher.launch(intent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue