diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/FlexaRepository.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/FlexaRepository.kt index f84195e2..df4cea4f 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/FlexaRepository.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/repository/FlexaRepository.kt @@ -32,6 +32,8 @@ class FlexaRepositoryImpl( get() = BuildConfig.ZCASH_FLEXA_KEY.takeIf { it.isNotEmpty() } override fun init() { + if (publishableKey == null) return + scope.launch { val configuration = getFlexaClientConfiguration() if (configuration != null) { @@ -102,6 +104,7 @@ class FlexaRepositoryImpl( assetId = "bip122:00040fe8ec8471911baa1db1266ea15d/slip44:133", balance = zecBalance, symbol = "ZEC", + icon = "https://cryptologos.cc/logos/zcash-zec-logo.png" ) ), custodyModel = CustodyModel.LOCAL, diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt index af302a40..7514bb8b 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/WalletViewModel.kt @@ -20,6 +20,7 @@ import cash.z.ecc.sdk.type.fromResources import co.electriccoin.zcash.preference.EncryptedPreferenceProvider import co.electriccoin.zcash.preference.StandardPreferenceProvider import co.electriccoin.zcash.spackle.Twig +import co.electriccoin.zcash.ui.BuildConfig import co.electriccoin.zcash.ui.MainActivity import co.electriccoin.zcash.ui.common.model.OnboardingState import co.electriccoin.zcash.ui.common.model.WalletRestoringState @@ -276,7 +277,7 @@ class WalletViewModel( private suspend fun disconnectFlexa() = suspendCoroutine { cont -> - if (isFlexaAvailable()) { + if (isFlexaAvailable() && BuildConfig.ZCASH_FLEXA_KEY.isNotEmpty()) { Flexa.buildIdentity().build().disconnect() cont.resume(Unit) } else { diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/AndroidIntegrations.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/AndroidIntegrations.kt index cb417c1a..e716b741 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/AndroidIntegrations.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/AndroidIntegrations.kt @@ -1,6 +1,7 @@ package co.electriccoin.zcash.ui.screen.integrations import android.net.Uri +import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.browser.customtabs.CustomTabsIntent import androidx.compose.runtime.Composable @@ -8,6 +9,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.lifecycle.compose.collectAsStateWithLifecycle import co.electriccoin.zcash.di.koinActivityViewModel +import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.common.compose.LocalActivity import co.electriccoin.zcash.ui.common.compose.LocalNavController import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel @@ -55,6 +57,12 @@ internal fun WrapIntegrations() { } } + LaunchedEffect(Unit) { + viewModel.showFlexaErrorToastCommand.collect { + Toast.makeText(activity, R.string.integrations_flexa_key_missing, Toast.LENGTH_LONG).show() + } + } + BackHandler { viewModel.onBack() } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/viewmodel/IntegrationsViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/viewmodel/IntegrationsViewModel.kt index 88ac50ce..21e9880a 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/viewmodel/IntegrationsViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/integrations/viewmodel/IntegrationsViewModel.kt @@ -59,6 +59,7 @@ class IntegrationsViewModel( val backNavigationCommand = MutableSharedFlow() val flexaNavigationCommand = MutableSharedFlow() val coinbaseNavigationCommand = MutableSharedFlow() + val showFlexaErrorToastCommand = MutableSharedFlow() private val versionInfo = getVersionInfo() private val isDebug = versionInfo.let { it.isDebuggable && !it.isRunningUnderTestService } @@ -143,7 +144,11 @@ class IntegrationsViewModel( private fun onFlexaClicked() = viewModelScope.launch { - flexaNavigationCommand.emit(Unit) + if (BuildConfig.ZCASH_FLEXA_KEY.isEmpty()) { + showFlexaErrorToastCommand.emit(Unit) + } else { + flexaNavigationCommand.emit(Unit) + } } fun onFlexaResultCallback(transaction: Result) = diff --git a/ui-lib/src/main/res/ui/integrations/values/strings.xml b/ui-lib/src/main/res/ui/integrations/values/strings.xml index 0f1552fc..247d44f6 100644 --- a/ui-lib/src/main/res/ui/integrations/values/strings.xml +++ b/ui-lib/src/main/res/ui/integrations/values/strings.xml @@ -7,4 +7,5 @@ Version %1$s During the Restore process, it is not possible to use payment integrations. Authenticate yourself to pay with Flexa + Flexa key missing