From 3e9ddd87203899a11e6887e448bf4510cb2b9e8a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 2 Apr 2023 15:26:18 +0200 Subject: ui: never throw on link clicks Signed-off-by: Jason A. Donenfeld --- .../main/java/com/wireguard/android/preference/DonatePreference.kt | 5 +++-- .../main/java/com/wireguard/android/preference/VersionPreference.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'ui/src/main/java/com/wireguard') diff --git a/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt b/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt index 57202c81..8a9916a9 100644 --- a/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt +++ b/ui/src/main/java/com/wireguard/android/preference/DonatePreference.kt @@ -6,11 +6,11 @@ package com.wireguard.android.preference import android.app.AlertDialog -import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import android.net.Uri import android.util.AttributeSet +import android.widget.Toast import androidx.preference.Preference import com.wireguard.android.BuildConfig import com.wireguard.android.R @@ -32,7 +32,8 @@ class DonatePreference(context: Context, attrs: AttributeSet?) : Preference(cont intent.data = Uri.parse("https://www.wireguard.com/donations/") try { context.startActivity(intent) - } catch (ignored: ActivityNotFoundException) { + } catch (e: Throwable) { + Toast.makeText(context, e.localizedMessage, Toast.LENGTH_SHORT).show() } } } \ No newline at end of file diff --git a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.kt b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.kt index 31c751d2..9993936a 100644 --- a/ui/src/main/java/com/wireguard/android/preference/VersionPreference.kt +++ b/ui/src/main/java/com/wireguard/android/preference/VersionPreference.kt @@ -4,11 +4,11 @@ */ package com.wireguard.android.preference -import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import android.net.Uri import android.util.AttributeSet +import android.widget.Toast import androidx.preference.Preference import com.wireguard.android.Application import com.wireguard.android.BuildConfig @@ -33,7 +33,8 @@ class VersionPreference(context: Context, attrs: AttributeSet?) : Preference(con intent.data = Uri.parse("https://www.wireguard.com/") try { context.startActivity(intent) - } catch (_: ActivityNotFoundException) { + } catch (e: Throwable) { + Toast.makeText(context, e.localizedMessage, Toast.LENGTH_SHORT).show() } } -- cgit v1.2.3