diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c59000924..7a2dab680 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -19,7 +19,7 @@ kotlin { jvmToolchain(17) } -// soralution 141 3.8.6.1 2024.10.29 +// soralution 142 3.8.6.2 2024.10.30 // sora dae 118 3.8.5.3 2024.10.23 android { @@ -30,8 +30,8 @@ android { applicationId = "jp.co.soramitsu.sora" minSdk = 26 targetSdk = 34 - versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 141 - versionName = "3.8.6.1" + versionCode = System.getenv("CI_BUILD_ID")?.toInt() ?: 142 + versionName = "3.8.6.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true // resConfigs "en", "ru", "es", "fr", "de", "nb", "in", "tr", "ar" @@ -172,7 +172,7 @@ play { serviceAccountCredentials = file(System.getenv("CI_PLAY_KEY") ?: "../key/fake.json") track = "internal" releaseStatus = ReleaseStatus.DRAFT - releaseName = "3.8.6.1 - SORA Card Improvements" + releaseName = "3.8.6.2 - SORA Card Improvements" defaultToAppBundles = true } diff --git a/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/BasicBannerCard.kt b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/BasicBannerCard.kt index a397f0d47..cfb154389 100644 --- a/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/BasicBannerCard.kt +++ b/common/src/main/java/jp/co/soramitsu/common/presentation/compose/components/BasicBannerCard.kt @@ -71,13 +71,14 @@ fun BasicBannerCard( title: String, description: String, button: String, + buttonEnabled: Boolean = true, onButtonClicked: () -> Unit, closeEnabled: Boolean, onCloseCard: () -> Unit, ) { ContentCard( modifier = Modifier.fillMaxWidth(), - onClick = onButtonClicked, + onClick = if (buttonEnabled) onButtonClicked else null, ) { Box( modifier = Modifier @@ -103,6 +104,7 @@ fun BasicBannerCard( description = description, button = button, onStartClicked = onButtonClicked, + buttonEnabled = buttonEnabled, ) Image( @@ -144,6 +146,7 @@ private fun CardContent( title: String, description: String, button: String, + buttonEnabled: Boolean, onStartClicked: () -> Unit, ) { Column( @@ -174,6 +177,7 @@ private fun CardContent( .padding(top = Dimens.x1_5), text = button, size = Size.ExtraSmall, + enabled = buttonEnabled, order = Order.PRIMARY, onClick = onStartClicked, ) @@ -188,6 +192,7 @@ private fun PreviewBasicBannerCard1() { title = "Some title of banner card, let it be longeeerr", description = "Long description of banner card, The quick brown fox jumps over the lazy dog, The quick brown fox jumps over the lazy dog.And I, even I Artaxerxes the king, do make a decree to all the treasurers which are beyond the river, that whatsoever Ezra the priest, the scribe of the law of the God of heaven, shall require of you, it be done speedily", button = "Just button title", + buttonEnabled = true, closeEnabled = true, onCloseCard = {}, onButtonClicked = {}, @@ -202,6 +207,7 @@ private fun PreviewBasicBannerCard12() { title = "Some title", description = "Long description of banner", button = "Just button title", + buttonEnabled = true, closeEnabled = false, onCloseCard = {}, onButtonClicked = {}, @@ -216,6 +222,7 @@ private fun PreviewBasicBannerCard2() { title = "Title", description = "Description", button = "Button", + buttonEnabled = true, closeEnabled = true, onCloseCard = {}, onButtonClicked = {}, diff --git a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt index 5e3162e8f..306810f7e 100644 --- a/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt +++ b/common_wallet/src/main/java/jp/co/soramitsu/common_wallet/presentation/compose/states/CardState.kt @@ -133,7 +133,7 @@ data class SoraCardState( override val loading: Boolean, ) : BasicBannerCardState(loading) -data object BuyXorState : BasicBannerCardState(false) +data class BuyXorState(val canStartGatehub: Boolean) : BasicBannerCardState(false) data object ReferralState : BasicBannerCardState(false) diff --git a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt index 70986ca3b..a0cabcdbb 100644 --- a/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt +++ b/feature_assets_impl/src/main/java/jp/co/soramitsu/feature_assets_impl/presentation/screens/assetdetails/AssetDetailsViewModel.kt @@ -197,7 +197,7 @@ class AssetDetailsViewModel @AssistedInject constructor( null }, isTransferableBalanceAvailable = asset.balance.transferable > BigDecimal.ZERO, - buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId), + buyCryptoAvailable = soraCard && (asset.token.id == SubstrateOptionsProvider.feeAssetId) && soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(), ) ) } @@ -319,7 +319,6 @@ class AssetDetailsViewModel @AssistedInject constructor( } fun onBuyCrypto() { - if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) - _launchSoraCardSignIn.value = createSoraCardGateHubContract() + _launchSoraCardSignIn.value = createSoraCardGateHubContract() } } diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt index 439e20f53..f76b49ed5 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreen.kt @@ -85,15 +85,17 @@ internal fun ProfileItems( icon = R.drawable.ic_buy_crypto, onClick = onSoraCardClick, ) - CategoryItem( - modifier = Modifier - .testTagAsId("BuyXor") - .padding(top = Dimens.x2), - title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title), - subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle), - icon = R.drawable.ic_settings_buy_crypto, - onClick = onBuyCrypto, - ) + if (state.canStartGatehubOnboarding) { + CategoryItem( + modifier = Modifier + .testTagAsId("BuyXor") + .padding(top = Dimens.x2), + title = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_title), + subtitle = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle), + icon = R.drawable.ic_settings_buy_crypto, + onClick = onBuyCrypto, + ) + } } CategoryItem( modifier = Modifier @@ -179,6 +181,7 @@ private fun PreviewProfile() { soraCardStatusStringRes = R.string.more_menu_sora_card_subtitle, soraCardStatusIconDrawableRes = R.drawable.ic_connection_indicator_green, soraCardIbanError = null, + canStartGatehubOnboarding = true, ), onAccountsClick = { }, onSoraCardClick = { }, diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreenState.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreenState.kt index 4cea16d4e..e37919e17 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreenState.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileScreenState.kt @@ -44,6 +44,7 @@ internal data class ProfileScreenState( val soraCardStatusStringRes: Int, val soraCardIbanError: String?, val soraCardStatusIconDrawableRes: Int?, + val canStartGatehubOnboarding: Boolean, ) internal val initialProfileScreenState = @@ -56,4 +57,5 @@ internal val initialProfileScreenState = soraCardStatusIconDrawableRes = null, soraCardNeedUpdate = false, soraCardIbanError = null, + canStartGatehubOnboarding = false, ) diff --git a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileViewModel.kt b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileViewModel.kt index 2700667cc..a9795e776 100644 --- a/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileViewModel.kt +++ b/feature_main_impl/src/main/java/jp/co/soramitsu/feature_main_impl/presentation/profile/ProfileViewModel.kt @@ -138,6 +138,7 @@ class ProfileViewModel @Inject constructor( soraCardStatusIconDrawableRes = soraCardStatusIconDrawableRes, soraCardEnabled = soraConfigManager.getSoraCard(), soraCardNeedUpdate = it.needInstallUpdate, + canStartGatehubOnboarding = it.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(), ) } .launchIn(viewModelScope) @@ -201,9 +202,7 @@ class ProfileViewModel @Inject constructor( } fun showBuyCrypto() { - if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) { - _launchSoraCardSignIn.value = createSoraCardGateHubContract() - } + _launchSoraCardSignIn.value = createSoraCardGateHubContract() } fun showSelectNode() { diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsScreen.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsScreen.kt index ff615b76f..e8930a46c 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsScreen.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsScreen.kt @@ -155,6 +155,7 @@ private fun PreviewSoraCardDetailsScreen() { balance = "3665.50", phone = "987654", soraCardMenuActions = SoraCardMenuAction.entries, + canStartGatehubFlow = true, ), soraCardReferralBannerCardState = true, soraCardRecentActivitiesCardState = SoraCardRecentActivitiesCardState( diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsViewModel.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsViewModel.kt index 09c63ea9f..18e63f6be 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsViewModel.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardDetailsViewModel.kt @@ -81,6 +81,7 @@ class SoraCardDetailsViewModel @Inject constructor( balance = null, phone = null, soraCardMenuActions = SoraCardMenuAction.entries, + canStartGatehubFlow = false, ), soraCardSettingsCard = SoraCardSettingsCardState( soraCardSettingsOptions = SoraCardSettingsOption.entries, @@ -116,10 +117,11 @@ class SoraCardDetailsViewModel @Inject constructor( soraCardMainSoraContentCardState = local.soraCardMainSoraContentCardState.copy( balance = basicStatus.ibanInfo?.balance, phone = phoneFormatted, + canStartGatehubFlow = basicStatus.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding(), ), soraCardSettingsCard = local.soraCardSettingsCard?.copy( phone = phoneFormatted.orEmpty(), - ) + ), ) } } @@ -165,10 +167,11 @@ class SoraCardDetailsViewModel @Inject constructor( } } + /** + * only clickable if IBAN is issued + */ fun onExchangeXorClick() { - if (soraCardInteractor.basicStatus.value.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) { - _launchSoraCard.value = createSoraCardGateHubContract() - } + _launchSoraCard.value = createSoraCardGateHubContract() } fun onSettingsOptionClick(position: Int, context: Context?) { diff --git a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardMainSoraContentCard.kt b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardMainSoraContentCard.kt index 852c70fcd..35a7779b6 100644 --- a/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardMainSoraContentCard.kt +++ b/feature_sora_card_impl/src/main/java/jp/co/soramitsu/feature_sora_card_impl/presentation/details/SoraCardMainSoraContentCard.kt @@ -70,6 +70,7 @@ data class SoraCardMainSoraContentCardState( val phone: String?, val actionsEnabled: Boolean = false, val soraCardMenuActions: List, + val canStartGatehubFlow: Boolean, ) { val menuState: List @@ -180,7 +181,7 @@ fun SoraCardMainSoraContentCard( .padding(horizontal = Dimens.x1) .weight(1f), size = Size.Large, - enabled = true, + enabled = soraCardMainSoraContentCardState.canStartGatehubFlow, order = Order.PRIMARY, onClick = onExchangeXor, text = stringResource(id = jp.co.soramitsu.oauth.R.string.exchange_xor), @@ -206,7 +207,8 @@ private fun PreviewMainSoraContentCard() { soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState( balance = "3644.50", phone = "", - soraCardMenuActions = SoraCardMenuAction.entries + soraCardMenuActions = SoraCardMenuAction.entries, + canStartGatehubFlow = true, ), onShowMoreClick = {}, onIconButtonClick = { _ -> }, @@ -222,7 +224,8 @@ private fun PreviewMainSoraContentCard2() { soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState( balance = "3644.50", phone = "", - soraCardMenuActions = SoraCardMenuAction.entries + soraCardMenuActions = SoraCardMenuAction.entries, + canStartGatehubFlow = true, ), onShowMoreClick = {}, onIconButtonClick = { _ -> }, @@ -238,7 +241,8 @@ private fun PreviewMainSoraContentCard3() { soraCardMainSoraContentCardState = SoraCardMainSoraContentCardState( balance = null, phone = "", - soraCardMenuActions = SoraCardMenuAction.entries + soraCardMenuActions = SoraCardMenuAction.entries, + canStartGatehubFlow = true, ), onShowMoreClick = {}, onIconButtonClick = { _ -> }, diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/BuyXorCard.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/BuyXorCard.kt index 15daa0795..f0d3ab5eb 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/BuyXorCard.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/BuyXorCard.kt @@ -42,6 +42,7 @@ import jp.co.soramitsu.common.presentation.compose.theme.SoraAppTheme @Composable fun BuyXorCard( + buttonEnabled: Boolean, onCloseCard: () -> Unit, onBuyXorClicked: () -> Unit, ) { @@ -50,6 +51,7 @@ fun BuyXorCard( title = stringResource(id = R.string.buy_crypto_buy_xor_banner_title), description = stringResource(id = R.string.buy_crypto_buy_xor_with_fiat_subtitle), button = stringResource(id = R.string.common_buy_xor), + buttonEnabled = buttonEnabled, closeEnabled = true, onButtonClicked = onBuyXorClicked, onCloseCard = onCloseCard, @@ -61,6 +63,7 @@ fun BuyXorCard( private fun PreviewBuyXorCard01() { SoraAppTheme { BuyXorCard( + buttonEnabled = true, onCloseCard = {}, onBuyXorClicked = {}, ) @@ -72,6 +75,7 @@ private fun PreviewBuyXorCard01() { private fun PreviewBuyXorCard02() { SoraAppTheme { BuyXorCard( + buttonEnabled = true, onCloseCard = {}, onBuyXorClicked = {}, ) diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt index 646d626ac..9e0de8070 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubFragment.kt @@ -210,8 +210,9 @@ private fun CardsMainScreen( onStartClicked = onBackupBannerClick, ) } - BuyXorState -> { + is BuyXorState -> { BuyXorCard( + buttonEnabled = cardState.canStartGatehub, onBuyXorClicked = onBuyXorClick, onCloseCard = onBuyXorClose, ) @@ -260,7 +261,7 @@ private fun PreviewCardsMainScreen() { accountAddress = "", loading = true, cards = listOf( - BuyXorState, ReferralState, BackupWalletState, + BuyXorState(true), ReferralState, BackupWalletState, ), ), {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} diff --git a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt index 3a87d7315..0e92b209c 100644 --- a/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt +++ b/feature_wallet_impl/src/main/java/jp/co/soramitsu/feature_wallet_impl/presentation/cardshub/CardsHubViewModel.kt @@ -74,6 +74,7 @@ import jp.co.soramitsu.feature_main_api.launcher.MainRouter import jp.co.soramitsu.feature_polkaswap_api.domain.interfaces.PoolsInteractor import jp.co.soramitsu.feature_polkaswap_api.launcher.PolkaswapRouter import jp.co.soramitsu.feature_referral_api.ReferralRouter +import jp.co.soramitsu.feature_sora_card_api.domain.SoraCardBasicStatus import jp.co.soramitsu.feature_sora_card_api.domain.SoraCardInteractor import jp.co.soramitsu.feature_sora_card_api.util.createSoraCardContract import jp.co.soramitsu.feature_sora_card_api.util.createSoraCardGateHubContract @@ -218,9 +219,13 @@ class CardsHubViewModel @Inject constructor( } CardHubType.BUY_XOR_TOKEN -> { - flowOf( - cardHub to BuyXorState - ) + soraCardInteractor.basicStatus + .map { soraCardBasicStatus: SoraCardBasicStatus -> + cardHub to BuyXorState(soraCardBasicStatus.ibanInfo?.ibanStatus.readyToStartGatehubOnboarding()) + } + .onStart { + cardHub to BuyXorState(false) + } } } } @@ -454,9 +459,7 @@ class CardsHubViewModel @Inject constructor( if (!connectionManager.isConnected) return if (soraCardInteractor.basicStatus.value.initialized) { _state.value.cards.filterIsInstance().firstOrNull()?.let { card -> - if (card.ibanBalance?.ibanStatus.readyToStartGatehubOnboarding()) { - _launchSoraCardSignIn.value = createSoraCardGateHubContract() - } + _launchSoraCardSignIn.value = createSoraCardGateHubContract() } } }