Skip to content

Commit

Permalink
Hoist DFU error dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Apr 2, 2024
1 parent 4c94417 commit 61b453d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/net/pipe01/pinepartner/NavFrame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ fun NavFrame(
onShowBottomBar(true)
navController.popBackStack()
},
onError = {
onShowBottomBar(true)
navController.popBackStack()
errors.add(it)
},
)
}
composable("${Route.DEVICES}/{address}/files?path={path}") { route ->
Expand Down
18 changes: 2 additions & 16 deletions app/src/main/java/net/pipe01/pinepartner/pages/devices/DFUPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import net.pipe01.pinepartner.components.Header
import net.pipe01.pinepartner.service.BackgroundService
import net.pipe01.pinepartner.service.TransferProgress
import net.pipe01.pinepartner.utils.PineError
import net.pipe01.pinepartner.utils.composables.ErrorDialog
import net.pipe01.pinepartner.utils.toMinutesSeconds
import java.time.Duration
import kotlin.random.Random
Expand All @@ -41,25 +40,15 @@ fun DFUPage(
onStart: () -> Unit,
onFinish: () -> Unit,
onCancel: () -> Unit,
onError: (PineError) -> Unit,
) {
var uri by remember { mutableStateOf<Uri?>(null) }

var showErrorDialog by remember { mutableStateOf<PineError?>(null) }

if (showErrorDialog != null) {
ErrorDialog(
error = showErrorDialog!!,
onDismissRequest = { showErrorDialog = null },
)
}

Column(
modifier = Modifier.padding(horizontal = 16.dp)
) {
Header("Firmware update")

Spacer(modifier = Modifier.height(48.dp))

if (uri == null) {
FileChooser { uri = it }
} else {
Expand All @@ -70,10 +59,7 @@ fun DFUPage(
onStart = onStart,
onFinish = onFinish,
onCancel = onCancel,
onError = {
onCancel()
showErrorDialog = it
},
onError = onError,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class BackgroundService : Service() {
}

private fun attachUnhandledExceptionHandler() {
if (!BuildConfig.DEBUG || true) {
if (!BuildConfig.DEBUG) {
Thread.setDefaultUncaughtExceptionHandler { _, e -> handleUncaughtException(e) }
}
}
Expand Down

0 comments on commit 61b453d

Please sign in to comment.