From a0a51bbf305c017a9e7df13fe6ee480a2d35cd2b Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Fri, 14 Apr 2023 14:40:16 +0900 Subject: [PATCH] fix gui --- .../ui/profile/ProfileSettingsActivity.kt | 6 ++++- .../java/moe/matsuri/nb4a/utils/SendLog.kt | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileSettingsActivity.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileSettingsActivity.kt index 553ae14a..596c34bf 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileSettingsActivity.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/profile/ProfileSettingsActivity.kt @@ -10,6 +10,7 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.LinearLayout +import android.widget.ScrollView import android.widget.Toast import androidx.activity.result.component1 import androidx.activity.result.component2 @@ -355,7 +356,10 @@ abstract class ProfileSettingsActivity( } } } - MaterialAlertDialogBuilder(activity).setView(view).show() + val scrollView = ScrollView(context).apply { + addView(view) + } + MaterialAlertDialogBuilder(activity).setView(scrollView).show() true } else -> false diff --git a/app/src/main/java/moe/matsuri/nb4a/utils/SendLog.kt b/app/src/main/java/moe/matsuri/nb4a/utils/SendLog.kt index e12fccfd..1b34033f 100644 --- a/app/src/main/java/moe/matsuri/nb4a/utils/SendLog.kt +++ b/app/src/main/java/moe/matsuri/nb4a/utils/SendLog.kt @@ -59,15 +59,19 @@ object SendLog { // Get log bytes from neko.log fun getNekoLog(max: Long): ByteArray { - val file = File( - SagerNet.application.cacheDir, - "neko.log" - ) - val len = file.length() - val stream = FileInputStream(file) - if (max in 1 until len) { - stream.skip(len - max) // TODO string? + return try { + val file = File( + SagerNet.application.cacheDir, + "neko.log" + ) + val len = file.length() + val stream = FileInputStream(file) + if (max in 1 until len) { + stream.skip(len - max) // TODO string? + } + stream.use { it.readBytes() } + } catch (e: Exception) { + e.stackTraceToString().toByteArray() } - return stream.use { it.readBytes() } } }