From a239d0abeffcca3c9543f9b017a722279f7e4938 Mon Sep 17 00:00:00 2001 From: Andrey Khokhlov Date: Thu, 11 May 2023 19:21:16 +0800 Subject: [PATCH 01/10] AND-3542 Biometry and Save cards: biometry appears again and again when trying to enter app via scanning the card --- .github/CODEOWNERS | 2 +- .../sdk/biometrics/AndroidBiometricManager.kt | 58 ++++++++++--------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7bf922c7..35c16252 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,4 +2,4 @@ # Each line is a file pattern followed by one or more owners. # These owners will be the default owners for everything in the repo. -* @lazutkin-andrey @gbixahue @roman-pv @iiiburnyiii @MamaLemon @kozarezvlad @Yoggam1 \ No newline at end of file +* @lazutkin-andrey @gbixahue @roman-pv @iiiburnyiii @Mama1emon @kozarezvlad @Yoggam1 \ No newline at end of file diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt index 08b4b76e..316e41c2 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt @@ -67,19 +67,25 @@ internal class AndroidBiometricManager( return if (canAuthenticate) { initCrypto(mode) .map { cryptographyManager.invoke(mode.keyName, mode.data) } - .mapFailure { e -> - when (val cause = (e as? TangemSdkError.ExceptionError)?.cause) { + .mapFailure { error -> + when (val cause = (error as? TangemSdkError.ExceptionError)?.cause) { is KeyPermanentlyInvalidatedException, is UserNotAuthenticatedException, -> { cryptographyManager.deleteMasterKey() TangemSdkError.BiometricCryptographyKeyInvalidated() } + is InvalidKeyException -> { TangemSdkError.InvalidBiometricCryptographyKey(cause.localizedMessage.orEmpty(), cause) } + + is TangemSdkError.UserCanceledBiometricsAuthentication -> { + error + } + else -> { - TangemSdkError.BiometricCryptographyOperationFailed(e.customMessage, e) + TangemSdkError.BiometricCryptographyOperationFailed(error.customMessage, error) } } } @@ -88,37 +94,35 @@ internal class AndroidBiometricManager( } } - private suspend fun authenticateInternal(): CompletionResult = suspendCoroutine { continuation -> - val biometricPrompt = BiometricPrompt( - activity, - createAuthenticationCallback { result -> - when (result) { - is AuthenticationResult.Failure -> { - continuation.resume(CompletionResult.Failure(result.error)) - } - is AuthenticationResult.Success -> { - continuation.resume(CompletionResult.Success(Unit)) - } - } - }, - ) + private suspend fun authenticateInternal(): CompletionResult { + return suspendCoroutine { continuation -> + val biometricPrompt = BiometricPrompt( + activity, + createAuthenticationCallback { result -> + continuation.resume( + value = when (result) { + is AuthenticationResult.Failure -> CompletionResult.Failure(result.error) + is AuthenticationResult.Success -> CompletionResult.Success(Unit) + }, + ) + }, + ) - biometricPrompt.authenticate(biometricPromptInfo) + biometricPrompt.authenticate(biometricPromptInfo) + } } private suspend fun initCrypto(mode: BiometricManager.AuthenticationMode): CompletionResult { return when (mode) { is BiometricManager.AuthenticationMode.Decryption -> { - catching { cryptographyManager.initDecryption() } - .flatMapOnFailure { e -> - when ((e as? TangemSdkError.ExceptionError)?.cause) { - is UserNotAuthenticatedException -> { - withContext(Dispatchers.Main) { authenticateInternal() } - .map { cryptographyManager.initDecryption() } - } - else -> CompletionResult.Failure(e) - } + catching(cryptographyManager::initDecryption).flatMapOnFailure { error -> + if ((error as? TangemSdkError.ExceptionError)?.cause is UserNotAuthenticatedException) { + withContext(Dispatchers.Main) { authenticateInternal() } + .map { cryptographyManager.initDecryption() } + } else { + CompletionResult.Failure(error) } + } } is BiometricManager.AuthenticationMode.Encryption -> { catching { cryptographyManager.initEncryption() } From e9cfa83d3db6743d21bea3fe4dda33e95f79ab4f Mon Sep 17 00:00:00 2001 From: Andrey Khokhlov Date: Fri, 12 May 2023 17:40:10 +0800 Subject: [PATCH 02/10] AND-3557 Fix CardSDK upload.gradle --- upload.gradle | 60 +++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/upload.gradle b/upload.gradle index 43bc8c16..a4800b32 100644 --- a/upload.gradle +++ b/upload.gradle @@ -1,50 +1,40 @@ apply from: '../artifactConfig.gradle' apply plugin: 'maven-publish' -publishing { - publications { - android(MavenPublication) { - groupId = "$artifactConfig.group" - artifactId = "$project.artifactId" - version = "$artifactConfig.version" +afterEvaluate { + publishing { + publications { + maven(MavenPublication) { + groupId = "$artifactConfig.group" + artifactId = "$project.artifactId" + version = "$artifactConfig.version" - afterEvaluate { if (artifactId == "android") { from components.release - } - - pom.withXml { - Node pomNode = asNode() - pomNode.dependencies.'*'.findAll() { - it.groupId.text() == artifactConfig.group - }.each() { it.parent().remove(it) } + artifact(sourceJar) - pomNode.dependencies.'*'.findAll() { - it.scope.text() == 'runtime' - }.each { it.scope*.value = 'compile' } - } - } - } + pom.withXml { + Node pomNode = asNode() + pomNode.dependencies.'*'.findAll() { + it.groupId.text() == artifactConfig.group + }.each() { it.parent().remove(it) } - core(MavenPublication) { - groupId = "$artifactConfig.group" - artifactId = "$project.artifactId" - version = "$artifactConfig.version" - - afterEvaluate { - if (artifactId == "core") { + pomNode.dependencies.'*'.findAll() { + it.scope.text() == 'runtime' + }.each { it.scope*.value = 'compile' } + } + } else if (artifactId == "core") { from components.java } } } - } - - repositories { - maven { - url = "https://nexus.tangem-tech.com/repository/maven-releases" - credentials { - username = "$nexusUser" - password = "$nexusPass" + repositories { + maven { + url = "https://nexus.tangem-tech.com/repository/maven-releases" + credentials { + username = "$nexusUser" + password = "$nexusPass" + } } } } From bc88434b22d0abd44aaf3b3a5d9fc93fdce4d347 Mon Sep 17 00:00:00 2001 From: Andrey Khokhlov Date: Fri, 12 May 2023 20:12:04 +0800 Subject: [PATCH 03/10] AND-3525 There is no error code in CardSDK bottom sheet dialog on scan or biometric --- .../tangem/sdk/extensions/TangemSdkError.kt | 165 ++++++++++-------- 1 file changed, 95 insertions(+), 70 deletions(-) diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/extensions/TangemSdkError.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/extensions/TangemSdkError.kt index ee797e6d..1c3e7e00 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/extensions/TangemSdkError.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/extensions/TangemSdkError.kt @@ -7,53 +7,120 @@ import com.tangem.sdk.R @Suppress("LongMethod", "ComplexMethod") fun TangemSdkError.localizedDescription(context: Context): String { val resId = when (this) { - is TangemSdkError.EncodingFailedTypeMismatch, is TangemSdkError.EncodingFailed, - is TangemSdkError.DecodingFailedMissingTag, is TangemSdkError.DecodingFailedTypeMismatch, - is TangemSdkError.DecodingFailed, is TangemSdkError.CryptoUtilsError, is TangemSdkError.NetworkError, - is TangemSdkError.ExceptionError, is TangemSdkError.HDWalletDisabled, is TangemSdkError.FileSettingsUnsupported, - is TangemSdkError.FilesDisabled, is TangemSdkError.FilesIsEmpty, is TangemSdkError.Underlying, + is TangemSdkError.EncodingFailedTypeMismatch, + is TangemSdkError.EncodingFailed, + is TangemSdkError.DecodingFailedMissingTag, + is TangemSdkError.DecodingFailedTypeMismatch, + is TangemSdkError.DecodingFailed, + is TangemSdkError.CryptoUtilsError, + is TangemSdkError.NetworkError, + is TangemSdkError.ExceptionError, + is TangemSdkError.HDWalletDisabled, + is TangemSdkError.FileSettingsUnsupported, + is TangemSdkError.FilesDisabled, + is TangemSdkError.FilesIsEmpty, + is TangemSdkError.Underlying, + is TangemSdkError.AccessCodeOrPasscodeRequired, + is TangemSdkError.BackupFailedCardNotLinked, + is TangemSdkError.BackupServiceInvalidState, + is TangemSdkError.CertificateSignatureRequired, + is TangemSdkError.EmptyBackupCards, + is TangemSdkError.MissingPrimaryAttestSignature, + is TangemSdkError.MissingPrimaryCard, + is TangemSdkError.NoActiveBackup, + is TangemSdkError.NoBackupCardForIndex, + is TangemSdkError.NoBackupDataForCard, + is TangemSdkError.ResetBackupFailedHasBackedUpWallets, + is TangemSdkError.ResetPinNoCardsToReset, + is TangemSdkError.TooMuchBackupCards, + is TangemSdkError.IssuerSignatureLoadingFailed, + is TangemSdkError.UserForgotTheCode, + is TangemSdkError.BiometricsAuthenticationFailed, + is TangemSdkError.BiometricsUnavailable, + is TangemSdkError.BiometricsAuthenticationLockout, + is TangemSdkError.BiometricsAuthenticationPermanentLockout, + is TangemSdkError.UserCanceledBiometricsAuthentication, + is TangemSdkError.BiometricCryptographyOperationFailed, + is TangemSdkError.InvalidBiometricCryptographyKey, + is TangemSdkError.KeyGenerationException, + is TangemSdkError.MnemonicException, + is TangemSdkError.KeysImportDisabled, + is TangemSdkError.WalletAlreadyCreated, + is TangemSdkError.UserCodeRecoveryDisabled, + is TangemSdkError.BiometricCryptographyKeyInvalidated, + is TangemSdkError.UnsupportedCurve, + is TangemSdkError.InvalidParams, -> null + + is TangemSdkError.SerializeCommandError, + is TangemSdkError.DeserializeApduFailed, + is TangemSdkError.UnknownStatus, + is TangemSdkError.ErrorProcessingCommand, + is TangemSdkError.InvalidState, + is TangemSdkError.InsNotSupported, + is TangemSdkError.NeedEncryption, + is TangemSdkError.FileNotFound, + is TangemSdkError.AccessCodeRequired, + is TangemSdkError.PasscodeRequired, + is TangemSdkError.UnknownError, + is TangemSdkError.MissingPreflightRead, + -> R.string.error_operation + + is TangemSdkError.BackupFailedEmptyWallets, + is TangemSdkError.BackupFailedHDWalletSettings, + is TangemSdkError.BackupFailedNotEnoughCurves, + is TangemSdkError.BackupFailedNotEnoughWallets, + is TangemSdkError.BackupFailedWrongIssuer, + is TangemSdkError.BackupNotAllowed, + is TangemSdkError.BackupFailedFirmware, + is TangemSdkError.BackupFailedIncompatibleBatch, + is TangemSdkError.BackupFailedIncompatibleFirmware, + is TangemSdkError.BackupFailedKeysImportSettings, + is TangemSdkError.BackupFailedAlreadyCreated, + -> R.string.error_backup_wrong_card + is TangemSdkError.TagLost -> R.string.error_tag_lost is TangemSdkError.ExtendedLengthNotSupported -> R.string.error_extended_apdu_not_supported - is TangemSdkError.SerializeCommandError -> R.string.error_operation - is TangemSdkError.DeserializeApduFailed -> R.string.error_operation - is TangemSdkError.UnknownStatus -> R.string.error_operation - is TangemSdkError.ErrorProcessingCommand -> R.string.error_operation - is TangemSdkError.InvalidState -> R.string.error_operation - is TangemSdkError.InsNotSupported -> R.string.error_operation - is TangemSdkError.InvalidParams -> R.string.error_operation - is TangemSdkError.NeedEncryption -> R.string.error_operation - is TangemSdkError.FileNotFound -> R.string.error_operation is TangemSdkError.AlreadyPersonalized -> R.string.error_already_personalized is TangemSdkError.CannotBeDepersonalized -> R.string.error_cannot_be_depersonalized - is TangemSdkError.AccessCodeRequired -> R.string.error_operation is TangemSdkError.AlreadyCreated -> R.string.error_already_created is TangemSdkError.PurgeWalletProhibited -> R.string.error_purge_prohibited - is TangemSdkError.AccessCodeCannotBeChanged -> R.string.error_pin_cannot_be_changed_format - is TangemSdkError.PasscodeCannotBeChanged -> R.string.error_pin_cannot_be_changed_format + is TangemSdkError.AccessCodeCannotBeChanged, + is TangemSdkError.PasscodeCannotBeChanged, + -> R.string.error_pin_cannot_be_changed_format + + is TangemSdkError.HashSizeMustBeEqual, + is TangemSdkError.SignHashesNotAvailable, + is TangemSdkError.TooManyHashesInOneTransaction, + -> R.string.error_cannot_be_signed + + is TangemSdkError.OverwritingDataIsProhibited, + is TangemSdkError.DataCannotBeWritten, + -> R.string.error_data_cannot_be_written + + is TangemSdkError.WrongPasscode, + is TangemSdkError.WrongAccessCode, + -> R.string.error_wrong_pin_format + + is TangemSdkError.BackupCardAlreadyAdded, + is TangemSdkError.BackupCardRequired, + -> R.string.error_backup_card_already_added + is TangemSdkError.AccessCodeCannotBeDefault -> R.string.error_pin_cannot_be_default_format is TangemSdkError.NoRemainingSignatures -> R.string.error_no_remaining_signatures is TangemSdkError.EmptyHashes -> R.string.error_empty_hashes - is TangemSdkError.HashSizeMustBeEqual -> R.string.error_cannot_be_signed is TangemSdkError.WalletIsNotCreated -> R.string.error_wallet_is_not_created is TangemSdkError.WalletIsPurged -> R.string.error_wallet_is_purged - is TangemSdkError.SignHashesNotAvailable -> R.string.error_cannot_be_signed - is TangemSdkError.TooManyHashesInOneTransaction -> R.string.error_cannot_be_signed is TangemSdkError.NotPersonalized -> R.string.error_not_personalized is TangemSdkError.NotActivated -> R.string.error_not_activated - is TangemSdkError.PasscodeRequired -> R.string.error_operation is TangemSdkError.VerificationFailed -> R.string.error_verification_failed is TangemSdkError.DataSizeTooLarge -> R.string.error_data_size_too_large is TangemSdkError.ExtendedDataSizeTooLarge -> R.string.error_data_size_too_large_extended is TangemSdkError.MissingCounter -> R.string.error_missing_counter - is TangemSdkError.OverwritingDataIsProhibited -> R.string.error_data_cannot_be_written - is TangemSdkError.DataCannotBeWritten -> R.string.error_data_cannot_be_written is TangemSdkError.MissingIssuerPubicKey -> R.string.error_missing_issuer_public_key is TangemSdkError.CardVerificationFailed -> R.string.error_card_verification_failed - is TangemSdkError.UnknownError -> R.string.error_operation is TangemSdkError.UserCancelled -> R.string.error_user_cancelled is TangemSdkError.Busy -> R.string.error_busy - is TangemSdkError.MissingPreflightRead -> R.string.error_operation is TangemSdkError.WrongCardNumber -> R.string.error_wrong_card_number is TangemSdkError.WrongCardType -> R.string.error_wrong_card_type is TangemSdkError.CardError -> R.string.error_card_error @@ -61,59 +128,14 @@ fun TangemSdkError.localizedDescription(context: Context): String { is TangemSdkError.NotSupportedFirmwareVersion -> R.string.error_old_firmware is TangemSdkError.MaxNumberOfWalletsCreated -> R.string.error_no_space_for_new_wallet is TangemSdkError.CardReadWrongWallet -> R.string.error_card_read_wrong_wallet - is TangemSdkError.UnsupportedCurve -> R.string.generic_error_code is TangemSdkError.WalletNotFound -> R.string.wallet_not_found - is TangemSdkError.WrongAccessCode -> R.string.error_wrong_pin_format - is TangemSdkError.WrongPasscode -> R.string.error_wrong_pin_format is TangemSdkError.CardWithMaxZeroWallets -> R.string.error_card_with_max_zero_wallets is TangemSdkError.WalletError -> R.string.error_wallet_error is TangemSdkError.UnsupportedWalletConfig -> R.string.error_wallet_index_not_correct is TangemSdkError.WalletCannotBeCreated -> R.string.error_wallet_cannot_be_created - is TangemSdkError.AccessCodeOrPasscodeRequired -> null - is TangemSdkError.BackupCardAlreadyAdded -> R.string.error_backup_card_already_added - is TangemSdkError.BackupCardRequired -> R.string.error_backup_card_already_added - is TangemSdkError.BackupFailedCardNotLinked -> null - is TangemSdkError.BackupFailedEmptyWallets -> R.string.error_backup_wrong_card - is TangemSdkError.BackupFailedHDWalletSettings -> R.string.error_backup_wrong_card is TangemSdkError.BackupFailedNotEmptyWallets -> R.string.error_backup_not_empty_wallets - is TangemSdkError.BackupFailedNotEnoughCurves -> R.string.error_backup_wrong_card - is TangemSdkError.BackupFailedNotEnoughWallets -> R.string.error_backup_wrong_card - is TangemSdkError.BackupFailedWrongIssuer -> R.string.error_backup_wrong_card - is TangemSdkError.BackupNotAllowed -> R.string.error_backup_wrong_card - is TangemSdkError.BackupServiceInvalidState -> null - is TangemSdkError.BackupFailedFirmware -> R.string.error_backup_wrong_card - is TangemSdkError.BackupFailedIncompatibleBatch, - is TangemSdkError.BackupFailedIncompatibleFirmware, - is TangemSdkError.BackupFailedKeysImportSettings, - is TangemSdkError.BackupFailedAlreadyCreated, - -> R.string.error_backup_wrong_card - is TangemSdkError.CertificateSignatureRequired -> null - is TangemSdkError.EmptyBackupCards -> null - is TangemSdkError.MissingPrimaryAttestSignature -> null - is TangemSdkError.MissingPrimaryCard -> null - is TangemSdkError.NoActiveBackup -> null - is TangemSdkError.NoBackupCardForIndex -> null - is TangemSdkError.NoBackupDataForCard -> null - is TangemSdkError.ResetBackupFailedHasBackedUpWallets -> null - is TangemSdkError.ResetPinNoCardsToReset -> null is TangemSdkError.ResetPinWrongCard -> R.string.error_reset_wrong_card - is TangemSdkError.TooMuchBackupCards -> null is TangemSdkError.WrongInteractionMode -> R.string.error_wrong_interaction_mode - is TangemSdkError.IssuerSignatureLoadingFailed -> null - is TangemSdkError.UserForgotTheCode -> null - is TangemSdkError.BiometricsAuthenticationFailed -> null - is TangemSdkError.BiometricsUnavailable -> null - is TangemSdkError.BiometricsAuthenticationLockout -> null - is TangemSdkError.BiometricsAuthenticationPermanentLockout -> null - is TangemSdkError.UserCanceledBiometricsAuthentication -> null - is TangemSdkError.BiometricCryptographyOperationFailed -> null - is TangemSdkError.InvalidBiometricCryptographyKey -> null - is TangemSdkError.KeyGenerationException -> null - is TangemSdkError.MnemonicException -> null - is TangemSdkError.KeysImportDisabled -> null - is TangemSdkError.WalletAlreadyCreated -> null - is TangemSdkError.UserCodeRecoveryDisabled -> null - is TangemSdkError.BiometricCryptographyKeyInvalidated -> null } return if (resId == null) { @@ -130,13 +152,16 @@ fun TangemSdkError.localizedDescription(context: Context): String { is TangemSdkError.BackupFailedIncompatibleBatch, is TangemSdkError.ResetPinWrongCard, -> context.getString(resId, code.toString()) + is TangemSdkError.AccessCodeCannotBeChanged, is TangemSdkError.AccessCodeCannotBeDefault, is TangemSdkError.WrongAccessCode, -> context.getString(resId, context.getString(R.string.pin1)) + is TangemSdkError.PasscodeCannotBeChanged, is TangemSdkError.WrongPasscode, -> context.getString(resId, context.getString(R.string.pin2)) + else -> context.getString(resId) } } From daf86eeaf4199ad1d00c93dcb34ff381b128134d Mon Sep 17 00:00:00 2001 From: iiiburnyiii Date: Tue, 16 May 2023 11:31:18 +0300 Subject: [PATCH 04/10] AND-3542 Fix handling of biometric authentication cancellation exception --- .../sdk/biometrics/AndroidBiometricManager.kt | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt index 316e41c2..615101f0 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/biometrics/AndroidBiometricManager.kt @@ -68,25 +68,22 @@ internal class AndroidBiometricManager( initCrypto(mode) .map { cryptographyManager.invoke(mode.keyName, mode.data) } .mapFailure { error -> - when (val cause = (error as? TangemSdkError.ExceptionError)?.cause) { - is KeyPermanentlyInvalidatedException, - is UserNotAuthenticatedException, - -> { - cryptographyManager.deleteMasterKey() - TangemSdkError.BiometricCryptographyKeyInvalidated() - } - - is InvalidKeyException -> { - TangemSdkError.InvalidBiometricCryptographyKey(cause.localizedMessage.orEmpty(), cause) - } - - is TangemSdkError.UserCanceledBiometricsAuthentication -> { - error - } - - else -> { - TangemSdkError.BiometricCryptographyOperationFailed(error.customMessage, error) + when (error) { + is TangemSdkError.ExceptionError -> when (val cause = error.cause) { + is KeyPermanentlyInvalidatedException, + is UserNotAuthenticatedException, + -> { + cryptographyManager.deleteMasterKey() + TangemSdkError.BiometricCryptographyKeyInvalidated() + } + is InvalidKeyException -> { + TangemSdkError.InvalidBiometricCryptographyKey(cause.localizedMessage.orEmpty(), cause) + } + else -> { + TangemSdkError.BiometricCryptographyOperationFailed(error.customMessage, error) + } } + else -> error } } } else { From 197cfadfbd1021ba6f31be87f5bf4ebdc39457d4 Mon Sep 17 00:00:00 2001 From: Roman Potapov Date: Wed, 17 May 2023 11:00:26 +0400 Subject: [PATCH 05/10] AND-3578: allow to select any available curve in DemoApp --- .../separtedCommands/CommandListFragment.kt | 22 +++----- .../src/main/res/layout/wallet.xml | 51 +++++-------------- 2 files changed, 20 insertions(+), 53 deletions(-) diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/separtedCommands/CommandListFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/separtedCommands/CommandListFragment.kt index 5dcf10b7..28854cb0 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/separtedCommands/CommandListFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/separtedCommands/CommandListFragment.kt @@ -160,21 +160,15 @@ class CommandListFragment : BaseFragment() { btnSignHash.setOnClickListener { sign(SignStrategyType.SINGLE) } btnSignHashes.setOnClickListener { sign(SignStrategyType.MULTIPLE) } - btnCreateWalletSecpK1.setOnClickListener { - createOrImportWallet( - EllipticCurve.Secp256k1, - etMnemonic.text?.toString(), - ) - } - btnCreateWalletSecpR1.setOnClickListener { - createOrImportWallet( - EllipticCurve.Secp256r1, - etMnemonic.text?.toString(), - ) - } - btnCreateWalletEdwards.setOnClickListener { + val spinnerAdapter = ArrayAdapter( + requireContext(), + android.R.layout.simple_list_item_1, + EllipticCurve.values(), + ) + spinnerCurves.adapter = spinnerAdapter + btnCreateWallet.setOnClickListener { createOrImportWallet( - EllipticCurve.Ed25519, + spinnerCurves.selectedItem as EllipticCurve, etMnemonic.text?.toString(), ) } diff --git a/tangem-sdk-android-demo/src/main/res/layout/wallet.xml b/tangem-sdk-android-demo/src/main/res/layout/wallet.xml index a0466841..2f5e2c15 100644 --- a/tangem-sdk-android-demo/src/main/res/layout/wallet.xml +++ b/tangem-sdk-android-demo/src/main/res/layout/wallet.xml @@ -52,6 +52,7 @@ android:translationX="10dp" /> @@ -85,48 +86,19 @@ android:src="@drawable/ic_paste" /> - - - -