Skip to content

Commit

Permalink
Disable swap
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Aug 29, 2024
1 parent 6bd8cca commit 57d6484
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
12 changes: 12 additions & 0 deletions app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ object BalanceModule {
App.localStorage,
App.wcManager,
AddressHandlerFactory(App.appConfigProvider.udnApiKey),
App.priceManager
App.priceManager,
App.instance.isSwapEnabled
) as T
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BalanceUiState>(), ITotalBalance by totalBalance {

private var balanceViewType = balanceViewTypeManager.balanceViewTypeFlow.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/horizontalsystems/core/CoreApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class CoreApp : Application() {

abstract fun localizedContext(): Context
abstract fun getApplicationSignatures(): List<ByteArray>
abstract val isSwapEnabled: Boolean

fun localeAwareContext(base: Context): Context {
return LocaleHelper.onAttach(base)
Expand Down

0 comments on commit 57d6484

Please sign in to comment.