Updated on 2026-08-14

This commit is contained in:
Tangem 2020-12-18 19:57:03 +00:00
commit 731b986378
7 changed files with 29 additions and 10 deletions

View file

@ -72,8 +72,8 @@ dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
implementation 'com.tangem:blockchain:1.123.0'
implementation 'com.tangem:core:1.89.0'
implementation 'com.tangem:sdk:1.89.0'
implementation 'com.tangem:core:1.90.0'
implementation 'com.tangem:sdk:1.90.0'
// WebView
implementation "androidx.browser:browser:1.2.0"

View file

@ -2,6 +2,7 @@ package com.tangem.tap.domain.twins
import com.tangem.CardSession
import com.tangem.CardSessionRunnable
import com.tangem.Message
import com.tangem.commands.CreateWalletResponse
import com.tangem.commands.PurgeWalletCommand
import com.tangem.commands.common.card.CardStatus
@ -9,11 +10,16 @@ import com.tangem.common.CompletionResult
import com.tangem.common.extensions.hexToBytes
import com.tangem.tasks.CreateWalletTask
class CreateSecondTwinWalletTask(private val firstPublicKey: String) : CardSessionRunnable<CreateWalletResponse> {
class CreateSecondTwinWalletTask(
private val firstPublicKey: String,
private val preparingMessage: Message,
private val creatingWalletMessage: Message
) : CardSessionRunnable<CreateWalletResponse> {
override val requiresPin2 = true
override fun run(session: CardSession, callback: (result: CompletionResult<CreateWalletResponse>) -> Unit) {
if (session.environment.card?.walletPublicKey != null) {
session.setInitialMessage(preparingMessage)
PurgeWalletCommand().run(session) { response ->
when (response) {
is CompletionResult.Success -> {
@ -30,6 +36,7 @@ class CreateSecondTwinWalletTask(private val firstPublicKey: String) : CardSessi
}
private fun finishTask(session: CardSession, callback: (result: CompletionResult<CreateWalletResponse>) -> Unit) {
session.setInitialMessage(creatingWalletMessage)
CreateWalletTask().run(session) { result ->
when (result) {
is CompletionResult.Success -> {

View file

@ -34,9 +34,14 @@ class TwinCardsManager(private val scanNoteResponse: ScanNoteResponse) {
}
suspend fun createSecondWallet(message: Message): SimpleResult {
suspend fun createSecondWallet(
initialMessage: Message,
preparingMessage: Message,
creatingWalletMessage: Message
): SimpleResult {
val response = tangemSdkManager.runTaskAsync(
CreateSecondTwinWalletTask(currentCardPublicKey!!), secondCardId, message
CreateSecondTwinWalletTask(currentCardPublicKey!!, preparingMessage, creatingWalletMessage),
secondCardId, initialMessage
)
when (response) {
is CompletionResult.Success -> {

View file

@ -65,7 +65,11 @@ sealed class DetailsAction : Action {
object Failure : CreateTwinWalletAction()
}
data class LaunchSecondStep(val message: Message) : CreateTwinWalletAction() {
data class LaunchSecondStep(
val initialMessage: Message,
val preparingMessage: Message,
val creatingWalletMessage: Message,
) : CreateTwinWalletAction() {
object Success : CreateTwinWalletAction()
object Failure : CreateTwinWalletAction()
}

View file

@ -71,7 +71,8 @@ class CreateTwinWalletMiddleware {
}
is DetailsAction.CreateTwinWalletAction.LaunchSecondStep ->
scope.launch {
val result = twinsManager?.createSecondWallet(action.message)
val result = twinsManager?.createSecondWallet(action.initialMessage,
action.preparingMessage, action.creatingWalletMessage)
withContext(Dispatchers.Main) {
when (result) {
SimpleResult.Success ->

View file

@ -115,9 +115,9 @@ class CreateTwinWalletFragment : Fragment(R.layout.fragment_details_twin_cards),
v_step_3.setBackgroundColor(defaultColor)
btn_tap.setOnClickListener {
store.dispatch(DetailsAction.CreateTwinWalletAction.LaunchSecondStep(
Message(getString(
R.string.details_twins_recreate_title_format, twinCardNumberString)
)
Message(getString(R.string.details_twins_recreate_title_format, twinCardNumberString)),
Message(getString(R.string.details_twins_recreate_title_preparing)),
Message(getString(R.string.details_twins_recreate_title_creating_wallet)),
))
}
btn_tap.text = getString(R.string.details_twins_recreate_button_format, "2")

View file

@ -22,6 +22,8 @@ this wallet.
<string name="details_twins_recreate_toolbar" translatable="false">Re-create wallet</string>
<string name="details_twins_recreate_step_format" translatable="false">Step %s</string>
<string name="details_twins_recreate_title_format" translatable="false">Tap the #%s twin card</string>
<string name="details_twins_recreate_title_preparing" translatable="false">Preparing card</string>
<string name="details_twins_recreate_title_creating_wallet" translatable="false">Creating wallet</string>
<string name="details_twins_recreate_subtitle" translatable="false">The wallet creation procedure consists of three steps. You must complete it to the end, otherwise you will have to start from the beginning.</string>
<string name="details_twins_recreate_button_format" translatable="false">Tap the card #%s</string>
<string name="details_twins_recreate_alert" translatable="false">You have already started the process of recreating twin wallet. If you interrupt it, you won\'t be able to use your twin cards until you start it again and complete recreating the wallet.</string>