diff --git a/app/src/main/java/com/dozingcatsoftware/vectorcamera/AboutActivity.kt b/app/src/main/java/com/dozingcatsoftware/vectorcamera/AboutActivity.kt index bab3102..56d7e22 100644 --- a/app/src/main/java/com/dozingcatsoftware/vectorcamera/AboutActivity.kt +++ b/app/src/main/java/com/dozingcatsoftware/vectorcamera/AboutActivity.kt @@ -1,11 +1,13 @@ package com.dozingcatsoftware.vectorcamera +import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle import android.webkit.WebView import android.webkit.WebViewClient +import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity import com.dozingcatsoftware.util.adjustPaddingForSystemUi @@ -42,11 +44,11 @@ class AboutActivity: AppCompatActivity() { override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { // Go to email for mailto: and default browser for http/https URLs. if (url.startsWith("mailto:")) { - startActivity(Intent(Intent.ACTION_SENDTO, Uri.parse(url))) + launchExternal(Intent(Intent.ACTION_SENDTO, Uri.parse(url))) return true } if (url.startsWith("http:") || url.startsWith("https:")) { - startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) + launchExternal(Intent(Intent.ACTION_VIEW, Uri.parse(url))) return true } // Load file URLs in the same WebView. @@ -56,6 +58,14 @@ class AboutActivity: AppCompatActivity() { return super.shouldOverrideUrlLoading(view, url) } + private fun launchExternal(intent: Intent) { + try { + startActivity(intent) + } catch (e: ActivityNotFoundException) { + Toast.makeText(this@AboutActivity, R.string.no_app_to_open_link, Toast.LENGTH_SHORT).show() + } + } + // Selectively enable the back navigation callback depending on // whether it should do a "back" action in the browser. override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 555ce0e..b51990b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ Vector Camera No pictures found. + No app available to open this link takePictureWithVolumeButton Take picture with volume button