Tell the user when no app can open a link

Privacy policy, donation, source code and license links silently did
nothing on devices without a browser.
This commit is contained in:
2026-10-25 14:48:16 +02:00
parent 4619292174
commit df41b44302
7 changed files with 15 additions and 1 deletions
@@ -1,9 +1,12 @@
package cc.skysparkle.sparkledns
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.fadeIn
@@ -264,7 +267,12 @@ private fun InfoRow(label: String, value: String) {
}
internal fun openUrl(context: Context, url: String) {
runCatching {
try {
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
} catch (_: ActivityNotFoundException) {
// Without a browser the tap used to do nothing at all
Toast.makeText(context, R.string.no_browser, Toast.LENGTH_SHORT).show()
} catch (e: RuntimeException) {
Log.w("SparkleDNS", "Cannot open $url", e)
}
}
+1
View File
@@ -98,4 +98,5 @@
<string name="servers_update">Serverliste aktualisieren</string>
<string name="servers_updated">Serverliste aktualisiert</string>
<string name="servers_update_failed">Serverliste konnte nicht aktualisiert werden: %1$s</string>
<string name="no_browser">Keine App zum Öffnen dieses Links gefunden</string>
</resources>
+1
View File
@@ -98,4 +98,5 @@
<string name="servers_update">サーバーリストを更新</string>
<string name="servers_updated">サーバーリストを更新しました</string>
<string name="servers_update_failed">サーバーリストを更新できませんでした: %1$s</string>
<string name="no_browser">このリンクを開けるアプリがありません</string>
</resources>
+1
View File
@@ -98,4 +98,5 @@
<string name="servers_update">Atnaujinti serverių sąrašą</string>
<string name="servers_updated">Serverių sąrašas atnaujintas</string>
<string name="servers_update_failed">Nepavyko atnaujinti serverių sąrašo: %1$s</string>
<string name="no_browser">Nerasta programėlės šiai nuorodai atidaryti</string>
</resources>
+1
View File
@@ -98,4 +98,5 @@
<string name="servers_update">Обновить список серверов</string>
<string name="servers_updated">Список серверов обновлён</string>
<string name="servers_update_failed">Не удалось обновить список серверов: %1$s</string>
<string name="no_browser">Не найдено приложение, чтобы открыть ссылку</string>
</resources>
+1
View File
@@ -98,4 +98,5 @@
<string name="servers_update">更新服务器列表</string>
<string name="servers_updated">服务器列表已更新</string>
<string name="servers_update_failed">无法更新服务器列表:%1$s</string>
<string name="no_browser">没有可以打开此链接的应用</string>
</resources>
+1
View File
@@ -99,4 +99,5 @@
<string name="servers_update">Update server list</string>
<string name="servers_updated">Server list updated</string>
<string name="servers_update_failed">Couldn\'t update the server list: %1$s</string>
<string name="no_browser">No app found to open this link</string>
</resources>