diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/ui/dialogs/AttestationFailedDialog.kt b/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/ui/dialogs/AttestationFailedDialog.kt index ef9363f8a0..3e9df5885e 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/ui/dialogs/AttestationFailedDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/products/wallet/ui/dialogs/AttestationFailedDialog.kt @@ -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() } diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/router/CustomTabsManager.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/router/CustomTabsManager.kt index 15e39f08f3..565d27a3b8 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/router/CustomTabsManager.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/router/CustomTabsManager.kt @@ -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) { + 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) + } } } \ No newline at end of file