Updated on 2026-08-14

This commit is contained in:
Tangem 2024-01-23 12:06:45 +03:00
parent ea935d10f2
commit 0c4a135923
2 changed files with 28 additions and 8 deletions

View file

@ -11,8 +11,8 @@ internal object AttestationFailedDialog {
fun create(context: Context): AlertDialog {
return MaterialAlertDialogBuilder(context, R.style.CustomMaterialDialog).apply {
setTitle(R.string.attestation_online_failed_title)
setMessage(R.string.attestation_online_failed_body)
setTitle(R.string.common_error)
setMessage(R.string.issuer_signature_loading_failed)
setPositiveButton(R.string.ok) { dialog, _ ->
dialog.dismiss()
}

View file

@ -1,18 +1,38 @@
package com.tangem.feature.swap.router
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import java.lang.ref.WeakReference
class CustomTabsManager(private val context: WeakReference<Context>) {
fun openUrl(url: String) {
val customTabsIntent = CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(
CustomTabColorSchemeParams.Builder().build(),
)
.build()
context.get()?.let { customTabsIntent.launchUrl(it, Uri.parse(url)) }
val mContext = context.get() ?: return
val browserIntent = Intent()
.setAction(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setDataAndType(Uri.fromParts("http", "", null), "text/plain")
var possibleBrowsers =
mContext.packageManager.queryIntentActivities(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)
if (possibleBrowsers.isEmpty()) {
possibleBrowsers =
mContext.packageManager.queryIntentActivities(browserIntent, PackageManager.MATCH_ALL)
}
if (possibleBrowsers.isNotEmpty()) {
val customTabsIntent = CustomTabsIntent.Builder()
.setDefaultColorSchemeParams(
CustomTabColorSchemeParams.Builder().build(),
)
.build()
customTabsIntent.intent.setPackage(possibleBrowsers[0].activityInfo.packageName)
context.get()?.let { customTabsIntent.launchUrl(it, Uri.parse(url)) }
} else {
val browserIntent2 = Intent(Intent.ACTION_VIEW, Uri.parse(url))
mContext.startActivity(browserIntent2)
}
}
}