From 2ac9f5ebd49fa8fad234af417cd18821fda3d66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Rychnovsk=C3=BD?= Date: Wed, 24 Apr 2024 18:47:23 +0200 Subject: [PATCH] Add more servers to the list (#1394) - 8 more servers added to the list - Order of servers changed to show default as 1st, custom as 2nd --- .../chooseserver/AvailableServerProvider.kt | 38 ++++++++++++++----- .../chooseserver/view/ChooseServerView.kt | 22 +++++++---- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/AvailableServerProvider.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/AvailableServerProvider.kt index 03e5fa9b..00ac7b07 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/AvailableServerProvider.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/AvailableServerProvider.kt @@ -18,20 +18,40 @@ object AvailableServerProvider { // Mainnet: mainnet.lightwalletd.com | 9067 // Testnet: lightwalletd.testnet.electriccoin.co | 9067 - private const val HOST_NA = "na.lightwalletd.com" // NON-NLS - private const val HOST_SA = "sa.lightwalletd.com" // NON-NLS - private const val HOST_EU = "eu.lightwalletd.com" // NON-NLS - private const val HOST_AI = "ai.lightwalletd.com" // NON-NLS - private const val PORT = 443 + private const val NH_HOST_NA = "na.lightwalletd.com" // NON-NLS + private const val NH_HOST_SA = "sa.lightwalletd.com" // NON-NLS + private const val NH_HOST_EU = "eu.lightwalletd.com" // NON-NLS + private const val NH_HOST_AI = "ai.lightwalletd.com" // NON-NLS + private const val NH_PORT = 443 + + private const val YW_HOST_1 = "lwd1.zcash-infra.com" // NON-NLS + private const val YW_HOST_2 = "lwd2.zcash-infra.com" // NON-NLS + private const val YW_HOST_3 = "lwd3.zcash-infra.com" // NON-NLS + private const val YW_HOST_4 = "lwd4.zcash-infra.com" // NON-NLS + private const val YW_HOST_5 = "lwd5.zcash-infra.com" // NON-NLS + private const val YW_HOST_6 = "lwd6.zcash-infra.com" // NON-NLS + private const val YW_HOST_7 = "lwd7.zcash-infra.com" // NON-NLS + private const val YW_HOST_8 = "lwd8.zcash-infra.com" // NON-NLS + private const val YW_PORT = 9067 fun toList(network: ZcashNetwork) = buildList { if (network == ZcashNetwork.Mainnet) { add(LightWalletEndpoint.Mainnet) - add(LightWalletEndpoint(HOST_NA, PORT, true)) - add(LightWalletEndpoint(HOST_SA, PORT, true)) - add(LightWalletEndpoint(HOST_EU, PORT, true)) - add(LightWalletEndpoint(HOST_AI, PORT, true)) + + add(LightWalletEndpoint(YW_HOST_1, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_2, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_3, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_4, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_5, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_6, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_7, YW_PORT, true)) + add(LightWalletEndpoint(YW_HOST_8, YW_PORT, true)) + + add(LightWalletEndpoint(NH_HOST_NA, NH_PORT, true)) + add(LightWalletEndpoint(NH_HOST_SA, NH_PORT, true)) + add(LightWalletEndpoint(NH_HOST_EU, NH_PORT, true)) + add(LightWalletEndpoint(NH_HOST_AI, NH_PORT, true)) } else { add(LightWalletEndpoint.Testnet) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/view/ChooseServerView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/view/ChooseServerView.kt index 591f417e..fba6dd76 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/view/ChooseServerView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/chooseserver/view/ChooseServerView.kt @@ -145,6 +145,8 @@ private fun ChooseServerTopAppBar( ) } +const val CUSTOM_SERVER_OPTION_INDEX = 1 + @Composable @Suppress("LongMethod", "LongParameterList") private fun ChooseServerMainContent( @@ -162,10 +164,10 @@ private fun ChooseServerMainContent( // server list obtaining is implemented. if (contains(wallet.endpoint)) { // We define the custom server as secured by default - add(LightWalletEndpoint("", -1, true)) + add(CUSTOM_SERVER_OPTION_INDEX, LightWalletEndpoint("", -1, true)) } else { // Adding previously chosen custom endpoint - add(wallet.endpoint) + add(CUSTOM_SERVER_OPTION_INDEX, wallet.endpoint) } }.toImmutableList() @@ -175,9 +177,13 @@ private fun ChooseServerMainContent( } val initialCustomServerValue = - options.last().run { - if (options.last().isValid()) { - stringResource(R.string.choose_server_textfield_value, options.last().host, options.last().port) + options[CUSTOM_SERVER_OPTION_INDEX].run { + if (options[CUSTOM_SERVER_OPTION_INDEX].isValid()) { + stringResource( + R.string.choose_server_textfield_value, + options[CUSTOM_SERVER_OPTION_INDEX].host, + options[CUSTOM_SERVER_OPTION_INDEX].port + ) } else { "" } @@ -243,7 +249,7 @@ fun ServerList( options.forEachIndexed { index, endpoint -> val isSelected = index == selectedOption - if (index == options.lastIndex) { + if (index == CUSTOM_SERVER_OPTION_INDEX) { Column( modifier = Modifier.animateContentSize() ) { @@ -284,6 +290,8 @@ fun ServerList( .fillMaxWidth() .padding(horizontal = ZcashTheme.dimens.spacingSmall) ) + + Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall)) } } } else { @@ -339,7 +347,7 @@ fun SaveButton( text = stringResource(id = R.string.choose_server_save), onClick = { val selectedServer = - if (selectedOption == options.lastIndex) { + if (selectedOption == CUSTOM_SERVER_OPTION_INDEX) { if (!validateCustomServerValue(customServerValue)) { setShowErrorDialog(true) return@PrimaryButton