Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9365b268 authored by tibbi's avatar tibbi
Browse files

check if the user has a browser installed before launching View intent

parent 6131ca9b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -126,8 +126,13 @@ fun Activity.isShowingSAFDialog(file: File, treeUri: String, requestCode: Int):
fun Activity.launchViewIntent(id: Int) = launchViewIntent(resources.getString(id))

fun Activity.launchViewIntent(url: String) {
    val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
    startActivity(browserIntent)
    Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
        if (resolveActivity(packageManager) != null) {
            startActivity(this)
        } else {
            toast(R.string.no_app_found)
        }
    }
}

fun Activity.shareUri(uri: Uri, applicationId: String) {