Skip to content

Commit bc647c1

Browse files
committed
Enable Both slot Flash options (Add Inactive slot flash warning) : Try 15
1 parent 581c6aa commit bc647c1

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotFlashContent.kt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,45 @@ fun ColumnScope.SlotFlashContent(
170170
}
171171
}
172172
}
173+
if (navController.currentDestination!!.route!!.contains("ak3") && viewModel.wasFlashSuccess == true && viewModel.showCautionDialog.value == true){
174+
AlertDialog(
175+
onDismissRequest = { viewModel.hideCautionDialog() },
176+
title = { Text("CAUTION", style = MaterialTheme.typography.titleLarge) },
177+
text = {
178+
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
179+
Text("You have flashed AnyKernel Zip to inactive slot!")
180+
Text("But the active slot is not changed after flashing.")
181+
Text("Use bootctl to change active slot or return to System Updater to complete OTA.")
182+
Text("Do not reboot from here, unless you know what you are doing.")
183+
}
184+
},
185+
confirmButton = {
186+
OutlinedButton(
187+
onClick = {
188+
viewModel.hideCautionDialog()
189+
// Add slot-switching logic here
190+
},
191+
shape = RoundedCornerShape(4.dp),
192+
colors = ButtonDefaults.outlinedButtonColors(
193+
contentColor = MaterialTheme.colorScheme.primary
194+
)
195+
) {
196+
Text("CHANGE SLOT")
197+
}
198+
},
199+
dismissButton = {
200+
OutlinedButton(
201+
onClick = { viewModel.hideCautionDialog() },
202+
shape = RoundedCornerShape(4.dp)
203+
) {
204+
Text("CANCEL")
205+
}
206+
},
207+
containerColor = MaterialTheme.colorScheme.surface,
208+
contentColor = MaterialTheme.colorScheme.onSurface,
209+
modifier = Modifier.padding(16.dp)
210+
)
211+
}
173212
if (viewModel.wasFlashSuccess != false && navController.currentDestination!!.route!!.endsWith("/backup/backup")) {
174213
OutlinedButton(
175214
modifier = Modifier

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class SlotViewModel(
6565
private val hashAlgorithm: String = "SHA-256"
6666
private var inInit = true
6767
private var _error: String? = null
68+
private val _showCautionDialog = mutableStateOf(false)
69+
val showCautionDialog: State<Boolean> = _showCautionDialog
6870

6971
val sha1: String?
7072
get() = _sha1
@@ -154,6 +156,10 @@ class SlotViewModel(
154156
_isRefreshing.value = false
155157
}
156158
}
159+
160+
private fun showCautionDialog() {
161+
_showCautionDialog.value = true
162+
}
157163

158164
// TODO: use base class for common functions
159165
@Suppress("SameParameterValue")
@@ -530,6 +536,9 @@ class SlotViewModel(
530536
uiPrint("Use bootctl to change active slot or Return to System Updater to complete OTA.")
531537
uiPrint("Do not reboot from here, unless you know what you are doing.")
532538
resetSlot()
539+
viewModelScope.launch(Dispatchers.Main) {
540+
showCautionDialog() // Show dialog instead of uiPrint
541+
}
533542
}
534543
}
535544
}

0 commit comments

Comments
 (0)