mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-01 03:12:25 -05:00
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:
@@ -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),
|
||||
) {
|
||||
|
||||
@@ -922,4 +922,5 @@
|
||||
<string name="two_days">48 Hours</string>
|
||||
<string name="last_heard_filter_label">Filter by Last Heard time: %s</string>
|
||||
<string name="dbm_value">%1$d dBm</string>
|
||||
<string name="error_no_app_to_handle_link">No application available to handle link.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user