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,10 +1,12 @@
package org.androidlabs.applistbackup.docs

import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -66,7 +68,15 @@ fun WebViewComposable(filename: String, modifier: Modifier = Modifier) {
): Boolean {
request?.url?.let { url ->
val intent = Intent(Intent.ACTION_VIEW, url)
context.startActivity(intent)
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(
context,
R.string.no_app_to_open_link,
Toast.LENGTH_SHORT
).show()
}
return true
}
return false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.androidlabs.applistbackup.reader

import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
Expand All @@ -9,6 +10,7 @@ import android.webkit.WebResourceRequest
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
Expand All @@ -27,6 +29,7 @@ import androidx.compose.ui.viewinterop.AndroidView
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.androidlabs.applistbackup.R

@SuppressLint("SetJavaScriptEnabled")
@Composable
Expand Down Expand Up @@ -72,7 +75,17 @@ fun BackupWebView(
coroutineScope.launch(Dispatchers.IO) {
val intent = Intent(Intent.ACTION_VIEW, url)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
R.string.no_app_to_open_link,
Toast.LENGTH_SHORT
).show()
}
}
}
return true
}
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,5 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">AppListBackup</string>
<string name="no_app_to_open_link">No app available to open this link</string>
<string name="appwidget_text">Backup now</string>
<string name="appwidget_text_in_progress">Backing up</string>
<string name="app_widget_description">This widget allow you to create backup immediately.</string>
Expand Down