From 628f648681e849abe234d063ba90bd3f667fd993 Mon Sep 17 00:00:00 2001 From: nift4 Date: Tue, 20 Aug 2024 22:18:45 +0200 Subject: [PATCH] logic fixes the second (and last for today i hope) --- app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt | 1 + app/src/main/java/org/andbootmgr/app/MainActivity.kt | 10 ++++++---- app/src/main/java/org/andbootmgr/app/WizardActivity.kt | 1 - app/src/main/java/org/andbootmgr/app/util/Terminal.kt | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt b/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt index 2083d035..42f6c35a 100644 --- a/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt +++ b/app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt @@ -1037,6 +1037,7 @@ private fun Flash(c: CreatePartDataHolder) { makeOne(0) } else { // Portable partition terminal.add(vm.activity.getString(R.string.term_create_part)) + vm.logic.unmountBootset() val r = vm.logic.create(c.p, c.l.toLong(), c.u.toLong(), diff --git a/app/src/main/java/org/andbootmgr/app/MainActivity.kt b/app/src/main/java/org/andbootmgr/app/MainActivity.kt index 77643cfa..f2a376a7 100644 --- a/app/src/main/java/org/andbootmgr/app/MainActivity.kt +++ b/app/src/main/java/org/andbootmgr/app/MainActivity.kt @@ -7,6 +7,7 @@ import android.util.Log import android.view.WindowManager import android.widget.Toast import androidx.activity.ComponentActivity +import androidx.activity.compose.BackHandler import androidx.activity.compose.setContent import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts @@ -76,7 +77,6 @@ class MainActivityState(val activity: MainActivity?) { var wizardCompat by mutableStateOf(null) fun startFlow(flow: String) { - unmountBootset() wizardCompat = flow } @@ -268,20 +268,22 @@ class MainActivity : ComponentActivity() { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) onDispose { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } } + BackHandler {} Column(modifier = Modifier.fillMaxSize()) { - Terminal(null, { canFinish = true }, null) + Row(modifier = Modifier.fillMaxWidth().weight(1.0f)) { + Terminal(null, { canFinish = true }, null) + } Row(modifier = Modifier.fillMaxWidth()) { TextButton(onClick = { }, modifier = Modifier.weight(1f, true)) { Text("") // This button is useless. } TextButton(onClick = { - if (canFinish) { + if (canFinish) CoroutineScope(Dispatchers.IO).launch { vm.init() showTerminal = false } - } }, modifier = Modifier.weight(1f, true)) { Text(if (canFinish) stringResource(R.string.finish) else "") } diff --git a/app/src/main/java/org/andbootmgr/app/WizardActivity.kt b/app/src/main/java/org/andbootmgr/app/WizardActivity.kt index 71774ff8..670924b6 100644 --- a/app/src/main/java/org/andbootmgr/app/WizardActivity.kt +++ b/app/src/main/java/org/andbootmgr/app/WizardActivity.kt @@ -124,7 +124,6 @@ class WizardActivityState(val mvm: MainActivityState) { mvm.wizardCompatE = null mvm.wizardCompatPid = null mvm.wizardCompatSid = null - mvm.mountBootset() } fun copy(inputStream: InputStream, outputStream: OutputStream): Long { diff --git a/app/src/main/java/org/andbootmgr/app/util/Terminal.kt b/app/src/main/java/org/andbootmgr/app/util/Terminal.kt index 2866b118..b6636647 100644 --- a/app/src/main/java/org/andbootmgr/app/util/Terminal.kt +++ b/app/src/main/java/org/andbootmgr/app/util/Terminal.kt @@ -177,7 +177,7 @@ fun Terminal(logFile: String? = null, doWhenDone: (() -> Unit)? = null, }, s) } else { val s = service.workExtra as BudgetCallbackList - text.value = s.joinToString("\n") + text.value = s.joinToString("\n").let { if (s.isNotEmpty()) it + "\n" else it } s.cb = { element -> scope.launch { text.value += element + "\n"