From 57d6484bb18399ccfd42f57a132f3057855e5455 Mon Sep 17 00:00:00 2001 From: bakyt Date: Thu, 29 Aug 2024 17:02:11 +0600 Subject: [PATCH 1/3] Disable swap --- .../horizontalsystems/bankwallet/core/App.kt | 12 ++++++++++ .../modules/balance/BalanceModule.kt | 3 ++- .../modules/balance/BalanceViewItemFactory.kt | 2 +- .../modules/balance/BalanceViewModel.kt | 3 ++- .../modules/balance/ui/BalanceItems.kt | 22 ++++++++++--------- .../java/io/horizontalsystems/core/CoreApp.kt | 1 + 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt index b202c98ba1..6b25c9ae7a 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt @@ -517,6 +517,18 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory { localeAwareContext(this) } + override val isSwapEnabled: Boolean by lazy { + val signatures = listOf( + "b797339fb356afce5160fe49274ee17a1c1816db", // appcenter + "5afb2517b06caac7f108ba9d96ad826f1c4ba30c", // hs + ) + + val applicationSignatures = App.instance.getApplicationSignatures() + applicationSignatures.none { + signatures.contains(it.toHexString()) + } + } + override fun getApplicationSignatures() = try { val signatureList = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { val signingInfo = packageManager.getPackageInfo( diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceModule.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceModule.kt index fe2f873089..027f44ef3f 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceModule.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceModule.kt @@ -40,7 +40,8 @@ object BalanceModule { App.localStorage, App.wcManager, AddressHandlerFactory(App.appConfigProvider.udnApiKey), - App.priceManager + App.priceManager, + App.instance.isSwapEnabled ) as T } } diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewItemFactory.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewItemFactory.kt index f6bab68012..c0eeb4d8dc 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewItemFactory.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewItemFactory.kt @@ -244,7 +244,7 @@ class BalanceViewItemFactory { failedIconVisible = state is AdapterState.NotSynced, coinIconVisible = state !is AdapterState.NotSynced, badge = wallet.badge, - swapVisible = wallet.token.swappable, + swapVisible = App.instance.isSwapEnabled && wallet.token.swappable, swapEnabled = state is AdapterState.Synced, errorMessage = (state as? AdapterState.NotSynced)?.error?.message, isWatchAccount = watchAccount, diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt index 68c2f9847e..28cf5bdcbb 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt @@ -45,7 +45,8 @@ class BalanceViewModel( private val localStorage: ILocalStorage, private val wCManager: WCManager, private val addressHandlerFactory: AddressHandlerFactory, - private val priceManager: PriceManager + private val priceManager: PriceManager, + val isSwapEnabled: Boolean ) : ViewModelUiState(), ITotalBalance by totalBalance { private var balanceViewType = balanceViewTypeManager.balanceViewTypeFlow.value diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceItems.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceItems.kt index 9a732a7be4..b1828cfe43 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceItems.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/ui/BalanceItems.kt @@ -306,16 +306,18 @@ fun BalanceItems( } } ) - HSpacer(8.dp) - ButtonPrimaryCircle( - icon = R.drawable.ic_swap_24, - contentDescription = stringResource(R.string.Swap), - onClick = { - navController.slideFromRight(R.id.multiswap) - - stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.Swap)) - } - ) + if (viewModel.isSwapEnabled) { + HSpacer(8.dp) + ButtonPrimaryCircle( + icon = R.drawable.ic_swap_24, + contentDescription = stringResource(R.string.Swap), + onClick = { + navController.slideFromRight(R.id.multiswap) + + stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.Swap)) + } + ) + } } VSpacer(12.dp) } diff --git a/core/src/main/java/io/horizontalsystems/core/CoreApp.kt b/core/src/main/java/io/horizontalsystems/core/CoreApp.kt index 0806523e2c..a48ead8f23 100644 --- a/core/src/main/java/io/horizontalsystems/core/CoreApp.kt +++ b/core/src/main/java/io/horizontalsystems/core/CoreApp.kt @@ -23,6 +23,7 @@ abstract class CoreApp : Application() { abstract fun localizedContext(): Context abstract fun getApplicationSignatures(): List + abstract val isSwapEnabled: Boolean fun localeAwareContext(base: Context): Context { return LocaleHelper.onAttach(base) From 2eba72db80007021398209cf3dbc22b3ca83ae70 Mon Sep 17 00:00:00 2001 From: bakyt Date: Thu, 29 Aug 2024 17:58:01 +0600 Subject: [PATCH 2/3] Increase version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6b50b18b5d..ade69a9963 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,8 +19,8 @@ android { compileSdk compile_sdk_version minSdkVersion min_sdk_version targetSdkVersion compile_sdk_version - versionCode 113 - versionName "0.39.3" + versionCode 114 + versionName "0.39.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ksp { From 80f512d52c95d185c6c8268e8af67437f4eb2008 Mon Sep 17 00:00:00 2001 From: bakyt Date: Thu, 29 Aug 2024 18:06:28 +0600 Subject: [PATCH 3/3] Fix checking --- app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt index 6b25c9ae7a..48b56bce0e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt @@ -112,6 +112,7 @@ import io.horizontalsystems.core.CoreApp import io.horizontalsystems.core.ICoreApp import io.horizontalsystems.core.security.EncryptionManager import io.horizontalsystems.core.security.KeyStoreManager +import io.horizontalsystems.core.toHexString import io.horizontalsystems.ethereumkit.core.EthereumKit import io.horizontalsystems.hdwalletkit.Mnemonic import io.reactivex.plugins.RxJavaPlugins