fix(ui): handle ActivityNotFoundException when opening firmware links (#3245)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-09-29 15:55:08 -05:00 committed by GitHub
parent 1ac5a0c7ec
commit 38332b346e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View file

@ -17,7 +17,9 @@
package com.geeksville.mesh.ui.node
import android.content.ActivityNotFoundException
import android.content.Intent
import android.widget.Toast
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.background
@ -167,6 +169,7 @@ import org.meshtastic.core.ui.theme.StatusColors.StatusGreen
import org.meshtastic.core.ui.theme.StatusColors.StatusOrange
import org.meshtastic.core.ui.theme.StatusColors.StatusRed
import org.meshtastic.core.ui.theme.StatusColors.StatusYellow
import timber.log.Timber
private data class VectorMetricInfo(
@StringRes val label: Int,
@ -595,8 +598,13 @@ private fun FirmwareReleaseSheetContent(firmwareRelease: FirmwareRelease) {
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Button(
onClick = {
val intent = Intent(Intent.ACTION_VIEW, firmwareRelease.pageUrl.toUri())
context.startActivity(intent)
try {
val intent = Intent(Intent.ACTION_VIEW, firmwareRelease.pageUrl.toUri())
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(context, R.string.error_no_app_to_handle_link, Toast.LENGTH_LONG).show()
Timber.e(e)
}
},
modifier = Modifier.weight(1f),
) {
@ -606,8 +614,13 @@ private fun FirmwareReleaseSheetContent(firmwareRelease: FirmwareRelease) {
}
Button(
onClick = {
val intent = Intent(Intent.ACTION_VIEW, firmwareRelease.zipUrl.toUri())
context.startActivity(intent)
try {
val intent = Intent(Intent.ACTION_VIEW, firmwareRelease.zipUrl.toUri())
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(context, R.string.error_no_app_to_handle_link, Toast.LENGTH_LONG).show()
Timber.e(e)
}
},
modifier = Modifier.weight(1f),
) {