Flexa optimization (#1661)
* Flexa optimization * Code cleanup * Code cleanup
This commit is contained in:
parent
438071a04f
commit
e638499de8
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ class IntegrationsViewModel(
|
|||
val backNavigationCommand = MutableSharedFlow<Unit>()
|
||||
val flexaNavigationCommand = MutableSharedFlow<Unit>()
|
||||
val coinbaseNavigationCommand = MutableSharedFlow<String>()
|
||||
val showFlexaErrorToastCommand = MutableSharedFlow<Unit>()
|
||||
|
||||
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<Transaction>) =
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
<string name="integrations_version">Version <xliff:g id="version" example="1.2.1">%1$s</xliff:g></string>
|
||||
<string name="integrations_disabled_info">During the Restore process, it is not possible to use payment integrations.</string>
|
||||
<string name="integrations_biometric_message">Authenticate yourself to pay with Flexa</string>
|
||||
<string name="integrations_flexa_key_missing">Flexa key missing</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue