fix: decouple animator for stories
This commit is contained in:
parent
4362dd94c1
commit
31c509f88c
4 changed files with 170 additions and 96 deletions
|
@ -25,12 +25,14 @@ object Logger {
|
|||
if (!PrefManager.getVal<Boolean>(PrefName.LogToFile) || file != null) return
|
||||
file = File(context.getExternalFilesDir(null), "log.txt")
|
||||
if (file?.exists() == true) {
|
||||
val oldFile = File(context.getExternalFilesDir(null), "old_log.txt")
|
||||
file?.copyTo(oldFile, true)
|
||||
if (file!!.length() > 1024 * 1024 * 10) { // 10MB
|
||||
file?.delete()
|
||||
file?.createNewFile()
|
||||
}
|
||||
} else {
|
||||
file?.createNewFile()
|
||||
}
|
||||
file?.writeText("log started\n")
|
||||
file?.appendText("log started\n")
|
||||
file?.appendText("date/time: ${Date()}\n")
|
||||
file?.appendText("device: ${Build.MODEL}\n")
|
||||
file?.appendText("os version: ${Build.VERSION.RELEASE}\n")
|
||||
|
@ -133,13 +135,6 @@ object Logger {
|
|||
snackString("No log file found")
|
||||
return
|
||||
}
|
||||
val oldFile = File(context.getExternalFilesDir(null), "old_log.txt")
|
||||
val fileToUse = if (oldFile.exists()) {
|
||||
file?.readText()?.let { oldFile.appendText(it) }
|
||||
oldFile
|
||||
} else {
|
||||
file
|
||||
}
|
||||
val shareIntent = Intent(Intent.ACTION_SEND)
|
||||
shareIntent.type = "text/plain"
|
||||
shareIntent.putExtra(
|
||||
|
@ -147,7 +142,7 @@ object Logger {
|
|||
FileProvider.getUriForFile(
|
||||
context,
|
||||
"${BuildConfig.APPLICATION_ID}.provider",
|
||||
fileToUse!!
|
||||
file!!
|
||||
)
|
||||
)
|
||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Log file")
|
||||
|
@ -155,6 +150,11 @@ object Logger {
|
|||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
context.startActivity(Intent.createChooser(shareIntent, "Share log file"))
|
||||
}
|
||||
|
||||
fun clearLog() {
|
||||
file?.delete()
|
||||
file = null
|
||||
}
|
||||
}
|
||||
|
||||
class FinalExceptionHandler : Thread.UncaughtExceptionHandler {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue