From 23e8a4ce4b0c6052a548719d64c3ae91884fd1ed Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 2 May 2019 16:20:11 +0200 Subject: [PATCH] Fixed shell long dumping to UI --- .../magisk/ui/flash/FlashViewModel.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt index e0413d233..4dbc278c7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt @@ -43,6 +43,7 @@ class FlashViewModel( } private val rawItems = ObservableArrayList() + private val logItems = ObservableArrayList() init { rawItems.sendUpdatesTo(items) { it.map { ConsoleRvItem(it) } } @@ -52,19 +53,19 @@ class FlashViewModel( val uri = uri ?: Uri.EMPTY when (action) { Const.Value.FLASH_ZIP -> Flashing - .Install(uri, rawItems, rawItems, this) + .Install(uri, rawItems, logItems, this) .exec() Const.Value.UNINSTALL -> Flashing - .Uninstall(uri, rawItems, rawItems, this) + .Uninstall(uri, rawItems, logItems, this) .exec() Const.Value.FLASH_MAGISK -> Patching - .Direct(rawItems, rawItems, this) + .Direct(rawItems, logItems, this) .exec() Const.Value.FLASH_INACTIVE_SLOT -> Patching - .SecondSlot(rawItems, rawItems, this) + .SecondSlot(rawItems, logItems, this) .exec() Const.Value.PATCH_FILE -> Patching - .File(uri, rawItems, rawItems, this) + .File(uri, rawItems, logItems, this) .exec() } } @@ -85,13 +86,20 @@ class FlashViewModel( fun savePressed() = withPermissions(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) .map { now } - .map { it.toTime(timeFormatFull) } + .map { it.toTime(timeFormatStandard) } .map { Const.MAGISK_INSTALL_LOG_FILENAME.format(it) } .map { File(Const.EXTERNAL_PATH, it) } .map { file -> val log = items.filterIsInstance() .joinToString("\n") { it.item } file.writeText(log) + + val rawLog = logItems.toList().joinToString("\n") + if (rawLog.isNotBlank()) { + file.appendText("\n=== LOG ===\n") + file.appendText(rawLog) + } + file.path } .subscribeK { SnackbarEvent(it).publish() }