Compare commits
6 Commits
b9249d6ebf
...
a95172ad76
Author | SHA1 | Date |
---|---|---|
Honza Rychnovský | a95172ad76 | |
Honza Rychnovský | 9b2bad6f10 | |
dependabot[bot] | 9ca5548ca3 | |
dependabot[bot] | 841e0e76d1 | |
dependabot[bot] | e1a805fc0a | |
dependabot[bot] | 9ae38c92bc |
|
@ -38,12 +38,12 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
# Gradle Wrapper validation can be flaky
|
||||
# https://github.com/gradle/wrapper-validation-action/issues/40
|
||||
- name: Gradle Wrapper Validation
|
||||
timeout-minutes: 1
|
||||
uses: gradle/wrapper-validation-action@5188e9b5527a0a094cee21e2fe9a8ca44b4629af
|
||||
uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5
|
||||
|
||||
check_secrets:
|
||||
environment: deployment
|
||||
|
@ -80,7 +80,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0 # To fetch all commits
|
||||
|
@ -91,7 +91,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 10
|
||||
with:
|
||||
gradle-home-cache-cleanup: true
|
||||
|
@ -184,9 +184,9 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Download release artifact
|
||||
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395
|
||||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
|
||||
with:
|
||||
name: Binaries
|
||||
- name: Unzip artifacts
|
||||
|
|
|
@ -32,12 +32,12 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
# Gradle Wrapper validation can be flaky
|
||||
# https://github.com/gradle/wrapper-validation-action/issues/40
|
||||
- name: Gradle Wrapper Validation
|
||||
timeout-minutes: 1
|
||||
uses: gradle/wrapper-validation-action@5188e9b5527a0a094cee21e2fe9a8ca44b4629af
|
||||
uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5
|
||||
|
||||
check_firebase_secrets:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -71,7 +71,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -79,7 +79,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Check properties
|
||||
timeout-minutes: 4
|
||||
|
@ -94,7 +94,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -102,7 +102,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Detekt
|
||||
timeout-minutes: 10
|
||||
|
@ -134,7 +134,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -142,7 +142,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Ktlint
|
||||
timeout-minutes: 4
|
||||
|
@ -174,7 +174,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -182,7 +182,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Android Lint
|
||||
timeout-minutes: 15
|
||||
|
@ -217,7 +217,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -225,7 +225,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Test
|
||||
timeout-minutes: 10
|
||||
|
@ -261,7 +261,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -269,7 +269,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Build
|
||||
timeout-minutes: 20
|
||||
|
@ -324,7 +324,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -332,7 +332,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Build and test
|
||||
timeout-minutes: 30
|
||||
|
@ -371,7 +371,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -379,7 +379,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Build and test
|
||||
timeout-minutes: 30
|
||||
|
@ -421,7 +421,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -429,7 +429,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Export Google Services JSON
|
||||
env:
|
||||
|
@ -475,7 +475,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -483,7 +483,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Export Google Services JSON
|
||||
env:
|
||||
|
@ -548,7 +548,7 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
timeout-minutes: 1
|
||||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f
|
||||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
|
||||
timeout-minutes: 1
|
||||
|
@ -556,7 +556,7 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
- name: Set up Gradle
|
||||
uses: gradle/gradle-build-action@e2097ccd7e8ed48671dc068ac4efa86d25745b39
|
||||
uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff
|
||||
timeout-minutes: 5
|
||||
- name: Authenticate to Google Cloud for Firebase Test Lab
|
||||
id: auth_test_lab
|
||||
|
@ -568,7 +568,7 @@ jobs:
|
|||
workload_identity_provider: ${{ secrets.FIREBASE_TEST_LAB_WORKLOAD_IDENTITY_PROVIDER }}
|
||||
access_token_lifetime: '900s'
|
||||
- name: Download a single artifact
|
||||
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395
|
||||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
|
||||
with:
|
||||
name: Binaries
|
||||
- name: Robo test
|
||||
|
|
|
@ -9,6 +9,12 @@ directly impact users rather than highlighting other key architectural updates.*
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0 (636)] - 2024-04-26
|
||||
|
||||
### Changed
|
||||
- We have added one more group of server options (zec.rocks) for increased coverage and reliability
|
||||
- zec.rocks:443 is now default wallet option
|
||||
|
||||
## [1.0 (630)] - 2024-04-24
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -21,9 +21,7 @@ import cash.z.ecc.android.sdk.model.WalletBalance
|
|||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
import cash.z.ecc.sdk.extension.defaultForNetwork
|
||||
import cash.z.ecc.sdk.type.fromResources
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import co.electriccoin.zcash.global.getInstance
|
||||
import co.electriccoin.zcash.spackle.Twig
|
||||
import co.electriccoin.zcash.ui.common.ANDROID_STATE_FLOW_TIMEOUT
|
||||
|
@ -42,6 +40,7 @@ import co.electriccoin.zcash.ui.preference.StandardPreferenceSingleton
|
|||
import co.electriccoin.zcash.ui.screen.account.ext.TransactionOverviewExt
|
||||
import co.electriccoin.zcash.ui.screen.account.ext.getSortHeight
|
||||
import co.electriccoin.zcash.ui.screen.account.state.TransactionHistorySyncState
|
||||
import co.electriccoin.zcash.ui.screen.chooseserver.AvailableServerProvider
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
|
@ -295,7 +294,7 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
|
|||
PersistableWallet.new(
|
||||
application = application,
|
||||
zcashNetwork = zcashNetwork,
|
||||
endpoint = LightWalletEndpoint.defaultForNetwork(zcashNetwork),
|
||||
endpoint = AvailableServerProvider.getDefaultServer(zcashNetwork),
|
||||
walletInitMode = WalletInitMode.NewWallet
|
||||
)
|
||||
persistWallet(newWallet)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package co.electriccoin.zcash.ui.screen.chooseserver
|
||||
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.sdk.extension.Mainnet
|
||||
import cash.z.ecc.sdk.extension.Testnet
|
||||
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
@ -9,20 +8,14 @@ import kotlinx.collections.immutable.toImmutableList
|
|||
// TODO [#1273]: Add ChooseServer Tests #1273
|
||||
// TODO [#1273]: https://github.com/Electric-Coin-Company/zashi-android/issues/1273
|
||||
|
||||
@Suppress("UnusedPrivateProperty")
|
||||
object AvailableServerProvider {
|
||||
// North America | [na.lightwalletd.com](http://na.lightwalletd.com/) | 443
|
||||
// South America | [sa.lightwalletd.com](http://sa.lightwalletd.com/) | 443
|
||||
// Europe & Africa | [eu.lightwalletd.com](http://eu.lightwalletd.com/) | 443
|
||||
// Asia & Oceania | [ai.lightwalletd.com](http://ai.lightwalletd.com/) | 443
|
||||
// Plus current network defaults:
|
||||
// Mainnet: mainnet.lightwalletd.com | 9067
|
||||
// Testnet: lightwalletd.testnet.electriccoin.co | 9067
|
||||
|
||||
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 ZR_HOST = "zec.rocks" // NON-NLS
|
||||
private const val ZR_HOST_NA = "na.zec.rocks" // NON-NLS
|
||||
private const val ZR_HOST_SA = "sa.zec.rocks" // NON-NLS
|
||||
private const val ZR_HOST_EU = "eu.zec.rocks" // NON-NLS
|
||||
private const val ZR_HOST_AP = "ap.zec.rocks" // NON-NLS
|
||||
private const val ZR_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
|
||||
|
@ -34,10 +27,24 @@ object AvailableServerProvider {
|
|||
private const val YW_HOST_8 = "lwd8.zcash-infra.com" // NON-NLS
|
||||
private const val YW_PORT = 9067
|
||||
|
||||
// NH servers are currently unused and are subject of removal in the future
|
||||
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
|
||||
|
||||
fun toList(network: ZcashNetwork) =
|
||||
buildList {
|
||||
if (network == ZcashNetwork.Mainnet) {
|
||||
add(LightWalletEndpoint.Mainnet)
|
||||
add(LightWalletEndpoint(ZR_HOST, ZR_PORT, true))
|
||||
|
||||
// Custom server item comes here in the view layer
|
||||
|
||||
add(LightWalletEndpoint(ZR_HOST_NA, ZR_PORT, true))
|
||||
add(LightWalletEndpoint(ZR_HOST_SA, ZR_PORT, true))
|
||||
add(LightWalletEndpoint(ZR_HOST_EU, ZR_PORT, true))
|
||||
add(LightWalletEndpoint(ZR_HOST_AP, ZR_PORT, true))
|
||||
|
||||
add(LightWalletEndpoint(YW_HOST_1, YW_PORT, true))
|
||||
add(LightWalletEndpoint(YW_HOST_2, YW_PORT, true))
|
||||
|
@ -47,15 +54,12 @@ object AvailableServerProvider {
|
|||
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)
|
||||
}
|
||||
}.toImmutableList()
|
||||
|
||||
fun getDefaultServer(zcashNetwork: ZcashNetwork): LightWalletEndpoint = toList(zcashNetwork).first()
|
||||
}
|
||||
|
||||
// This regex validates server URLs with ports in format: <hostname>:<port>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
@file:Suppress("TooManyFunctions")
|
||||
|
||||
package co.electriccoin.zcash.ui.screen.chooseserver.view
|
||||
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
|
@ -11,6 +14,9 @@ import androidx.compose.foundation.rememberScrollState
|
|||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DividerDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -25,7 +31,6 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import cash.z.ecc.android.sdk.internal.Twig
|
||||
import cash.z.ecc.android.sdk.model.PersistableWallet
|
||||
|
@ -41,7 +46,6 @@ import co.electriccoin.zcash.ui.design.component.GradientSurface
|
|||
import co.electriccoin.zcash.ui.design.component.PrimaryButton
|
||||
import co.electriccoin.zcash.ui.design.component.RadioButton
|
||||
import co.electriccoin.zcash.ui.design.component.SmallTopAppBar
|
||||
import co.electriccoin.zcash.ui.design.component.SubHeader
|
||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||
import co.electriccoin.zcash.ui.screen.chooseserver.ChooseServerTag
|
||||
import co.electriccoin.zcash.ui.screen.chooseserver.validateCustomServerValue
|
||||
|
@ -70,7 +74,7 @@ private fun PreviewChooseServer() {
|
|||
}
|
||||
|
||||
@Composable
|
||||
@Suppress("LongParameterList")
|
||||
@Suppress("LongMethod", "LongParameterList")
|
||||
fun ChooseServer(
|
||||
availableServers: ImmutableList<LightWalletEndpoint>,
|
||||
onBack: () -> Unit,
|
||||
|
@ -82,80 +86,6 @@ fun ChooseServer(
|
|||
isShowingSuccessDialog: Boolean,
|
||||
setShowSuccessDialog: (Boolean) -> Unit,
|
||||
walletRestoringState: WalletRestoringState,
|
||||
) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
ChooseServerTopAppBar(
|
||||
onBack = onBack,
|
||||
showRestoring = walletRestoringState == WalletRestoringState.RESTORING,
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
ChooseServerMainContent(
|
||||
modifier =
|
||||
Modifier
|
||||
.verticalScroll(
|
||||
rememberScrollState()
|
||||
)
|
||||
.padding(
|
||||
top = paddingValues.calculateTopPadding(),
|
||||
bottom = paddingValues.calculateBottomPadding(),
|
||||
start = ZcashTheme.dimens.screenHorizontalSpacingRegular,
|
||||
end = ZcashTheme.dimens.screenHorizontalSpacingRegular
|
||||
)
|
||||
.fillMaxWidth(),
|
||||
availableServers = availableServers,
|
||||
onServerChange = onServerChange,
|
||||
setShowErrorDialog = setShowErrorDialog,
|
||||
validationResult = validationResult,
|
||||
wallet = wallet,
|
||||
)
|
||||
|
||||
// Show validation popups
|
||||
if (isShowingErrorDialog && validationResult is ServerValidation.InValid) {
|
||||
ValidationErrorDialog(
|
||||
reason = validationResult.reason.message,
|
||||
onDone = { setShowErrorDialog(false) }
|
||||
)
|
||||
} else if (isShowingSuccessDialog) {
|
||||
SaveSuccessDialog(
|
||||
onDone = { setShowSuccessDialog(false) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChooseServerTopAppBar(
|
||||
onBack: () -> Unit,
|
||||
showRestoring: Boolean
|
||||
) {
|
||||
SmallTopAppBar(
|
||||
restoringLabel =
|
||||
if (showRestoring) {
|
||||
stringResource(id = R.string.restoring_wallet_label)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
modifier = Modifier.testTag(ChooseServerTag.CHOOSE_SERVER_TOP_APP_BAR),
|
||||
showTitleLogo = true,
|
||||
backText = stringResource(id = R.string.choose_server_back).uppercase(),
|
||||
backContentDescriptionText = stringResource(R.string.choose_server_back_content_description),
|
||||
onBack = onBack,
|
||||
)
|
||||
}
|
||||
|
||||
const val CUSTOM_SERVER_OPTION_INDEX = 1
|
||||
|
||||
@Composable
|
||||
@Suppress("LongMethod", "LongParameterList")
|
||||
private fun ChooseServerMainContent(
|
||||
availableServers: ImmutableList<LightWalletEndpoint>,
|
||||
onServerChange: (LightWalletEndpoint) -> Unit,
|
||||
validationResult: ServerValidation,
|
||||
wallet: PersistableWallet,
|
||||
modifier: Modifier = Modifier,
|
||||
setShowErrorDialog: (Boolean) -> Unit,
|
||||
) {
|
||||
val options =
|
||||
availableServers.toMutableList().apply {
|
||||
|
@ -193,27 +123,84 @@ private fun ChooseServerMainContent(
|
|||
mutableStateOf(initialCustomServerValue)
|
||||
}
|
||||
|
||||
Column(modifier = modifier) {
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
|
||||
SubHeader(
|
||||
text = stringResource(id = R.string.choose_server_title),
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
|
||||
ServerList(
|
||||
Scaffold(
|
||||
topBar = {
|
||||
ChooseServerTopAppBar(
|
||||
onBack = onBack,
|
||||
showRestoring = walletRestoringState == WalletRestoringState.RESTORING,
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
ChooseServerBottomBar(
|
||||
customServerValue = customServerValue,
|
||||
onServerChange = onServerChange,
|
||||
options = options,
|
||||
selectedOption = selectedOption,
|
||||
setShowErrorDialog = setShowErrorDialog,
|
||||
validationResult = validationResult,
|
||||
wallet = wallet
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
ChooseServerMainContent(
|
||||
customServerValue = customServerValue,
|
||||
modifier =
|
||||
Modifier
|
||||
.verticalScroll(
|
||||
rememberScrollState()
|
||||
)
|
||||
.padding(
|
||||
top = paddingValues.calculateTopPadding(),
|
||||
bottom = paddingValues.calculateBottomPadding(),
|
||||
start = ZcashTheme.dimens.screenHorizontalSpacingRegular,
|
||||
end = ZcashTheme.dimens.screenHorizontalSpacingRegular
|
||||
)
|
||||
.fillMaxWidth(),
|
||||
options = options,
|
||||
selectedOption = selectedOption,
|
||||
setSelectedOption = setSelectedOption,
|
||||
customServerValue = customServerValue,
|
||||
setCustomServerValue = setCustomServerValue,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
setSelectedOption = setSelectedOption,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
// Show validation popups
|
||||
if (isShowingErrorDialog && validationResult is ServerValidation.InValid) {
|
||||
ValidationErrorDialog(
|
||||
reason = validationResult.reason.message,
|
||||
onDone = { setShowErrorDialog(false) }
|
||||
)
|
||||
} else if (isShowingSuccessDialog) {
|
||||
SaveSuccessDialog(
|
||||
onDone = { setShowSuccessDialog(false) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Suppress("LongParameterList")
|
||||
fun ChooseServerBottomBar(
|
||||
customServerValue: String,
|
||||
onServerChange: (LightWalletEndpoint) -> Unit,
|
||||
options: ImmutableList<LightWalletEndpoint>,
|
||||
selectedOption: Int,
|
||||
setShowErrorDialog: (Boolean) -> Unit,
|
||||
validationResult: ServerValidation,
|
||||
wallet: PersistableWallet,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
modifier.then(
|
||||
Modifier
|
||||
.background(MaterialTheme.colorScheme.surface)
|
||||
)
|
||||
) {
|
||||
HorizontalDivider(
|
||||
thickness = DividerDefaults.Thickness,
|
||||
color = ZcashTheme.colors.dividerColor
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall))
|
||||
|
||||
SaveButton(
|
||||
enabled = validationResult != ServerValidation.Running,
|
||||
|
@ -227,13 +214,62 @@ private fun ChooseServerMainContent(
|
|||
},
|
||||
setShowErrorDialog = setShowErrorDialog,
|
||||
selectedOption = selectedOption,
|
||||
modifier = Modifier.padding(horizontal = ZcashTheme.dimens.spacingUpLarge)
|
||||
modifier = Modifier.padding(horizontal = ZcashTheme.dimens.screenHorizontalSpacingBig)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingHuge))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ChooseServerTopAppBar(
|
||||
onBack: () -> Unit,
|
||||
showRestoring: Boolean
|
||||
) {
|
||||
SmallTopAppBar(
|
||||
titleText = stringResource(id = R.string.choose_server_title),
|
||||
restoringLabel =
|
||||
if (showRestoring) {
|
||||
stringResource(id = R.string.restoring_wallet_label)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
modifier = Modifier.testTag(ChooseServerTag.CHOOSE_SERVER_TOP_APP_BAR),
|
||||
showTitleLogo = true,
|
||||
backText = stringResource(id = R.string.choose_server_back).uppercase(),
|
||||
backContentDescriptionText = stringResource(R.string.choose_server_back_content_description),
|
||||
onBack = onBack,
|
||||
)
|
||||
}
|
||||
|
||||
const val CUSTOM_SERVER_OPTION_INDEX = 1
|
||||
|
||||
@Composable
|
||||
@Suppress("LongParameterList")
|
||||
private fun ChooseServerMainContent(
|
||||
customServerValue: String,
|
||||
options: ImmutableList<LightWalletEndpoint>,
|
||||
selectedOption: Int,
|
||||
setCustomServerValue: (String) -> Unit,
|
||||
setSelectedOption: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(modifier = modifier) {
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
|
||||
|
||||
ServerList(
|
||||
options = options,
|
||||
selectedOption = selectedOption,
|
||||
setSelectedOption = setSelectedOption,
|
||||
customServerValue = customServerValue,
|
||||
setCustomServerValue = setCustomServerValue,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
@Suppress("LongParameterList")
|
||||
|
|
Loading…
Reference in New Issue