mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 22:12:46 +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.IOException
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
object DebugFlags {
|
object DebugFlags {
|
||||||
|
@ -63,7 +65,8 @@ ${Log.getLog(100).joinToString("\n")}
|
||||||
private fun writeCrashReportToFile(text: String) {
|
private fun writeCrashReportToFile(text: String) {
|
||||||
try {
|
try {
|
||||||
val dir = appContext.getExternalFilesDir(null) ?: return
|
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)
|
crashReportFile.writeText(text)
|
||||||
} catch (ignored: IOException) {
|
} catch (ignored: IOException) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ import helium314.keyboard.settings.SettingsActivity
|
||||||
import helium314.keyboard.settings.Theme
|
import helium314.keyboard.settings.Theme
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AboutScreen(
|
fun AboutScreen(
|
||||||
|
@ -155,12 +157,13 @@ fun createAboutSettings(context: Context) = listOf(
|
||||||
name = setting.title,
|
name = setting.title,
|
||||||
description = setting.description,
|
description = setting.description,
|
||||||
onClick = {
|
onClick = {
|
||||||
|
val date = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Calendar.getInstance().time)
|
||||||
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
.putExtra(
|
.putExtra(
|
||||||
Intent.EXTRA_TITLE,
|
Intent.EXTRA_TITLE,
|
||||||
ctx.getString(R.string.english_ime_name)
|
ctx.getString(R.string.english_ime_name)
|
||||||
.replace(" ", "_") + "_log_${System.currentTimeMillis()}.txt"
|
.replace(" ", "_") + "_log_$date.txt"
|
||||||
)
|
)
|
||||||
.setType("text/plain")
|
.setType("text/plain")
|
||||||
launcher.launch(intent)
|
launcher.launch(intent)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue