From c3dbed54e50430b585e9d7b88cf22c9f3a6cc54c Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Wed, 11 Feb 2026 21:39:01 +0800 Subject: [PATCH] ErrorActivity: Kotlin-fy buildMarkdown method Signed-off-by: Aayush Gupta --- .../org/schabi/newpipe/error/ErrorActivity.kt | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt index 7fbeb1716..b29190a55 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.kt @@ -208,8 +208,8 @@ class ErrorActivity : AppCompatActivity() { private fun buildMarkdown(): String { try { return buildString(1024) { - val userComment = binding.errorCommentBox.getText().toString() - if (!userComment.isEmpty()) { + val userComment = binding.errorCommentBox.text.toString() + if (userComment.isNotEmpty()) { appendLine(userComment) } @@ -229,28 +229,27 @@ class ErrorActivity : AppCompatActivity() { // Collapse all logs to a single paragraph when there are more than one // to keep the GitHub issue clean. - if (errorInfo.stackTraces.size > 1) { + if (errorInfo.stackTraces.isNotEmpty()) { append("
Exceptions (") append(errorInfo.stackTraces.size) append(")

\n") - } - // add the logs - for (i in errorInfo.stackTraces.indices) { - append("

Crash log ") - if (errorInfo.stackTraces.size > 1) { - append(i + 1) + // add the logs + errorInfo.stackTraces.forEachIndexed { index, stacktrace -> + append("
Crash log ") + if (errorInfo.stackTraces.isNotEmpty()) { + append(index + 1) + } + append("") + append("

\n") + append("\n```\n${stacktrace}\n```\n") + append("

\n") } - append("
") - append("

\n") - append("\n```\n${errorInfo.stackTraces[i]}\n```\n") - append("

\n") - } - // make sure to close everything - if (errorInfo.stackTraces.size > 1) { + // make sure to close everything append("

\n") } + append("
\n") } } catch (exception: Exception) {