aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-03-26 16:59:54 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2020-03-26 16:59:54 -0600
commit2b6eff9ae329d9bf6bc550c759f1ab3eebb07c1a (patch)
tree0d724797a4f9d76c04c8566b61229b188142494d
parentLogViewerActivity: re-add error case to log export (diff)
downloadwireguard-android-2b6eff9ae329d9bf6bc550c759f1ab3eebb07c1a.tar.xz
wireguard-android-2b6eff9ae329d9bf6bc550c759f1ab3eebb07c1a.zip
LogViewerActivity: merge lines that don't match regex
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt13
1 files changed, 10 insertions, 3 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
index a41aac4b..6e1bde99 100644
--- a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
@@ -209,8 +209,8 @@ class LogViewerActivity : AppCompatActivity() {
rawLogLines.append(line)
rawLogLines.append('\n')
val logLine = parseLine(line)
- if (logLine != null) {
- withContext(Dispatchers.Main) {
+ withContext(Dispatchers.Main) {
+ if (logLine != null) {
recyclerView?.let {
val shouldScroll = it.canScrollVertically(1)
logLines.add(logLine)
@@ -218,6 +218,13 @@ class LogViewerActivity : AppCompatActivity() {
if (!shouldScroll)
it.scrollToPosition(logLines.size - 1)
}
+ } else {
+ /* I'd prefer for the next line to be:
+ * logLines.lastOrNull()?.msg += "\n$line"
+ * However, as of writing, that causes the kotlin compiler to freak out and crash, spewing bytecode.
+ */
+ logLines.lastOrNull()?.apply { msg += "\n$line" }
+ logAdapter.notifyDataSetChanged()
}
}
}
@@ -241,7 +248,7 @@ class LogViewerActivity : AppCompatActivity() {
}
}
- private data class LogLine(val pid: Int, val tid: Int, val time: Date?, val level: String, val tag: String, val msg: String)
+ private data class LogLine(val pid: Int, val tid: Int, val time: Date?, val level: String, val tag: String, var msg: String)
companion object {
/**