Updated on 2026-08-14

This commit is contained in:
Tangem 2020-12-09 07:57:35 +00:00
commit 37236d8add
4 changed files with 21 additions and 15 deletions

View file

@ -89,7 +89,7 @@ class ScanNoteTask(val card: Card? = null) : CardSessionRunnable<ScanNoteRespons
card: Card, session: CardSession,
callback: (result: CompletionResult<ScanNoteResponse>) -> Unit
) {
ReadFileDataCommand(readPrivateFiles = true).run(session) { filesResult ->
ReadFileDataCommand().run(session) { filesResult ->
when (filesResult) {
is CompletionResult.Success -> {
val decoder = Tlv.deserialize(filesResult.data.fileData)?.let { TlvDecoder(it) }

View file

@ -42,7 +42,7 @@ class TwinsHelper {
}
private fun String.calculateLuhn(): Int {
return 10 - this.reversed()
val checksum = this.reversed()
.mapIndexed { index, c ->
val digit = if (c in '0'..'9') c - '0' else c - 'A'
if (!index.isEven()) {
@ -51,8 +51,9 @@ private fun String.calculateLuhn(): Int {
val newDigit = digit * 2
if (newDigit >= 10) newDigit - 9 else newDigit
}
}
.sum() % 10
}.sum()
.rem(10)
return (10 - checksum) % 10
}
enum class TwinCardNumber(val number: Int) {

View file

@ -34,7 +34,7 @@ class CreateTwinWalletMiddleware {
}
is DetailsAction.CreateTwinWalletAction.Cancel.Confirm -> {
twinsManager = null
store.dispatch(NavigationAction.PopBackTo())
store.dispatch(NavigationAction.PopBackTo(AppScreen.Home))
}
is DetailsAction.CreateTwinWalletAction.LaunchFirstStep -> {
store.state.globalState.scanNoteResponse?.let {

View file

@ -147,16 +147,21 @@ class CreateTwinWalletFragment : Fragment(R.layout.fragment_details_twin_cards),
tv_twin_title.text = getString(R.string.details_twins_recreate_title_format, cardNumber)
if (state.createTwinWalletState?.showAlert == true) {
dialog = MaterialAlertDialogBuilder(requireContext())
.setMessage(R.string.details_twins_recreate_alert)
.setPositiveButton(R.string.common_ok) { _, _ ->
store.dispatch(DetailsAction.CreateTwinWalletAction.Cancel.Confirm)
}
.setNegativeButton(R.string.common_cancel) { _, _ ->
store.dispatch(DetailsAction.CreateTwinWalletAction.HideAlert)
}
.create()
dialog?.show()
if (dialog == null) {
dialog = MaterialAlertDialogBuilder(requireContext())
.setMessage(R.string.details_twins_recreate_alert)
.setPositiveButton(R.string.common_ok) { _, _ ->
store.dispatch(DetailsAction.CreateTwinWalletAction.Cancel.Confirm)
}
.setNegativeButton(R.string.common_cancel) { _, _ ->
dialog?.cancel()
}
.setOnCancelListener {
store.dispatch(DetailsAction.CreateTwinWalletAction.HideAlert)
}
.create()
dialog?.show()
}
} else {
dialog?.cancel()
dialog = null