From a425c2fab839f1cb97f5b23c2db3e71d24b05cb7 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Fri, 25 Oct 2024 17:12:21 +0200 Subject: [PATCH 01/11] Add colored asset icon support --- .../nova/ChainMappingIntegrationTest.kt | 7 ++- .../nova/common/data/model/AssetIconMode.kt | 5 ++ .../data/repository/AssetsIconModeService.kt | 54 +++++++++++++++++++ ...Repository.kt => AssetsViewModeService.kt} | 6 +-- .../nova/common/di/CommonApi.kt | 7 ++- .../nova/common/di/modules/CommonModule.kt | 12 +++-- .../res/drawable/ic_token_dot_colored.xml | 27 ++++++++++ .../src/main/res/layout/view_labeled_text.xml | 4 +- .../di/AssetsFeatureDependencies.kt | 4 +- .../feature_assets/di/AssetsFeatureModule.kt | 6 +-- .../assets/list/AssetsListInteractor.kt | 8 +-- .../assets/search/AssetSearchInteractor.kt | 12 ++--- .../domain/tokens/add/AddTokensInteractor.kt | 2 +- .../balance/list/di/BalanceListModule.kt | 6 +-- .../tokens/manage/ManageTokensAdapter.kt | 4 +- .../res/layout/fragment_balance_detail.xml | 5 +- .../layout/item_manage_token_multichain.xml | 2 +- .../main/res/layout/item_network_asset.xml | 6 +-- .../src/main/res/layout/item_token_asset.xml | 6 +-- .../res/layout/item_token_asset_group.xml | 6 +-- feature-assets/src/main/res/values/styles.xml | 1 - .../domain/sign/evm/EvmSignInteractor.kt | 2 +- .../domain/utils/CustomChainFactory.kt | 2 +- .../presentation/view/SwapAssetView.kt | 2 - .../src/main/res/layout/view_swap_asset.xml | 4 +- .../presentation/views/SwapAmountInputView.kt | 3 -- .../res/layout/view_swap_amount_input.xml | 6 +-- .../main/res/layout/item_asset_selector.xml | 1 - .../main/res/layout/view_asset_selector.xml | 4 +- .../res/layout/view_choose_amount_input.xml | 2 - .../repository/RealChainAssetRepository.kt | 3 +- runtime/build.gradle | 16 +++--- .../nova/runtime/di/ChainRegistryModule.kt | 7 ++- .../nova/runtime/di/RuntimeDependencies.kt | 3 ++ .../nova/runtime/di/RuntimeModule.kt | 11 +++- .../runtime/multiNetwork/ChainRegistry.kt | 11 ++-- .../chain/mappers/DomainToLocalChainMapper.kt | 2 +- .../chain/mappers/LocalToDomainChainMapper.kt | 27 +++++++--- .../RemoteToDomainChainMapperFacade.kt | 7 ++- .../runtime/multiNetwork/chain/model/Chain.kt | 16 +++++- 40 files changed, 224 insertions(+), 95 deletions(-) create mode 100644 common/src/main/java/io/novafoundation/nova/common/data/model/AssetIconMode.kt create mode 100644 common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt rename common/src/main/java/io/novafoundation/nova/common/data/repository/{AssetsViewModeRepository.kt => AssetsViewModeService.kt} (93%) create mode 100644 common/src/main/res/drawable/ic_token_dot_colored.xml diff --git a/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt b/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt index bb0a481b88..3ae472fde7 100644 --- a/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt +++ b/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt @@ -4,6 +4,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.gson.Gson import androidx.test.platform.app.InstrumentationRegistry import dagger.Component +import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.di.CommonApi import io.novafoundation.nova.common.di.FeatureContainer @@ -100,7 +101,8 @@ class ChainMappingIntegrationTest { assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson + gson = gson, + assetIconMode = AssetIconMode.COLORED ) } @@ -123,7 +125,8 @@ class ChainMappingIntegrationTest { assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson + gson = gson, + assetIconMode = AssetIconMode.COLORED ) } } diff --git a/common/src/main/java/io/novafoundation/nova/common/data/model/AssetIconMode.kt b/common/src/main/java/io/novafoundation/nova/common/data/model/AssetIconMode.kt new file mode 100644 index 0000000000..76fda50d5f --- /dev/null +++ b/common/src/main/java/io/novafoundation/nova/common/data/model/AssetIconMode.kt @@ -0,0 +1,5 @@ +package io.novafoundation.nova.common.data.model + +enum class AssetIconMode { + COLORED, WHITE +} diff --git a/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt new file mode 100644 index 0000000000..7d75ee2560 --- /dev/null +++ b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt @@ -0,0 +1,54 @@ +package io.novafoundation.nova.common.data.repository + +import io.novafoundation.nova.common.data.model.AssetIconMode +import io.novafoundation.nova.common.data.storage.Preferences +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.withContext + +interface AssetsIconModeService { + fun assetsIconModeFlow(): Flow + + suspend fun setAssetsIconMode(assetsViewMode: AssetIconMode) + + fun getIconMode(): AssetIconMode +} + +private const val PREFS_ASSETS_ICON_MODE = "PREFS_ASSETS_ICON_MODE" +private val ASSET_ICON_MODE_DEFAULT = AssetIconMode.COLORED + +class RealAssetsIconModeService( + private val preferences: Preferences +) : AssetsIconModeService { + + override fun assetsIconModeFlow(): Flow { + return preferences.stringFlow(PREFS_ASSETS_ICON_MODE) + .map { + it?.fromPrefsValue() ?: ASSET_ICON_MODE_DEFAULT + } + } + + override suspend fun setAssetsIconMode(assetsViewMode: AssetIconMode) = withContext(Dispatchers.IO) { + preferences.putString(PREFS_ASSETS_ICON_MODE, assetsViewMode.toPrefsValue()) + } + + override fun getIconMode(): AssetIconMode { + return preferences.getString(PREFS_ASSETS_ICON_MODE)?.fromPrefsValue() ?: ASSET_ICON_MODE_DEFAULT + } + + private fun AssetIconMode.toPrefsValue(): String { + return when (this) { + AssetIconMode.COLORED -> "colored" + AssetIconMode.WHITE -> "solid" + } + } + + private fun String.fromPrefsValue(): AssetIconMode? { + return when (this) { + "colored" -> AssetIconMode.COLORED + "solid" -> AssetIconMode.WHITE + else -> null + } + } +} diff --git a/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeRepository.kt b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeService.kt similarity index 93% rename from common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeRepository.kt rename to common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeService.kt index d1438523eb..cf3d27cfbd 100644 --- a/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeRepository.kt +++ b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsViewModeService.kt @@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext -interface AssetsViewModeRepository { +interface AssetsViewModeService { fun assetsViewModeFlow(): Flow suspend fun setAssetsViewMode(assetsViewMode: AssetViewMode) } @@ -15,9 +15,9 @@ interface AssetsViewModeRepository { private const val PREFS_ASSETS_VIEW_MODE = "PREFS_ASSETS_VIEW_MODE" private val ASSET_VIEW_MODE_DEFAULT = AssetViewMode.TOKENS -class RealAssetsViewModeRepository( +class RealAssetsViewModeService( private val preferences: Preferences -) : AssetsViewModeRepository { +) : AssetsViewModeService { override fun assetsViewModeFlow(): Flow { return preferences.stringFlow(PREFS_ASSETS_VIEW_MODE) diff --git a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt index 0da563e315..02bafdac71 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt @@ -14,7 +14,8 @@ import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser import io.novafoundation.nova.common.data.network.rpc.SocketSingleRequestExecutor -import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository +import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeService import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 import io.novafoundation.nova.common.data.secrets.v2.SecretStoreV2 @@ -155,7 +156,9 @@ interface CommonApi { fun buildTypeProvider(): BuildTypeProvider - fun assetsViewModeRepository(): AssetsViewModeRepository + fun assetsViewModeRepository(): AssetsViewModeService + + fun assetsIconModeService(): AssetsIconModeService val systemCallExecutor: SystemCallExecutor diff --git a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt index 3715d0f894..c74a772484 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt @@ -19,9 +19,11 @@ import io.novafoundation.nova.common.data.RealGoogleApiAvailabilityProvider import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.memory.RealComputationalCache import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser -import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository +import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeService import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository -import io.novafoundation.nova.common.data.repository.RealAssetsViewModeRepository +import io.novafoundation.nova.common.data.repository.RealAssetsIconModeService +import io.novafoundation.nova.common.data.repository.RealAssetsViewModeService import io.novafoundation.nova.common.data.repository.RealBannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1Impl @@ -352,5 +354,9 @@ class CommonModule { @Provides @ApplicationScope - fun assetsViewModeRepository(preferences: Preferences): AssetsViewModeRepository = RealAssetsViewModeRepository(preferences) + fun assetsViewModeService(preferences: Preferences): AssetsViewModeService = RealAssetsViewModeService(preferences) + + @Provides + @ApplicationScope + fun assetsIconModeService(preferences: Preferences): AssetsIconModeService = RealAssetsIconModeService(preferences) } diff --git a/common/src/main/res/drawable/ic_token_dot_colored.xml b/common/src/main/res/drawable/ic_token_dot_colored.xml new file mode 100644 index 0000000000..6bf4dc417f --- /dev/null +++ b/common/src/main/res/drawable/ic_token_dot_colored.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/common/src/main/res/layout/view_labeled_text.xml b/common/src/main/res/layout/view_labeled_text.xml index 79b30095ba..812438890f 100644 --- a/common/src/main/res/layout/view_labeled_text.xml +++ b/common/src/main/res/layout/view_labeled_text.xml @@ -16,7 +16,9 @@ android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:src="@drawable/ic_token_dot_colored" + tools:visibility="visible" /> { val filter = { asset: Asset -> asset.token.configuration.buyProviders.isNotEmpty() } - return assetsViewModeRepository.assetsViewModeFlow().flatMapLatest { viewMode -> + return assetsViewModeService.assetsViewModeFlow().flatMapLatest { viewMode -> when (viewMode) { AssetViewMode.NETWORKS -> searchAssetsByNetworksInternalFlow(queryFlow, externalBalancesFlow, filter = filter) .map { AssetFlowSearchResult.ByNetworks(it) } @@ -68,7 +68,7 @@ class AssetSearchInteractor( ): Flow { val filter = { asset: Asset -> asset.transferableInPlanks.isPositive() } - return assetsViewModeRepository.assetsViewModeFlow().flatMapLatest { viewMode -> + return assetsViewModeService.assetsViewModeFlow().flatMapLatest { viewMode -> when (viewMode) { AssetViewMode.NETWORKS -> searchAssetsByNetworksInternalFlow( queryFlow, @@ -106,7 +106,7 @@ class AssetSearchInteractor( filter } - return assetsViewModeRepository.assetsViewModeFlow().flatMapLatest { viewMode -> + return assetsViewModeService.assetsViewModeFlow().flatMapLatest { viewMode -> when (viewMode) { AssetViewMode.NETWORKS -> searchAssetsByNetworksInternalFlow(queryFlow, externalBalancesFlow, filterFlow = filterFlow) .map { AssetFlowSearchResult.ByNetworks(it) } @@ -121,7 +121,7 @@ class AssetSearchInteractor( queryFlow: Flow, externalBalancesFlow: Flow>, ): Flow { - return assetsViewModeRepository.assetsViewModeFlow().flatMapLatest { viewMode -> + return assetsViewModeService.assetsViewModeFlow().flatMapLatest { viewMode -> when (viewMode) { AssetViewMode.NETWORKS -> searchAssetsByNetworksInternalFlow(queryFlow, externalBalancesFlow, filter = null) .map { AssetFlowSearchResult.ByNetworks(it) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/add/AddTokensInteractor.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/add/AddTokensInteractor.kt index 06b9c5f640..170b42b074 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/add/AddTokensInteractor.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/add/AddTokensInteractor.kt @@ -77,7 +77,7 @@ class RealAddTokensInteractor( val priceId = coinGeckoLinkParser.parse(customErc20Token.priceLink).getOrNull()?.priceId val asset = Chain.Asset( - iconUrl = null, + icon = null, id = chainAssetIdOfErc20Token(customErc20Token.contract), priceId = priceId, chainId = customErc20Token.chainId, diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt index dfdcbc7bc4..bd955e79e0 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt @@ -6,7 +6,7 @@ import androidx.lifecycle.ViewModelProvider import dagger.Module import dagger.Provides import dagger.multibindings.IntoMap -import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository +import io.novafoundation.nova.common.data.repository.AssetsViewModeService import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey @@ -37,8 +37,8 @@ class BalanceListModule { accountRepository: AccountRepository, nftRepository: NftRepository, bannerVisibilityRepository: BannerVisibilityRepository, - assetsViewModeRepository: AssetsViewModeRepository - ) = AssetsListInteractor(accountRepository, nftRepository, bannerVisibilityRepository, assetsViewModeRepository) + assetsViewModeService: AssetsViewModeService + ) = AssetsListInteractor(accountRepository, nftRepository, bannerVisibilityRepository, assetsViewModeService) @Provides @ScreenScope diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt index c03b01efd9..ff3b442deb 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt @@ -10,7 +10,6 @@ import io.novafoundation.nova.common.list.BaseViewHolder import io.novafoundation.nova.common.list.PayloadGenerator import io.novafoundation.nova.common.list.resolvePayload import io.novafoundation.nova.common.utils.inflateChild -import io.novafoundation.nova.common.utils.setImageTintRes import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R @@ -91,8 +90,9 @@ class ManageTokensViewHolder( itemManageTokenMultichainEnabled.isChecked = item.enabled itemManageTokenMultichainEnabled.isEnabled = item.switchable + itemManageTokenMultichainIcon.alpha = if (item.enabled) 1f else 0.48f + val contentColorRes = if (item.enabled) R.color.text_primary else R.color.text_secondary - itemManageTokenMultichainIcon.setImageTintRes(contentColorRes) itemManageTokenMultichainSymbol.setTextColorRes(contentColorRes) } diff --git a/feature-assets/src/main/res/layout/fragment_balance_detail.xml b/feature-assets/src/main/res/layout/fragment_balance_detail.xml index 83c3fd3dc5..420e7a9470 100644 --- a/feature-assets/src/main/res/layout/fragment_balance_detail.xml +++ b/feature-assets/src/main/res/layout/fragment_balance_detail.xml @@ -53,8 +53,7 @@ app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="@+id/balanceDetailTokenName" - app:tint="@color/icon_primary" /> + app:layout_constraintTop_toTopOf="@+id/balanceDetailTokenName" /> + tools:text="$10.25" /> + tools:src="@drawable/ic_token_dot_colored" /> + tools:src="@drawable/ic_token_dot_colored" /> + tools:text="DOT" /> + tools:src="@drawable/ic_token_dot_colored" /> + tools:text="DOT" /> + tools:src="@drawable/ic_token_dot_colored" /> + tools:text="DOT" /> diff --git a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt index fd8cea9162..9d45570312 100644 --- a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt +++ b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt @@ -311,7 +311,7 @@ class EvmSignInteractor( val chainCurrency = evmChain.nativeCurrency return Chain.Asset( - iconUrl = evmChain.iconUrl, + icon = evmChain.iconUrl?.let { Chain.Icon(it) }, id = 0, priceId = null, chainId = evmChain.chainId, diff --git a/feature-settings-impl/src/main/java/io/novafoundation/nova/feature_settings_impl/domain/utils/CustomChainFactory.kt b/feature-settings-impl/src/main/java/io/novafoundation/nova/feature_settings_impl/domain/utils/CustomChainFactory.kt index 2a6ec8f606..f63fb16290 100644 --- a/feature-settings-impl/src/main/java/io/novafoundation/nova/feature_settings_impl/domain/utils/CustomChainFactory.kt +++ b/feature-settings-impl/src/main/java/io/novafoundation/nova/feature_settings_impl/domain/utils/CustomChainFactory.kt @@ -91,7 +91,7 @@ class CustomChainFactory( id = 0, name = payload.chainName, enabled = true, - iconUrl = prefilledUtilityAsset?.iconUrl, + icon = prefilledUtilityAsset?.icon, priceId = priceId, chainId = chainId, symbol = payload.tokenSymbol.asTokenSymbol(), diff --git a/feature-swap-api/src/main/java/io/novafoundation/nova/feature_swap_api/presentation/view/SwapAssetView.kt b/feature-swap-api/src/main/java/io/novafoundation/nova/feature_swap_api/presentation/view/SwapAssetView.kt index adfe97ee92..dfd7591b82 100644 --- a/feature-swap-api/src/main/java/io/novafoundation/nova/feature_swap_api/presentation/view/SwapAssetView.kt +++ b/feature-swap-api/src/main/java/io/novafoundation/nova/feature_swap_api/presentation/view/SwapAssetView.kt @@ -9,7 +9,6 @@ import io.novafoundation.nova.common.di.FeatureUtils import io.novafoundation.nova.common.utils.WithContextExtensions import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.images.setIcon -import io.novafoundation.nova.common.utils.setImageTint import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.view.shape.getInputBackground @@ -49,7 +48,6 @@ class SwapAssetView @JvmOverloads constructor( } private fun setAssetImageUrl(icon: Icon) { - swapAssetImage.setImageTint(context.getColor(R.color.icon_primary)) swapAssetImage.setIcon(icon, imageLoader) swapAssetImage.setBackgroundResource(R.drawable.bg_token_container) } diff --git a/feature-swap-api/src/main/res/layout/view_swap_asset.xml b/feature-swap-api/src/main/res/layout/view_swap_asset.xml index ab2bbf7b30..854c4cf9ef 100644 --- a/feature-swap-api/src/main/res/layout/view_swap_asset.xml +++ b/feature-swap-api/src/main/res/layout/view_swap_asset.xml @@ -13,12 +13,10 @@ android:layout_height="40dp" android:layout_marginTop="16dp" android:background="@drawable/bg_token_container" - android:padding="5dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:tint="@color/icon_primary" - tools:src="@drawable/ic_token_ksm" /> + tools:src="@drawable/ic_token_dot_colored" /> { - swapAmountInputImage.setImageTint(context.getColor(R.color.icon_primary)) swapAmountInputImage.loadTokenIcon(icon.assetIconUrl, imageLoader) swapAmountInputImage.setBackgroundResource(R.drawable.bg_token_container) } SwapInputAssetModel.SwapAssetIcon.NotChosen -> { - swapAmountInputImage.setImageTint(context.getColor(R.color.icon_accent)) swapAmountInputImage.setImageResource(R.drawable.ic_add) swapAmountInputImage.setBackgroundResource(R.drawable.ic_swap_asset_default_background) } diff --git a/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml b/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml index 0f70968c2c..c89b1fa759 100644 --- a/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml +++ b/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml @@ -20,12 +20,10 @@ android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:background="@drawable/bg_token_container" - android:padding="5dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:tint="@color/icon_primary" - tools:src="@drawable/ic_token_ksm" /> + tools:src="@drawable/ic_token_dot_colored" /> diff --git a/feature-wallet-api/src/main/res/layout/item_asset_selector.xml b/feature-wallet-api/src/main/res/layout/item_asset_selector.xml index 55d9d464a9..aae6877e27 100644 --- a/feature-wallet-api/src/main/res/layout/item_asset_selector.xml +++ b/feature-wallet-api/src/main/res/layout/item_asset_selector.xml @@ -28,7 +28,6 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toEndOf="@+id/itemAssetSelectorCheckmark" app:layout_constraintTop_toTopOf="parent" - app:tint="@color/icon_primary" tools:src="@drawable/ic_token_dot" /> + tools:src="@drawable/ic_token_dot_colored" /> { - return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson) } + return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson, AssetIconMode.WHITE) } } } diff --git a/runtime/build.gradle b/runtime/build.gradle index 9a5db02627..1e96af753e 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -7,22 +7,24 @@ apply plugin: 'kotlin-android-extensions' android { compileSdkVersion rootProject.compileSdkVersion - defaultConfig { minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - buildConfigField "String", "CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/chains_dev.json\"" + buildConfigField "String", "CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/chains_dev.json\"" buildConfigField "String", "EVM_ASSETS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/assets/evm/v2/assets_dev.json\"" - buildConfigField "String", "PRE_CONFIGURED_CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/preConfigured/chains_dev.json\"" - buildConfigField "String", "PRE_CONFIGURED_CHAIN_DETAILS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/preConfigured/detailsDev\"" + buildConfigField "String", "PRE_CONFIGURED_CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/preConfigured/chains_dev.json\"" + buildConfigField "String", "PRE_CONFIGURED_CHAIN_DETAILS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/preConfigured/detailsDev\"" buildConfigField "String", "TEST_CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/tests/chains_for_testBalance.json\"" buildConfigField "String", "INFURA_API_KEY", readStringSecret("INFURA_API_KEY") buildConfigField "String", "DWELLIR_API_KEY", readStringSecret("DWELLIR_API_KEY") + + buildConfigField "String", "ASSET_COLORED_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/colored/\"" + buildConfigField "String", "ASSET_WHITE_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/\"" } buildTypes { @@ -34,10 +36,10 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "String", "CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/chains.json\"" + buildConfigField "String", "CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/chains.json\"" buildConfigField "String", "EVM_ASSETS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/assets/evm/v2/assets.json\"" - buildConfigField "String", "PRE_CONFIGURED_CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/preConfigured/chains.json\"" - buildConfigField "String", "PRE_CONFIGURED_CHAIN_DETAILS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v20/preConfigured/details\"" + buildConfigField "String", "PRE_CONFIGURED_CHAINS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/preConfigured/chains.json\"" + buildConfigField "String", "PRE_CONFIGURED_CHAIN_DETAILS_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/chains/v21/preConfigured/details\"" } } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt index 97e74a266d..965c36544b 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt @@ -6,6 +6,7 @@ import dagger.Provides import io.novafoundation.nova.common.BuildConfig import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.rpc.BulkRetriever +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.common.interfaces.FileProvider @@ -228,7 +229,8 @@ class ChainRegistryModule { baseTypeSynchronizer: BaseTypeSynchronizer, runtimeSyncService: RuntimeSyncService, web3ApiPool: Web3ApiPool, - gson: Gson + gson: Gson, + assetsIconModeService: AssetsIconModeService ) = ChainRegistry( runtimeProviderPool, chainConnectionPool, @@ -239,6 +241,7 @@ class ChainRegistryModule { baseTypeSynchronizer, runtimeSyncService, web3ApiPool, - gson + gson, + assetsIconModeService ) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt index 4b6975a99b..c681bac045 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.runtime.di import android.content.Context import com.google.gson.Gson import io.novafoundation.nova.common.data.network.NetworkApiCreator +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.interfaces.FileProvider import io.novafoundation.nova.core_db.dao.ChainAssetDao @@ -29,4 +30,6 @@ interface RuntimeDependencies { fun chainDao(): ChainDao fun chainAssetDao(): ChainAssetDao + + fun assetsIconModeService(): AssetsIconModeService } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt index bed655baa2..f512bb5174 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt @@ -4,6 +4,7 @@ import com.google.gson.Gson import dagger.Module import dagger.Provides import io.novafoundation.nova.common.data.network.rpc.BulkRetriever +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.core.storage.StorageCache @@ -265,8 +266,14 @@ class RuntimeModule { @Provides @ApplicationScope - fun provideRemoteToDomainChainMapperFacade(gson: Gson): RemoteToDomainChainMapperFacade { - return RemoteToDomainChainMapperFacade(gson) + fun provideRemoteToDomainChainMapperFacade( + gson: Gson, + assetsIconModeService: AssetsIconModeService + ): RemoteToDomainChainMapperFacade { + return RemoteToDomainChainMapperFacade( + gson, + assetsIconModeService + ) } @Provides diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt index f8c0879a0a..87bb55624d 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt @@ -2,11 +2,11 @@ package io.novafoundation.nova.runtime.multiNetwork import android.util.Log import com.google.gson.Gson +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.utils.LOG_TAG import io.novafoundation.nova.common.utils.diffed import io.novafoundation.nova.common.utils.filterList import io.novafoundation.nova.common.utils.inBackground -import io.novafoundation.nova.common.utils.mapList import io.novafoundation.nova.common.utils.mapNotNullToSet import io.novafoundation.nova.common.utils.removeHexPrefix import io.novafoundation.nova.core.ethereum.Web3Api @@ -40,6 +40,7 @@ import io.novasama.substrate_sdk_android.wsrpc.SocketService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first @@ -63,11 +64,13 @@ class ChainRegistry( private val baseTypeSynchronizer: BaseTypeSynchronizer, private val runtimeSyncService: RuntimeSyncService, private val web3ApiPool: Web3ApiPool, - private val gson: Gson + private val gson: Gson, + private val assetsIconModeService: AssetsIconModeService ) : CoroutineScope by CoroutineScope(Dispatchers.Default) { - val currentChains = chainDao.joinChainInfoFlow() - .mapList { mapChainLocalToChain(it, gson) } + val currentChains = combine(chainDao.joinChainInfoFlow(), assetsIconModeService.assetsIconModeFlow()) { chains, assetIconMode -> + chains.map { mapChainLocalToChain(it, gson, assetIconMode) } + } .diffed() .map { diff -> diff.removed.forEach { unregisterChain(it) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt index fb90529a77..29cd0b6451 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt @@ -97,7 +97,7 @@ fun mapChainAssetToLocal(asset: Chain.Asset, gson: Gson): ChainAssetLocal { source = mapAssetSourceToLocal(asset.source), buyProviders = gson.toJson(asset.buyProviders), typeExtras = gson.toJson(typeExtras), - icon = asset.iconUrl, + icon = asset.icon?.name, enabled = asset.enabled ) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt index 81ce937317..186898f00a 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt @@ -2,6 +2,7 @@ package io.novafoundation.nova.runtime.multiNetwork.chain.mappers import android.util.Log import com.google.gson.Gson +import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.utils.asPrecision import io.novafoundation.nova.common.utils.asTokenSymbol import io.novafoundation.nova.common.utils.enumValueOfOrNull @@ -21,6 +22,7 @@ import io.novafoundation.nova.core_db.model.chain.ChainLocal.ConnectionStateLoca import io.novafoundation.nova.core_db.model.chain.ChainNodeLocal import io.novafoundation.nova.core_db.model.chain.JoinedChainInfo import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal +import io.novafoundation.nova.runtime.BuildConfig import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.EVM_TRANSFER_PARAMETER import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.GovernanceReferendaParameters import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.SUBSTRATE_TRANSFER_PARAMETER @@ -182,7 +184,7 @@ private fun mapNodeSelectionFromLocal(nodeSelectionPreferencesLocal: NodeSelecti } } -fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson): Chain { +fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson, assetIconMode: AssetIconMode): Chain { return mapChainLocalToChain( chainLocal.chain, chainLocal.nodes, @@ -190,7 +192,8 @@ fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson): Chain { chainLocal.assets, chainLocal.explorers, chainLocal.externalApis, - gson + gson, + assetIconMode ) } @@ -201,7 +204,8 @@ fun mapChainLocalToChain( assetsLocal: List, explorersLocal: List, externalApisLocal: List, - gson: Gson + gson: Gson, + assetIconMode: AssetIconMode ): Chain { val nodes = nodesLocal.sortedBy { it.orderId }.map { Chain.Node( @@ -219,7 +223,7 @@ fun mapChainLocalToChain( nodes = nodes ) - val assets = assetsLocal.map { mapChainAssetLocalToAsset(it, gson) } + val assets = assetsLocal.map { mapChainAssetLocalToAsset(it, gson, assetIconMode) } val explorers = explorersLocal.map { Chain.Explorer( @@ -274,12 +278,12 @@ fun mapChainLocalToChain( } } -fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson): Chain.Asset { +fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson, assetIconMode: AssetIconMode): Chain.Asset { val typeExtrasParsed = local.typeExtras?.let(gson::parseArbitraryObject) val buyProviders = local.buyProviders?.let?>(gson::fromJsonOrNull).orEmpty() return Chain.Asset( - iconUrl = local.icon, + icon = getAssetIconUrl(local.icon, assetIconMode), id = local.id, symbol = local.symbol.asTokenSymbol(), precision = local.precision.asPrecision(), @@ -294,6 +298,17 @@ fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson): Chain.Asset { ) } +private fun getAssetIconUrl(icon: String?, assetIconMode: AssetIconMode): Chain.Icon? { + return icon?.let { + val baseUrl = when (assetIconMode) { + AssetIconMode.COLORED -> BuildConfig.ASSET_COLORED_ICON_URL + AssetIconMode.WHITE -> BuildConfig.ASSET_WHITE_ICON_URL + } + + Chain.Icon(it, baseUrl) + } +} + private fun mapSourceFromLocal(local: ChainLocal.Source): Chain.Source { return when (local) { ChainLocal.Source.DEFAULT -> Chain.Source.DEFAULT diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt index 0dcaa94782..01e45dae0a 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt @@ -1,13 +1,15 @@ package io.novafoundation.nova.runtime.multiNetwork.chain.mappers import com.google.gson.Gson +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.core_db.model.chain.ChainLocal import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain import io.novafoundation.nova.runtime.multiNetwork.chain.remote.model.ChainRemote class RemoteToDomainChainMapperFacade( - private val gson: Gson + private val gson: Gson, + private val assetsIconModeService: AssetsIconModeService ) { fun mapRemoteChainToDomain(chainRemote: ChainRemote, source: Chain.Source): Chain { @@ -28,7 +30,8 @@ class RemoteToDomainChainMapperFacade( assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson + gson = gson, + assetsIconModeService.getIconMode() ) } } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt index 76b61f9ae2..6ccbdbd207 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt @@ -46,6 +46,17 @@ data class Chain( val assetsById = assets.associateBy(Asset::id) + data class Icon( + val name: String, + val baseUrl: String, + ) { + companion object; + + constructor(url: String) : this("", url) + + fun getIconUrl(): String = "$baseUrl/$name" + } + data class Additional( val defaultTip: BigInteger?, val themeColor: String?, @@ -65,7 +76,7 @@ data class Chain( ) data class Asset( - val iconUrl: String?, + val icon: Icon?, val id: ChainAssetId, val priceId: String?, val chainId: ChainId, @@ -79,6 +90,9 @@ data class Chain( val enabled: Boolean, ) : Identifiable, Serializable { + // To support legacy code + val iconUrl = icon?.getIconUrl() + enum class Source { DEFAULT, ERC20, MANUAL } From 1902b9f5ae9da9a52b6be3346b12f08bfdd8a433 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Fri, 25 Oct 2024 22:08:11 +0200 Subject: [PATCH 02/11] Clean code --- .../data/repository/RealChainAssetRepository.kt | 8 +++++--- .../feature_wallet_impl/di/WalletFeatureDependencies.kt | 3 +++ .../nova/feature_wallet_impl/di/WalletFeatureModule.kt | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt index 8e24dd42e8..962ba816eb 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt @@ -1,7 +1,7 @@ package io.novafoundation.nova.feature_wallet_impl.data.repository import com.google.gson.Gson -import io.novafoundation.nova.common.data.model.AssetIconMode +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.core_db.dao.ChainAssetDao import io.novafoundation.nova.core_db.dao.SetAssetEnabledParams import io.novafoundation.nova.feature_wallet_api.domain.interfaces.ChainAssetRepository @@ -12,7 +12,8 @@ import io.novafoundation.nova.runtime.multiNetwork.chain.model.FullChainAssetId class RealChainAssetRepository( private val chainAssetDao: ChainAssetDao, - private val gson: Gson + private val gson: Gson, + private val assetsIconModeService: AssetsIconModeService ) : ChainAssetRepository { override suspend fun setAssetsEnabled(enabled: Boolean, assetIds: List) { @@ -27,6 +28,7 @@ class RealChainAssetRepository( } override suspend fun getEnabledAssets(): List { - return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson, AssetIconMode.WHITE) } + val iconMode = assetsIconModeService.getIconMode() + return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson, iconMode) } } } diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt index 8b79b7f3eb..02428e750d 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt @@ -8,6 +8,7 @@ import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.network.AppLinksProvider import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences import io.novafoundation.nova.common.interfaces.FileCache @@ -134,6 +135,8 @@ interface WalletFeatureDependencies { fun hydraDxAssetIdConverter(): HydraDxAssetIdConverter + fun assetsIconModeService(): AssetsIconModeService + val fileCache: FileCache val storageCache: StorageCache diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt index c1dbadcdbb..07f4bc9659 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt @@ -6,6 +6,7 @@ import dagger.Provides import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator +import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.FeatureScope import io.novafoundation.nova.common.interfaces.FileCache @@ -322,8 +323,9 @@ class WalletFeatureModule { @FeatureScope fun provideChainAssetRepository( chainAssetDao: ChainAssetDao, - gson: Gson - ): ChainAssetRepository = RealChainAssetRepository(chainAssetDao, gson) + gson: Gson, + assetsIconModeService: AssetsIconModeService + ): ChainAssetRepository = RealChainAssetRepository(chainAssetDao, gson, assetsIconModeService) @Provides @FeatureScope From 068be0641f0ed7ecc7964f9a94b17d3b45feb2a5 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 13:37:14 +0100 Subject: [PATCH 03/11] Change providing colored icons --- common/build.gradle | 3 + ...Service.kt => AssetsIconModeRepository.kt} | 10 +- .../nova/common/di/CommonApi.kt | 65 +++---- .../nova/common/di/modules/CommonModule.kt | 21 ++- .../common/presentation/AssetIconProvider.kt | 34 ++++ .../nova/common/view/AmountView.kt | 7 +- .../presenatation/chain/ChainUi.kt | 9 +- .../di/AssetsFeatureDependencies.kt | 160 +++++++++--------- .../di/modules/ManageTokensCommonModule.kt | 4 +- .../domain/common/TokenAssetSorting.kt | 2 +- .../tokens/manage/ManageTokenInteractor.kt | 2 +- .../balance/common/AssetListMixin.kt | 7 +- .../common/holders/NetworkAssetViewHolder.kt | 3 +- .../holders/TokenAssetGroupViewHolder.kt | 3 +- .../common/holders/TokenAssetViewHolder.kt | 3 +- .../common/mappers/NetworkAssetMappers.kt | 13 +- .../common/mappers/TokenAssetMappers.kt | 20 ++- .../balance/detail/AssetDetailsModel.kt | 2 + .../balance/detail/BalanceDetailFragment.kt | 3 +- .../balance/detail/BalanceDetailViewModel.kt | 8 +- .../balance/detail/di/BalanceDetailModule.kt | 13 +- .../balance/list/di/BalanceListModule.kt | 3 + .../list/model/items/NetworkAssetUi.kt | 3 +- .../balance/list/model/items/TokenAssetUi.kt | 8 +- .../balance/list/model/items/TokenGroupUi.kt | 3 +- .../balance/search/AssetSearchViewModel.kt | 4 +- .../balance/search/di/AssetSearchModule.kt | 7 +- .../buy/flow/asset/AssetBuyFlowViewModel.kt | 3 + .../buy/flow/asset/di/AssetBuyFlowModule.kt | 7 +- .../flow/asset/AssetFlowViewModel.kt | 6 +- .../presentation/receive/ReceiveFragment.kt | 3 +- .../presentation/receive/ReceiveViewModel.kt | 5 +- .../presentation/receive/di/ReceiveModule.kt | 3 + .../flow/asset/AssetReceiveFlowViewModel.kt | 3 + .../flow/asset/di/AssetReceiveFlowModule.kt | 7 +- .../receive/model/TokenReceiver.kt | 3 +- .../send/flow/asset/AssetSendFlowViewModel.kt | 7 +- .../send/flow/asset/di/AssetSendFlowModule.kt | 7 +- .../swap/asset/AssetSwapFlowViewModel.kt | 9 +- .../swap/asset/di/AssetSwapFlowModule.kt | 7 +- .../tokens/manage/ManageTokensAdapter.kt | 3 +- .../manage/chain/ManageChainTokensFragment.kt | 3 +- .../manage/model/MultiChainTokenModel.kt | 7 +- .../detail/di/ExtrinsicDetailModule.kt | 5 +- .../extrinsic/ExtrinsicDetailFragment.kt | 3 +- .../extrinsic/ExtrinsicDetailViewModel.kt | 6 +- .../detail/swap/SwapDetailViewModel.kt | 6 +- .../detail/swap/di/SwapDetailModule.kt | 5 +- .../history/mixin/OperationMappers.kt | 5 +- .../mixin/TransactionHistoryProvider.kt | 6 +- .../di/CrowdloanFeatureDependencies.kt | 19 ++- .../confirm/ConfirmContributeFragment.kt | 2 +- .../confirm/ConfirmContributeViewModel.kt | 4 +- .../confirm/di/ConfirmContributeModule.kt | 3 + .../select/CrowdloanContributeFragment.kt | 2 +- .../select/CrowdloanContributeViewModel.kt | 4 +- .../select/di/CrowdloanContributeModule.kt | 3 + .../domain/sign/evm/EvmSignInteractor.kt | 2 +- .../di/GovernanceFeatureDependencies.kt | 35 ++-- .../di/GovernanceFeatureModule.kt | 6 +- .../presentation/track/TrackFormatter.kt | 21 ++- .../di/SwapFeatureDependencies.kt | 3 + .../confirmation/SwapConfirmationViewModel.kt | 6 +- .../confirmation/di/SwapConfirmationModule.kt | 7 +- .../main/di/SwapMainSettingsModule.kt | 6 +- .../main/input/SwapAmountInputMixin.kt | 2 +- .../main/input/SwapAmountInputMixinFactory.kt | 13 +- .../presentation/views/SwapAmountInputView.kt | 3 +- .../feature_wallet_api/data/mappers/Asset.kt | 5 +- .../di/common/SelectableAssetUseCaseModule.kt | 3 + .../amountChooser/AmountChooserProvider.kt | 8 +- .../assetSelector/AssetSelectorProvider.kt | 7 +- .../presentation/model/AssetModel.kt | 4 +- .../presentation/model/ChooseAmountModel.kt | 12 +- .../view/AssetSelectorBottomSheet.kt | 3 +- .../presentation/view/AssetSelectorView.kt | 3 +- .../view/amount/ChooseAmountInputView.kt | 7 +- .../view/amount/ChooseAmountView.kt | 5 +- .../repository/RealChainAssetRepository.kt | 8 +- .../di/WalletFeatureDependencies.kt | 62 +++---- .../di/WalletFeatureModule.kt | 13 +- runtime/build.gradle | 3 - .../nova/runtime/di/ChainRegistryModule.kt | 9 +- .../nova/runtime/di/RuntimeDependencies.kt | 4 +- .../nova/runtime/di/RuntimeModule.kt | 8 +- .../runtime/multiNetwork/ChainRegistry.kt | 9 +- .../chain/mappers/DomainToLocalChainMapper.kt | 2 +- .../chain/mappers/LocalToDomainChainMapper.kt | 25 +-- .../RemoteToDomainChainMapperFacade.kt | 8 +- .../runtime/multiNetwork/chain/model/Chain.kt | 16 +- 90 files changed, 561 insertions(+), 343 deletions(-) rename common/src/main/java/io/novafoundation/nova/common/data/repository/{AssetsIconModeService.kt => AssetsIconModeRepository.kt} (89%) create mode 100644 common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt diff --git a/common/build.gradle b/common/build.gradle index 0a119a8950..7b2dfa6b78 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -42,6 +42,9 @@ android { buildConfigField "String", "LEDGER_BLEUTOOTH_GUIDE", "\"https://support.ledger.com/hc/en-us/articles/360019138694-Set-up-Bluetooth-connection\"" buildConfigField "String", "APP_UPDATE_SOURCE_LINK", "\"https://play.google.com/store/apps/details?id=io.novafoundation.nova.market\"" + + buildConfigField "String", "ASSET_COLORED_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/colored\"" + buildConfigField "String", "ASSET_WHITE_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white\"" } buildTypes { diff --git a/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeRepository.kt similarity index 89% rename from common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt rename to common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeRepository.kt index 7d75ee2560..0a2455e699 100644 --- a/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeService.kt +++ b/common/src/main/java/io/novafoundation/nova/common/data/repository/AssetsIconModeRepository.kt @@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext -interface AssetsIconModeService { +interface AssetsIconModeRepository { fun assetsIconModeFlow(): Flow suspend fun setAssetsIconMode(assetsViewMode: AssetIconMode) @@ -18,9 +18,9 @@ interface AssetsIconModeService { private const val PREFS_ASSETS_ICON_MODE = "PREFS_ASSETS_ICON_MODE" private val ASSET_ICON_MODE_DEFAULT = AssetIconMode.COLORED -class RealAssetsIconModeService( +class RealAssetsIconModeRepository( private val preferences: Preferences -) : AssetsIconModeService { +) : AssetsIconModeRepository { override fun assetsIconModeFlow(): Flow { return preferences.stringFlow(PREFS_ASSETS_ICON_MODE) @@ -40,14 +40,14 @@ class RealAssetsIconModeService( private fun AssetIconMode.toPrefsValue(): String { return when (this) { AssetIconMode.COLORED -> "colored" - AssetIconMode.WHITE -> "solid" + AssetIconMode.WHITE -> "white" } } private fun String.fromPrefsValue(): AssetIconMode? { return when (this) { "colored" -> AssetIconMode.COLORED - "solid" -> AssetIconMode.WHITE + "white" -> AssetIconMode.WHITE else -> null } } diff --git a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt index 02bafdac71..359cb144d8 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt @@ -14,7 +14,7 @@ import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser import io.novafoundation.nova.common.data.network.rpc.SocketSingleRequestExecutor -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.repository.AssetsViewModeService import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 @@ -31,6 +31,7 @@ import io.novafoundation.nova.common.mixin.api.CustomDialogDisplayer import io.novafoundation.nova.common.mixin.api.NetworkStateMixin import io.novafoundation.nova.common.mixin.condition.ConditionMixinFactory import io.novafoundation.nova.common.mixin.hints.ResourcesHintsMixinFactory +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.AppVersionProvider import io.novafoundation.nova.common.resources.ClipboardManager import io.novafoundation.nova.common.resources.ContextManager @@ -65,6 +66,36 @@ import java.util.Random interface CommonApi { + val systemCallExecutor: SystemCallExecutor + + val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory + + val resourcesHintsMixinFactory: ResourcesHintsMixinFactory + + val okHttpClient: OkHttpClient + + val fileCache: FileCache + + val permissionsAskerFactory: PermissionsAskerFactory + + val bluetoothManager: BluetoothManager + + val locationManager: LocationManager + + val listChooserMixinFactory: ListChooserMixin.Factory + + val partialRetriableMixinFactory: PartialRetriableMixin.Factory + + val automaticInteractionGate: AutomaticInteractionGate + + val bannerVisibilityRepository: BannerVisibilityRepository + + val provideActivityIntentProvider: ActivityIntentProvider + + val googleApiAvailabilityProvider: GoogleApiAvailabilityProvider + + val coinGeckoLinkParser: CoinGeckoLinkParser + fun computationalCache(): ComputationalCache fun imageLoader(): ImageLoader @@ -158,35 +189,7 @@ interface CommonApi { fun assetsViewModeRepository(): AssetsViewModeService - fun assetsIconModeService(): AssetsIconModeService + fun assetsIconModeService(): AssetsIconModeRepository - val systemCallExecutor: SystemCallExecutor - - val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory - - val resourcesHintsMixinFactory: ResourcesHintsMixinFactory - - val okHttpClient: OkHttpClient - - val fileCache: FileCache - - val permissionsAskerFactory: PermissionsAskerFactory - - val bluetoothManager: BluetoothManager - - val locationManager: LocationManager - - val listChooserMixinFactory: ListChooserMixin.Factory - - val partialRetriableMixinFactory: PartialRetriableMixin.Factory - - val automaticInteractionGate: AutomaticInteractionGate - - val bannerVisibilityRepository: BannerVisibilityRepository - - val provideActivityIntentProvider: ActivityIntentProvider - - val googleApiAvailabilityProvider: GoogleApiAvailabilityProvider - - val coinGeckoLinkParser: CoinGeckoLinkParser + fun assetIconProvider(): AssetIconProvider } diff --git a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt index c74a772484..bd8bb0367e 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt @@ -9,6 +9,7 @@ import coil.ImageLoader import coil.decode.SvgDecoder import dagger.Module import dagger.Provides +import io.novafoundation.nova.common.BuildConfig import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.address.CachingAddressIconGenerator import io.novafoundation.nova.common.address.StatelessAddressIconGenerator @@ -19,10 +20,10 @@ import io.novafoundation.nova.common.data.RealGoogleApiAvailabilityProvider import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.memory.RealComputationalCache import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.repository.AssetsViewModeService import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository -import io.novafoundation.nova.common.data.repository.RealAssetsIconModeService +import io.novafoundation.nova.common.data.repository.RealAssetsIconModeRepository import io.novafoundation.nova.common.data.repository.RealAssetsViewModeService import io.novafoundation.nova.common.data.repository.RealBannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 @@ -44,6 +45,8 @@ import io.novafoundation.nova.common.mixin.condition.ConditionMixinFactory import io.novafoundation.nova.common.mixin.condition.RealConditionMixinFactory import io.novafoundation.nova.common.mixin.hints.ResourcesHintsMixinFactory import io.novafoundation.nova.common.mixin.impl.CustomDialogProvider +import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.RealAssetIconProvider import io.novafoundation.nova.common.resources.AppVersionProvider import io.novafoundation.nova.common.resources.ClipboardManager import io.novafoundation.nova.common.resources.ContextManager @@ -354,9 +357,19 @@ class CommonModule { @Provides @ApplicationScope - fun assetsViewModeService(preferences: Preferences): AssetsViewModeService = RealAssetsViewModeService(preferences) + fun provideAssetsViewModeService(preferences: Preferences): AssetsViewModeService = RealAssetsViewModeService(preferences) @Provides @ApplicationScope - fun assetsIconModeService(preferences: Preferences): AssetsIconModeService = RealAssetsIconModeService(preferences) + fun provideAssetsIconModeRepository(preferences: Preferences): AssetsIconModeRepository = RealAssetsIconModeRepository(preferences) + + @Provides + @ApplicationScope + fun provideAssetIconProvider(repository: AssetsIconModeRepository): AssetIconProvider { + return RealAssetIconProvider( + repository, + BuildConfig.ASSET_COLORED_ICON_URL, + BuildConfig.ASSET_WHITE_ICON_URL, + ) + } } diff --git a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt new file mode 100644 index 0000000000..6d262086f7 --- /dev/null +++ b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt @@ -0,0 +1,34 @@ +package io.novafoundation.nova.common.presentation + +import io.novafoundation.nova.common.R +import io.novafoundation.nova.common.data.model.AssetIconMode +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository +import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.common.utils.images.asIcon + +interface AssetIconProvider { + + val fallbackIcon: Icon + + fun getAssetIcon(iconName: String?, fallback: Icon = fallbackIcon): Icon +} + +class RealAssetIconProvider( + private val assetsIconModeRepository: AssetsIconModeRepository, + private val coloredBaseUrl: String, + private val whiteBaseUrl: String +) : AssetIconProvider { + + override val fallbackIcon: Icon = R.drawable.ic_nova.asIcon() + + override fun getAssetIcon(iconName: String?, fallback: Icon): Icon { + if (iconName == null) return fallback + + val iconUrl = when (assetsIconModeRepository.getIconMode()) { + AssetIconMode.COLORED -> "$coloredBaseUrl/$iconName" + AssetIconMode.WHITE -> "$coloredBaseUrl/$whiteBaseUrl" + } + + return iconUrl.asIcon() + } +} diff --git a/common/src/main/java/io/novafoundation/nova/common/view/AmountView.kt b/common/src/main/java/io/novafoundation/nova/common/view/AmountView.kt index 1f06343917..2cb0e6491a 100644 --- a/common/src/main/java/io/novafoundation/nova/common/view/AmountView.kt +++ b/common/src/main/java/io/novafoundation/nova/common/view/AmountView.kt @@ -8,9 +8,10 @@ import android.view.View import android.widget.EditText import androidx.constraintlayout.widget.ConstraintLayout import coil.ImageLoader -import coil.load import io.novafoundation.nova.common.R import io.novafoundation.nova.common.di.FeatureUtils +import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.view.shape.getBlockDrawable import io.novafoundation.nova.common.view.shape.getCornersStateDrawable @@ -87,8 +88,8 @@ class AmountView @JvmOverloads constructor( stakingAssetImage.setImageDrawable(image) } - fun loadAssetImage(imageUrl: String?) { - stakingAssetImage.load(imageUrl, imageLoader) + fun loadAssetImage(icon: Icon) { + stakingAssetImage.setIcon(icon, imageLoader) } fun setAssetName(name: String) { diff --git a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt index a5f61e4aa0..715f73de83 100644 --- a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt +++ b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt @@ -6,6 +6,7 @@ import android.widget.ImageView import coil.ImageLoader import coil.load import coil.request.ImageRequest +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.images.asIcon import io.novafoundation.nova.feature_account_api.R @@ -45,10 +46,6 @@ fun ImageView.loadTokenIcon(icon: String?, imageLoader: ImageLoader) { } } -fun Chain.Asset.icon(): Icon { - return iconUrl?.asIcon() ?: ASSET_ICON_PLACEHOLDER.asIcon() -} - fun Chain.iconOrFallback(): Icon { return icon?.asIcon() ?: chainIconFallback() } @@ -60,3 +57,7 @@ fun String?.asIconOrFallback(): Icon { fun chainIconFallback(): Icon { return R.drawable.ic_fallback_network_icon.asIcon() } + +fun AssetIconProvider.getAssetIcon(asset: Chain.Asset, fallbackIcon: Icon = this.fallbackIcon): Icon { + return this.getAssetIcon(asset.icon, fallbackIcon) +} diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt index ee8bc8885c..a1afb2e043 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt @@ -17,6 +17,7 @@ import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences import io.novafoundation.nova.common.interfaces.FileProvider import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin import io.novafoundation.nova.common.mixin.hints.ResourcesHintsMixinFactory +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ClipboardManager import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.QrCodeGenerator @@ -88,6 +89,88 @@ import javax.inject.Named interface AssetsFeatureDependencies { + val assetsSourceRegistry: AssetSourceRegistry + + val addressInputMixinFactory: AddressInputMixinFactory + + val multiChainQrSharingFactory: MultiChainQrSharingFactory + + val walletUiUseCase: WalletUiUseCase + + val computationalCache: ComputationalCache + + val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory + + val crossChainTraRepository: CrossChainTransfersRepository + + val crossChainWeigher: CrossChainWeigher + + val crossChainTransactor: CrossChainTransactor + + val resourcesHintsMixinFactory: ResourcesHintsMixinFactory + + val parachainInfoRepository: ParachainInfoRepository + + val watchOnlyMissingKeysPresenter: WatchOnlyMissingKeysPresenter + + val balanceLocksRepository: BalanceLocksRepository + + val chainAssetRepository: ChainAssetRepository + + val erc20Standard: Erc20Standard + + val externalBalanceRepository: ExternalBalanceRepository + + val pooledBalanceUpdaterFactory: PooledBalanceUpdaterFactory + + val paymentUpdaterFactory: PaymentUpdaterFactory + + val locksUpdaterFactory: BalanceLocksUpdaterFactory + + val accountUpdateScope: AccountUpdateScope + + val storageSharedRequestBuilderFactory: StorageSharedRequestsBuilderFactory + + val poolDisplayUseCase: PoolDisplayUseCase + + val poolAccountDerivation: PoolAccountDerivation + + val operationDao: OperationDao + + val coinPriceRepository: CoinPriceRepository + + val swapSettingsStateProvider: SwapSettingsStateProvider + + val swapService: SwapService + + val swapAvailabilityInteractor: SwapAvailabilityInteractor + + val bannerVisibilityRepository: BannerVisibilityRepository + + val buyMixinFactory: BuyMixin.Factory + + val buyMixinUi: BuyMixinUi + + val crossChainTransfersUseCase: CrossChainTransfersUseCase + + val arbitraryTokenUseCase: ArbitraryTokenUseCase + + val swapRateFormatter: SwapRateFormatter + + val bottomSheetLauncher: DescriptionBottomSheetLauncher + + val selectAddressMixinFactory: SelectAddressMixin.Factory + + val chainStateRepository: ChainStateRepository + + val holdsRepository: BalanceHoldsRepository + + val holdsDao: HoldsDao + + val coinGeckoLinkParser: CoinGeckoLinkParser + + val assetIconProvider: AssetIconProvider + fun web3NamesInteractor(): Web3NamesInteractor fun contributionsInteractor(): ContributionsInteractor @@ -174,83 +257,6 @@ interface AssetsFeatureDependencies { fun walletConnectSessionsUseCase(): WalletConnectSessionsUseCase - val assetsSourceRegistry: AssetSourceRegistry - fun nftRepository(): NftRepository - val addressInputMixinFactory: AddressInputMixinFactory - - val multiChainQrSharingFactory: MultiChainQrSharingFactory - - val walletUiUseCase: WalletUiUseCase - - val computationalCache: ComputationalCache - - val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory - - val crossChainTraRepository: CrossChainTransfersRepository - val crossChainWeigher: CrossChainWeigher - val crossChainTransactor: CrossChainTransactor - - val resourcesHintsMixinFactory: ResourcesHintsMixinFactory - - val parachainInfoRepository: ParachainInfoRepository - - val watchOnlyMissingKeysPresenter: WatchOnlyMissingKeysPresenter - - val balanceLocksRepository: BalanceLocksRepository - - val chainAssetRepository: ChainAssetRepository - - val erc20Standard: Erc20Standard - - val externalBalanceRepository: ExternalBalanceRepository - - val pooledBalanceUpdaterFactory: PooledBalanceUpdaterFactory - - val paymentUpdaterFactory: PaymentUpdaterFactory - - val locksUpdaterFactory: BalanceLocksUpdaterFactory - - val accountUpdateScope: AccountUpdateScope - - val storageSharedRequestBuilderFactory: StorageSharedRequestsBuilderFactory - - val poolDisplayUseCase: PoolDisplayUseCase - - val poolAccountDerivation: PoolAccountDerivation - - val operationDao: OperationDao - - val coinPriceRepository: CoinPriceRepository - - val swapSettingsStateProvider: SwapSettingsStateProvider - - val swapService: SwapService - - val swapAvailabilityInteractor: SwapAvailabilityInteractor - - val bannerVisibilityRepository: BannerVisibilityRepository - - val buyMixinFactory: BuyMixin.Factory - - val buyMixinUi: BuyMixinUi - - val crossChainTransfersUseCase: CrossChainTransfersUseCase - - val arbitraryTokenUseCase: ArbitraryTokenUseCase - - val swapRateFormatter: SwapRateFormatter - - val bottomSheetLauncher: DescriptionBottomSheetLauncher - - val selectAddressMixinFactory: SelectAddressMixin.Factory - - val chainStateRepository: ChainStateRepository - - val holdsRepository: BalanceHoldsRepository - - val holdsDao: HoldsDao - - val coinGeckoLinkParser: CoinGeckoLinkParser } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/modules/ManageTokensCommonModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/modules/ManageTokensCommonModule.kt index 00bfa90407..d4244715e4 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/modules/ManageTokensCommonModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/modules/ManageTokensCommonModule.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.di.modules import dagger.Module import dagger.Provides import io.novafoundation.nova.common.di.scope.FeatureScope +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_assets.domain.tokens.AssetsDataCleaner import io.novafoundation.nova.feature_assets.domain.tokens.RealAssetsDataCleaner @@ -21,8 +22,9 @@ class ManageTokensCommonModule { @Provides @FeatureScope fun provideMultiChainTokenUiMapper( + assetIconProvider: AssetIconProvider, resourceManager: ResourceManager - ) = MultiChainTokenMapper(resourceManager) + ) = MultiChainTokenMapper(assetIconProvider, resourceManager) @Provides @FeatureScope diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/common/TokenAssetSorting.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/common/TokenAssetSorting.kt index dcf6da759a..53e97054f8 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/common/TokenAssetSorting.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/common/TokenAssetSorting.kt @@ -72,7 +72,7 @@ fun getTokenAssetGroupBaseComparator( } private fun mapToTokenGroup(it: AssetWithNetwork) = TokenAssetGroup.Token( - it.asset.token.configuration.iconUrl, + it.asset.token.configuration.icon, it.asset.token.configuration.symbol.normalize(), it.asset.token.currency, it.asset.token.coinRate diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/manage/ManageTokenInteractor.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/manage/ManageTokenInteractor.kt index ebd60d114b..93f79b809a 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/manage/ManageTokenInteractor.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/tokens/manage/ManageTokenInteractor.kt @@ -103,7 +103,7 @@ class RealManageTokenInteractor( MultiChainToken( id = symbol, symbol = symbol, - icon = firstAsset.iconUrl, + icon = firstAsset.icon, isSwitchable = !isLastTokenEnabled, instances = chainsWithAssets.map { (chain, asset) -> MultiChainToken.ChainTokenInstance( diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/AssetListMixin.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/AssetListMixin.kt index 53a779c724..a26ca88f23 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/AssetListMixin.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/AssetListMixin.kt @@ -2,6 +2,7 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common import io.novafoundation.nova.common.data.model.AssetViewMode import io.novafoundation.nova.common.data.model.switch +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.utils.shareInBackground import io.novafoundation.nova.common.utils.toggle import io.novafoundation.nova.common.utils.updateValue @@ -24,6 +25,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.first class AssetListMixinFactory( + private val assetIconProvider: AssetIconProvider, private val walletInteractor: WalletInteractor, private val assetsListInteractor: AssetsListInteractor, private val currencyInteractor: CurrencyInteractor, @@ -31,6 +33,7 @@ class AssetListMixinFactory( ) { fun create(coroutineScope: CoroutineScope): AssetListMixin = RealAssetListMixin( + assetIconProvider, walletInteractor, assetsListInteractor, currencyInteractor, @@ -57,6 +60,7 @@ interface AssetListMixin { } class RealAssetListMixin( + assetIconProvider: AssetIconProvider, private val walletInteractor: WalletInteractor, private val assetsListInteractor: AssetsListInteractor, private val currencyInteractor: CurrencyInteractor, @@ -89,9 +93,10 @@ class RealAssetListMixin( expandedTokenIdsFlow ) { assets, currency, externalBalances, viewMode, expandedTokens -> when (viewMode) { - AssetViewMode.NETWORKS -> walletInteractor.groupAssetsByNetwork(assets, externalBalances).mapGroupedAssetsToUi(currency) + AssetViewMode.NETWORKS -> walletInteractor.groupAssetsByNetwork(assets, externalBalances).mapGroupedAssetsToUi(assetIconProvider, currency) AssetViewMode.TOKENS -> walletInteractor.groupAssetsByToken(assets, externalBalances) .mapGroupedAssetsToUi( + assetIconProvider = assetIconProvider, assetFilter = { groupId, assetsInGroup -> filterTokens(groupId, assetsInGroup, expandedTokens) } ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt index 36e8d75d6d..2e4ccceee8 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.holder import android.view.View import coil.ImageLoader import io.novafoundation.nova.common.list.GroupedListHolder +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.presentation.balance.common.BalanceListAdapter @@ -22,7 +23,7 @@ class NetworkAssetViewHolder( fun bind(networkAsset: NetworkAssetUi, itemHandler: BalanceListAdapter.ItemAssetHandler) = with(containerView) { val asset = networkAsset.asset - itemAssetImage.loadTokenIcon(asset.token.configuration.iconUrl, imageLoader) + itemAssetImage.setIcon(networkAsset.icon, imageLoader) bindPriceInfo(asset) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt index 6127ea1e1d..83afa58aa1 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.holder import android.view.View import coil.ImageLoader import io.novafoundation.nova.common.list.GroupedListHolder +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.recyclerView.expandable.ExpandableParentViewHolder import io.novafoundation.nova.common.utils.recyclerView.expandable.items.ExpandableParentItem import io.novafoundation.nova.common.utils.setTextColorRes @@ -26,7 +27,7 @@ class TokenAssetGroupViewHolder( fun bind(tokenGroup: TokenGroupUi, itemHandler: BalanceListAdapter.ItemAssetHandler) = with(containerView) { expandableItem = tokenGroup - itemTokenGroupAssetImage.loadTokenIcon(tokenGroup.tokenIcon, imageLoader) + itemTokenGroupAssetImage.setIcon(tokenGroup.tokenIcon, imageLoader) bindPriceRate(tokenGroup) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetViewHolder.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetViewHolder.kt index 1b298b9bfa..fff22ec99b 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetViewHolder.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetViewHolder.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.holder import android.view.View import coil.ImageLoader import io.novafoundation.nova.common.list.GroupedListHolder +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.recyclerView.expandable.ExpandableChildViewHolder import io.novafoundation.nova.common.utils.recyclerView.expandable.items.ExpandableChildItem import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon @@ -27,7 +28,7 @@ class TokenAssetViewHolder( expandableItem = tokenAsset val asset = tokenAsset.asset - itemTokenAssetImage.loadTokenIcon(asset.token.configuration.iconUrl, imageLoader) + itemTokenAssetImage.setIcon(tokenAsset.assetIcon, imageLoader) itemTokenAssetChainIcon.loadTokenIcon(tokenAsset.chain.icon, imageLoader) itemTokenAssetChainName.text = tokenAsset.chain.name diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt index 85be66a4cb..e651a0c7c3 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt @@ -2,7 +2,9 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.mapper import io.novafoundation.nova.common.list.GroupedList import io.novafoundation.nova.common.list.toListWithHeaders +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.domain.common.PricedAmount import io.novafoundation.nova.feature_assets.domain.common.NetworkAssetGroup import io.novafoundation.nova.feature_assets.domain.common.AssetWithOffChainBalance @@ -15,21 +17,28 @@ import io.novafoundation.nova.feature_currency_api.presentation.formatters.forma import java.math.BigDecimal fun GroupedList.mapGroupedAssetsToUi( + assetIconProvider: AssetIconProvider, currency: Currency, groupBalance: (NetworkAssetGroup) -> BigDecimal = NetworkAssetGroup::groupTotalBalanceFiat, balance: (AssetBalance) -> PricedAmount = AssetBalance::total, ): List { return mapKeys { (assetGroup, _) -> mapAssetGroupToUi(assetGroup, currency, groupBalance) } - .mapValues { (group, assets) -> mapAssetsToAssetModels(assets, balance) } + .mapValues { (group, assets) -> mapAssetsToAssetModels(assetIconProvider, assets, balance) } .toListWithHeaders() .filterIsInstance() } private fun mapAssetsToAssetModels( + assetIconProvider: AssetIconProvider, assets: List, balance: (AssetBalance) -> PricedAmount ): List { - return assets.map { NetworkAssetUi(mapAssetToAssetModel(it.asset, balance(it.balanceWithOffchain))) } + return assets.map { + NetworkAssetUi( + mapAssetToAssetModel(it.asset, balance(it.balanceWithOffchain)), + assetIconProvider.getAssetIcon(it.asset.token.configuration) + ) + } } fun mapAssetGroupToUi( diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt index 39438a2fec..b5bd313d0a 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt @@ -2,10 +2,12 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.mapper import io.novafoundation.nova.common.list.GroupedList import io.novafoundation.nova.common.list.toListWithHeaders +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.utils.formatTokenAmount import io.novafoundation.nova.common.utils.formatting.formatAsChange import io.novafoundation.nova.common.utils.orZero import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.domain.common.PricedAmount import io.novafoundation.nova.feature_assets.domain.common.AssetWithNetwork import io.novafoundation.nova.feature_assets.domain.common.TokenAssetGroup @@ -17,13 +19,14 @@ import io.novafoundation.nova.feature_currency_api.presentation.formatters.forma import io.novafoundation.nova.feature_wallet_api.presentation.model.AmountModel fun GroupedList.mapGroupedAssetsToUi( + assetIconProvider: AssetIconProvider, assetFilter: (groupId: String, List) -> List, groupBalance: (TokenAssetGroup) -> PricedAmount = { it.groupBalance.total }, balance: (AssetBalance) -> PricedAmount = AssetBalance::total, ): List { - return mapKeys { (group, assets) -> mapTokenAssetGroupToUi(group, assets, groupBalance) } + return mapKeys { (group, assets) -> mapTokenAssetGroupToUi(assetIconProvider, group, assets, groupBalance) } .mapValues { (group, assets) -> - val assetModels = mapAssetsToAssetModels(group, assets, balance) + val assetModels = mapAssetsToAssetModels(assetIconProvider, group, assets, balance) assetFilter(group.itemId, assetModels) } .toListWithHeaders() @@ -31,6 +34,7 @@ fun GroupedList.mapGroupedAssetsToUi( } fun mapTokenAssetGroupToUi( + assetIconProvider: AssetIconProvider, assetGroup: TokenAssetGroup, assets: List, groupBalance: (TokenAssetGroup) -> PricedAmount = { it.groupBalance.total } @@ -38,7 +42,7 @@ fun mapTokenAssetGroupToUi( val balance = groupBalance(assetGroup) return TokenGroupUi( itemId = assetGroup.groupId, - tokenIcon = assetGroup.token.icon, + tokenIcon = assetIconProvider.getAssetIcon(assetGroup.token.icon), rate = mapCoinRateChange(assetGroup.token.coinRate, assetGroup.token.currency), recentRateChange = assetGroup.token.coinRate?.recentRateChange.orZero().formatAsChange(), rateChangeColorRes = mapCoinRateChangeColorRes(assetGroup.token.coinRate), @@ -53,11 +57,19 @@ fun mapTokenAssetGroupToUi( } private fun mapAssetsToAssetModels( + assetIconProvider: AssetIconProvider, group: TokenGroupUi, assets: List, balance: (AssetBalance) -> PricedAmount ): List { - return assets.map { TokenAssetUi(group.getId(), mapAssetToAssetModel(it.asset, balance(it.balanceWithOffChain)), mapChainToUi(it.chain)) } + return assets.map { + TokenAssetUi( + group.getId(), + mapAssetToAssetModel(it.asset, balance(it.balanceWithOffChain)), + assetIconProvider.getAssetIcon(it.asset.token.configuration), + mapChainToUi(it.chain) + ) + } } private fun mapType( diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/AssetDetailsModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/AssetDetailsModel.kt index 438cb5c8c8..73731acf2f 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/AssetDetailsModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/AssetDetailsModel.kt @@ -1,10 +1,12 @@ package io.novafoundation.nova.feature_assets.presentation.balance.detail +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.feature_assets.presentation.model.TokenModel import io.novafoundation.nova.feature_wallet_api.presentation.model.AmountModel class AssetDetailsModel( val token: TokenModel, + val assetIcon: Icon, val total: AmountModel, val transferable: AmountModel, val locked: AmountModel diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt index 0684fd9f62..5bae792337 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt @@ -10,6 +10,7 @@ import io.novafoundation.nova.common.base.BaseFragment import io.novafoundation.nova.common.di.FeatureUtils import io.novafoundation.nova.common.utils.applyBarMargin import io.novafoundation.nova.common.utils.hideKeyboard +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R @@ -120,7 +121,7 @@ class BalanceDetailFragment : BaseFragment() { } viewModel.assetDetailsModel.observe { asset -> - balanceDetailTokenIcon.loadTokenIcon(asset.token.configuration.iconUrl, imageLoader) + balanceDetailTokenIcon.setIcon(asset.assetIcon, imageLoader) balanceDetailTokenName.text = asset.token.configuration.symbol.value balanceDetailRate.text = asset.token.rate diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt index a1f48315d7..161607ecd6 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt @@ -4,11 +4,13 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.inBackground import io.novafoundation.nova.common.utils.sumByBigInteger import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.domain.WalletInteractor import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -63,7 +65,8 @@ class BalanceDetailViewModel( private val currencyInteractor: CurrencyInteractor, private val controllableAssetCheck: ControllableAssetCheckMixin, private val externalBalancesInteractor: ExternalBalancesInteractor, - private val swapAvailabilityInteractor: SwapAvailabilityInteractor + private val swapAvailabilityInteractor: SwapAvailabilityInteractor, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel(), TransactionHistoryUi by transactionHistoryMixin { @@ -204,7 +207,8 @@ class BalanceDetailViewModel( token = mapTokenToTokenModel(asset.token), total = mapAmountToAmountModel(asset.total + totalContributed, asset), transferable = mapAmountToAmountModel(asset.transferable, asset), - locked = mapAmountToAmountModel(asset.locked + totalContributed, asset) + locked = mapAmountToAmountModel(asset.locked + totalContributed, asset), + assetIcon = assetIconProvider.getAssetIcon(asset.token.configuration) ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/di/BalanceDetailModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/di/BalanceDetailModule.kt index 224b1b101d..801c3ab5d6 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/di/BalanceDetailModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/di/BalanceDetailModule.kt @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase @@ -64,7 +65,8 @@ class BalanceDetailModule { assetPayload: AssetPayload, addressDisplayUseCase: AddressDisplayUseCase, chainRegistry: ChainRegistry, - currencyRepository: CurrencyRepository + currencyRepository: CurrencyRepository, + assetIconProvider: AssetIconProvider ): TransactionHistoryMixin { return TransactionHistoryProvider( walletInteractor = walletInteractor, @@ -76,7 +78,8 @@ class BalanceDetailModule { chainRegistry = chainRegistry, chainId = assetPayload.chainId, assetId = assetPayload.chainAssetId, - currencyRepository = currencyRepository + currencyRepository = currencyRepository, + assetIconProvider ) } @@ -96,7 +99,8 @@ class BalanceDetailModule { currencyInteractor: CurrencyInteractor, controllableAssetCheckMixin: ControllableAssetCheckMixin, externalBalancesInteractor: ExternalBalancesInteractor, - swapAvailabilityInteractor: SwapAvailabilityInteractor + swapAvailabilityInteractor: SwapAvailabilityInteractor, + assetIconProvider: AssetIconProvider ): ViewModel { return BalanceDetailViewModel( walletInteractor = walletInteractor, @@ -111,7 +115,8 @@ class BalanceDetailModule { currencyInteractor = currencyInteractor, controllableAssetCheck = controllableAssetCheckMixin, externalBalancesInteractor = externalBalancesInteractor, - swapAvailabilityInteractor = swapAvailabilityInteractor + swapAvailabilityInteractor = swapAvailabilityInteractor, + assetIconProvider = assetIconProvider ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt index bd955e79e0..8e9dc7a6b5 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt @@ -11,6 +11,7 @@ import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase @@ -57,12 +58,14 @@ class BalanceListModule { @Provides @ScreenScope fun provideAssetListMixinFactory( + assetIconProvider: AssetIconProvider, walletInteractor: WalletInteractor, assetsListInteractor: AssetsListInteractor, currencyInteractor: CurrencyInteractor, externalBalancesInteractor: ExternalBalancesInteractor ): AssetListMixinFactory { return AssetListMixinFactory( + assetIconProvider, walletInteractor, assetsListInteractor, currencyInteractor, diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/NetworkAssetUi.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/NetworkAssetUi.kt index 5c086bec41..e5aa6c204b 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/NetworkAssetUi.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/NetworkAssetUi.kt @@ -1,8 +1,9 @@ package io.novafoundation.nova.feature_assets.presentation.balance.list.model.items +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.feature_assets.presentation.model.AssetModel import io.novafoundation.nova.runtime.ext.fullId -data class NetworkAssetUi(override val asset: AssetModel) : AssetRvItem { +data class NetworkAssetUi(override val asset: AssetModel, val icon: Icon) : AssetRvItem { override val itemId: String = "network_" + asset.token.configuration.fullId.toString() } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenAssetUi.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenAssetUi.kt index 464ded3603..3c179a103e 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenAssetUi.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenAssetUi.kt @@ -1,11 +1,17 @@ package io.novafoundation.nova.feature_assets.presentation.balance.list.model.items +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.recyclerView.expandable.items.ExpandableChildItem import io.novafoundation.nova.feature_account_api.presenatation.chain.ChainUi import io.novafoundation.nova.feature_assets.presentation.model.AssetModel import io.novafoundation.nova.runtime.ext.fullId -data class TokenAssetUi(override val groupId: String, override val asset: AssetModel, val chain: ChainUi) : AssetRvItem, ExpandableChildItem { +data class TokenAssetUi( + override val groupId: String, + override val asset: AssetModel, + val assetIcon: Icon, + val chain: ChainUi +) : AssetRvItem, ExpandableChildItem { override val itemId: String = "token_" + asset.token.configuration.fullId.toString() } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenGroupUi.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenGroupUi.kt index 6adbd9b5c7..b30d917195 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenGroupUi.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/model/items/TokenGroupUi.kt @@ -1,13 +1,14 @@ package io.novafoundation.nova.feature_assets.presentation.balance.list.model.items import androidx.annotation.ColorRes +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.recyclerView.expandable.items.ExpandableParentItem import io.novafoundation.nova.feature_assets.presentation.model.AssetModel import io.novafoundation.nova.feature_wallet_api.presentation.model.AmountModel data class TokenGroupUi( override val itemId: String, - val tokenIcon: String?, + val tokenIcon: Icon, val rate: String, val recentRateChange: String, @ColorRes val rateChangeColorRes: Int, diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/AssetSearchViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/AssetSearchViewModel.kt index 6c6fb62850..b9e2ff7993 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/AssetSearchViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/AssetSearchViewModel.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_assets.presentation.balance.search import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.utils.inBackground import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor import io.novafoundation.nova.feature_assets.domain.assets.search.AssetSearchInteractor @@ -18,6 +19,7 @@ class AssetSearchViewModel( interactor: AssetSearchInteractor, currencyInteractor: CurrencyInteractor, externalBalancesInteractor: ExternalBalancesInteractor, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel() { val query = MutableStateFlow("") @@ -32,7 +34,7 @@ class AssetSearchViewModel( interactor.searchAssetsFlow(query, externalBalances), selectedCurrency, ) { assets, currency -> - assets.mapGroupedAssetsToUi(currency) + assets.mapGroupedAssetsToUi(assetIconProvider, currency) } .distinctUntilChanged() .shareInBackground() diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/di/AssetSearchModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/di/AssetSearchModule.kt index c85f6e372f..c8c9aaaa12 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/di/AssetSearchModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/search/di/AssetSearchModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor import io.novafoundation.nova.feature_assets.domain.assets.search.AssetSearchInteractor import io.novafoundation.nova.feature_assets.presentation.AssetsRouter @@ -29,13 +30,15 @@ class AssetSearchModule { router: AssetsRouter, interactor: AssetSearchInteractor, currencyInteractor: CurrencyInteractor, - externalBalancesInteractor: ExternalBalancesInteractor + externalBalancesInteractor: ExternalBalancesInteractor, + assetIconProvider: AssetIconProvider ): ViewModel { return AssetSearchViewModel( router = router, interactor = interactor, currencyInteractor = currencyInteractor, - externalBalancesInteractor = externalBalancesInteractor + externalBalancesInteractor = externalBalancesInteractor, + assetIconProvider = assetIconProvider ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/AssetBuyFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/AssetBuyFlowViewModel.kt index df2c280bc6..47c0e1af03 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/AssetBuyFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/AssetBuyFlowViewModel.kt @@ -1,5 +1,6 @@ package io.novafoundation.nova.feature_assets.presentation.buy.flow.asset +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -24,6 +25,7 @@ class AssetBuyFlowViewModel( accountUseCase: SelectedAccountUseCase, buyMixinFactory: BuyMixin.Factory, resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ) : AssetFlowViewModel( interactor, router, @@ -32,6 +34,7 @@ class AssetBuyFlowViewModel( accountUseCase, externalBalancesInteractor, resourceManager, + assetIconProvider ) { val buyMixin = buyMixinFactory.create(scope = this) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/di/AssetBuyFlowModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/di/AssetBuyFlowModule.kt index d0c63c162e..1347155d1d 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/di/AssetBuyFlowModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/buy/flow/asset/di/AssetBuyFlowModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -37,7 +38,8 @@ class AssetBuyFlowModule { controllableAssetCheck: ControllableAssetCheckMixin, accountUseCase: SelectedAccountUseCase, buyMixinFactory: BuyMixin.Factory, - resourceManager: ResourceManager + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ): ViewModel { return AssetBuyFlowViewModel( interactor = interactor, @@ -47,7 +49,8 @@ class AssetBuyFlowModule { controllableAssetCheck = controllableAssetCheck, accountUseCase = accountUseCase, buyMixinFactory = buyMixinFactory, - resourceManager = resourceManager + resourceManager = resourceManager, + assetIconProvider = assetIconProvider ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/flow/asset/AssetFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/flow/asset/AssetFlowViewModel.kt index c4e9976e83..286d20be4a 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/flow/asset/AssetFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/flow/asset/AssetFlowViewModel.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_assets.presentation.flow.asset import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.flowOfAll import io.novafoundation.nova.common.utils.inBackground @@ -40,6 +41,7 @@ abstract class AssetFlowViewModel( internal val accountUseCase: SelectedAccountUseCase, externalBalancesInteractor: ExternalBalancesInteractor, internal val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel() { val acknowledgeLedgerWarning = controllableAssetCheck.acknowledgeLedgerWarning @@ -82,11 +84,11 @@ abstract class AssetFlowViewModel( } open fun mapNetworkAssets(assets: Map>, currency: Currency): List { - return assets.mapGroupedAssetsToUi(currency) + return assets.mapGroupedAssetsToUi(assetIconProvider, currency) } open fun mapTokensAssets(assets: Map>): List { - return assets.map { mapTokenAssetGroupToUi(it.key, assets = it.value) } + return assets.map { mapTokenAssetGroupToUi(assetIconProvider, it.key, assets = it.value) } } internal fun validate(assetModel: AssetModel, onAccept: (AssetModel) -> Unit) { diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt index 21a865ae63..9f8f20725b 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt @@ -7,6 +7,7 @@ import android.view.ViewGroup import coil.ImageLoader import io.novafoundation.nova.common.base.BaseFragment import io.novafoundation.nova.common.di.FeatureUtils +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setVisible import io.novafoundation.nova.common.view.shape.getRoundedCornerDrawable import io.novafoundation.nova.feature_account_api.presenatation.actions.setupExternalActions @@ -72,7 +73,7 @@ class ReceiveFragment : BaseFragment() { viewModel.receiver.observe { receiveFrom.setTextIcon(it.addressModel.image) - receiveFrom.primaryIcon.loadTokenIcon(it.chainAssetIcon, imageLoader) + receiveFrom.primaryIcon.setIcon(it.chainAssetIcon, imageLoader) receiveFrom.setMessage(it.addressModel.address) receiveFrom.setLabel(it.chain.name) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt index c0f8b830f1..9f40c2f599 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.QrCodeGenerator @@ -17,6 +18,7 @@ import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAcco import io.novafoundation.nova.feature_account_api.domain.model.addressIn import io.novafoundation.nova.feature_account_api.presenatation.account.icon.createAddressModel import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.domain.receive.ReceiveInteractor import io.novafoundation.nova.feature_wallet_api.presentation.model.AssetPayload @@ -40,6 +42,7 @@ class ReceiveViewModel( private val chainRegistry: ChainRegistry, selectedAccountUseCase: SelectedAccountUseCase, private val router: AssetsRouter, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel(), ExternalActions by externalActions { private val selectedMetaAccountFlow = selectedAccountUseCase.selectedMetaAccountFlow() @@ -64,7 +67,7 @@ class ReceiveViewModel( TokenReceiver( addressModel = addressIconGenerator.createAddressModel(chain, address, AddressIconGenerator.SIZE_BIG, it.name), chain = mapChainToUi(chain), - chainAssetIcon = chainAsset.iconUrl + chainAssetIcon = assetIconProvider.getAssetIcon(chainAsset) ) } .inBackground() diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/di/ReceiveModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/di/ReceiveModule.kt index 52d8931d6c..03c04eb825 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/di/ReceiveModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/di/ReceiveModule.kt @@ -11,6 +11,7 @@ import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule import io.novafoundation.nova.common.interfaces.FileProvider +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.QrCodeGenerator import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository @@ -46,6 +47,7 @@ class ReceiveModule { chainRegistry: ChainRegistry, selectedAccountUseCase: SelectedAccountUseCase, payload: AssetPayload, + assetIconProvider: AssetIconProvider ): ViewModel { return ReceiveViewModel( interactor, @@ -57,6 +59,7 @@ class ReceiveModule { chainRegistry, selectedAccountUseCase, router, + assetIconProvider ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/AssetReceiveFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/AssetReceiveFlowViewModel.kt index 309a023e52..a53af9202d 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/AssetReceiveFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/AssetReceiveFlowViewModel.kt @@ -1,5 +1,6 @@ package io.novafoundation.nova.feature_assets.presentation.receive.flow.asset +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -23,6 +24,7 @@ class AssetReceiveFlowViewModel( controllableAssetCheck: ControllableAssetCheckMixin, accountUseCase: SelectedAccountUseCase, resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ) : AssetFlowViewModel( interactor, router, @@ -31,6 +33,7 @@ class AssetReceiveFlowViewModel( accountUseCase, externalBalancesInteractor, resourceManager, + assetIconProvider ) { override fun searchAssetsFlow(): Flow { return interactor.searchReceiveAssetsFlow(query, externalBalancesFlow) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/di/AssetReceiveFlowModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/di/AssetReceiveFlowModule.kt index b918a582c8..ca0772c392 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/di/AssetReceiveFlowModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/flow/asset/di/AssetReceiveFlowModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -35,7 +36,8 @@ class AssetReceiveFlowModule { externalBalancesInteractor: ExternalBalancesInteractor, controllableAssetCheck: ControllableAssetCheckMixin, accountUseCase: SelectedAccountUseCase, - resourceManager: ResourceManager + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ): ViewModel { return AssetReceiveFlowViewModel( interactor = interactor, @@ -44,7 +46,8 @@ class AssetReceiveFlowModule { externalBalancesInteractor = externalBalancesInteractor, controllableAssetCheck = controllableAssetCheck, accountUseCase = accountUseCase, - resourceManager = resourceManager + resourceManager = resourceManager, + assetIconProvider = assetIconProvider ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/model/TokenReceiver.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/model/TokenReceiver.kt index 71ce98ed89..a9edb9ac2a 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/model/TokenReceiver.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/model/TokenReceiver.kt @@ -1,10 +1,11 @@ package io.novafoundation.nova.feature_assets.presentation.receive.model import io.novafoundation.nova.common.address.AddressModel +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.feature_account_api.presenatation.chain.ChainUi class TokenReceiver( val addressModel: AddressModel, val chain: ChainUi, - val chainAssetIcon: String? + val chainAssetIcon: Icon ) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/AssetSendFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/AssetSendFlowViewModel.kt index 9401f1c763..5d9e60f033 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/AssetSendFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/AssetSendFlowViewModel.kt @@ -1,5 +1,6 @@ package io.novafoundation.nova.feature_assets.presentation.send.flow.asset +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.view.PlaceholderModel import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase @@ -35,6 +36,7 @@ class AssetSendFlowViewModel( controllableAssetCheck: ControllableAssetCheckMixin, accountUseCase: SelectedAccountUseCase, resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider ) : AssetFlowViewModel( interactor, router, @@ -43,6 +45,7 @@ class AssetSendFlowViewModel( accountUseCase, externalBalancesInteractor, resourceManager, + assetIconProvider ) { override fun searchAssetsFlow(): Flow { @@ -64,12 +67,12 @@ class AssetSendFlowViewModel( } override fun mapNetworkAssets(assets: Map>, currency: Currency): List { - return assets.mapGroupedAssetsToUi(currency, NetworkAssetGroup::groupTransferableBalanceFiat, AssetBalance::transferable) + return assets.mapGroupedAssetsToUi(assetIconProvider, currency, NetworkAssetGroup::groupTransferableBalanceFiat, AssetBalance::transferable) } override fun mapTokensAssets(assets: Map>): List { return assets.map { (group, assets) -> - mapTokenAssetGroupToUi(group, assets = assets) { it.groupBalance.transferable } + mapTokenAssetGroupToUi(assetIconProvider, group, assets = assets) { it.groupBalance.transferable } } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/di/AssetSendFlowModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/di/AssetSendFlowModule.kt index 7fdf4bb8f1..66e83a07aa 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/di/AssetSendFlowModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/send/flow/asset/di/AssetSendFlowModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -35,7 +36,8 @@ class AssetSendFlowModule { externalBalancesInteractor: ExternalBalancesInteractor, controllableAssetCheck: ControllableAssetCheckMixin, accountUseCase: SelectedAccountUseCase, - resourceManager: ResourceManager + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ): ViewModel { return AssetSendFlowViewModel( interactor = interactor, @@ -44,7 +46,8 @@ class AssetSendFlowModule { externalBalancesInteractor = externalBalancesInteractor, controllableAssetCheck = controllableAssetCheck, accountUseCase = accountUseCase, - resourceManager = resourceManager + resourceManager = resourceManager, + assetIconProvider = assetIconProvider ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt index 63db3e3d28..fabeae84a2 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt @@ -2,6 +2,7 @@ package io.novafoundation.nova.feature_assets.presentation.swap.asset import androidx.annotation.StringRes import androidx.lifecycle.viewModelScope +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.launchUnit import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase @@ -42,7 +43,8 @@ class AssetSwapFlowViewModel( resourceManager: ResourceManager, private val swapAvailabilityInteractor: SwapAvailabilityInteractor, private val swapFlowExecutor: SwapFlowExecutor, - private val swapPayload: SwapFlowPayload + private val swapPayload: SwapFlowPayload, + private val assetIconProvider: AssetIconProvider ) : AssetFlowViewModel( interactor, router, @@ -51,6 +53,7 @@ class AssetSwapFlowViewModel( accountUseCase, externalBalancesInteractor, resourceManager, + assetIconProvider ) { init { @@ -92,12 +95,12 @@ class AssetSwapFlowViewModel( } override fun mapNetworkAssets(assets: Map>, currency: Currency): List { - return assets.mapGroupedAssetsToUi(currency, NetworkAssetGroup::groupTransferableBalanceFiat, AssetBalance::transferable) + return assets.mapGroupedAssetsToUi(assetIconProvider, currency, NetworkAssetGroup::groupTransferableBalanceFiat, AssetBalance::transferable) } override fun mapTokensAssets(assets: Map>): List { return assets.map { (group, assets) -> - mapTokenAssetGroupToUi(group, assets = assets) { it.groupBalance.transferable } + mapTokenAssetGroupToUi(assetIconProvider, group, assets = assets) { it.groupBalance.transferable } } } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/di/AssetSwapFlowModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/di/AssetSwapFlowModule.kt index 3ee24a13bf..1ec2f3962d 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/di/AssetSwapFlowModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/di/AssetSwapFlowModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -41,7 +42,8 @@ class AssetSwapFlowModule { resourceManager: ResourceManager, payload: SwapFlowPayload, executorFactory: SwapFlowExecutorFactory, - swapAvailabilityInteractor: SwapAvailabilityInteractor + swapAvailabilityInteractor: SwapAvailabilityInteractor, + assetIconProvider: AssetIconProvider ): ViewModel { return AssetSwapFlowViewModel( interactor = interactor, @@ -53,7 +55,8 @@ class AssetSwapFlowModule { resourceManager = resourceManager, swapFlowExecutor = executorFactory.create(payload), swapPayload = payload, - swapAvailabilityInteractor = swapAvailabilityInteractor + swapAvailabilityInteractor = swapAvailabilityInteractor, + assetIconProvider = assetIconProvider ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt index ff3b442deb..29d3ceeb6e 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt @@ -9,6 +9,7 @@ import io.novafoundation.nova.common.list.BaseListAdapter import io.novafoundation.nova.common.list.BaseViewHolder import io.novafoundation.nova.common.list.PayloadGenerator import io.novafoundation.nova.common.list.resolvePayload +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.inflateChild import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon @@ -78,7 +79,7 @@ class ManageTokensViewHolder( bindEnabled(item) - itemManageTokenMultichainIcon.loadTokenIcon(item.header.icon, imageLoader) + itemManageTokenMultichainIcon.setIcon(item.header.icon, imageLoader) itemManageTokenMultichainSymbol.text = item.header.symbol } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt index b5a6c7d457..7946aa79da 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt @@ -8,6 +8,7 @@ import androidx.core.os.bundleOf import coil.ImageLoader import io.novafoundation.nova.common.base.BaseBottomSheetFragment import io.novafoundation.nova.common.di.FeatureUtils +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.di.AssetsFeatureApi @@ -58,7 +59,7 @@ class ManageChainTokensFragment : override fun subscribe(viewModel: ManageChainTokensViewModel) { viewModel.headerModel.observe { headerModel -> - manageChainTokenIcon.loadTokenIcon(headerModel.icon, imageLoader) + manageChainTokenIcon.setIcon(headerModel.icon, imageLoader) manageChainTokenSymbol.text = headerModel.symbol manageChainTokenSubtitle.text = headerModel.networks } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt index 9432c0a24b..1b3b497f24 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt @@ -1,7 +1,9 @@ package io.novafoundation.nova.feature_assets.presentation.tokens.manage.model +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.resources.formatListPreview +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.domain.tokens.manage.MultiChainToken @@ -12,19 +14,20 @@ data class MultiChainTokenModel( ) { class HeaderModel( - val icon: String?, + val icon: Icon, val symbol: String, val networks: String, ) } class MultiChainTokenMapper( + private val assetIconProvider: AssetIconProvider, private val resourceManager: ResourceManager ) { fun mapHeaderToUi(multiChainToken: MultiChainToken): MultiChainTokenModel.HeaderModel { return MultiChainTokenModel.HeaderModel( - icon = multiChainToken.icon, + icon = assetIconProvider.getAssetIcon(multiChainToken.icon), symbol = multiChainToken.symbol, networks = constructNetworksSubtitle(multiChainToken) ) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/di/ExtrinsicDetailModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/di/ExtrinsicDetailModule.kt index 6d8205acbc..ea43083787 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/di/ExtrinsicDetailModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/di/ExtrinsicDetailModule.kt @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.presenatation.account.AddressDisplayUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions @@ -30,6 +31,7 @@ class ExtrinsicDetailModule { operation: OperationParcelizeModel.Extrinsic, externalActions: ExternalActions.Presentation, resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ): ViewModel { return ExtrinsicDetailViewModel( addressDisplayUseCase, @@ -38,7 +40,8 @@ class ExtrinsicDetailModule { router, operation, externalActions, - resourceManager + resourceManager, + assetIconProvider ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt index bb18c64e30..1e7f0abada 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt @@ -9,6 +9,7 @@ import coil.ImageLoader import io.novafoundation.nova.common.base.BaseFragment import io.novafoundation.nova.common.di.FeatureUtils import io.novafoundation.nova.common.utils.formatting.formatDateTime +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextColorRes import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.view.TableCellView @@ -93,7 +94,7 @@ class ExtrinsicDetailFragment : BaseFragment() { viewModel.chainUi.observe(extrinsicDetailNetwork::showChain) viewModel.operationIcon.observe { - extrinsicDetailIcon.loadTokenIcon(it, imageLoader) + extrinsicDetailIcon.setIcon(it, imageLoader) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt index b655729a3c..2dfc929632 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt @@ -2,6 +2,7 @@ package io.novafoundation.nova.feature_assets.presentation.transaction.detail.ex import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.flowOf import io.novafoundation.nova.common.utils.inBackground @@ -28,6 +29,7 @@ class ExtrinsicDetailViewModel( val operation: OperationParcelizeModel.Extrinsic, private val externalActions: ExternalActions.Presentation, private val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel(), ExternalActions by externalActions { @@ -52,7 +54,7 @@ class ExtrinsicDetailViewModel( .share() val operationIcon = flowOf { - chainAsset().iconUrl + assetIconProvider.getAssetIcon(chainAsset().icon) }.shareInBackground() val content = flowOf { @@ -91,10 +93,12 @@ class ExtrinsicDetailViewModel( label = blockEntry.label, addressModel = getIcon(blockEntry.address), ) + is ExtrinsicContentParcel.BlockEntry.LabeledValue -> ExtrinsicContentModel.BlockEntry.LabeledValue( label = blockEntry.label, value = blockEntry.value ) + is ExtrinsicContentParcel.BlockEntry.TransactionId -> ExtrinsicContentModel.BlockEntry.TransactionId( label = resourceManager.getString(R.string.common_transaction_id), hash = blockEntry.hash diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt index 6530111bcf..b8a1aea05c 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.presentation.transaction.detail.sw import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.address.AddressModel import io.novafoundation.nova.common.base.BaseViewModel +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.utils.flowOf import io.novafoundation.nova.common.utils.invoke import io.novafoundation.nova.common.utils.lazyAsync @@ -13,7 +14,7 @@ import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi import io.novafoundation.nova.feature_account_api.presenatation.account.icon.createAccountAddressModel import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.WalletUiUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.icon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.AssetsRouter import io.novafoundation.nova.feature_assets.presentation.model.ChainAssetWithAmountParcelModel @@ -49,6 +50,7 @@ class SwapDetailViewModel( private val walletUiUseCase: WalletUiUseCase, private val swapRateFormatter: SwapRateFormatter, private val descriptionBottomSheetLauncher: DescriptionBottomSheetLauncher, + private val assetIconProvider: AssetIconProvider, val operation: OperationParcelizeModel.Swap, ) : BaseViewModel(), ExternalActions by externalActions, @@ -152,7 +154,7 @@ class SwapDetailViewModel( income: Boolean ): SwapAssetView.Model { return SwapAssetView.Model( - assetIcon = token.configuration.icon(), + assetIcon = assetIconProvider.getAssetIcon(token.configuration), amount = mapAmountToAmountModel(amount, token, estimatedFiat = true), chainUi = mapChainToUi(chainRegistry.getChain(token.configuration.chainId)), amountTextColorRes = if (income) R.color.text_positive else R.color.text_primary diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/di/SwapDetailModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/di/SwapDetailModule.kt index fead69fb8b..bdce8bbff5 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/di/SwapDetailModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/di/SwapDetailModule.kt @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.view.bottomSheet.description.DescriptionBottomSheetLauncher import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.WalletUiUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions @@ -34,6 +35,7 @@ class SwapDetailModule { arbitraryTokenUseCase: ArbitraryTokenUseCase, walletUiUseCase: WalletUiUseCase, swapRateFormatter: SwapRateFormatter, + assetIconProvider: AssetIconProvider, descriptionBottomSheetLauncher: DescriptionBottomSheetLauncher ): ViewModel { return SwapDetailViewModel( @@ -45,7 +47,8 @@ class SwapDetailModule { arbitraryTokenUseCase = arbitraryTokenUseCase, walletUiUseCase = walletUiUseCase, swapRateFormatter = swapRateFormatter, - descriptionBottomSheetLauncher = descriptionBottomSheetLauncher + descriptionBottomSheetLauncher = descriptionBottomSheetLauncher, + assetIconProvider = assetIconProvider ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt index 62de34155a..9610c02a7c 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt @@ -5,12 +5,14 @@ import android.text.TextUtils import android.text.style.ImageSpan import androidx.annotation.ColorRes import androidx.annotation.DrawableRes +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.buildSpannable import io.novafoundation.nova.common.utils.capitalize import io.novafoundation.nova.common.utils.images.asIcon import io.novafoundation.nova.common.utils.splitSnakeOrCamelCase import io.novafoundation.nova.feature_account_api.presenatation.account.AddressDisplayUseCase +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.model.AmountParcelModel import io.novafoundation.nova.feature_assets.presentation.model.ChainAssetWithAmountParcelModel @@ -212,6 +214,7 @@ fun mapOperationToOperationModel( operation: Operation, nameIdentifier: AddressDisplayUseCase.Identifier, resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider ): OperationModel { val statusAppearance = mapStatusToStatusAppearance(operation.status) val formattedTime = resourceManager.formatTime(operation.time) @@ -273,7 +276,7 @@ fun mapOperationToOperationModel( subHeader = subHeader.value, subHeaderEllipsize = subHeader.elipsize, statusAppearance = statusAppearance, - operationIcon = operation.chainAsset.iconUrl?.asIcon() ?: R.drawable.ic_nova.asIcon() + operationIcon = assetIconProvider.getAssetIcon(operation.chainAsset) ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/TransactionHistoryProvider.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/TransactionHistoryProvider.kt index 0e2d560ddd..2aabcd9418 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/TransactionHistoryProvider.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/TransactionHistoryProvider.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_assets.presentation.transaction.history.mixin import android.util.Log +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.LOG_TAG import io.novafoundation.nova.common.utils.daysFromMillis @@ -50,7 +51,8 @@ class TransactionHistoryProvider( private val chainRegistry: ChainRegistry, private val chainId: ChainId, private val assetId: Int, - private val currencyRepository: CurrencyRepository + private val currencyRepository: CurrencyRepository, + private val assetIconProvider: AssetIconProvider ) : TransactionHistoryMixin, CoroutineScope by CoroutineScope(Dispatchers.Default) { private val domainState = singleReplaySharedFlow() @@ -237,7 +239,7 @@ class TransactionHistoryProvider( val header = DayHeader(daysSinceEpoch) val operationModels = operationsPerDay.map { operation -> - mapOperationToOperationModel(chain, token, operation, accountIdentifier, resourceManager) + mapOperationToOperationModel(chain, token, operation, accountIdentifier, resourceManager, assetIconProvider) } listOf(header) + operationModels diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/di/CrowdloanFeatureDependencies.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/di/CrowdloanFeatureDependencies.kt index 400677e556..d750c8a7fa 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/di/CrowdloanFeatureDependencies.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/di/CrowdloanFeatureDependencies.kt @@ -9,6 +9,7 @@ import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.secrets.v2.SecretStoreV2 import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.mixin.api.CustomDialogDisplayer +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.core.storage.StorageCache @@ -36,6 +37,16 @@ import javax.inject.Named interface CrowdloanFeatureDependencies { + val parachainInfoRepository: ParachainInfoRepository + + val signerProvider: SignerProvider + + val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory + + val externalBalanceDao: ExternalBalanceDao + + val assetIconProvider: AssetIconProvider + fun contributionDao(): ContributionDao fun accountUpdaterScope(): AccountUpdateScope @@ -91,12 +102,4 @@ interface CrowdloanFeatureDependencies { fun customDialogDisplayer(): CustomDialogDisplayer.Presentation fun feeLoaderMixinFactory(): FeeLoaderMixin.Factory - - val parachainInfoRepository: ParachainInfoRepository - - val signerProvider: SignerProvider - - val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory - - val externalBalanceDao: ExternalBalanceDao } diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeFragment.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeFragment.kt index 52d0fc69f0..a782831241 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeFragment.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeFragment.kt @@ -89,7 +89,7 @@ class ConfirmContributeFragment : BaseFragment() { viewModel.assetModelFlow.observe { confirmContributeAmount.setAssetBalance(it.assetBalance) confirmContributeAmount.setAssetName(it.tokenSymbol) - confirmContributeAmount.loadAssetImage(it.imageUrl) + confirmContributeAmount.loadAssetImage(it.icon) } confirmContributeAmount.amountInput.setText(viewModel.selectedAmount) diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeViewModel.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeViewModel.kt index c580567744..13d0fdd50c 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeViewModel.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/ConfirmContributeViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.base.BaseViewModel import io.novafoundation.nova.common.mixin.api.Validatable +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.flowOf @@ -43,6 +44,7 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch class ConfirmContributeViewModel( + private val assetIconProvider: AssetIconProvider, private val router: CrowdloanRouter, private val contributionInteractor: CrowdloanContributeInteractor, private val resourceManager: ResourceManager, @@ -72,7 +74,7 @@ class ConfirmContributeViewModel( .share() val assetModelFlow = assetFlow - .map { mapAssetToAssetModel(it, resourceManager) } + .map { mapAssetToAssetModel(assetIconProvider, it, resourceManager) } .inBackground() .share() diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/di/ConfirmContributeModule.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/di/ConfirmContributeModule.kt index 8dc0a3d630..d309b4d198 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/di/ConfirmContributeModule.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/confirm/di/ConfirmContributeModule.kt @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase @@ -30,6 +31,7 @@ class ConfirmContributeModule { @IntoMap @ViewModelKey(ConfirmContributeViewModel::class) fun provideViewModel( + assetIconProvider: AssetIconProvider, interactor: CrowdloanContributeInteractor, router: CrowdloanRouter, resourceManager: ResourceManager, @@ -44,6 +46,7 @@ class ConfirmContributeModule { singleAssetSharedState: CrowdloanSharedState, ): ViewModel { return ConfirmContributeViewModel( + assetIconProvider, router, interactor, resourceManager, diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeFragment.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeFragment.kt index 3cb84a9615..54e6b2c4dc 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeFragment.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeFragment.kt @@ -96,7 +96,7 @@ class CrowdloanContributeFragment : BaseFragment() viewModel.assetModelFlow.observe { crowdloanContributeAmount.setAssetBalance(it.assetBalance) crowdloanContributeAmount.setAssetName(it.tokenSymbol) - crowdloanContributeAmount.loadAssetImage(it.imageUrl) + crowdloanContributeAmount.loadAssetImage(it.icon) } crowdloanContributeAmount.amountInput.bindTo(viewModel.enteredAmountFlow, lifecycleScope) diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeViewModel.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeViewModel.kt index 89d25edf56..e26f2a889b 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeViewModel.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/CrowdloanContributeViewModel.kt @@ -8,6 +8,7 @@ import io.novafoundation.nova.common.base.BaseViewModel import io.novafoundation.nova.common.mixin.api.Browserable import io.novafoundation.nova.common.mixin.api.Validatable import io.novafoundation.nova.common.mixin.api.of +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.flowOf @@ -71,6 +72,7 @@ sealed class ExtraBonusState { } class CrowdloanContributeViewModel( + private val assetIconProvider: AssetIconProvider, private val router: CrowdloanRouter, private val contributionInteractor: CrowdloanContributeInteractor, private val resourceManager: ResourceManager, @@ -97,7 +99,7 @@ class CrowdloanContributeViewModel( .share() val assetModelFlow = assetFlow - .map { mapAssetToAssetModel(it, resourceManager) } + .map { mapAssetToAssetModel(assetIconProvider, it, resourceManager) } .inBackground() .share() diff --git a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/di/CrowdloanContributeModule.kt b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/di/CrowdloanContributeModule.kt index ef392ef335..19d820cce0 100644 --- a/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/di/CrowdloanContributeModule.kt +++ b/feature-crowdloan-impl/src/main/java/io/novafoundation/nova/feature_crowdloan_impl/presentation/contribute/select/di/CrowdloanContributeModule.kt @@ -8,6 +8,7 @@ import dagger.Provides import dagger.multibindings.IntoMap import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.feature_crowdloan_impl.di.customCrowdloan.CustomContributeManager @@ -27,6 +28,7 @@ class CrowdloanContributeModule { @IntoMap @ViewModelKey(CrowdloanContributeViewModel::class) fun provideViewModel( + assetIconProvider: AssetIconProvider, interactor: CrowdloanContributeInteractor, router: CrowdloanRouter, resourceManager: ResourceManager, @@ -38,6 +40,7 @@ class CrowdloanContributeModule { customContributeManager: CustomContributeManager, ): ViewModel { return CrowdloanContributeViewModel( + assetIconProvider, router, interactor, resourceManager, diff --git a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt index 9d45570312..dca0ce27dc 100644 --- a/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt +++ b/feature-external-sign-impl/src/main/java/io/novafoundation/nova/feature_external_sign_impl/domain/sign/evm/EvmSignInteractor.kt @@ -311,7 +311,7 @@ class EvmSignInteractor( val chainCurrency = evmChain.nativeCurrency return Chain.Asset( - icon = evmChain.iconUrl?.let { Chain.Icon(it) }, + icon = null, id = 0, priceId = null, chainId = evmChain.chainId, diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureDependencies.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureDependencies.kt index ab6fe593b2..3fc3d9edd1 100644 --- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureDependencies.kt +++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureDependencies.kt @@ -11,6 +11,7 @@ import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.modules.Caching import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin import io.novafoundation.nova.common.mixin.hints.ResourcesHintsMixinFactory +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.multiResult.PartialRetriableMixin import io.novafoundation.nova.common.validation.ValidationExecutor @@ -48,6 +49,24 @@ import javax.inject.Named interface GovernanceFeatureDependencies { + val onChainIdentityRepository: OnChainIdentityRepository + + val listChooserMixinFactory: ListChooserMixin.Factory + + val identityMixinFactory: IdentityMixin.Factory + + val partialRetriableMixinFactory: PartialRetriableMixin.Factory + + val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory + + val bannerVisibilityRepository: BannerVisibilityRepository + + val chainMultiLocationConverterFactory: ChainMultiLocationConverterFactory + + val assetMultiLocationConverterFactory: MultiLocationConverterFactory + + val assetIconProvider: AssetIconProvider + val feeLoaderMixinFactory: FeeLoaderMixin.Factory val validationExecutor: ValidationExecutor @@ -118,20 +137,4 @@ interface GovernanceFeatureDependencies { @Named(REMOTE_STORAGE_SOURCE) fun remoteStorageDataSource(): StorageDataSource - - val onChainIdentityRepository: OnChainIdentityRepository - - val listChooserMixinFactory: ListChooserMixin.Factory - - val identityMixinFactory: IdentityMixin.Factory - - val partialRetriableMixinFactory: PartialRetriableMixin.Factory - - val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory - - val bannerVisibilityRepository: BannerVisibilityRepository - - val chainMultiLocationConverterFactory: ChainMultiLocationConverterFactory - - val assetMultiLocationConverterFactory: MultiLocationConverterFactory } diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureModule.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureModule.kt index 6b5a05461c..01af05c6f5 100644 --- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureModule.kt +++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/di/GovernanceFeatureModule.kt @@ -6,6 +6,7 @@ import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.FeatureScope +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.data.repository.OnChainIdentityRepository import io.novafoundation.nova.feature_account_api.domain.account.identity.IdentityProvider @@ -156,8 +157,9 @@ class GovernanceFeatureModule { @FeatureScope fun provideTracksFormatter( trackCategorizer: TrackCategorizer, - resourceManager: ResourceManager - ): TrackFormatter = RealTrackFormatter(trackCategorizer, resourceManager) + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider + ): TrackFormatter = RealTrackFormatter(trackCategorizer, resourceManager, assetIconProvider) @Provides @FeatureScope diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt index 9cecfa905e..c0bae59d97 100644 --- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt +++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt @@ -1,9 +1,12 @@ package io.novafoundation.nova.feature_governance_impl.presentation.track +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.resources.formatListPreview import io.novafoundation.nova.common.utils.capitalize import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.common.utils.images.asIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_governance_api.domain.referendum.track.category.TrackType import io.novafoundation.nova.feature_governance_api.domain.track.Track import io.novafoundation.nova.feature_governance_impl.R @@ -27,70 +30,86 @@ fun TrackFormatter.formatTracks(tracks: List, asset: Chain.Asset): Tracks class RealTrackFormatter( private val trackCategorizer: TrackCategorizer, private val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider ) : TrackFormatter { override fun formatTrack(track: Track, asset: Chain.Asset): TrackModel { return when (trackCategorizer.typeOf(track.name)) { TrackType.ROOT -> TrackModel( name = resourceManager.getString(R.string.referendum_track_root), - icon = asset.iconUrl?.let { Icon.FromLink(it) } ?: Icon.FromDrawableRes(R.drawable.ic_block), + icon = assetIconProvider.getAssetIcon(asset, fallbackIcon = R.drawable.ic_block.asIcon()), ) + TrackType.WHITELISTED_CALLER -> TrackModel( name = resourceManager.getString(R.string.referendum_whitelisted_caller), icon = Icon.FromDrawableRes(R.drawable.ic_users), ) + TrackType.STAKING_ADMIN -> TrackModel( name = resourceManager.getString(R.string.referendum_staking_admin), icon = Icon.FromDrawableRes(R.drawable.ic_staking_filled), ) + TrackType.TREASURER -> TrackModel( name = resourceManager.getString(R.string.referendum_track_treasurer), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.LEASE_ADMIN -> TrackModel( name = resourceManager.getString(R.string.referendum_track_lease_admin), icon = Icon.FromDrawableRes(R.drawable.ic_governance_check_to_slot), ) + TrackType.FELLOWSHIP_ADMIN -> TrackModel( name = resourceManager.getString(R.string.referendum_track_fellowship_admin), icon = Icon.FromDrawableRes(R.drawable.ic_users), ) + TrackType.GENERAL_ADMIN -> TrackModel( name = resourceManager.getString(R.string.referendum_track_general_admin), icon = Icon.FromDrawableRes(R.drawable.ic_governance_check_to_slot), ) + TrackType.AUCTION_ADMIN -> TrackModel( name = resourceManager.getString(R.string.referendum_track_auction_admin), icon = Icon.FromDrawableRes(R.drawable.ic_rocket), ) + TrackType.REFERENDUM_CANCELLER -> TrackModel( name = resourceManager.getString(R.string.referendum_track_referendum_canceller), icon = Icon.FromDrawableRes(R.drawable.ic_governance_check_to_slot), ) + TrackType.REFERENDUM_KILLER -> TrackModel( name = resourceManager.getString(R.string.referendum_track_referendum_killer), icon = Icon.FromDrawableRes(R.drawable.ic_governance_check_to_slot), ) + TrackType.SMALL_TIPPER -> TrackModel( name = resourceManager.getString(R.string.referendum_track_small_tipper), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.BIG_TIPPER -> TrackModel( name = resourceManager.getString(R.string.referendum_track_big_tipper), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.SMALL_SPEND -> TrackModel( name = resourceManager.getString(R.string.referendum_track_small_spender), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.MEDIUM_SPEND -> TrackModel( name = resourceManager.getString(R.string.referendum_track_medium_spender), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.BIG_SPEND -> TrackModel( name = resourceManager.getString(R.string.referendum_track_big_spender), icon = Icon.FromDrawableRes(R.drawable.ic_gem), ) + TrackType.OTHER -> TrackModel( name = mapUnknownTrackNameToUi(track.name), icon = Icon.FromDrawableRes(R.drawable.ic_block), diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/di/SwapFeatureDependencies.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/di/SwapFeatureDependencies.kt index a16bd0c308..fd24d197cb 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/di/SwapFeatureDependencies.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/di/SwapFeatureDependencies.kt @@ -8,6 +8,7 @@ import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin import io.novafoundation.nova.common.mixin.hints.ResourcesHintsMixinFactory +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.common.view.bottomSheet.description.DescriptionBottomSheetLauncher @@ -128,4 +129,6 @@ interface SwapFeatureDependencies { val gson: Gson val customFeeCapabilityFacade: CustomFeeCapabilityFacade + + val assetIconProvider: AssetIconProvider } diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt index cf3d45e4a9..4cc2e64d8b 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt @@ -5,6 +5,7 @@ import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.address.AddressModel import io.novafoundation.nova.common.base.BaseViewModel import io.novafoundation.nova.common.mixin.api.Validatable +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Percent import io.novafoundation.nova.common.utils.asPercent @@ -26,7 +27,7 @@ import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.W import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.WalletUiUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions import io.novafoundation.nova.feature_account_api.presenatation.actions.showAddressActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.icon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_swap_core.domain.model.SwapDirection import io.novafoundation.nova.feature_swap_api.domain.model.SwapFee import io.novafoundation.nova.feature_swap_api.domain.model.SwapQuote @@ -116,6 +117,7 @@ class SwapConfirmationViewModel( private val descriptionBottomSheetLauncher: DescriptionBottomSheetLauncher, private val arbitraryAssetUseCase: ArbitraryAssetUseCase, private val maxActionProviderFactory: MaxActionProviderFactory, + private val assetIconProvider: AssetIconProvider ) : BaseViewModel(), ExternalActions by externalActions, Validatable by validationExecutor, @@ -290,7 +292,7 @@ class SwapConfirmationViewModel( ): SwapAssetView.Model { val amount = formatAmount(metaAccount, chainAsset, amountInPlanks) return SwapAssetView.Model( - assetIcon = chainAsset.icon(), + assetIcon = assetIconProvider.getAssetIcon(chainAsset), amount = amount, chainUi = mapChainToUi(chain), ) diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/di/SwapConfirmationModule.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/di/SwapConfirmationModule.kt index 81af3688ca..3fd4b7de44 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/di/SwapConfirmationModule.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/di/SwapConfirmationModule.kt @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.common.view.bottomSheet.description.DescriptionBottomSheetLauncher @@ -56,7 +57,8 @@ class SwapConfirmationModule { feeLoaderMixinFactory: FeeLoaderMixin.Factory, descriptionBottomSheetLauncher: DescriptionBottomSheetLauncher, assetUseCase: ArbitraryAssetUseCase, - maxActionProviderFactory: MaxActionProviderFactory + maxActionProviderFactory: MaxActionProviderFactory, + assetIconProvider: AssetIconProvider ): ViewModel { return SwapConfirmationViewModel( swapRouter, @@ -78,7 +80,8 @@ class SwapConfirmationModule { feeLoaderMixinFactory, descriptionBottomSheetLauncher, assetUseCase, - maxActionProviderFactory + maxActionProviderFactory, + assetIconProvider ) } diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/di/SwapMainSettingsModule.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/di/SwapMainSettingsModule.kt index 51f0b15b37..df574276a8 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/di/SwapMainSettingsModule.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/di/SwapMainSettingsModule.kt @@ -10,6 +10,7 @@ import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey import io.novafoundation.nova.common.di.viewmodel.ViewModelModule import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.ValidationExecutor import io.novafoundation.nova.common.view.bottomSheet.description.DescriptionBottomSheetLauncher @@ -41,8 +42,9 @@ class SwapMainSettingsModule { @ScreenScope fun provideSwapAmountMixinFactory( chainRegistry: ChainRegistry, - resourceManager: ResourceManager - ) = SwapAmountInputMixinFactory(chainRegistry, resourceManager) + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider + ) = SwapAmountInputMixinFactory(chainRegistry, resourceManager, assetIconProvider) @Provides @ScreenScope diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixin.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixin.kt index 092ba8275e..2f18f475bd 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixin.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixin.kt @@ -19,7 +19,7 @@ interface SwapAmountInputMixin : AmountChooserMixinBase { ) { sealed class SwapAssetIcon { - class Chosen(val assetIconUrl: String?) : SwapAssetIcon() + class Chosen(val assetIcon: Icon) : SwapAssetIcon() object NotChosen : SwapAssetIcon() } diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt index 628d1e8b98..d64f15daaf 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt @@ -1,8 +1,10 @@ package io.novafoundation.nova.feature_swap_impl.presentation.main.input import androidx.annotation.StringRes +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.FieldValidator +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_account_api.presenatation.chain.iconOrFallback import io.novafoundation.nova.feature_swap_impl.R import io.novafoundation.nova.feature_swap_impl.presentation.main.input.SwapAmountInputMixin.SwapInputAssetModel @@ -19,7 +21,8 @@ import kotlinx.coroutines.flow.map class SwapAmountInputMixinFactory( private val chainRegistry: ChainRegistry, - private val resourceManager: ResourceManager + private val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider ) { fun create( @@ -38,7 +41,8 @@ class SwapAmountInputMixinFactory( resourceManager = resourceManager, maxActionProvider = maxActionProvider, fiatFormatter = fiatFormatter, - fieldValidator = fieldValidator + fieldValidator = fieldValidator, + assetIconProvider = assetIconProvider ) } } @@ -51,7 +55,8 @@ private class RealSwapAmountInputMixin( private val resourceManager: ResourceManager, maxActionProvider: MaxActionProvider?, fiatFormatter: AmountChooserMixinBase.FiatFormatter, - fieldValidator: FieldValidator + fieldValidator: FieldValidator, + private val assetIconProvider: AssetIconProvider ) : BaseAmountChooserProvider( coroutineScope = coroutineScope, tokenFlow = tokenFlow, @@ -75,7 +80,7 @@ private class RealSwapAmountInputMixin( val chain = chainRegistry.getChain(chainAsset.chainId) return SwapInputAssetModel( - assetIcon = SwapInputAssetModel.SwapAssetIcon.Chosen(chainAsset.iconUrl), + assetIcon = SwapInputAssetModel.SwapAssetIcon.Chosen(assetIconProvider.getAssetIcon(chainAsset)), title = chainAsset.symbol.value, subtitleIcon = chain.iconOrFallback(), subtitle = chain.name, diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt index 4a5289f6fe..e6c6d935b8 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt @@ -9,6 +9,7 @@ import coil.ImageLoader import io.novafoundation.nova.common.di.FeatureUtils import io.novafoundation.nova.common.utils.WithContextExtensions import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.images.setIconOrMakeGone import io.novafoundation.nova.common.view.shape.getInputBackground import io.novafoundation.nova.common.view.shape.getInputBackgroundError @@ -81,7 +82,7 @@ class SwapAmountInputView @JvmOverloads constructor( private fun setAssetIcon(icon: SwapInputAssetModel.SwapAssetIcon) { return when (icon) { is SwapInputAssetModel.SwapAssetIcon.Chosen -> { - swapAmountInputImage.loadTokenIcon(icon.assetIconUrl, imageLoader) + swapAmountInputImage.setIcon(icon.assetIcon, imageLoader) swapAmountInputImage.setBackgroundResource(R.drawable.bg_token_container) } diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt index 1bf7065461..7f87ac6e0e 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt @@ -1,7 +1,9 @@ package io.novafoundation.nova.feature_wallet_api.data.mappers import androidx.annotation.StringRes +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_wallet_api.R import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.feature_wallet_api.presentation.formatters.formatTokenAmount @@ -9,6 +11,7 @@ import io.novafoundation.nova.feature_wallet_api.presentation.model.AssetModel import java.math.BigDecimal fun mapAssetToAssetModel( + assetIconProvider: AssetIconProvider, asset: Asset, resourceManager: ResourceManager, retrieveAmount: (Asset) -> BigDecimal = Asset::transferable, @@ -21,7 +24,7 @@ fun mapAssetToAssetModel( AssetModel( chainId = asset.token.configuration.chainId, chainAssetId = asset.token.configuration.id, - imageUrl = token.configuration.iconUrl, + icon = assetIconProvider.getAssetIcon(token.configuration), tokenName = token.configuration.name, tokenSymbol = token.configuration.symbol.value, assetBalance = formattedAmount diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/di/common/SelectableAssetUseCaseModule.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/di/common/SelectableAssetUseCaseModule.kt index 57c99077fe..ed7e85c500 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/di/common/SelectableAssetUseCaseModule.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/di/common/SelectableAssetUseCaseModule.kt @@ -4,6 +4,7 @@ import dagger.Binds import dagger.Module import dagger.Provides import io.novafoundation.nova.common.di.scope.FeatureScope +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.feature_wallet_api.domain.AssetUseCase @@ -32,10 +33,12 @@ class SelectableAssetUseCaseModule { @Provides @FeatureScope fun provideAssetSelectorMixinFactory( + assetIconProvider: AssetIconProvider, assetUseCase: SelectableAssetUseCase<*>, singleAssetSharedState: SelectableSingleAssetSharedState<*>, resourceManager: ResourceManager ) = AssetSelectorFactory( + assetIconProvider, assetUseCase, singleAssetSharedState, resourceManager diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/amountChooser/AmountChooserProvider.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/amountChooser/AmountChooserProvider.kt index 764a3c289e..67fc2b642c 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/amountChooser/AmountChooserProvider.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/amountChooser/AmountChooserProvider.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_wallet_api.presentation.mixin.amountChooser import androidx.annotation.StringRes +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.feature_wallet_api.domain.model.planksFromAmount @@ -15,7 +16,8 @@ import java.math.BigDecimal import java.math.BigInteger class AmountChooserProviderFactory( - private val resourceManager: ResourceManager + private val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider, ) : AmountChooserMixin.Factory { override fun create( @@ -29,6 +31,7 @@ class AmountChooserProviderFactory( usedAssetFlow = assetFlow, balanceLabel = balanceLabel, resourceManager = resourceManager, + assetIconProvider = assetIconProvider, maxActionProvider = SimpleMaxActionProvider( maxAvailableForDisplay = availableBalanceFlow, // TODO amount chooser max button @@ -56,6 +59,7 @@ class AmountChooserProvider( coroutineScope: CoroutineScope, override val usedAssetFlow: Flow, private val resourceManager: ResourceManager, + private val assetIconProvider: AssetIconProvider, @StringRes private val balanceLabel: Int?, maxActionProvider: MaxActionProvider ) : BaseAmountChooserProvider( @@ -66,7 +70,7 @@ class AmountChooserProvider( AmountChooserMixin.Presentation { override val assetModel = usedAssetFlow.map { asset -> - ChooseAmountModel(asset, resourceManager, balanceLabel) + ChooseAmountModel(asset, assetIconProvider, resourceManager, balanceLabel) } .shareInBackground() } diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/assetSelector/AssetSelectorProvider.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/assetSelector/AssetSelectorProvider.kt index 6cf92e820d..0c08903e45 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/assetSelector/AssetSelectorProvider.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/mixin/assetSelector/AssetSelectorProvider.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_wallet_api.presentation.mixin.assetSelector import androidx.lifecycle.MutableLiveData +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.WithCoroutineScopeExtensions @@ -20,6 +21,7 @@ import kotlinx.coroutines.launch import java.math.BigDecimal class AssetSelectorFactory( + private val assetIconProvider: AssetIconProvider, private val assetUseCase: SelectableAssetUseCase<*>, private val singleAssetSharedState: SingleAssetSharedState, private val resourceManager: ResourceManager @@ -29,11 +31,12 @@ class AssetSelectorFactory( scope: CoroutineScope, amountProvider: (Asset) -> BigDecimal ): AssetSelectorMixin.Presentation { - return AssetSelectorProvider(assetUseCase, resourceManager, singleAssetSharedState, scope, amountProvider) + return AssetSelectorProvider(assetIconProvider, assetUseCase, resourceManager, singleAssetSharedState, scope, amountProvider) } } private class AssetSelectorProvider( + private val assetIconProvider: AssetIconProvider, private val assetUseCase: SelectableAssetUseCase<*>, private val resourceManager: ResourceManager, private val singleAssetSharedState: SingleAssetSharedState, @@ -79,7 +82,7 @@ private class AssetSelectorProvider( } private fun mapAssetAndOptionToSelectorModel(assetAndOption: SelectableAssetAndOption): AssetSelectorModel { - val assetModel = mapAssetToAssetModel(assetAndOption.asset, resourceManager, patternId = null, retrieveAmount = amountProvider) + val assetModel = mapAssetToAssetModel(assetIconProvider, assetAndOption.asset, resourceManager, patternId = null, retrieveAmount = amountProvider) val title = assetAndOption.formatTitle() return AssetSelectorModel(assetModel, title, assetAndOption.option.additional.identifier) diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/AssetModel.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/AssetModel.kt index aff6430b9e..4a20b6396b 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/AssetModel.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/AssetModel.kt @@ -1,9 +1,11 @@ package io.novafoundation.nova.feature_wallet_api.presentation.model +import io.novafoundation.nova.common.utils.images.Icon + data class AssetModel( val chainId: String, val chainAssetId: Int, - val imageUrl: String?, + val icon: Icon, val tokenName: String, val tokenSymbol: String, val assetBalance: String diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt index 49b9b8a133..b46b57616e 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt @@ -1,8 +1,11 @@ package io.novafoundation.nova.feature_wallet_api.presentation.model import androidx.annotation.StringRes +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.ensureSuffix +import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain @@ -13,19 +16,20 @@ class ChooseAmountModel( class ChooseAmountInputModel( val tokenSymbol: String, - val tokenIcon: String?, + val tokenIcon: Icon, ) internal fun ChooseAmountModel( asset: Asset, + assetIconProvider: AssetIconProvider, resourceManager: ResourceManager, @StringRes balanceLabelRes: Int?, ): ChooseAmountModel = ChooseAmountModel( - input = ChooseAmountInputModel(asset.token.configuration), + input = ChooseAmountInputModel(asset.token.configuration, assetIconProvider), balanceLabel = balanceLabelRes?.let(resourceManager::getString)?.ensureSuffix(":"), ) -internal fun ChooseAmountInputModel(chainAsset: Chain.Asset): ChooseAmountInputModel = ChooseAmountInputModel( +internal fun ChooseAmountInputModel(chainAsset: Chain.Asset, assetIconProvider: AssetIconProvider): ChooseAmountInputModel = ChooseAmountInputModel( tokenSymbol = chainAsset.symbol.value, - tokenIcon = chainAsset.iconUrl, + tokenIcon = assetIconProvider.getAssetIcon(chainAsset), ) diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt index fb069b2dc0..614907f913 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt @@ -6,6 +6,7 @@ import android.view.View import androidx.recyclerview.widget.DiffUtil import coil.ImageLoader import coil.load +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.inflateChild import io.novafoundation.nova.common.utils.setVisible import io.novafoundation.nova.common.view.bottomSheet.list.dynamic.ClickHandler @@ -57,7 +58,7 @@ private class AssetSelectorHolder( with(itemView) { itemAssetSelectorBalance.text = item.assetModel.assetBalance itemAssetSelectorTokenName.text = item.title - itemAssetSelectorIcon.load(item.assetModel.imageUrl, imageLoader) + itemAssetSelectorIcon.setIcon(item.assetModel.icon, imageLoader) itemAssetSelectorCheckmark.setVisible(isSelected, falseState = View.INVISIBLE) } } diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt index ede1dd55a5..e4386f646c 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt @@ -9,6 +9,7 @@ import coil.ImageLoader import coil.load import io.novafoundation.nova.common.utils.WithContextExtensions import io.novafoundation.nova.common.utils.getEnum +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.useAttributes import io.novafoundation.nova.common.view.shape.addRipple import io.novafoundation.nova.common.view.shape.getBlockDrawable @@ -71,7 +72,7 @@ class AssetSelectorView @JvmOverloads constructor( with(assetSelectorModel) { assetSelectorBalance.text = assetModel.assetBalance assetSelectorTokenName.text = title - assetSelectorIcon.load(assetModel.imageUrl, imageLoader) + assetSelectorIcon.setIcon(assetModel.icon, imageLoader) } } } diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountInputView.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountInputView.kt index 3dbf57cfe3..92fb7292de 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountInputView.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountInputView.kt @@ -7,9 +7,10 @@ import android.widget.EditText import androidx.constraintlayout.widget.ConstraintLayout import coil.ImageLoader import io.novafoundation.nova.common.di.FeatureUtils +import io.novafoundation.nova.common.utils.images.Icon +import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.view.shape.getInputBackground -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_wallet_api.R import io.novafoundation.nova.feature_wallet_api.presentation.model.ChooseAmountInputModel import kotlinx.android.synthetic.main.view_choose_amount_input.view.chooseAmountInputFiat @@ -38,8 +39,8 @@ class ChooseAmountInputView @JvmOverloads constructor( background = context.getInputBackground() } - fun loadAssetImage(imageUrl: String?) { - chooseAmountInputImage.loadTokenIcon(imageUrl, imageLoader) + fun loadAssetImage(icon: Icon) { + chooseAmountInputImage.setIcon(icon, imageLoader) } fun setAssetName(name: String) { diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountView.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountView.kt index 7ba63914d9..94ec888463 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountView.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/amount/ChooseAmountView.kt @@ -5,6 +5,7 @@ import android.util.AttributeSet import android.view.View import android.widget.EditText import androidx.constraintlayout.widget.ConstraintLayout +import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.utils.useAttributes import io.novafoundation.nova.feature_wallet_api.R @@ -37,8 +38,8 @@ class ChooseAmountView @JvmOverloads constructor( chooseAmountBalanceLabel.setTextOrHide(label) } - fun loadAssetImage(imageUrl: String) { - chooseAmountInput.loadAssetImage(imageUrl) + fun loadAssetImage(icon: Icon) { + chooseAmountInput.loadAssetImage(icon) } fun setTitle(title: String?) { diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt index 962ba816eb..9b0be97bd9 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt @@ -1,7 +1,7 @@ package io.novafoundation.nova.feature_wallet_impl.data.repository import com.google.gson.Gson -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.core_db.dao.ChainAssetDao import io.novafoundation.nova.core_db.dao.SetAssetEnabledParams import io.novafoundation.nova.feature_wallet_api.domain.interfaces.ChainAssetRepository @@ -12,8 +12,7 @@ import io.novafoundation.nova.runtime.multiNetwork.chain.model.FullChainAssetId class RealChainAssetRepository( private val chainAssetDao: ChainAssetDao, - private val gson: Gson, - private val assetsIconModeService: AssetsIconModeService + private val gson: Gson ) : ChainAssetRepository { override suspend fun setAssetsEnabled(enabled: Boolean, assetIds: List) { @@ -28,7 +27,6 @@ class RealChainAssetRepository( } override suspend fun getEnabledAssets(): List { - val iconMode = assetsIconModeService.getIconMode() - return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson, iconMode) } + return chainAssetDao.getEnabledAssets().map { mapChainAssetLocalToAsset(it, gson) } } } diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt index 02428e750d..4e762bb0c2 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt @@ -8,12 +8,13 @@ import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.network.AppLinksProvider import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences import io.novafoundation.nova.common.interfaces.FileCache import io.novafoundation.nova.common.interfaces.FileProvider import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ClipboardManager import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.QrCodeGenerator @@ -57,6 +58,36 @@ import javax.inject.Named interface WalletFeatureDependencies { + val fileCache: FileCache + + val storageCache: StorageCache + + val evmTransactionService: EvmTransactionService + + val chainAssetDao: ChainAssetDao + + val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory + + val currencyRepository: CurrencyRepository + + val externalBalanceDao: ExternalBalanceDao + + val computationalCache: ComputationalCache + + val multiLocationConverterFactory: MultiLocationConverterFactory + + val extrinsicWalk: ExtrinsicWalk + + val holdsDao: HoldsDao + + val feePaymentProviderRegistry: FeePaymentProviderRegistry + + val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory + + val customFeeCapabilityFacade: CustomFeeCapabilityFacade + + val assetIconProvider: AssetIconProvider + fun preferences(): Preferences fun encryptedPreferences(): EncryptedPreferences @@ -135,33 +166,6 @@ interface WalletFeatureDependencies { fun hydraDxAssetIdConverter(): HydraDxAssetIdConverter - fun assetsIconModeService(): AssetsIconModeService - - val fileCache: FileCache - - val storageCache: StorageCache - - val evmTransactionService: EvmTransactionService - - val chainAssetDao: ChainAssetDao - - val storageStorageSharedRequestsBuilderFactory: StorageSharedRequestsBuilderFactory - - val currencyRepository: CurrencyRepository - - val externalBalanceDao: ExternalBalanceDao - - val computationalCache: ComputationalCache - - val multiLocationConverterFactory: MultiLocationConverterFactory - - val extrinsicWalk: ExtrinsicWalk + fun assetsIconModeService(): AssetsIconModeRepository - val holdsDao: HoldsDao - - val feePaymentProviderRegistry: FeePaymentProviderRegistry - - val actionAwaitableMixinFactory: ActionAwaitableMixin.Factory - - val customFeeCapabilityFacade: CustomFeeCapabilityFacade } diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt index 07f4bc9659..7a516665cf 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt @@ -6,11 +6,12 @@ import dagger.Provides import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.FeatureScope import io.novafoundation.nova.common.interfaces.FileCache import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.core_db.dao.AssetDao import io.novafoundation.nova.core_db.dao.ChainAssetDao @@ -215,8 +216,9 @@ class WalletFeatureModule { @Provides @FeatureScope fun provideAmountChooserFactory( - resourceManager: ResourceManager - ): AmountChooserMixin.Factory = AmountChooserProviderFactory(resourceManager) + resourceManager: ResourceManager, + assetIconProvider: AssetIconProvider + ): AmountChooserMixin.Factory = AmountChooserProviderFactory(resourceManager, assetIconProvider) @Provides @FeatureScope @@ -323,9 +325,8 @@ class WalletFeatureModule { @FeatureScope fun provideChainAssetRepository( chainAssetDao: ChainAssetDao, - gson: Gson, - assetsIconModeService: AssetsIconModeService - ): ChainAssetRepository = RealChainAssetRepository(chainAssetDao, gson, assetsIconModeService) + gson: Gson + ): ChainAssetRepository = RealChainAssetRepository(chainAssetDao, gson) @Provides @FeatureScope diff --git a/runtime/build.gradle b/runtime/build.gradle index 1e96af753e..dcf08a110a 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -22,9 +22,6 @@ android { buildConfigField "String", "INFURA_API_KEY", readStringSecret("INFURA_API_KEY") buildConfigField "String", "DWELLIR_API_KEY", readStringSecret("DWELLIR_API_KEY") - - buildConfigField "String", "ASSET_COLORED_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/colored/\"" - buildConfigField "String", "ASSET_WHITE_ICON_URL", "\"https://raw.githubusercontent.com/novasamatech/nova-utils/master/icons/tokens/white/\"" } buildTypes { diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt index 965c36544b..dc3a9ee67c 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt @@ -6,10 +6,11 @@ import dagger.Provides import io.novafoundation.nova.common.BuildConfig import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.rpc.BulkRetriever -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.common.interfaces.FileProvider +import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.core_db.dao.ChainAssetDao import io.novafoundation.nova.core_db.dao.ChainDao import io.novafoundation.nova.runtime.ethereum.Web3ApiFactory @@ -229,8 +230,7 @@ class ChainRegistryModule { baseTypeSynchronizer: BaseTypeSynchronizer, runtimeSyncService: RuntimeSyncService, web3ApiPool: Web3ApiPool, - gson: Gson, - assetsIconModeService: AssetsIconModeService + gson: Gson ) = ChainRegistry( runtimeProviderPool, chainConnectionPool, @@ -241,7 +241,6 @@ class ChainRegistryModule { baseTypeSynchronizer, runtimeSyncService, web3ApiPool, - gson, - assetsIconModeService + gson ) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt index c681bac045..f56a081e10 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeDependencies.kt @@ -3,7 +3,7 @@ package io.novafoundation.nova.runtime.di import android.content.Context import com.google.gson.Gson import io.novafoundation.nova.common.data.network.NetworkApiCreator -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.interfaces.FileProvider import io.novafoundation.nova.core_db.dao.ChainAssetDao @@ -31,5 +31,5 @@ interface RuntimeDependencies { fun chainAssetDao(): ChainAssetDao - fun assetsIconModeService(): AssetsIconModeService + fun assetsIconModeService(): AssetsIconModeRepository } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt index f512bb5174..dd87161fc4 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt @@ -4,7 +4,7 @@ import com.google.gson.Gson import dagger.Module import dagger.Provides import io.novafoundation.nova.common.data.network.rpc.BulkRetriever -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.core.storage.StorageCache @@ -267,12 +267,10 @@ class RuntimeModule { @Provides @ApplicationScope fun provideRemoteToDomainChainMapperFacade( - gson: Gson, - assetsIconModeService: AssetsIconModeService + gson: Gson ): RemoteToDomainChainMapperFacade { return RemoteToDomainChainMapperFacade( - gson, - assetsIconModeService + gson ) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt index 87bb55624d..93d464b140 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt @@ -2,7 +2,6 @@ package io.novafoundation.nova.runtime.multiNetwork import android.util.Log import com.google.gson.Gson -import io.novafoundation.nova.common.data.repository.AssetsIconModeService import io.novafoundation.nova.common.utils.LOG_TAG import io.novafoundation.nova.common.utils.diffed import io.novafoundation.nova.common.utils.filterList @@ -40,7 +39,6 @@ import io.novasama.substrate_sdk_android.wsrpc.SocketService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.first @@ -64,12 +62,11 @@ class ChainRegistry( private val baseTypeSynchronizer: BaseTypeSynchronizer, private val runtimeSyncService: RuntimeSyncService, private val web3ApiPool: Web3ApiPool, - private val gson: Gson, - private val assetsIconModeService: AssetsIconModeService + private val gson: Gson ) : CoroutineScope by CoroutineScope(Dispatchers.Default) { - val currentChains = combine(chainDao.joinChainInfoFlow(), assetsIconModeService.assetsIconModeFlow()) { chains, assetIconMode -> - chains.map { mapChainLocalToChain(it, gson, assetIconMode) } + val currentChains = chainDao.joinChainInfoFlow().map { chains -> + chains.map { mapChainLocalToChain(it, gson) } } .diffed() .map { diff -> diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt index 29cd0b6451..595ac2d3c8 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/DomainToLocalChainMapper.kt @@ -97,7 +97,7 @@ fun mapChainAssetToLocal(asset: Chain.Asset, gson: Gson): ChainAssetLocal { source = mapAssetSourceToLocal(asset.source), buyProviders = gson.toJson(asset.buyProviders), typeExtras = gson.toJson(typeExtras), - icon = asset.icon?.name, + icon = asset.icon, enabled = asset.enabled ) } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt index 186898f00a..b8c7a90ab4 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt @@ -184,7 +184,7 @@ private fun mapNodeSelectionFromLocal(nodeSelectionPreferencesLocal: NodeSelecti } } -fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson, assetIconMode: AssetIconMode): Chain { +fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson): Chain { return mapChainLocalToChain( chainLocal.chain, chainLocal.nodes, @@ -192,8 +192,7 @@ fun mapChainLocalToChain(chainLocal: JoinedChainInfo, gson: Gson, assetIconMode: chainLocal.assets, chainLocal.explorers, chainLocal.externalApis, - gson, - assetIconMode + gson ) } @@ -204,8 +203,7 @@ fun mapChainLocalToChain( assetsLocal: List, explorersLocal: List, externalApisLocal: List, - gson: Gson, - assetIconMode: AssetIconMode + gson: Gson ): Chain { val nodes = nodesLocal.sortedBy { it.orderId }.map { Chain.Node( @@ -223,7 +221,7 @@ fun mapChainLocalToChain( nodes = nodes ) - val assets = assetsLocal.map { mapChainAssetLocalToAsset(it, gson, assetIconMode) } + val assets = assetsLocal.map { mapChainAssetLocalToAsset(it, gson) } val explorers = explorersLocal.map { Chain.Explorer( @@ -278,12 +276,12 @@ fun mapChainLocalToChain( } } -fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson, assetIconMode: AssetIconMode): Chain.Asset { +fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson): Chain.Asset { val typeExtrasParsed = local.typeExtras?.let(gson::parseArbitraryObject) val buyProviders = local.buyProviders?.let?>(gson::fromJsonOrNull).orEmpty() return Chain.Asset( - icon = getAssetIconUrl(local.icon, assetIconMode), + icon = local.icon, id = local.id, symbol = local.symbol.asTokenSymbol(), precision = local.precision.asPrecision(), @@ -298,17 +296,6 @@ fun mapChainAssetLocalToAsset(local: ChainAssetLocal, gson: Gson, assetIconMode: ) } -private fun getAssetIconUrl(icon: String?, assetIconMode: AssetIconMode): Chain.Icon? { - return icon?.let { - val baseUrl = when (assetIconMode) { - AssetIconMode.COLORED -> BuildConfig.ASSET_COLORED_ICON_URL - AssetIconMode.WHITE -> BuildConfig.ASSET_WHITE_ICON_URL - } - - Chain.Icon(it, baseUrl) - } -} - private fun mapSourceFromLocal(local: ChainLocal.Source): Chain.Source { return when (local) { ChainLocal.Source.DEFAULT -> Chain.Source.DEFAULT diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt index 01e45dae0a..8f96f95377 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt @@ -1,15 +1,14 @@ package io.novafoundation.nova.runtime.multiNetwork.chain.mappers import com.google.gson.Gson -import io.novafoundation.nova.common.data.repository.AssetsIconModeService +import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.core_db.model.chain.ChainLocal import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain import io.novafoundation.nova.runtime.multiNetwork.chain.remote.model.ChainRemote class RemoteToDomainChainMapperFacade( - private val gson: Gson, - private val assetsIconModeService: AssetsIconModeService + private val gson: Gson ) { fun mapRemoteChainToDomain(chainRemote: ChainRemote, source: Chain.Source): Chain { @@ -30,8 +29,7 @@ class RemoteToDomainChainMapperFacade( assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson, - assetsIconModeService.getIconMode() + gson = gson ) } } diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt index 6ccbdbd207..f4cd220ae6 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/model/Chain.kt @@ -46,17 +46,6 @@ data class Chain( val assetsById = assets.associateBy(Asset::id) - data class Icon( - val name: String, - val baseUrl: String, - ) { - companion object; - - constructor(url: String) : this("", url) - - fun getIconUrl(): String = "$baseUrl/$name" - } - data class Additional( val defaultTip: BigInteger?, val themeColor: String?, @@ -76,7 +65,7 @@ data class Chain( ) data class Asset( - val icon: Icon?, + val icon: String?, val id: ChainAssetId, val priceId: String?, val chainId: ChainId, @@ -90,9 +79,6 @@ data class Chain( val enabled: Boolean, ) : Identifiable, Serializable { - // To support legacy code - val iconUrl = icon?.getIconUrl() - enum class Source { DEFAULT, ERC20, MANUAL } From e2b2ef259af46c3134f18b0e7b88e5766a4c3e3c Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 13:42:24 +0100 Subject: [PATCH 04/11] Fixed swap icon size and color --- .../presentation/views/SwapAmountInputView.kt | 3 +++ .../src/main/res/layout/view_swap_amount_input.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt index e6c6d935b8..512b3b4835 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt @@ -11,6 +11,7 @@ import io.novafoundation.nova.common.utils.WithContextExtensions import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.images.setIconOrMakeGone +import io.novafoundation.nova.common.utils.setImageTint import io.novafoundation.nova.common.view.shape.getInputBackground import io.novafoundation.nova.common.view.shape.getInputBackgroundError import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon @@ -82,11 +83,13 @@ class SwapAmountInputView @JvmOverloads constructor( private fun setAssetIcon(icon: SwapInputAssetModel.SwapAssetIcon) { return when (icon) { is SwapInputAssetModel.SwapAssetIcon.Chosen -> { + swapAmountInputImage.setImageTint(null) swapAmountInputImage.setIcon(icon.assetIcon, imageLoader) swapAmountInputImage.setBackgroundResource(R.drawable.bg_token_container) } SwapInputAssetModel.SwapAssetIcon.NotChosen -> { + swapAmountInputImage.setImageTint(context.getColor(R.color.icon_accent)) swapAmountInputImage.setImageResource(R.drawable.ic_add) swapAmountInputImage.setBackgroundResource(R.drawable.ic_swap_asset_default_background) } diff --git a/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml b/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml index c89b1fa759..160199a5fc 100644 --- a/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml +++ b/feature-swap-impl/src/main/res/layout/view_swap_amount_input.xml @@ -19,6 +19,7 @@ android:layout_marginStart="12dp" android:layout_marginTop="16dp" android:layout_marginBottom="16dp" + android:scaleType="centerInside" android:background="@drawable/bg_token_container" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" From 1da858b85ab72d48765e9c751e1b66e08cf4ebec Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 13:43:05 +0100 Subject: [PATCH 05/11] Run ktlint --- .../nova/feature_assets/di/AssetsFeatureDependencies.kt | 1 - .../balance/common/holders/NetworkAssetViewHolder.kt | 1 - .../balance/common/holders/TokenAssetGroupViewHolder.kt | 1 - .../presentation/balance/detail/BalanceDetailFragment.kt | 1 - .../nova/feature_assets/presentation/receive/ReceiveFragment.kt | 1 - .../presentation/tokens/manage/ManageTokensAdapter.kt | 1 - .../tokens/manage/chain/ManageChainTokensFragment.kt | 1 - .../transaction/detail/extrinsic/ExtrinsicDetailFragment.kt | 1 - .../feature_swap_impl/presentation/views/SwapAmountInputView.kt | 1 - .../presentation/view/AssetSelectorBottomSheet.kt | 1 - .../feature_wallet_api/presentation/view/AssetSelectorView.kt | 1 - .../data/repository/RealChainAssetRepository.kt | 1 - .../nova/feature_wallet_impl/di/WalletFeatureDependencies.kt | 1 - .../nova/feature_wallet_impl/di/WalletFeatureModule.kt | 1 - .../io/novafoundation/nova/runtime/di/ChainRegistryModule.kt | 2 -- .../java/io/novafoundation/nova/runtime/di/RuntimeModule.kt | 1 - .../multiNetwork/chain/mappers/LocalToDomainChainMapper.kt | 2 -- .../chain/mappers/RemoteToDomainChainMapperFacade.kt | 1 - 18 files changed, 20 deletions(-) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt index a1afb2e043..c418ae6e4d 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt @@ -258,5 +258,4 @@ interface AssetsFeatureDependencies { fun walletConnectSessionsUseCase(): WalletConnectSessionsUseCase fun nftRepository(): NftRepository - } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt index 2e4ccceee8..272b16dfe9 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/NetworkAssetViewHolder.kt @@ -5,7 +5,6 @@ import coil.ImageLoader import io.novafoundation.nova.common.list.GroupedListHolder import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextColorRes -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.presentation.balance.common.BalanceListAdapter import io.novafoundation.nova.feature_assets.presentation.balance.list.model.items.NetworkAssetUi import io.novafoundation.nova.feature_assets.presentation.model.AssetModel diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt index 83afa58aa1..d13f981843 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/holders/TokenAssetGroupViewHolder.kt @@ -7,7 +7,6 @@ import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.recyclerView.expandable.ExpandableParentViewHolder import io.novafoundation.nova.common.utils.recyclerView.expandable.items.ExpandableParentItem import io.novafoundation.nova.common.utils.setTextColorRes -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.presentation.balance.common.BalanceListAdapter import io.novafoundation.nova.feature_assets.presentation.balance.list.model.items.TokenGroupUi import kotlinx.android.synthetic.main.item_token_asset_group.view.itemAssetTokenGroupBalance diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt index 5bae792337..2c6c968608 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailFragment.kt @@ -12,7 +12,6 @@ import io.novafoundation.nova.common.utils.applyBarMargin import io.novafoundation.nova.common.utils.hideKeyboard import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setTextColorRes -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.di.AssetsFeatureApi import io.novafoundation.nova.feature_assets.di.AssetsFeatureComponent diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt index 9f8f20725b..fd7688f268 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveFragment.kt @@ -11,7 +11,6 @@ import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.setVisible import io.novafoundation.nova.common.view.shape.getRoundedCornerDrawable import io.novafoundation.nova.feature_account_api.presenatation.actions.setupExternalActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.di.AssetsFeatureApi import io.novafoundation.nova.feature_assets.di.AssetsFeatureComponent diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt index 29d3ceeb6e..56d4b8f5db 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/ManageTokensAdapter.kt @@ -12,7 +12,6 @@ import io.novafoundation.nova.common.list.resolvePayload import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.inflateChild import io.novafoundation.nova.common.utils.setTextColorRes -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.tokens.manage.model.MultiChainTokenModel import kotlinx.android.synthetic.main.item_manage_token_multichain.view.itemManageTokenMultichainEnabled diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt index 7946aa79da..fc68f835a2 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/chain/ManageChainTokensFragment.kt @@ -9,7 +9,6 @@ import coil.ImageLoader import io.novafoundation.nova.common.base.BaseBottomSheetFragment import io.novafoundation.nova.common.di.FeatureUtils import io.novafoundation.nova.common.utils.images.setIcon -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.di.AssetsFeatureApi import io.novafoundation.nova.feature_assets.di.AssetsFeatureComponent diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt index 1e7f0abada..cb3a9b7ca6 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailFragment.kt @@ -15,7 +15,6 @@ import io.novafoundation.nova.common.utils.setTextOrHide import io.novafoundation.nova.common.view.TableCellView import io.novafoundation.nova.common.view.TableView import io.novafoundation.nova.feature_account_api.presenatation.actions.setupExternalActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_account_api.view.showAddress import io.novafoundation.nova.feature_account_api.view.showChain import io.novafoundation.nova.feature_assets.R diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt index 512b3b4835..2362cb1a09 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/views/SwapAmountInputView.kt @@ -14,7 +14,6 @@ import io.novafoundation.nova.common.utils.images.setIconOrMakeGone import io.novafoundation.nova.common.utils.setImageTint import io.novafoundation.nova.common.view.shape.getInputBackground import io.novafoundation.nova.common.view.shape.getInputBackgroundError -import io.novafoundation.nova.feature_account_api.presenatation.chain.loadTokenIcon import io.novafoundation.nova.feature_swap_impl.R import io.novafoundation.nova.feature_swap_impl.presentation.main.input.SwapAmountInputMixin.SwapInputAssetModel import io.novafoundation.nova.feature_wallet_api.presentation.mixin.amountChooser.AmountChooserMixinBase.AmountErrorState diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt index 614907f913..40d51d6954 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorBottomSheet.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.View import androidx.recyclerview.widget.DiffUtil import coil.ImageLoader -import coil.load import io.novafoundation.nova.common.utils.images.setIcon import io.novafoundation.nova.common.utils.inflateChild import io.novafoundation.nova.common.utils.setVisible diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt index e4386f646c..6fc4786e5f 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/view/AssetSelectorView.kt @@ -6,7 +6,6 @@ import android.util.AttributeSet import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import coil.ImageLoader -import coil.load import io.novafoundation.nova.common.utils.WithContextExtensions import io.novafoundation.nova.common.utils.getEnum import io.novafoundation.nova.common.utils.images.setIcon diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt index 9b0be97bd9..51fdb233f5 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/data/repository/RealChainAssetRepository.kt @@ -1,7 +1,6 @@ package io.novafoundation.nova.feature_wallet_impl.data.repository import com.google.gson.Gson -import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.core_db.dao.ChainAssetDao import io.novafoundation.nova.core_db.dao.SetAssetEnabledParams import io.novafoundation.nova.feature_wallet_api.domain.interfaces.ChainAssetRepository diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt index 4e762bb0c2..b1bde1f76b 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureDependencies.kt @@ -167,5 +167,4 @@ interface WalletFeatureDependencies { fun hydraDxAssetIdConverter(): HydraDxAssetIdConverter fun assetsIconModeService(): AssetsIconModeRepository - } diff --git a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt index 7a516665cf..1233a3560f 100644 --- a/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt +++ b/feature-wallet-impl/src/main/java/io/novafoundation/nova/feature_wallet_impl/di/WalletFeatureModule.kt @@ -6,7 +6,6 @@ import dagger.Provides import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator -import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.FeatureScope import io.novafoundation.nova.common.interfaces.FileCache diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt index dc3a9ee67c..97e74a266d 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/ChainRegistryModule.kt @@ -6,11 +6,9 @@ import dagger.Provides import io.novafoundation.nova.common.BuildConfig import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.rpc.BulkRetriever -import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.common.interfaces.FileProvider -import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.core_db.dao.ChainAssetDao import io.novafoundation.nova.core_db.dao.ChainDao import io.novafoundation.nova.runtime.ethereum.Web3ApiFactory diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt index dd87161fc4..6953bf5f1f 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/di/RuntimeModule.kt @@ -4,7 +4,6 @@ import com.google.gson.Gson import dagger.Module import dagger.Provides import io.novafoundation.nova.common.data.network.rpc.BulkRetriever -import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.ApplicationScope import io.novafoundation.nova.core.storage.StorageCache diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt index b8c7a90ab4..1c5c6ddab1 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/LocalToDomainChainMapper.kt @@ -2,7 +2,6 @@ package io.novafoundation.nova.runtime.multiNetwork.chain.mappers import android.util.Log import com.google.gson.Gson -import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.utils.asPrecision import io.novafoundation.nova.common.utils.asTokenSymbol import io.novafoundation.nova.common.utils.enumValueOfOrNull @@ -22,7 +21,6 @@ import io.novafoundation.nova.core_db.model.chain.ChainLocal.ConnectionStateLoca import io.novafoundation.nova.core_db.model.chain.ChainNodeLocal import io.novafoundation.nova.core_db.model.chain.JoinedChainInfo import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal -import io.novafoundation.nova.runtime.BuildConfig import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.EVM_TRANSFER_PARAMETER import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.GovernanceReferendaParameters import io.novafoundation.nova.runtime.multiNetwork.chain.mappers.utils.SUBSTRATE_TRANSFER_PARAMETER diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt index 8f96f95377..0dcaa94782 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/chain/mappers/RemoteToDomainChainMapperFacade.kt @@ -1,7 +1,6 @@ package io.novafoundation.nova.runtime.multiNetwork.chain.mappers import com.google.gson.Gson -import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository import io.novafoundation.nova.core_db.model.chain.ChainLocal import io.novafoundation.nova.core_db.model.chain.NodeSelectionPreferencesLocal import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain From 58d6aab418f8e8d8694deff5fa710da1c69a0604 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 13:51:18 +0100 Subject: [PATCH 06/11] Clean code --- .../main/java/io/novafoundation/nova/common/di/CommonApi.kt | 4 ++-- .../novafoundation/nova/common/di/modules/CommonModule.kt | 6 +++--- .../nova/feature_assets/di/AssetsFeatureDependencies.kt | 4 ++-- .../nova/feature_assets/di/AssetsFeatureModule.kt | 4 ++-- .../domain/assets/list/AssetsListInteractor.kt | 4 ++-- .../presentation/balance/list/di/BalanceListModule.kt | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt index 359cb144d8..f148d5d495 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/CommonApi.kt @@ -15,7 +15,7 @@ import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser import io.novafoundation.nova.common.data.network.rpc.SocketSingleRequestExecutor import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 import io.novafoundation.nova.common.data.secrets.v2.SecretStoreV2 @@ -187,7 +187,7 @@ interface CommonApi { fun buildTypeProvider(): BuildTypeProvider - fun assetsViewModeRepository(): AssetsViewModeService + fun assetsViewModeRepository(): AssetsViewModeRepository fun assetsIconModeService(): AssetsIconModeRepository diff --git a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt index bd8bb0367e..7e2440a0f7 100644 --- a/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt +++ b/common/src/main/java/io/novafoundation/nova/common/di/modules/CommonModule.kt @@ -21,10 +21,10 @@ import io.novafoundation.nova.common.data.memory.ComputationalCache import io.novafoundation.nova.common.data.memory.RealComputationalCache import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser import io.novafoundation.nova.common.data.repository.AssetsIconModeRepository -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.data.repository.RealAssetsIconModeRepository -import io.novafoundation.nova.common.data.repository.RealAssetsViewModeService +import io.novafoundation.nova.common.data.repository.RealAssetsViewModeRepository import io.novafoundation.nova.common.data.repository.RealBannerVisibilityRepository import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1 import io.novafoundation.nova.common.data.secrets.v1.SecretStoreV1Impl @@ -357,7 +357,7 @@ class CommonModule { @Provides @ApplicationScope - fun provideAssetsViewModeService(preferences: Preferences): AssetsViewModeService = RealAssetsViewModeService(preferences) + fun provideAssetsViewModeRepository(preferences: Preferences): AssetsViewModeRepository = RealAssetsViewModeRepository(preferences) @Provides @ApplicationScope diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt index c418ae6e4d..12f27d4abc 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureDependencies.kt @@ -10,7 +10,7 @@ import io.novafoundation.nova.common.data.network.AppLinksProvider import io.novafoundation.nova.common.data.network.HttpExceptionHandler import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.data.network.coingecko.CoinGeckoLinkParser -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.data.storage.encrypt.EncryptedPreferences @@ -253,7 +253,7 @@ interface AssetsFeatureDependencies { fun coingeckoApi(): CoingeckoApi - fun assetsViewModeRepository(): AssetsViewModeService + fun assetsViewModeRepository(): AssetsViewModeRepository fun walletConnectSessionsUseCase(): WalletConnectSessionsUseCase diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureModule.kt index 3d4bc36115..ac85f5d176 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/di/AssetsFeatureModule.kt @@ -3,7 +3,7 @@ package io.novafoundation.nova.feature_assets.di import dagger.Module import dagger.Provides import io.novafoundation.nova.common.data.memory.ComputationalCache -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.storage.Preferences import io.novafoundation.nova.common.di.scope.FeatureScope import io.novafoundation.nova.common.mixin.actionAwaitable.ActionAwaitableMixin @@ -70,7 +70,7 @@ class AssetsFeatureModule { @Provides @FeatureScope fun provideSearchInteractorFactory( - assetViewModeRepository: AssetsViewModeService.AssetsViewModeRepository, + assetViewModeRepository: AssetsViewModeRepository, assetSearchUseCase: AssetSearchUseCase, chainRegistry: ChainRegistry ): AssetSearchInteractorFactory = AssetViewModeAssetSearchInteractorFactory(assetViewModeRepository, assetSearchUseCase, chainRegistry) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt index 1b7aa7aac6..9ed77ae763 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt @@ -1,7 +1,7 @@ package io.novafoundation.nova.feature_assets.domain.assets.list import io.novafoundation.nova.common.data.model.AssetViewMode -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.feature_nft_api.data.model.Nft @@ -18,7 +18,7 @@ class AssetsListInteractor( private val accountRepository: AccountRepository, private val nftRepository: NftRepository, private val bannerVisibilityRepository: BannerVisibilityRepository, - private val assetsViewModeService: AssetsViewModeService + private val assetsViewModeService: AssetsViewModeRepository ) { fun assetsViewModeFlow() = assetsViewModeService.assetsViewModeFlow() diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt index 8e9dc7a6b5..e6b06143b8 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/list/di/BalanceListModule.kt @@ -6,7 +6,7 @@ import androidx.lifecycle.ViewModelProvider import dagger.Module import dagger.Provides import dagger.multibindings.IntoMap -import io.novafoundation.nova.common.data.repository.AssetsViewModeService +import io.novafoundation.nova.common.data.repository.AssetsViewModeRepository import io.novafoundation.nova.common.data.repository.BannerVisibilityRepository import io.novafoundation.nova.common.di.scope.ScreenScope import io.novafoundation.nova.common.di.viewmodel.ViewModelKey @@ -38,8 +38,8 @@ class BalanceListModule { accountRepository: AccountRepository, nftRepository: NftRepository, bannerVisibilityRepository: BannerVisibilityRepository, - assetsViewModeService: AssetsViewModeService - ) = AssetsListInteractor(accountRepository, nftRepository, bannerVisibilityRepository, assetsViewModeService) + assetsViewModeRepository: AssetsViewModeRepository + ) = AssetsListInteractor(accountRepository, nftRepository, bannerVisibilityRepository, assetsViewModeRepository) @Provides @ScreenScope From 310ee08c72418fab4e58bf938826faf103bbbb33 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 13:52:12 +0100 Subject: [PATCH 07/11] Run ktlint --- .../feature_assets/domain/networks/AssetNetworksInteractor.kt | 3 --- .../presentation/swap/asset/AssetSwapFlowViewModel.kt | 1 - 2 files changed, 4 deletions(-) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/networks/AssetNetworksInteractor.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/networks/AssetNetworksInteractor.kt index 688385d856..db36fa1921 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/networks/AssetNetworksInteractor.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/networks/AssetNetworksInteractor.kt @@ -4,7 +4,6 @@ import io.novafoundation.nova.common.utils.TokenSymbol import io.novafoundation.nova.common.utils.filterList import io.novafoundation.nova.common.utils.filterSet import io.novafoundation.nova.common.utils.flowOfAll -import io.novafoundation.nova.feature_account_api.domain.interfaces.AccountRepository import io.novafoundation.nova.feature_assets.domain.assets.search.AssetSearchFilter import io.novafoundation.nova.feature_assets.domain.assets.search.AssetSearchUseCase import io.novafoundation.nova.feature_assets.domain.common.AssetWithNetwork @@ -13,7 +12,6 @@ import io.novafoundation.nova.feature_assets.domain.common.getTokenAssetBaseComp import io.novafoundation.nova.feature_assets.domain.common.getTokenAssetGroupBaseComparator import io.novafoundation.nova.feature_assets.domain.common.groupAndSortAssetsByToken import io.novafoundation.nova.feature_swap_api.domain.swap.SwapService -import io.novafoundation.nova.feature_wallet_api.domain.interfaces.WalletRepository import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.feature_wallet_api.domain.model.ExternalBalance import io.novafoundation.nova.feature_wallet_api.domain.model.aggregatedBalanceByAsset @@ -27,7 +25,6 @@ import io.novasama.substrate_sdk_android.hash.isPositive import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt index dc3fe82f39..0f8e98a2df 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/swap/asset/AssetSwapFlowViewModel.kt @@ -1,6 +1,5 @@ package io.novafoundation.nova.feature_assets.presentation.swap.asset -import android.util.Log import androidx.annotation.StringRes import androidx.lifecycle.viewModelScope import io.novafoundation.nova.common.presentation.AssetIconProvider From 865028238ea2f461c9471e7ad651e3b01a9b02d5 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 17:00:16 +0100 Subject: [PATCH 08/11] Set asset icon as white for operations --- .../nova/common/presentation/AssetIconProvider.kt | 12 +++++++++++- .../presenatation/chain/ChainUi.kt | 4 ++++ .../transaction/history/mixin/OperationMappers.kt | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt index 6d262086f7..0ace0a04ad 100644 --- a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt +++ b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt @@ -11,6 +11,8 @@ interface AssetIconProvider { val fallbackIcon: Icon fun getAssetIcon(iconName: String?, fallback: Icon = fallbackIcon): Icon + + fun getWhiteAssetIcon(iconName: String?, fallback: Icon = fallbackIcon): Icon } class RealAssetIconProvider( @@ -26,9 +28,17 @@ class RealAssetIconProvider( val iconUrl = when (assetsIconModeRepository.getIconMode()) { AssetIconMode.COLORED -> "$coloredBaseUrl/$iconName" - AssetIconMode.WHITE -> "$coloredBaseUrl/$whiteBaseUrl" + AssetIconMode.WHITE -> "$whiteBaseUrl/$iconName" } return iconUrl.asIcon() } + + override fun getWhiteAssetIcon(iconName: String?, fallback: Icon): Icon { + return if (iconName == null) { + fallback + } else { + "$whiteBaseUrl/$iconName".asIcon() + } + } } diff --git a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt index 715f73de83..1e9856a6e1 100644 --- a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt +++ b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt @@ -61,3 +61,7 @@ fun chainIconFallback(): Icon { fun AssetIconProvider.getAssetIcon(asset: Chain.Asset, fallbackIcon: Icon = this.fallbackIcon): Icon { return this.getAssetIcon(asset.icon, fallbackIcon) } + +fun AssetIconProvider.getWhiteAssetIcon(asset: Chain.Asset, fallbackIcon: Icon = this.fallbackIcon): Icon { + return this.getWhiteAssetIcon(asset.icon, fallbackIcon) +} diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt index 9610c02a7c..f710389ff2 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt @@ -12,7 +12,7 @@ import io.novafoundation.nova.common.utils.capitalize import io.novafoundation.nova.common.utils.images.asIcon import io.novafoundation.nova.common.utils.splitSnakeOrCamelCase import io.novafoundation.nova.feature_account_api.presenatation.account.AddressDisplayUseCase -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getWhiteAssetIcon import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.model.AmountParcelModel import io.novafoundation.nova.feature_assets.presentation.model.ChainAssetWithAmountParcelModel @@ -276,7 +276,7 @@ fun mapOperationToOperationModel( subHeader = subHeader.value, subHeaderEllipsize = subHeader.elipsize, statusAppearance = statusAppearance, - operationIcon = assetIconProvider.getAssetIcon(operation.chainAsset) + operationIcon = assetIconProvider.getWhiteAssetIcon(operation.chainAsset) ) } From e1d771cc921def6ddd710ccc3fd1931051d66095 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Wed, 30 Oct 2024 17:21:40 +0100 Subject: [PATCH 09/11] Fix test --- .../io/novafoundation/nova/ChainMappingIntegrationTest.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt b/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt index 3ae472fde7..bb0a481b88 100644 --- a/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt +++ b/app/src/androidTest/java/io/novafoundation/nova/ChainMappingIntegrationTest.kt @@ -4,7 +4,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.gson.Gson import androidx.test.platform.app.InstrumentationRegistry import dagger.Component -import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.data.network.NetworkApiCreator import io.novafoundation.nova.common.di.CommonApi import io.novafoundation.nova.common.di.FeatureContainer @@ -101,8 +100,7 @@ class ChainMappingIntegrationTest { assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson, - assetIconMode = AssetIconMode.COLORED + gson = gson ) } @@ -125,8 +123,7 @@ class ChainMappingIntegrationTest { assetsLocal = assetsLocal, explorersLocal = explorersLocal, externalApisLocal = externalApisLocal, - gson = gson, - assetIconMode = AssetIconMode.COLORED + gson = gson ) } } From 57732314e615a12f4b85af5d5bc247534ee9dc24 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Fri, 1 Nov 2024 10:11:30 +0100 Subject: [PATCH 10/11] Fixed pr notes --- .../common/presentation/AssetIconProvider.kt | 37 ++++++++++++------- .../presenatation/chain/ChainUi.kt | 11 ++++-- .../assets/list/AssetsListInteractor.kt | 6 +-- .../common/mappers/NetworkAssetMappers.kt | 4 +- .../common/mappers/TokenAssetMappers.kt | 7 ++-- .../balance/detail/BalanceDetailViewModel.kt | 4 +- .../presentation/receive/ReceiveViewModel.kt | 4 +- .../manage/model/MultiChainTokenModel.kt | 3 +- .../extrinsic/ExtrinsicDetailViewModel.kt | 3 +- .../detail/swap/SwapDetailViewModel.kt | 4 +- .../history/mixin/OperationMappers.kt | 6 ++- .../presentation/track/TrackFormatter.kt | 4 +- .../confirmation/SwapConfirmationViewModel.kt | 4 +- .../main/input/SwapAmountInputMixinFactory.kt | 4 +- .../feature_wallet_api/data/mappers/Asset.kt | 4 +- .../presentation/model/ChooseAmountModel.kt | 4 +- .../runtime/multiNetwork/ChainRegistry.kt | 6 +-- 17 files changed, 67 insertions(+), 48 deletions(-) diff --git a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt index 0ace0a04ad..2a1fe45762 100644 --- a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt +++ b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt @@ -8,11 +8,11 @@ import io.novafoundation.nova.common.utils.images.asIcon interface AssetIconProvider { - val fallbackIcon: Icon + companion object; - fun getAssetIcon(iconName: String?, fallback: Icon = fallbackIcon): Icon + fun getAssetIconOrFallback(iconName: String): Icon - fun getWhiteAssetIcon(iconName: String?, fallback: Icon = fallbackIcon): Icon + fun getAssetIconOrFallback(iconName: String, iconMode: AssetIconMode): Icon } class RealAssetIconProvider( @@ -21,11 +21,12 @@ class RealAssetIconProvider( private val whiteBaseUrl: String ) : AssetIconProvider { - override val fallbackIcon: Icon = R.drawable.ic_nova.asIcon() - override fun getAssetIcon(iconName: String?, fallback: Icon): Icon { - if (iconName == null) return fallback + override fun getAssetIconOrFallback(iconName: String): Icon { + return getAssetIconOrFallback(iconName, assetsIconModeRepository.getIconMode()) + } + override fun getAssetIconOrFallback(iconName: String, iconMode: AssetIconMode): Icon { val iconUrl = when (assetsIconModeRepository.getIconMode()) { AssetIconMode.COLORED -> "$coloredBaseUrl/$iconName" AssetIconMode.WHITE -> "$whiteBaseUrl/$iconName" @@ -33,12 +34,22 @@ class RealAssetIconProvider( return iconUrl.asIcon() } +} - override fun getWhiteAssetIcon(iconName: String?, fallback: Icon): Icon { - return if (iconName == null) { - fallback - } else { - "$whiteBaseUrl/$iconName".asIcon() - } - } +val AssetIconProvider.Companion.fallbackIcon: Icon + get() = R.drawable.ic_nova.asIcon() + +fun AssetIconProvider.getAssetIconOrFallback( + iconName: String?, + fallback: Icon = AssetIconProvider.fallbackIcon +): Icon { + return iconName?.let { getAssetIconOrFallback(it) } ?: fallback +} + +fun AssetIconProvider.getAssetIconOrFallback( + iconName: String?, + iconMode: AssetIconMode, + fallback: Icon = AssetIconProvider.fallbackIcon +): Icon { + return iconName?.let { getAssetIconOrFallback(it, iconMode) } ?: fallback } diff --git a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt index 1e9856a6e1..7e38f07a7d 100644 --- a/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt +++ b/feature-account-api/src/main/java/io/novafoundation/nova/feature_account_api/presenatation/chain/ChainUi.kt @@ -6,7 +6,10 @@ import android.widget.ImageView import coil.ImageLoader import coil.load import coil.request.ImageRequest +import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.fallbackIcon +import io.novafoundation.nova.common.presentation.getAssetIconOrFallback import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.images.asIcon import io.novafoundation.nova.feature_account_api.R @@ -58,10 +61,10 @@ fun chainIconFallback(): Icon { return R.drawable.ic_fallback_network_icon.asIcon() } -fun AssetIconProvider.getAssetIcon(asset: Chain.Asset, fallbackIcon: Icon = this.fallbackIcon): Icon { - return this.getAssetIcon(asset.icon, fallbackIcon) +fun AssetIconProvider.getAssetIconOrFallback(asset: Chain.Asset, fallbackIcon: Icon = AssetIconProvider.fallbackIcon): Icon { + return this.getAssetIconOrFallback(asset.icon, fallbackIcon) } -fun AssetIconProvider.getWhiteAssetIcon(asset: Chain.Asset, fallbackIcon: Icon = this.fallbackIcon): Icon { - return this.getWhiteAssetIcon(asset.icon, fallbackIcon) +fun AssetIconProvider.getAssetIconOrFallback(asset: Chain.Asset, iconMode: AssetIconMode, fallbackIcon: Icon = AssetIconProvider.fallbackIcon): Icon { + return this.getAssetIconOrFallback(asset.icon, iconMode, fallbackIcon) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt index 9ed77ae763..13388f4e1a 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/domain/assets/list/AssetsListInteractor.kt @@ -18,13 +18,13 @@ class AssetsListInteractor( private val accountRepository: AccountRepository, private val nftRepository: NftRepository, private val bannerVisibilityRepository: BannerVisibilityRepository, - private val assetsViewModeService: AssetsViewModeRepository + private val assetsViewModeRepository: AssetsViewModeRepository ) { - fun assetsViewModeFlow() = assetsViewModeService.assetsViewModeFlow() + fun assetsViewModeFlow() = assetsViewModeRepository.assetsViewModeFlow() suspend fun setAssetViewMode(assetViewModel: AssetViewMode) { - assetsViewModeService.setAssetsViewMode(assetViewModel) + assetsViewModeRepository.setAssetsViewMode(assetViewModel) } suspend fun fullSyncNft(nft: Nft) = nftRepository.fullNftSync(nft) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt index e651a0c7c3..4f9c0eccce 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/NetworkAssetMappers.kt @@ -4,7 +4,7 @@ import io.novafoundation.nova.common.list.GroupedList import io.novafoundation.nova.common.list.toListWithHeaders import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.domain.common.PricedAmount import io.novafoundation.nova.feature_assets.domain.common.NetworkAssetGroup import io.novafoundation.nova.feature_assets.domain.common.AssetWithOffChainBalance @@ -36,7 +36,7 @@ private fun mapAssetsToAssetModels( return assets.map { NetworkAssetUi( mapAssetToAssetModel(it.asset, balance(it.balanceWithOffchain)), - assetIconProvider.getAssetIcon(it.asset.token.configuration) + assetIconProvider.getAssetIconOrFallback(it.asset.token.configuration) ) } } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt index 6e88ff09ca..8668b70184 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/common/mappers/TokenAssetMappers.kt @@ -3,11 +3,12 @@ package io.novafoundation.nova.feature_assets.presentation.balance.common.mapper import io.novafoundation.nova.common.list.GroupedList import io.novafoundation.nova.common.list.toListWithHeaders import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.getAssetIconOrFallback import io.novafoundation.nova.common.utils.formatTokenAmount import io.novafoundation.nova.common.utils.formatting.formatAsChange import io.novafoundation.nova.common.utils.orZero import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.domain.common.PricedAmount import io.novafoundation.nova.feature_assets.domain.common.AssetWithNetwork import io.novafoundation.nova.feature_assets.domain.common.TokenAssetGroup @@ -42,7 +43,7 @@ fun mapTokenAssetGroupToUi( val balance = groupBalance(assetGroup) return TokenGroupUi( itemId = assetGroup.groupId, - tokenIcon = assetIconProvider.getAssetIcon(assetGroup.token.icon), + tokenIcon = assetIconProvider.getAssetIconOrFallback(assetGroup.token.icon), rate = mapCoinRateChange(assetGroup.token.coinRate, assetGroup.token.currency), recentRateChange = assetGroup.token.coinRate?.recentRateChange.orZero().formatAsChange(), rateChangeColorRes = mapCoinRateChangeColorRes(assetGroup.token.coinRate), @@ -66,7 +67,7 @@ private fun mapAssetsToAssetModels( TokenAssetUi( group.getId(), mapAssetToAssetModel(it.asset, balance(it.balanceWithOffChain)), - assetIconProvider.getAssetIcon(it.asset.token.configuration), + assetIconProvider.getAssetIconOrFallback(it.asset.token.configuration), mapChainToUi(it.chain) ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt index 161607ecd6..d6d1a4cc19 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/balance/detail/BalanceDetailViewModel.kt @@ -10,7 +10,7 @@ import io.novafoundation.nova.common.utils.Event import io.novafoundation.nova.common.utils.inBackground import io.novafoundation.nova.common.utils.sumByBigInteger import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAccountUseCase -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.domain.WalletInteractor import io.novafoundation.nova.feature_assets.domain.assets.ExternalBalancesInteractor @@ -208,7 +208,7 @@ class BalanceDetailViewModel( total = mapAmountToAmountModel(asset.total + totalContributed, asset), transferable = mapAmountToAmountModel(asset.transferable, asset), locked = mapAmountToAmountModel(asset.locked + totalContributed, asset), - assetIcon = assetIconProvider.getAssetIcon(asset.token.configuration) + assetIcon = assetIconProvider.getAssetIconOrFallback(asset.token.configuration) ) } diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt index 9f40c2f599..8d96d75247 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/receive/ReceiveViewModel.kt @@ -18,7 +18,7 @@ import io.novafoundation.nova.feature_account_api.domain.interfaces.SelectedAcco import io.novafoundation.nova.feature_account_api.domain.model.addressIn import io.novafoundation.nova.feature_account_api.presenatation.account.icon.createAddressModel import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.domain.receive.ReceiveInteractor import io.novafoundation.nova.feature_wallet_api.presentation.model.AssetPayload @@ -67,7 +67,7 @@ class ReceiveViewModel( TokenReceiver( addressModel = addressIconGenerator.createAddressModel(chain, address, AddressIconGenerator.SIZE_BIG, it.name), chain = mapChainToUi(chain), - chainAssetIcon = assetIconProvider.getAssetIcon(chainAsset) + chainAssetIcon = assetIconProvider.getAssetIconOrFallback(chainAsset) ) } .inBackground() diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt index 1b3b497f24..e8bb7404fb 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/tokens/manage/model/MultiChainTokenModel.kt @@ -1,6 +1,7 @@ package io.novafoundation.nova.feature_assets.presentation.tokens.manage.model import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.getAssetIconOrFallback import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.resources.formatListPreview import io.novafoundation.nova.common.utils.images.Icon @@ -27,7 +28,7 @@ class MultiChainTokenMapper( fun mapHeaderToUi(multiChainToken: MultiChainToken): MultiChainTokenModel.HeaderModel { return MultiChainTokenModel.HeaderModel( - icon = assetIconProvider.getAssetIcon(multiChainToken.icon), + icon = assetIconProvider.getAssetIconOrFallback(multiChainToken.icon), symbol = multiChainToken.symbol, networks = constructNetworksSubtitle(multiChainToken) ) diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt index 2dfc929632..f23d9a1273 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/extrinsic/ExtrinsicDetailViewModel.kt @@ -3,6 +3,7 @@ package io.novafoundation.nova.feature_assets.presentation.transaction.detail.ex import io.novafoundation.nova.common.address.AddressIconGenerator import io.novafoundation.nova.common.base.BaseViewModel import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.getAssetIconOrFallback import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.flowOf import io.novafoundation.nova.common.utils.inBackground @@ -54,7 +55,7 @@ class ExtrinsicDetailViewModel( .share() val operationIcon = flowOf { - assetIconProvider.getAssetIcon(chainAsset().icon) + assetIconProvider.getAssetIconOrFallback(chainAsset().icon) }.shareInBackground() val content = flowOf { diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt index b8a1aea05c..0ea5fa3d21 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/detail/swap/SwapDetailViewModel.kt @@ -14,7 +14,7 @@ import io.novafoundation.nova.feature_account_api.data.mappers.mapChainToUi import io.novafoundation.nova.feature_account_api.presenatation.account.icon.createAccountAddressModel import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.WalletUiUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.AssetsRouter import io.novafoundation.nova.feature_assets.presentation.model.ChainAssetWithAmountParcelModel @@ -154,7 +154,7 @@ class SwapDetailViewModel( income: Boolean ): SwapAssetView.Model { return SwapAssetView.Model( - assetIcon = assetIconProvider.getAssetIcon(token.configuration), + assetIcon = assetIconProvider.getAssetIconOrFallback(token.configuration), amount = mapAmountToAmountModel(amount, token, estimatedFiat = true), chainUi = mapChainToUi(chainRegistry.getChain(token.configuration.chainId)), amountTextColorRes = if (income) R.color.text_positive else R.color.text_primary diff --git a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt index f710389ff2..da56fc1fc7 100644 --- a/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt +++ b/feature-assets/src/main/java/io/novafoundation/nova/feature_assets/presentation/transaction/history/mixin/OperationMappers.kt @@ -5,14 +5,16 @@ import android.text.TextUtils import android.text.style.ImageSpan import androidx.annotation.ColorRes import androidx.annotation.DrawableRes +import io.novafoundation.nova.common.data.model.AssetIconMode import io.novafoundation.nova.common.presentation.AssetIconProvider +import io.novafoundation.nova.common.presentation.getAssetIconOrFallback import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.buildSpannable import io.novafoundation.nova.common.utils.capitalize import io.novafoundation.nova.common.utils.images.asIcon import io.novafoundation.nova.common.utils.splitSnakeOrCamelCase import io.novafoundation.nova.feature_account_api.presenatation.account.AddressDisplayUseCase -import io.novafoundation.nova.feature_account_api.presenatation.chain.getWhiteAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_assets.R import io.novafoundation.nova.feature_assets.presentation.model.AmountParcelModel import io.novafoundation.nova.feature_assets.presentation.model.ChainAssetWithAmountParcelModel @@ -276,7 +278,7 @@ fun mapOperationToOperationModel( subHeader = subHeader.value, subHeaderEllipsize = subHeader.elipsize, statusAppearance = statusAppearance, - operationIcon = assetIconProvider.getWhiteAssetIcon(operation.chainAsset) + operationIcon = assetIconProvider.getAssetIconOrFallback(operation.chainAsset, AssetIconMode.WHITE) ) } diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt index c0bae59d97..e0897e4fcf 100644 --- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt +++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/presentation/track/TrackFormatter.kt @@ -6,7 +6,7 @@ import io.novafoundation.nova.common.resources.formatListPreview import io.novafoundation.nova.common.utils.capitalize import io.novafoundation.nova.common.utils.images.Icon import io.novafoundation.nova.common.utils.images.asIcon -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_governance_api.domain.referendum.track.category.TrackType import io.novafoundation.nova.feature_governance_api.domain.track.Track import io.novafoundation.nova.feature_governance_impl.R @@ -37,7 +37,7 @@ class RealTrackFormatter( return when (trackCategorizer.typeOf(track.name)) { TrackType.ROOT -> TrackModel( name = resourceManager.getString(R.string.referendum_track_root), - icon = assetIconProvider.getAssetIcon(asset, fallbackIcon = R.drawable.ic_block.asIcon()), + icon = assetIconProvider.getAssetIconOrFallback(asset, fallbackIcon = R.drawable.ic_block.asIcon()), ) TrackType.WHITELISTED_CALLER -> TrackModel( diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt index 4cc2e64d8b..d35b2d7767 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/confirmation/SwapConfirmationViewModel.kt @@ -27,7 +27,7 @@ import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.W import io.novafoundation.nova.feature_account_api.presenatation.account.wallet.WalletUiUseCase import io.novafoundation.nova.feature_account_api.presenatation.actions.ExternalActions import io.novafoundation.nova.feature_account_api.presenatation.actions.showAddressActions -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_swap_core.domain.model.SwapDirection import io.novafoundation.nova.feature_swap_api.domain.model.SwapFee import io.novafoundation.nova.feature_swap_api.domain.model.SwapQuote @@ -292,7 +292,7 @@ class SwapConfirmationViewModel( ): SwapAssetView.Model { val amount = formatAmount(metaAccount, chainAsset, amountInPlanks) return SwapAssetView.Model( - assetIcon = assetIconProvider.getAssetIcon(chainAsset), + assetIcon = assetIconProvider.getAssetIconOrFallback(chainAsset), amount = amount, chainUi = mapChainToUi(chain), ) diff --git a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt index d64f15daaf..35f1f0bb5c 100644 --- a/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt +++ b/feature-swap-impl/src/main/java/io/novafoundation/nova/feature_swap_impl/presentation/main/input/SwapAmountInputMixinFactory.kt @@ -4,7 +4,7 @@ import androidx.annotation.StringRes import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.validation.FieldValidator -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_account_api.presenatation.chain.iconOrFallback import io.novafoundation.nova.feature_swap_impl.R import io.novafoundation.nova.feature_swap_impl.presentation.main.input.SwapAmountInputMixin.SwapInputAssetModel @@ -80,7 +80,7 @@ private class RealSwapAmountInputMixin( val chain = chainRegistry.getChain(chainAsset.chainId) return SwapInputAssetModel( - assetIcon = SwapInputAssetModel.SwapAssetIcon.Chosen(assetIconProvider.getAssetIcon(chainAsset)), + assetIcon = SwapInputAssetModel.SwapAssetIcon.Chosen(assetIconProvider.getAssetIconOrFallback(chainAsset)), title = chainAsset.symbol.value, subtitleIcon = chain.iconOrFallback(), subtitle = chain.name, diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt index 7f87ac6e0e..09e8bf058b 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/data/mappers/Asset.kt @@ -3,7 +3,7 @@ package io.novafoundation.nova.feature_wallet_api.data.mappers import androidx.annotation.StringRes import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_wallet_api.R import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.feature_wallet_api.presentation.formatters.formatTokenAmount @@ -24,7 +24,7 @@ fun mapAssetToAssetModel( AssetModel( chainId = asset.token.configuration.chainId, chainAssetId = asset.token.configuration.id, - icon = assetIconProvider.getAssetIcon(token.configuration), + icon = assetIconProvider.getAssetIconOrFallback(token.configuration), tokenName = token.configuration.name, tokenSymbol = token.configuration.symbol.value, assetBalance = formattedAmount diff --git a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt index b46b57616e..ba8a3b74f8 100644 --- a/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt +++ b/feature-wallet-api/src/main/java/io/novafoundation/nova/feature_wallet_api/presentation/model/ChooseAmountModel.kt @@ -5,7 +5,7 @@ import io.novafoundation.nova.common.presentation.AssetIconProvider import io.novafoundation.nova.common.resources.ResourceManager import io.novafoundation.nova.common.utils.ensureSuffix import io.novafoundation.nova.common.utils.images.Icon -import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIcon +import io.novafoundation.nova.feature_account_api.presenatation.chain.getAssetIconOrFallback import io.novafoundation.nova.feature_wallet_api.domain.model.Asset import io.novafoundation.nova.runtime.multiNetwork.chain.model.Chain @@ -31,5 +31,5 @@ internal fun ChooseAmountModel( internal fun ChooseAmountInputModel(chainAsset: Chain.Asset, assetIconProvider: AssetIconProvider): ChooseAmountInputModel = ChooseAmountInputModel( tokenSymbol = chainAsset.symbol.value, - tokenIcon = assetIconProvider.getAssetIcon(chainAsset), + tokenIcon = assetIconProvider.getAssetIconOrFallback(chainAsset), ) diff --git a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt index 93d464b140..f8c0879a0a 100644 --- a/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt +++ b/runtime/src/main/java/io/novafoundation/nova/runtime/multiNetwork/ChainRegistry.kt @@ -6,6 +6,7 @@ import io.novafoundation.nova.common.utils.LOG_TAG import io.novafoundation.nova.common.utils.diffed import io.novafoundation.nova.common.utils.filterList import io.novafoundation.nova.common.utils.inBackground +import io.novafoundation.nova.common.utils.mapList import io.novafoundation.nova.common.utils.mapNotNullToSet import io.novafoundation.nova.common.utils.removeHexPrefix import io.novafoundation.nova.core.ethereum.Web3Api @@ -65,9 +66,8 @@ class ChainRegistry( private val gson: Gson ) : CoroutineScope by CoroutineScope(Dispatchers.Default) { - val currentChains = chainDao.joinChainInfoFlow().map { chains -> - chains.map { mapChainLocalToChain(it, gson) } - } + val currentChains = chainDao.joinChainInfoFlow() + .mapList { mapChainLocalToChain(it, gson) } .diffed() .map { diff -> diff.removed.forEach { unregisterChain(it) } From 2c92c852ca4acee1d7a555210bc56c61b63bc705 Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Fri, 1 Nov 2024 10:24:31 +0100 Subject: [PATCH 11/11] Update AssetIconProvider.kt --- .../novafoundation/nova/common/presentation/AssetIconProvider.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt index 2a1fe45762..a174975a4f 100644 --- a/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt +++ b/common/src/main/java/io/novafoundation/nova/common/presentation/AssetIconProvider.kt @@ -21,7 +21,6 @@ class RealAssetIconProvider( private val whiteBaseUrl: String ) : AssetIconProvider { - override fun getAssetIconOrFallback(iconName: String): Icon { return getAssetIconOrFallback(iconName, assetsIconModeRepository.getIconMode()) }