Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name">Vector Camera</string>
<string name="noImagesFound">No pictures found.</string>
<string name="no_app_to_open_link">No app available to open this link</string>

<string name="takePictureWithVolumeButtonPrefsKey">takePictureWithVolumeButton</string>
<string name="takePictureWithVolumeButtonPrefsTitle">Take picture with volume button</string>
Expand Down