aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt10
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt6
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt6
3 files changed, 12 insertions, 10 deletions
diff --git a/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt b/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt
index 72740df..c925515 100644
--- a/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt
+++ b/taler-kotlin-android/src/main/java/net/taler/common/AndroidUtils.kt
@@ -16,6 +16,7 @@
package net.taler.common
+import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Context.CONNECTIVITY_SERVICE
import android.content.Intent
@@ -35,6 +36,7 @@ import android.text.format.DateUtils.FORMAT_SHOW_YEAR
import android.text.format.DateUtils.MINUTE_IN_MILLIS
import android.text.format.DateUtils.formatDateTime
import android.text.format.DateUtils.getRelativeTimeSpanString
+import android.util.Log
import android.view.View
import android.view.View.INVISIBLE
import android.view.View.VISIBLE
@@ -100,8 +102,12 @@ fun Context.showLogViewer() {
startActivity(lynxActivityIntent)
}
-fun Intent.isSafe(context: Context): Boolean {
- return context.packageManager.queryIntentActivities(this, MATCH_DEFAULT_ONLY).isNotEmpty()
+fun Fragment.startActivitySafe(intent: Intent) {
+ try {
+ startActivity(intent)
+ } catch (e: ActivityNotFoundException) {
+ Log.e("taler-kotlin-android", "Error starting $intent", e)
+ }
}
fun Fragment.navigate(directions: NavDirections) = findNavController().navigate(directions)
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
index 302e684..866b363 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -25,7 +25,7 @@ import android.view.MenuItem
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
-import net.taler.common.isSafe
+import net.taler.common.startActivitySafe
import net.taler.lib.common.Amount
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
@@ -80,9 +80,7 @@ abstract class TransactionDetailFragment : Fragment() {
val i = Intent().apply {
data = Uri.parse(info.fulfillmentUrl)
}
- if (i.isSafe(requireContext())) {
- orderSummaryView.setOnClickListener { startActivity(i) }
- }
+ orderSummaryView.setOnClickListener { startActivitySafe(i) }
}
orderIdView.text = getString(R.string.transaction_order_id, info.orderId)
}
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
index 26965ef..96782fd 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
@@ -22,7 +22,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import net.taler.common.isSafe
+import net.taler.common.startActivitySafe
import net.taler.common.toAbsoluteTime
import net.taler.wallet.R
import net.taler.wallet.cleanExchange
@@ -53,9 +53,7 @@ class TransactionWithdrawalFragment : TransactionDetailFragment() {
val i = Intent().apply {
data = Uri.parse(t.withdrawalDetails.bankConfirmationUrl)
}
- if (i.isSafe(requireContext())) {
- ui.confirmWithdrawalButton.setOnClickListener { startActivity(i) }
- }
+ ui.confirmWithdrawalButton.setOnClickListener { startActivitySafe(i) }
} else ui.confirmWithdrawalButton.visibility = View.GONE
ui.chosenAmountLabel.text = getString(R.string.amount_chosen)
ui.chosenAmountView.text =