From df9770c51de3fca116f5c4a0478acea2adbe1445 Mon Sep 17 00:00:00 2001 From: Vlad Kozarez Date: Thu, 3 Oct 2024 17:26:41 +0300 Subject: [PATCH 1/4] AND-8534 reverse image when animate tap --- .../tangem/sdk/ui/widget/TouchCardWidget.kt | 20 +++++++ .../main/res/drawable/img_hand_scan_ring.xml | 54 +++++++++++++++++++ .../tangem/operations/backup/BackupService.kt | 5 +- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 tangem-sdk-android/src/main/res/drawable/img_hand_scan_ring.xml diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/TouchCardWidget.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/TouchCardWidget.kt index f1c0446f5..f3289b306 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/TouchCardWidget.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/TouchCardWidget.kt @@ -40,6 +40,8 @@ class TouchCardWidget( private val ivHandCardHorizontal = mainView.findViewById(R.id.ivHandCardHorizontal) private val ivHandCardVertical = mainView.findViewById(R.id.ivHandCardVertical) private val ivPhone = mainView.findViewById(R.id.ivPhone) + private var isReversedImage: Boolean = false + private var iconScanResource: Int? = null private val touchCardAnimation = TouchCardAnimation( ivPhone, @@ -131,6 +133,9 @@ class TouchCardWidget( onTapOutStarted = { rippleBackgroundNfc.fadeOut(fadeOutDuration = 800) { rippleBackgroundNfc.stopRippleAnimation() } }, + onTapOutFinished = { + reverseIconScan() + }, ) touchCardAnimation.animatorCallback = object : Animator.AnimatorListener { override fun onAnimationStart(animation: Animator) {} @@ -155,6 +160,8 @@ class TouchCardWidget( } fun setIconScanRes(iconScanRes: Int?) { + iconScanResource = iconScanRes + isReversedImage = false if (iconScanRes != null) { ivHandCardHorizontal.setImageResource(iconScanRes) ivHandCardVertical.setImageResource(iconScanRes) @@ -164,6 +171,19 @@ class TouchCardWidget( } } + private fun reverseIconScan() { + if (iconScanResource == null) { + if (isReversedImage) { + ivHandCardHorizontal.setImageResource(R.drawable.hand_full_card_horizontal) + ivHandCardVertical.setImageResource(R.drawable.hand_full_card_vertical) + } else { + ivHandCardHorizontal.setImageResource(R.drawable.img_hand_scan_ring) + ivHandCardVertical.setImageResource(R.drawable.img_hand_scan_ring) + } + isReversedImage = !isReversedImage + } + } + private data class BitmapImageHolder( val bitmapArray: ByteArray, val bitmap: Bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.size, BitmapFactory.Options()), diff --git a/tangem-sdk-android/src/main/res/drawable/img_hand_scan_ring.xml b/tangem-sdk-android/src/main/res/drawable/img_hand_scan_ring.xml new file mode 100644 index 000000000..d9fd7d42f --- /dev/null +++ b/tangem-sdk-android/src/main/res/drawable/img_hand_scan_ring.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt index 0d0162a6e..4aa396318 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt @@ -165,7 +165,7 @@ class BackupService( handleFinalizePrimaryCard(iconScanRes = iconScanRes) { result -> handleCompletion(result, callback) } is State.FinalizingBackupCard -> - handleWriteBackupCard(currentState.index) { result -> + handleWriteBackupCard(currentState.index, iconScanRes) { result -> handleCompletion(result, callback) } @@ -365,7 +365,7 @@ class BackupService( } @Suppress("LongMethod") - private fun handleWriteBackupCard(index: Int, callback: CompletionCallback) { + private fun handleWriteBackupCard(index: Int, iconScanRes: Int?, callback: CompletionCallback) { try { if (handleErrors && repo.data.accessCode == null && repo.data.passcode == null) { throw TangemSdkError.AccessCodeOrPasscodeRequired() @@ -417,6 +417,7 @@ class BackupService( runnable = task, cardId = backupCard.cardId, initialMessage = message, + iconScanRes = iconScanRes, ) { result -> when (result) { is CompletionResult.Success -> { From 68b6431ba856485bce4744338f0e17f12ad5bc51 Mon Sep 17 00:00:00 2001 From: Mama1emon Date: Tue, 8 Oct 2024 20:25:09 +0400 Subject: [PATCH 2/4] AND-8703 Update SDK lokalise --- .../com/tangem/sdk/AndroidStringLocator.kt | 6 +++ .../src/main/res/values-de/strings.xml | 29 ++++++++----- .../src/main/res/values-es/strings.xml | 7 +++ .../src/main/res/values-fr/strings.xml | 7 +++ .../src/main/res/values-it/strings.xml | 23 ++++++---- .../src/main/res/values-ja/strings.xml | 7 +++ .../src/main/res/values-ru/strings.xml | 31 +++++++------ .../src/main/res/values-uk-rUA/strings.xml | 7 +++ .../src/main/res/values-zh-rTW/strings.xml | 7 +++ .../src/main/res/values/strings.xml | 33 ++++++++------ .../java/com/tangem/common/StringsLocator.kt | 4 ++ .../com/tangem/common/core/CardSession.kt | 19 +++++++- .../java/com/tangem/common/core/Config.kt | 39 ++++++++++++++++- .../java/com/tangem/operations/Command.kt | 20 ++++++++- .../tangem/operations/backup/BackupService.kt | 43 +++++++++++++++---- .../backup/StartBackupCardLinkingCommand.kt | 7 ++- 16 files changed, 231 insertions(+), 58 deletions(-) diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/AndroidStringLocator.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/AndroidStringLocator.kt index 41aac4cc2..bcf3c5974 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/AndroidStringLocator.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/AndroidStringLocator.kt @@ -35,7 +35,9 @@ class AndroidStringLocator(val context: Context) : StringsLocator { StringsLocator.ID.BACKUP_ADD_BACKUP_CARD_MESSAGE -> "backup_add_backup_card_message" StringsLocator.ID.BACKUP_FINALIZE_PRIMARY_CARD_MESSAGE_FORMAT -> "backup_finalize_primary_card_message_format" + StringsLocator.ID.BACKUP_FINALIZE_PRIMARY_RING_MESSAGE -> "backup_finalize_primary_ring_message" StringsLocator.ID.BACKUP_FINALIZE_BACKUP_CARD_MESSAGE_FORMAT -> "backup_finalize_backup_card_message_format" + StringsLocator.ID.BACKUP_FINALIZE_BACKUP_RING_MESSAGE -> "backup_finalize_backup_ring_message" StringsLocator.ID.RESET_CODES_SCAN_FIRST_CARD -> "reset_codes_scan_first_card" StringsLocator.ID.RESET_CODES_SCAN_CONFIRMATION_CARD -> "reset_codes_scan_confirmation_card" StringsLocator.ID.RESET_CODES_SCAN_TO_RESET -> "reset_codes_scan_to_reset" @@ -50,6 +52,10 @@ class AndroidStringLocator(val context: Context) : StringsLocator { StringsLocator.ID.PIN_2 -> "pin2" StringsLocator.ID.PIN_RESET_CODE_FORMAT -> "pin_reset_code_format" StringsLocator.ID.SIGN_MULTIPLE_CHUNKS_PART -> "sign_multiple_chunks_part" + StringsLocator.ID.VIEW_DELEGATE_SCAN_DESCRIPTION_FORMAT -> "view_delegate_scan_description_format" + StringsLocator.ID.VIEW_DELEGATE_SECURITY_DELAY_DESCRIPTION_FORMAT -> { + "view_delegate_security_delay_description_format" + } } return R.string::class.java.getDeclaredField(resourceId) diff --git a/tangem-sdk-android/src/main/res/values-de/strings.xml b/tangem-sdk-android/src/main/res/values-de/strings.xml index 45a9191e5..3cd96bc62 100644 --- a/tangem-sdk-android/src/main/res/values-de/strings.xml +++ b/tangem-sdk-android/src/main/res/values-de/strings.xml @@ -5,17 +5,22 @@ Der Online-Nachweis/ Prüfung der Karte kann derzeit nicht durchgeführt werden. Du kannst auf eigenem Risiko fortfahren oder es später erneut versuchen. Online-Nachweis/Prüfung fehlgeschlagen Eine verdächtige Verwendung der Wallet auf der Karte wurde festgestellt. - Verbinde dein Telefon und die Karte, die du als Backup verwenden möchten, genau wie oben gezeigt. + Verbinde dein Telefon und die Karte oder den Ring, die du als Backup verwenden möchten, genau wie oben gezeigt. Halte die Karte mit der Nummer %s genau wie oben gezeigt, auf deinem Telefon. + Tippe mit dem Ring genau wie oben gezeigt auf Dein Smartphone. Verbinde dein Telefon und die vorherige Karte mit der Nummer %s genau wie oben gezeigt. + Verbinde Dein Telefon und den primären Ring wie oben gezeigt. Verbinde dein Telefon und die primäre Karte genau wie oben gezeigt. Verbinde dein Telefon und die primäre Karte mit der Nummer %s genau wie oben gezeigt. Tresor entsperren Abbrechen + card + card or ring Fortsetzen Fehler OK Wiederholen + ring Erfolg Ich verstehe Warnung @@ -50,13 +55,13 @@ Ok, verstanden! Deine NFC-Antenne ist hier Hier findest du Informationen, wie man Tangem Karten mit (Telefon) verwendet - Lege deine Karte zu der Vorderseite des Telefons an + Halte Deine Karte oder Deinen Ring an die Vorderseite des Telefons Du hast gerade die richtige Position deiner NFC-Antenne gefunden. Bitte merke dir diese Stelle. Erneut anzeigen Funktioniert noch immer nicht - Um festzustellen, wo deine NFC-Antenne ist, bewege die Karte nach oben und nach unten, bis eine Bestätigung erscheint. + Um festzustellen, wo deine NFC-Antenne ist, bewege die Karte oder den Ring nach oben und nach unten, bis eine Bestätigung erscheint. Nichts passiert? Versuche die Karte vom Handy wegzunehmen und wieder darauf zu legen. - Halte die Karte hinter dem Handy und scanne diese + Halte die Karte oder den Ring hinter dem Handy und scanne diese Das Zertifikat der Karte konnte nicht geladen werden. Bitte versuche es später erneut. Unvollständiger Prozess. Um den Vorgang abzuschließen,halte die Karte bitte erneut an. Zugangscode @@ -71,20 +76,22 @@ Aktuelle Karte Verknüpfte Karte Halte die verknüpfte Karte dran - Bereite zunächst die Karte für den Wiederherstellungsprozess vor + Bereite zunächst die Karte oder den Ring für den Wiederherstellungsprozess vor Halte die Karte erneut dran, auf der du den Zugangscode wiederherstellen möchtest - Halte eine Backup-Karte dran - Halte die Karte dran, die du wiederherstellen möchtest - Eine andere verknüpfte Karte scannen + Halte eine Backup-Karte oder Ring dran + Halte die Karte oder den Ring dran, die du wiederherstellen möchtest + Eine andere verknüpfte Karte oder Ring scannen Scanne die Karte, auf der du %s zurücksetzen möchtest - Scanne die Karte, um Benutzercodes zurückzusetzen + Scanne die Karte oder den Ring, um Benutzercodes zurückzusetzen Code wurde erfolgreich zurückgesetzt Unterzeichnung von Teil %1$d von %2$d Der Vorgang läuft Karte Bereit zum Scannen - Halte die Karte bis zum Ende des Vorgangs gedrückt, wie oben gezeigt + Halte die Karte oder den Ring bis zum Ende des Vorgangs gedrückt, wie oben gezeigt + Tap the %s as shown above and hold until the end of the operation Langes Drücken - Um die Sicherheit zu gewährleisten, halte die Karte bitte bis zum Abschluss des Vorgangs angedrückt. + Um die Sicherheit zu gewährleisten, halte die Karte oder den Ring bitte bis zum Abschluss des Vorgangs angedrückt. + To ensure security please hold the %s until the operation is complete Sieht so aus, als hättest du die falsche Karte. Der Vorgang kann mit dieser Karte nicht durchgeführt werden. diff --git a/tangem-sdk-android/src/main/res/values-es/strings.xml b/tangem-sdk-android/src/main/res/values-es/strings.xml index 74110efc1..f5da5fb61 100644 --- a/tangem-sdk-android/src/main/res/values-es/strings.xml +++ b/tangem-sdk-android/src/main/res/values-es/strings.xml @@ -7,15 +7,20 @@ Se ha detectado un uso sospechoso del monedero de la tarjeta. Conecte su teléfono y la tarjeta que desea usar como respaldo exactamente como se muestra arriba. Toque la tarjeta con el número %s en su teléfono exactamente como se muestra arriba. + Tap the ring to your phone exactly as shown above. Conecte su teléfono y la placa principal con el número %s exactamente como se muestra arriba. + Connect your phone and the primary ring as it shown above. Conecte su teléfono y la placa principal exactamente como se muestra arriba. Conecte su teléfono y la placa principal con el número %s exactamente como se muestra arriba. Desbloqueo de bóveda Cancelar + card + card or ring Continuar Error OK Inténtalo de nuevo + ring Con éxito Entiendo Cuidado @@ -84,7 +89,9 @@ Tarjeta Listo para escanear Presione la tarjeta como se muestra arriba y manténgala presionada hasta que se complete la operación. + Tap the %s as shown above and hold until the end of the operation Toque largo Para garantizar la seguridad, conserve la tarjeta hasta que se complete la transacción. + To ensure security please hold the %s until the operation is complete Parece que se equivocó de mapa. La operación no se puede realizar con esta tarjeta. diff --git a/tangem-sdk-android/src/main/res/values-fr/strings.xml b/tangem-sdk-android/src/main/res/values-fr/strings.xml index 4264d3779..584e34e2d 100644 --- a/tangem-sdk-android/src/main/res/values-fr/strings.xml +++ b/tangem-sdk-android/src/main/res/values-fr/strings.xml @@ -7,15 +7,20 @@ Une utilisation suspecte du portefeuille sur la carte a été détectée. Connectez votre téléphone et la carte que vous souhaitez utiliser comme sauvegarde exactement comme indiqué ci-dessus. Appuyez la carte portant le numéro %s sur votre téléphone exactement comme indiqué ci-dessus. + Tap the ring to your phone exactly as shown above. Connectez votre téléphone et la carte principale avec le numéro %s exactement comme indiqué ci-dessus. + Connect your phone and the primary ring as it shown above. Connectez votre téléphone et la carte principale exactement comme indiqué ci-dessus. Connectez votre téléphone et la carte principale avec le numéro %s exactement comme indiqué ci-dessus. Déverrouillage du coffre-fort Annuler + card + card or ring Continuer Erreur OK Réessayez + ring Avec succès Je comprends Attention @@ -84,7 +89,9 @@ Carte Prêt pour scanner Appuyez sur la carte comme indiqué ci-dessus et maintenez jusqu\'à la fin de l\'opération + Tap the %s as shown above and hold until the end of the operation Tenez la carte fermement Pour garantir la sécurité, veuillez conserver la carte jusqu\'à ce que l\'opération soit terminée. + To ensure security please hold the %s until the operation is complete On dirait que vous vous êtes trompé de carte. L\'opération ne peut pas être effectuée avec cette carte. diff --git a/tangem-sdk-android/src/main/res/values-it/strings.xml b/tangem-sdk-android/src/main/res/values-it/strings.xml index 2f41f5ead..8217491e5 100644 --- a/tangem-sdk-android/src/main/res/values-it/strings.xml +++ b/tangem-sdk-android/src/main/res/values-it/strings.xml @@ -5,17 +5,22 @@ At the moment, online attestation of the card cannot be performed. You can continue at your own risk or try again later. Online attestation failed Suspicious use of the wallet on the card has been detected. - Connect your phone and the card you want to use as a backup exactly as it shown above. + Connect your phone to the card or ring you want to use as a backup, exactly as shown above. Tap the card with number %s to your phone exactly as shown above. + Tap the ring to your phone exactly as shown above. Connect your phone and the primary card with number %s exactly as it shown above. + Connect your phone and the primary ring as it shown above. Connect your phone and the primary card exactly as it shown above. Connect your phone and the primary card with number %s exactly as it shown above. Vault unlocking Annulla + card + card or ring Continua Errore OK Retry + ring Con successo I understand Warning @@ -71,20 +76,22 @@ Current card Linked card Tap the linked card - First, prepare the card for restore process + First, prepare the card or ring for restore process Tap again the card on which you want to restore the access code - Tap a backup card - Tap the card you want to restore - Scan another linked card + Tap a backup card or ring + Tap the card or ring you want to restore + Scan another linked card or ring Scan the card on which you want to reset the %s - Scan card to reset user codes + Scan card or ring to reset user codes Code was reset successfully Signing part %1$d of %2$d Operazione in corso Carta Pronta alla scansione - Tap the card as shown above and hold until the end of the operation + Tap the card or ring as shown above and hold until the end of the operation + Tap the %s as shown above and hold until the end of the operation Pressione lunga - To ensure security please hold the card until the operation complete + To ensure security please hold the card or ring until the operation complete + To ensure security please hold the %s until the operation is complete Looks like you got the wrong card. The operation cannot be performed with this card. diff --git a/tangem-sdk-android/src/main/res/values-ja/strings.xml b/tangem-sdk-android/src/main/res/values-ja/strings.xml index 7ee4521c6..6a4c34f2f 100644 --- a/tangem-sdk-android/src/main/res/values-ja/strings.xml +++ b/tangem-sdk-android/src/main/res/values-ja/strings.xml @@ -7,15 +7,20 @@ カードのウォレットの不審な使用が検出されました。 スマートフォンとバックアップとして使用したいカードを、上記のとおりに接続してください。 上図のように、番号%sのカードをスマートフォンにタップしてください。 + Tap the ring to your phone exactly as shown above. お使いのスマートフォンと番号%sのプライマリカードを、上記のように接続してください。 + Connect your phone and the primary ring as it shown above. スマートフォンとプライマリカードを上記のとおりに接続してください。 お使いのスマートフォンと番号%sのプライマリカードを、上記のように接続してください。 金庫のロック解除 キャンセル + card + card or ring 続ける エラー わかりました 再試行 + ring 成功 わかりました 警告 @@ -84,7 +89,9 @@ カード スキャン準備完了 上記のようにカードをタップし、操作が完了するまでホールドし続けます。 + Tap the %s as shown above and hold until the end of the operation 長くタップ セキュリティを確保するため、操作が完了するまでカードをホールドしてください。 + To ensure security please hold the %s until the operation is complete カードが間違っているようです。このカードでは操作を実行できません。 diff --git a/tangem-sdk-android/src/main/res/values-ru/strings.xml b/tangem-sdk-android/src/main/res/values-ru/strings.xml index b9231606d..e8dd53ad2 100644 --- a/tangem-sdk-android/src/main/res/values-ru/strings.xml +++ b/tangem-sdk-android/src/main/res/values-ru/strings.xml @@ -5,17 +5,22 @@ В настоящее время онлайн аттестация карты не может быть выполнена. Вы можете продолжить на свой страх и риск или повторить попытку. Онлайн-аттестация не удалась Обнаружено подозрительное использование кошелька на карте. - Соедините телефон и карту, которую вы хотите использовать в качестве резервной, в точности, как показано выше. + Соедините телефон с картой или кольцом, которые вы хотите использовать в качестве резервных, точно так, как показано выше. Поднесите карту с номером %s к телефону в точности, как показано выше. + Поднесите кольцо к телефону в точности, как показано выше. Соедините телефон и основную карту с номером %s в точности, как показано выше. + Соедините телефон и основное кольцо в точности, как показано выше. Соедините телефон и основную карту в точности, как показано выше. Соедините телефон и основную карту с номером %s в точности, как показано выше. Разблокировка хранилища Отменить + карту + кольцо или карту Продолжить Ошибка OK Повторить + кольцо Успешно Я понимаю Предупреждение @@ -49,14 +54,14 @@ Помощь Хорошо, понял! Ваша NFC антенна здесь - Вот как использовать карты Tangem с (телефоном) + Вот как использовать кошелек Tangem с (телефоном) Приложите карту к передней панели телефона Вы только что нашли местоположение вашей NFC антенны. Пожалуйста, запомните это. Показать еще раз До сих пор не работает - Чтобы определить, где находится ваша антенна NFC, перемещайте карту вверх и вниз пока не почувствуете вибрацию. - Ничего не случилось? Попробуйте отнести карту от телефона и поднести обратно. - Приложите карту к задней панели телефона + Чтобы определить, где находится ваша антенна NFC, перемещайте карту или кольцо вверх и вниз пока не почувствуете вибрацию. + Ничего не случилось? Попробуйте отнести карту или кольцо от телефона и поднести обратно. + Приложите карту или кольцо к задней панели телефона Не удалось загрузить сертификат карты. Пожалуйста, повторите попытку позже. Процесс не завершен. Для завершения операции, приложите карту повторно Код доступа @@ -71,20 +76,22 @@ Текущая карта Связанная карта Приложите связанную карту - Сначала подготовьте карту к процессу восстановления + Сначала подготовьте карту или кольцо к процессу восстановления Приложите еще раз карту, на которой хотите восстановить код доступа - Приложите резервную карту - Отсканируйте карту, которую хотите восстановить - Отсканируйте другую привязанную карту + Приложите резервную карту или кольцо + Отсканируйте карту или кольцо, которую хотите восстановить + Отсканируйте другую привязанную карту или кольцо Отсканируйте карту, на которой вы хотите сбросить %s - Отсканируйте карту для сброса кода + Отсканируйте карту или кольцо для сброса кода Код успешно сброшен Подпись части %1$d из %2$d Операция в процессе Карта Готово к сканированию - Поднесите карту, как показано выше, и удерживайте до конца операции + Поднесите карту или кольцо, как показано выше, и удерживайте до конца операции + Поднесите %s, как показано выше, и удерживайте до конца операции Удерживайте карту - Пожалуйста, удерживайте карту до завершения операции + Пожалуйста, удерживайте карту или кольцо до завершения операции + Пожалуйста, удерживайте %s до завершения операции Кажется, вы ошиблись картой. Операция не может быть выполнена с этой картой. diff --git a/tangem-sdk-android/src/main/res/values-uk-rUA/strings.xml b/tangem-sdk-android/src/main/res/values-uk-rUA/strings.xml index 81ccc9690..c286cfefa 100644 --- a/tangem-sdk-android/src/main/res/values-uk-rUA/strings.xml +++ b/tangem-sdk-android/src/main/res/values-uk-rUA/strings.xml @@ -7,15 +7,20 @@ Виявлено підозріле використання гаманця на картці. З\'єднайте телефон і картку, яку ви хочете використати як резервну, точно так, як показано вище. Піднесіть картку з номером %s до телефону точно так, як показано вище. + Tap the ring to your phone exactly as shown above. З\'єднайте телефон і основну картку з номером %s точно так, як показано вище. + Connect your phone and the primary ring as it shown above. З\'єднайте телефон і основну картку точно так, як показано вище. З\'єднайте телефон і основну картку з номером %s точно так, як показано вище. Розблокування сховища Скасувати + card + card or ring Продовжити Помилка OK Повторити + ring Успішно Я розумію Попередження @@ -84,7 +89,9 @@ Картка Готово до сканування Піднесіть картку, як показано вище, і утримуйте до кінця операції + Tap the %s as shown above and hold until the end of the operation Утримуйте картку Будь ласка, утримуйте картку до завершення операції + To ensure security please hold the %s until the operation is complete Здається, ви помилилися карткою. Операція не може бути виконана з цією карткою. diff --git a/tangem-sdk-android/src/main/res/values-zh-rTW/strings.xml b/tangem-sdk-android/src/main/res/values-zh-rTW/strings.xml index f34b044eb..a889260ce 100644 --- a/tangem-sdk-android/src/main/res/values-zh-rTW/strings.xml +++ b/tangem-sdk-android/src/main/res/values-zh-rTW/strings.xml @@ -7,15 +7,20 @@ Suspicious use of the wallet on the card has been detected. 完全按照上圖所示連接手機和要用作備份的卡 Tap the card with number %s to your phone exactly as shown above. + Tap the ring to your phone exactly as shown above. 完全按照上面顯示的方式連接您的手機和編號為 %s 的主卡 + Connect your phone and the primary ring as it shown above. 完全按照上圖所示連接手機和主卡 完全按照上面顯示的方式連接您的手機和編號為 %s 的主卡 金庫解鎖 取消 + card + card or ring 繼續 錯誤 OK 重試 + ring 成功 我明白 警告 @@ -84,7 +89,9 @@ 卡片 已準備好掃描 如上圖觸碰卡片並按住直到操作結束 + Tap the %s as shown above and hold until the end of the operation 長按 為確保安全,請持有卡直至操作完成 + To ensure security please hold the %s until the operation is complete Looks like you got the wrong card. The operation cannot be performed with this card. diff --git a/tangem-sdk-android/src/main/res/values/strings.xml b/tangem-sdk-android/src/main/res/values/strings.xml index 9d16f99fa..a42c5ece6 100644 --- a/tangem-sdk-android/src/main/res/values/strings.xml +++ b/tangem-sdk-android/src/main/res/values/strings.xml @@ -5,17 +5,22 @@ At the moment, online attestation of the card cannot be performed. You can continue at your own risk or try again later. Online attestation failed Suspicious use of the wallet on the card has been detected. - Connect your phone and the card you want to use as a backup exactly as it shown above. + Connect your phone to the card or ring you want to use as a backup, exactly as shown above. Tap the card with number %s to your phone exactly as shown above. + Tap the ring to your phone exactly as shown above. Connect your phone and the primary card with number %s exactly as it shown above. + Connect your phone and the primary ring as it shown above. Connect your phone and the primary card exactly as it shown above. Connect your phone and the primary card with number %s exactly as it shown above. Vault unlocking Cancel + card + card or ring Continue Error OK Retry + ring Success I understand Warning @@ -49,14 +54,14 @@ How to Ok, got it! Your NFC antenna is here - Here\'s how to use Tangem Cards with (phone) - Tap your card to the front of the phone + Here\'s how to use Tangem wallet with (phone) + Tap your card or ring to the front of the phone You just found the location of your NFC antenna. Please remember it. Show again Still not working - To detect where your NFC antenna is located, move the card up and down until confirmation. - Nothing happened? Try removing your card from the phone and then put it back. - Tap your card to the back of the phone + To detect where your NFC antenna is located, move the card or ring up and down until confirmation. + Nothing happened? Try removing your card or ring from the phone and then put it back. + Tap your card or ring to the back of the phone Couldn\'t load the card\'s certificate. Please try again later. Incomplete process. To finalize the operation, kindly tap the card again Access code @@ -71,20 +76,22 @@ Current card Linked card Tap the linked card - First, prepare the card for restore process + First, prepare the card or ring for restore process Tap again the card on which you want to restore the access code - Tap a backup card - Tap the card you want to restore - Scan another linked card + Tap a backup card or ring + Tap the card or ring you want to restore + Scan another linked card or ring Scan the card on which you want to reset the %s - Scan card to reset user codes + Scan card or ring to reset user codes Code was reset successfully Signing part %1$d of %2$d Operation is in progress Card Ready to scan - Tap the card as shown above and hold until the end of the operation + Tap the card or ring as shown above and hold until the end of the operation + Tap the %s as shown above and hold until the end of the operation Long tap - To ensure security please hold the card until the operation complete + To ensure security please hold the card or ring until the operation complete + To ensure security please hold the %s until the operation is complete Looks like you got the wrong card. The operation cannot be performed with this card. diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/StringsLocator.kt b/tangem-sdk-core/src/main/java/com/tangem/common/StringsLocator.kt index c36697d3c..00bfaa7b3 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/StringsLocator.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/StringsLocator.kt @@ -13,7 +13,9 @@ interface StringsLocator { enum class ID { BACKUP_ADD_BACKUP_CARD_MESSAGE, BACKUP_FINALIZE_BACKUP_CARD_MESSAGE_FORMAT, + BACKUP_FINALIZE_BACKUP_RING_MESSAGE, BACKUP_FINALIZE_PRIMARY_CARD_MESSAGE_FORMAT, + BACKUP_FINALIZE_PRIMARY_RING_MESSAGE, BACKUP_PREPARE_PRIMARY_CARD_MESSAGE, BACKUP_PREPARE_PRIMARY_CARD_MESSAGE_FORMAT, COMMON_SUCCESS, @@ -30,5 +32,7 @@ interface StringsLocator { RESET_CODES_SCAN_TO_RESET, RESET_CODES_SUCCESS_MESSAGE, SIGN_MULTIPLE_CHUNKS_PART, + VIEW_DELEGATE_SCAN_DESCRIPTION_FORMAT, + VIEW_DELEGATE_SECURITY_DELAY_DESCRIPTION_FORMAT, } } diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt b/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt index 5bd6a84fa..ab4297c0a 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt @@ -1,5 +1,6 @@ package com.tangem.common.core +import com.tangem.LocatorMessage import com.tangem.Log import com.tangem.Message import com.tangem.SessionViewDelegate @@ -7,6 +8,7 @@ import com.tangem.ViewDelegateMessage import com.tangem.WrongValueType import com.tangem.common.CardIdFormatter import com.tangem.common.CompletionResult +import com.tangem.common.StringsLocator import com.tangem.common.UserCode import com.tangem.common.UserCodeType import com.tangem.common.apdu.Apdu @@ -99,6 +101,14 @@ class CardSession( private var onTagConnectedAfterResume: VoidCallback? = null + private val defaultScanMessage = LocatorMessage( + headerSource = null, + bodySource = LocatorMessage.Source( + id = StringsLocator.ID.VIEW_DELEGATE_SCAN_DESCRIPTION_FORMAT, + formatArgs = arrayOf(environment.config.productType.getLocalizedDescription()), + ), + ) + fun setInitialMessage(message: ViewDelegateMessage?) { initialMessage = message } @@ -170,7 +180,12 @@ class CardSession( reader.startSession() state = CardSessionState.Active - viewDelegate.onSessionStarted(cardId, initialMessage, environment.config.howToIsEnabled, iconScanRes) + viewDelegate.onSessionStarted( + cardId = cardId, + message = initialMessage ?: defaultScanMessage, + enableHowTo = environment.config.howToIsEnabled, + iconScanRes = iconScanRes, + ) scope.launch { reader.tag.asFlow() @@ -197,6 +212,7 @@ class CardSession( .drop(1) .collect { if (it == null) { + setMessage(defaultScanMessage) viewDelegate.onTagLost() } else { viewDelegate.onTagConnected() @@ -514,6 +530,7 @@ class CardSession( is CompletionResult.Success -> { Log.session { "requestUserCode: Success" } updateEnvironment(type, result.data) + setMessage(defaultScanMessage) callback(CompletionResult.Success(Unit)) } is CompletionResult.Failure -> { diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt b/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt index bf10c1a63..455436690 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt @@ -73,7 +73,29 @@ class Config( * Options for displaying different tags on the scanning screen */ var scanTagImage: ScanTagImage = ScanTagImage.GenericCard, -) + + var productType: ProductType = ProductType.ANY, +) { + + fun setupForProduct(type: ProductType) { + when (type) { + ProductType.CARD -> { + productType = ProductType.CARD + cardIdDisplayFormat = CardIdDisplayFormat.Full + } + + ProductType.RING -> { + productType = ProductType.RING + cardIdDisplayFormat = CardIdDisplayFormat.None + } + + ProductType.ANY -> { + productType = ProductType.ANY + cardIdDisplayFormat = CardIdDisplayFormat.Full + } + } + } +} sealed class ScanTagImage { @@ -124,3 +146,18 @@ sealed class UserCodeRequestPolicy { * */ object Default : UserCodeRequestPolicy() } + +enum class ProductType { + ANY, + CARD, + RING, + ; + + fun getLocalizedDescription(): String { + return when (this) { + ANY -> "common_card_or_ring" + CARD -> "common_card" + RING -> "common_ring" + } + } +} diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt index aa31660aa..9baeedbc1 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt @@ -1,7 +1,9 @@ package com.tangem.operations +import com.tangem.LocatorMessage import com.tangem.Log import com.tangem.common.CompletionResult +import com.tangem.common.StringsLocator import com.tangem.common.UserCode import com.tangem.common.UserCodeType import com.tangem.common.apdu.CommandApdu @@ -10,7 +12,12 @@ import com.tangem.common.apdu.StatusWord import com.tangem.common.apdu.toTangemSdkError import com.tangem.common.card.Card import com.tangem.common.card.EncryptionMode -import com.tangem.common.core.* +import com.tangem.common.core.CardSession +import com.tangem.common.core.CardSessionRunnable +import com.tangem.common.core.CompletionCallback +import com.tangem.common.core.SessionEnvironment +import com.tangem.common.core.TangemError +import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.toInt import com.tangem.common.tlv.Tlv import com.tangem.common.tlv.TlvTag @@ -191,6 +198,17 @@ abstract class Command : ApduSerializable, CardSessionRu } is CompletionResult.Failure -> if (result.error is TangemSdkError.TagLost) { + session.setMessage( + LocatorMessage( + headerSource = null, + bodySource = LocatorMessage.Source( + id = StringsLocator.ID.VIEW_DELEGATE_SECURITY_DELAY_DESCRIPTION_FORMAT, + formatArgs = arrayOf( + session.environment.config.productType.getLocalizedDescription(), + ), + ), + ), + ) session.viewDelegate.onTagLost() } else { callback(CompletionResult.Failure(result.error)) diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt index 4aa396318..94112143c 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt @@ -12,6 +12,7 @@ import com.tangem.common.card.Card import com.tangem.common.card.EllipticCurve import com.tangem.common.card.FirmwareVersion import com.tangem.common.core.CompletionCallback +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.calculateSha256 import com.tangem.common.extensions.guard @@ -66,6 +67,8 @@ class BackupService( val primaryCardId: String? get() = repo.data.primaryCard?.cardId val primaryPublicKey: ByteArray? get() = repo.data.primaryCard?.cardPublicKey val backupCardIds: List get() = repo.data.backupCards.map { it.cardId } + val primaryCardBatchId: String? get() = repo.data.primaryCard?.batchId + val backupCardsBatchIds: List get() = repo.data.backupCards.mapNotNull(BackupCard::batchId) /** * Perform additional compatibility checks while adding backup cards. Change this setting only if you understand what you do. @@ -341,14 +344,25 @@ class BackupService( repo.data = repo.data.copy(backupData = repo.data.backupData.plus(Pair(cardId, data))) }, ) - val formattedCardId = CardIdFormatter(style = sdk.config.cardIdDisplayFormat) - .getFormattedCardId(primaryCard.cardId) - val message = formattedCardId?.let { + val message = if (sdk.config.productType == ProductType.RING) { Message( header = null, - body = stringsLocator.getString(StringsLocator.ID.BACKUP_FINALIZE_PRIMARY_CARD_MESSAGE_FORMAT, it), + body = stringsLocator.getString(StringsLocator.ID.BACKUP_FINALIZE_PRIMARY_RING_MESSAGE), ) + } else { + val formattedCardId = CardIdFormatter(style = sdk.config.cardIdDisplayFormat) + .getFormattedCardId(primaryCard.cardId) + + formattedCardId?.let { + Message( + header = null, + body = stringsLocator.getString( + StringsLocator.ID.BACKUP_FINALIZE_PRIMARY_CARD_MESSAGE_FORMAT, + it, + ), + ) + } } sdk.startSessionWithRunnable( @@ -403,14 +417,24 @@ class BackupService( passcode = passcode, ) - val formattedCardId = CardIdFormatter(style = sdk.config.cardIdDisplayFormat) - .getFormattedCardId(backupCard.cardId) - - val message = formattedCardId?.let { + val message = if (sdk.config.productType == ProductType.RING) { Message( header = null, - body = stringsLocator.getString(StringsLocator.ID.BACKUP_FINALIZE_BACKUP_CARD_MESSAGE_FORMAT, it), + body = stringsLocator.getString(StringsLocator.ID.BACKUP_FINALIZE_BACKUP_RING_MESSAGE), ) + } else { + val formattedCardId = CardIdFormatter(style = sdk.config.cardIdDisplayFormat) + .getFormattedCardId(backupCard.cardId) + + formattedCardId?.let { + Message( + header = null, + body = stringsLocator.getString( + StringsLocator.ID.BACKUP_FINALIZE_BACKUP_CARD_MESSAGE_FORMAT, + it, + ), + ) + } } sdk.startSessionWithRunnable( @@ -516,6 +540,7 @@ data class BackupCard( val attestSignature: ByteArray, val firmwareVersion: FirmwareVersion? = null, val certificate: ByteArray?, + val batchId: String? = null, ) : CommandResponse { constructor(rawBackupCard: RawBackupCard, certificate: ByteArray) : this( cardId = rawBackupCard.cardId, diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/StartBackupCardLinkingCommand.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/StartBackupCardLinkingCommand.kt index ab42b67ce..7365b5459 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/StartBackupCardLinkingCommand.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/StartBackupCardLinkingCommand.kt @@ -52,14 +52,17 @@ class StartBackupCardLinkingCommand( val tlvData = apdu.getTlvData() ?: throw TangemSdkError.DeserializeApduFailed() + val card = environment.card ?: throw TangemSdkError.UnknownError() + val decoder = TlvDecoder(tlvData) return BackupCard( cardId = decoder.decode(TlvTag.CardId), - cardPublicKey = environment.card?.cardPublicKey ?: throw TangemSdkError.UnknownError(), + cardPublicKey = card.cardPublicKey, linkingKey = decoder.decode(TlvTag.BackupCardLinkingKey), - firmwareVersion = environment.card?.firmwareVersion ?: throw TangemSdkError.UnknownError(), + firmwareVersion = card.firmwareVersion, attestSignature = decoder.decode(TlvTag.CardSignature), certificate = null, + batchId = card.batchId, ) } } From 7e16d97e99c22c654988d84959543e20539055c0 Mon Sep 17 00:00:00 2001 From: Mama1emon Date: Wed, 9 Oct 2024 12:34:36 +0400 Subject: [PATCH 3/4] AND-8722 Fix security delay placeholder --- .../ui/tasksLogger/CommandsTesterFragment.kt | 9 ++-- .../ui/viewDelegate/ViewDelegateAction.kt | 53 ++++++++++++------- .../tangem/sdk/DefaultSessionViewDelegate.kt | 21 +++++--- .../tangem/sdk/SessionViewDelegateState.kt | 15 ++++-- .../com/tangem/sdk/ui/NfcSessionDialog.kt | 17 ++++-- .../com/tangem/sdk/ui/widget/HeaderWidget.kt | 2 - .../com/tangem/sdk/ui/widget/MessageWidget.kt | 33 ++++++++++-- .../java/com/tangem/SessionViewDelegate.kt | 8 +-- .../com/tangem/common/core/CardSession.kt | 17 ++---- .../java/com/tangem/common/core/Config.kt | 8 --- .../java/com/tangem/operations/Command.kt | 26 ++++----- .../operations/files/WriteFileCommand.kt | 2 +- .../ReadIssuerExtraDataCommand.kt | 7 ++- .../WriteIssuerExtraDataCommand.kt | 7 ++- 14 files changed, 136 insertions(+), 89 deletions(-) diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/tasksLogger/CommandsTesterFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/tasksLogger/CommandsTesterFragment.kt index 424ce583c..483529eaa 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/tasksLogger/CommandsTesterFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/tasksLogger/CommandsTesterFragment.kt @@ -17,6 +17,7 @@ import com.tangem.common.card.Card import com.tangem.common.card.EllipticCurve import com.tangem.common.core.CompletionCallback import com.tangem.common.core.Config +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemError import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.VoidCallback @@ -180,10 +181,12 @@ class SdkTaskSpinnerFragment : BaseFragment() { message: ViewDelegateMessage?, enableHowTo: Boolean, iconScanRes: Int?, + productType: ProductType, ) {} - override fun onSecurityDelay(ms: Int, totalDurationSeconds: Int) {} - override fun onDelay(total: Int, current: Int, step: Int) {} - override fun onTagLost() {} + + override fun onSecurityDelay(ms: Int, totalDurationSeconds: Int, productType: ProductType) {} + override fun onDelay(total: Int, current: Int, step: Int, productType: ProductType) {} + override fun onTagLost(productType: ProductType) {} override fun onTagConnected() {} override fun onWrongCard(wrongValueType: WrongValueType) {} override fun onSessionStopped(message: Message?) {} diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/viewDelegate/ViewDelegateAction.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/viewDelegate/ViewDelegateAction.kt index 553797a67..c3e11fbe2 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/viewDelegate/ViewDelegateAction.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/demo/ui/viewDelegate/ViewDelegateAction.kt @@ -12,6 +12,7 @@ import com.google.android.material.slider.Slider import com.tangem.SessionViewDelegate import com.tangem.WrongValueType import com.tangem.common.UserCodeType +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemSdkError import com.tangem.demo.inflate import com.tangem.demo.ui.extension.withMainContext @@ -87,19 +88,19 @@ class TagConnectTagLostError : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } delay(timeMillis = 2000) - withMainContext { delegate.onTagLost() } + withMainContext { delegate.onTagLost(ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } delay(timeMillis = 2000) - withMainContext { delegate.onTagLost() } + withMainContext { delegate.onTagLost(ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onError(TangemSdkError.UnknownError()) } delay(timeMillis = 2000) - withMainContext { delegate.onTagLost() } + withMainContext { delegate.onTagLost(ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.dismiss() } } @@ -129,7 +130,7 @@ class SecurityDelay : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } @@ -139,7 +140,13 @@ class SecurityDelay : BaseDelegateAction() { repeat(securityDelayCounts) { delay(timeMillis = 1000) currentMs = currentMs.minus(other = 100) - withMainContext { delegate.onSecurityDelay(currentMs, totalDurationMs) } + withMainContext { + delegate.onSecurityDelay( + ms = currentMs, + totalDurationSeconds = totalDurationMs, + productType = ProductType.ANY, + ) + } } withMainContext { delegate.onSessionStopped(null) } @@ -170,7 +177,7 @@ class SecurityDelayPinFails : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } delay(timeMillis = 1000) @@ -180,11 +187,17 @@ class SecurityDelayPinFails : BaseDelegateAction() { repeat(repeatCounts) { delay(timeMillis = 1000) currentMs = currentMs.minus(other = 100) - withMainContext { delegate.onSecurityDelay(ms = currentMs, totalDurationSeconds = 0) } + withMainContext { + delegate.onSecurityDelay( + ms = currentMs, + totalDurationSeconds = 0, + productType = ProductType.ANY, + ) + } } delay(timeMillis = 2000) - withMainContext { delegate.onTagLost() } + withMainContext { delegate.onTagLost(ProductType.ANY) } delay(timeMillis = 1000) withMainContext { delegate.dismiss() } } @@ -201,7 +214,7 @@ class WrongCard : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } delay(timeMillis = 2000) @@ -224,7 +237,7 @@ class OnError : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onTagConnected() } delay(timeMillis = 2000) @@ -247,19 +260,19 @@ class RequestAccessCode : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.AccessCode, true, false, null) {} } delay(timeMillis = 2000) withMainContext { delegate.dismiss() } delay(timeMillis = 500) - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.AccessCode, false, false, null) {} } delay(timeMillis = 2000) withMainContext { delegate.dismiss() } delay(timeMillis = 500) - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.AccessCode, true, false, null) {} } delay(timeMillis = 2000) @@ -276,7 +289,7 @@ class SingleRequestAccessCode( override fun usedCommandsInfo(): String = "RequestUserCode(access,true), Dismiss" override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.AccessCode, true, showForgotButton, null) {} } } @@ -295,19 +308,19 @@ class RequestPasscode : BaseDelegateAction() { } override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.Passcode, true, false, null) {} } delay(timeMillis = 2000) withMainContext { delegate.dismiss() } delay(timeMillis = 500) - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.Passcode, false, false, null) {} } delay(timeMillis = 2000) withMainContext { delegate.dismiss() } delay(timeMillis = 500) - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCode(UserCodeType.Passcode, true, false, null) {} } delay(timeMillis = 2000) @@ -349,7 +362,7 @@ class RequestPinSetup : BaseDelegateAction() { override fun usedCommandsInfo(): String = "SessionStarted, RequestPinSetup" override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 500) withMainContext { delegate.requestUserCodeChange(UserCodeType.Passcode, null) {} } } @@ -364,7 +377,7 @@ class ErrorsWithDifferentFormats : BaseDelegateAction() { """.trimIndent() override fun getCommandsPool(): suspend () -> Unit = suspend { - withMainContext { delegate.onSessionStarted(null, null, true) } + withMainContext { delegate.onSessionStarted(null, null, true, null, ProductType.ANY) } delay(timeMillis = 2000) withMainContext { delegate.onError(TangemSdkError.BackupFailedIncompatibleBatch()) } delay(timeMillis = 5000) diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/DefaultSessionViewDelegate.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/DefaultSessionViewDelegate.kt index 087e80daf..8d37f9a0e 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/DefaultSessionViewDelegate.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/DefaultSessionViewDelegate.kt @@ -12,6 +12,7 @@ import com.tangem.common.CardIdFormatter import com.tangem.common.UserCodeType import com.tangem.common.core.CompletionCallback import com.tangem.common.core.Config +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemError import com.tangem.common.extensions.VoidCallback import com.tangem.operations.resetcode.ResetCodesViewDelegate @@ -44,9 +45,15 @@ class DefaultSessionViewDelegate( message: ViewDelegateMessage?, enableHowTo: Boolean, iconScanRes: Int?, + productType: ProductType, ) { Log.view { "session started" } - createAndShowState(SessionViewDelegateState.Ready(formatCardId(cardId)), enableHowTo, message, iconScanRes) + createAndShowState( + state = SessionViewDelegateState.Ready(formatCardId(cardId), productType), + enableHowTo = enableHowTo, + message = message, + iconScanRes = iconScanRes, + ) checkNfcEnabled() } @@ -72,19 +79,19 @@ class DefaultSessionViewDelegate( readingDialog?.show(SessionViewDelegateState.Success(message)) } - override fun onSecurityDelay(ms: Int, totalDurationSeconds: Int) { + override fun onSecurityDelay(ms: Int, totalDurationSeconds: Int, productType: ProductType) { Log.view { "showing security delay: $ms, $totalDurationSeconds" } - readingDialog?.show(SessionViewDelegateState.SecurityDelay(ms, totalDurationSeconds)) + readingDialog?.show(SessionViewDelegateState.SecurityDelay(ms, totalDurationSeconds, productType)) } - override fun onDelay(total: Int, current: Int, step: Int) { + override fun onDelay(total: Int, current: Int, step: Int, productType: ProductType) { Log.view { "showing delay" } - readingDialog?.show(SessionViewDelegateState.Delay(total, current, step)) + readingDialog?.show(SessionViewDelegateState.Delay(total, current, step, productType)) } - override fun onTagLost() { + override fun onTagLost(productType: ProductType) { Log.view { "tag lost" } - readingDialog?.show(SessionViewDelegateState.TagLost) + readingDialog?.show(SessionViewDelegateState.TagLost(productType)) } override fun onTagConnected() { diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/SessionViewDelegateState.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/SessionViewDelegateState.kt index ea5b71559..933ad22d5 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/SessionViewDelegateState.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/SessionViewDelegateState.kt @@ -4,17 +4,24 @@ import com.tangem.Message import com.tangem.WrongValueType import com.tangem.common.UserCodeType import com.tangem.common.core.CompletionCallback +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemError import com.tangem.operations.resetcode.ResetPinService sealed class SessionViewDelegateState { data class Error(val error: TangemError) : SessionViewDelegateState() data class Success(val message: Message?) : SessionViewDelegateState() - data class SecurityDelay(val ms: Int, val totalDurationSeconds: Int) : + data class SecurityDelay(val ms: Int, val totalDurationSeconds: Int, val productType: ProductType) : SessionViewDelegateState() - data class Delay(val total: Int, val current: Int, val step: Int) : SessionViewDelegateState() - data class Ready(val cardId: String?) : SessionViewDelegateState() + data class Delay( + val total: Int, + val current: Int, + val step: Int, + val productType: ProductType, + ) : SessionViewDelegateState() + + data class Ready(val cardId: String?, val productType: ProductType) : SessionViewDelegateState() data class PinRequested( val type: UserCodeType, val isFirstAttempt: Boolean, @@ -37,7 +44,7 @@ sealed class SessionViewDelegateState { ) : SessionViewDelegateState() data class WrongCard(val wrongValueType: WrongValueType) : SessionViewDelegateState() - object TagLost : SessionViewDelegateState() + data class TagLost(val productType: ProductType) : SessionViewDelegateState() object TagConnected : SessionViewDelegateState() object HowToTap : SessionViewDelegateState() object None : SessionViewDelegateState() diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/NfcSessionDialog.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/NfcSessionDialog.kt index e227054e8..10d885085 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/NfcSessionDialog.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/NfcSessionDialog.kt @@ -10,6 +10,7 @@ import com.tangem.Log import com.tangem.ViewDelegateMessage import com.tangem.common.CompletionResult import com.tangem.common.Timer +import com.tangem.common.core.ProductType import com.tangem.common.core.ScanTagImage import com.tangem.common.core.SessionEnvironment import com.tangem.common.core.TangemSdkError @@ -292,10 +293,18 @@ class NfcSessionDialog( private fun activateTrickySecurityDelay(totalDuration: Long) { val timer = Timer(period = totalDuration, step = 100L, delayMs = 1000L, dispatcher = Dispatchers.IO) timer.onComplete = { - postUI { onSecurityDelay(SessionViewDelegateState.SecurityDelay(0, 0)) } + postUI { onSecurityDelay(SessionViewDelegateState.SecurityDelay(0, 0, ProductType.ANY)) } } timer.onTick = { - postUI { onSecurityDelay(SessionViewDelegateState.SecurityDelay((totalDuration - it).toInt(), 0)) } + postUI { + onSecurityDelay( + SessionViewDelegateState.SecurityDelay( + ms = (totalDuration - it).toInt(), + totalDurationSeconds = 0, + productType = ProductType.ANY, + ), + ) + } } timer.start() emulateSecurityDelayTimer = timer @@ -310,7 +319,7 @@ class NfcSessionDialog( emulateSecurityDelayTimer?.period?.let { activateTrickySecurityDelay(it) } } - SessionViewDelegateState.TagLost -> { + is SessionViewDelegateState.TagLost -> { emulateSecurityDelayTimer?.cancel() } @@ -326,7 +335,7 @@ class NfcSessionDialog( } private fun getEmptyOnReadyEvent(): SessionViewDelegateState { - return SessionViewDelegateState.Ready(headerWidget.cardId) + return SessionViewDelegateState.Ready(headerWidget.cardId, ProductType.ANY) } private companion object { diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/HeaderWidget.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/HeaderWidget.kt index a70bec6da..03ff4d601 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/HeaderWidget.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/HeaderWidget.kt @@ -84,8 +84,6 @@ class HeaderWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { if (scannedCardId == null) { tvCard.text = "" } else { - tvCard.show() - tvCard.text = getString(R.string.view_delegate_header_card) tvCardId.show() tvCardId.text = scannedCardId } diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/MessageWidget.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/MessageWidget.kt index 5632cc958..54d1d102f 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/MessageWidget.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/ui/widget/MessageWidget.kt @@ -7,6 +7,10 @@ import com.tangem.LocatorMessage import com.tangem.ViewDelegateMessage import com.tangem.WrongValueType import com.tangem.common.StringsLocator +import com.tangem.common.core.ProductType +import com.tangem.common.core.ProductType.ANY +import com.tangem.common.core.ProductType.CARD +import com.tangem.common.core.ProductType.RING import com.tangem.common.core.TangemError import com.tangem.common.core.TangemSdkError import com.tangem.sdk.AndroidStringLocator @@ -27,6 +31,7 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { private var initialMessage: ViewDelegateMessage? = null private var externalMessage: ViewDelegateMessage? = null + @Suppress("LongMethod") override fun setState(params: SessionViewDelegateState) { val message = getMessage(params) when (params) { @@ -34,7 +39,10 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { setTaskBlock( message = message, titleId = R.string.view_delegate_scan, - messageId = R.string.view_delegate_scan_description, + messageText = getFormattedString( + R.string.view_delegate_scan_description_format, + params.productType.getLocalizedDescription(), + ), ) } @@ -55,7 +63,10 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { setTaskBlock( message = message, titleId = R.string.view_delegate_security_delay, - messageId = R.string.view_delegate_security_delay_description, + messageText = getFormattedString( + id = R.string.view_delegate_security_delay_description_format, + params.productType.getLocalizedDescription(), + ), ) } @@ -63,7 +74,10 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { setTaskBlock( message = message, titleId = R.string.view_delegate_delay, - messageId = R.string.view_delegate_security_delay_description, + messageText = getFormattedString( + id = R.string.view_delegate_security_delay_description_format, + params.productType.getLocalizedDescription(), + ), ) } @@ -71,7 +85,10 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { setTaskBlock( message = message, titleId = R.string.view_delegate_scan, - messageId = R.string.view_delegate_scan_description, + messageText = getFormattedString( + R.string.view_delegate_scan_description_format, + params.productType.getLocalizedDescription(), + ), ) } @@ -152,4 +169,12 @@ class MessageWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { tv.text = getString(id) } } + + private fun ProductType.getLocalizedDescription(): String { + return when (this) { + ANY -> getString(R.string.common_card_or_ring) + CARD -> getString(R.string.common_card) + RING -> getString(R.string.common_ring) + } + } } diff --git a/tangem-sdk-core/src/main/java/com/tangem/SessionViewDelegate.kt b/tangem-sdk-core/src/main/java/com/tangem/SessionViewDelegate.kt index b84356016..44fd31356 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/SessionViewDelegate.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/SessionViewDelegate.kt @@ -5,6 +5,7 @@ import com.tangem.common.StringsLocator import com.tangem.common.UserCodeType import com.tangem.common.core.CompletionCallback import com.tangem.common.core.Config +import com.tangem.common.core.ProductType import com.tangem.common.core.TangemError import com.tangem.common.extensions.VoidCallback import com.tangem.operations.resetcode.ResetCodesViewDelegate @@ -26,25 +27,26 @@ interface SessionViewDelegate { message: ViewDelegateMessage? = null, enableHowTo: Boolean, iconScanRes: Int? = null, + productType: ProductType, ) /** * It is called when security delay is triggered by the card. * A user is expected to hold the card until the security delay is over. */ - fun onSecurityDelay(ms: Int, totalDurationSeconds: Int) + fun onSecurityDelay(ms: Int, totalDurationSeconds: Int, productType: ProductType) /** * It is called when long tasks are performed. * A user is expected to hold the card until the task is complete. */ - fun onDelay(total: Int, current: Int, step: Int) + fun onDelay(total: Int, current: Int, step: Int, productType: ProductType) /** * It is called when user takes the card away from the Android device during the scanning * (for example when security delay is in progress) and the TagLostException is received. */ - fun onTagLost() + fun onTagLost(productType: ProductType) fun onTagConnected() diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt b/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt index ab4297c0a..fe253e983 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/core/CardSession.kt @@ -1,6 +1,5 @@ package com.tangem.common.core -import com.tangem.LocatorMessage import com.tangem.Log import com.tangem.Message import com.tangem.SessionViewDelegate @@ -8,7 +7,6 @@ import com.tangem.ViewDelegateMessage import com.tangem.WrongValueType import com.tangem.common.CardIdFormatter import com.tangem.common.CompletionResult -import com.tangem.common.StringsLocator import com.tangem.common.UserCode import com.tangem.common.UserCodeType import com.tangem.common.apdu.Apdu @@ -101,14 +99,6 @@ class CardSession( private var onTagConnectedAfterResume: VoidCallback? = null - private val defaultScanMessage = LocatorMessage( - headerSource = null, - bodySource = LocatorMessage.Source( - id = StringsLocator.ID.VIEW_DELEGATE_SCAN_DESCRIPTION_FORMAT, - formatArgs = arrayOf(environment.config.productType.getLocalizedDescription()), - ), - ) - fun setInitialMessage(message: ViewDelegateMessage?) { initialMessage = message } @@ -182,9 +172,10 @@ class CardSession( state = CardSessionState.Active viewDelegate.onSessionStarted( cardId = cardId, - message = initialMessage ?: defaultScanMessage, + message = initialMessage, enableHowTo = environment.config.howToIsEnabled, iconScanRes = iconScanRes, + productType = environment.config.productType, ) scope.launch { @@ -212,8 +203,7 @@ class CardSession( .drop(1) .collect { if (it == null) { - setMessage(defaultScanMessage) - viewDelegate.onTagLost() + viewDelegate.onTagLost(productType = environment.config.productType) } else { viewDelegate.onTagConnected() onTagConnectedAfterResume?.invoke() @@ -530,7 +520,6 @@ class CardSession( is CompletionResult.Success -> { Log.session { "requestUserCode: Success" } updateEnvironment(type, result.data) - setMessage(defaultScanMessage) callback(CompletionResult.Success(Unit)) } is CompletionResult.Failure -> { diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt b/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt index 455436690..47872039f 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/core/Config.kt @@ -152,12 +152,4 @@ enum class ProductType { CARD, RING, ; - - fun getLocalizedDescription(): String { - return when (this) { - ANY -> "common_card_or_ring" - CARD -> "common_card" - RING -> "common_ring" - } - } } diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt index 9baeedbc1..5ec89cc02 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/Command.kt @@ -1,9 +1,7 @@ package com.tangem.operations -import com.tangem.LocatorMessage import com.tangem.Log import com.tangem.common.CompletionResult -import com.tangem.common.StringsLocator import com.tangem.common.UserCode import com.tangem.common.UserCodeType import com.tangem.common.apdu.CommandApdu @@ -156,8 +154,9 @@ abstract class Command : ApduSerializable, CardSessionRu val remainingTime = deserializeSecurityDelay(responseApdu) if (remainingTime != null) { session.viewDelegate.onSecurityDelay( - remainingTime, - session.environment.card?.settings?.securityDelay ?: 0, + ms = remainingTime, + totalDurationSeconds = session.environment.card?.settings?.securityDelay ?: 0, + productType = session.environment.config.productType, ) } transceiveApdu(apdu, session, callback) @@ -198,18 +197,7 @@ abstract class Command : ApduSerializable, CardSessionRu } is CompletionResult.Failure -> if (result.error is TangemSdkError.TagLost) { - session.setMessage( - LocatorMessage( - headerSource = null, - bodySource = LocatorMessage.Source( - id = StringsLocator.ID.VIEW_DELEGATE_SECURITY_DELAY_DESCRIPTION_FORMAT, - formatArgs = arrayOf( - session.environment.config.productType.getLocalizedDescription(), - ), - ), - ), - ) - session.viewDelegate.onTagLost() + session.viewDelegate.onTagLost(session.environment.config.productType) } else { callback(CompletionResult.Failure(result.error)) } @@ -223,7 +211,11 @@ abstract class Command : ApduSerializable, CardSessionRu var totalDuration = session.environment.card!!.settings.securityDelay totalDuration = if (totalDuration == 0) 0 else totalDuration + totalDuration.div(other = 3) - session.viewDelegate.onSecurityDelay(SessionEnvironment.missingSecurityDelayCode, totalDuration) + session.viewDelegate.onSecurityDelay( + ms = SessionEnvironment.missingSecurityDelayCode, + totalDurationSeconds = totalDuration, + productType = session.environment.config.productType, + ) } /** diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/files/WriteFileCommand.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/files/WriteFileCommand.kt index 550375c34..035d205c9 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/files/WriteFileCommand.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/files/WriteFileCommand.kt @@ -224,7 +224,7 @@ class WriteFileCommand private constructor( private fun writeFileData(session: CardSession, callback: CompletionCallback) { if (mode == FileDataMode.WriteFile) { - session.viewDelegate.onDelay(data.size, offset, SINGLE_WRITE_SIZE) + session.viewDelegate.onDelay(data.size, offset, SINGLE_WRITE_SIZE, session.environment.config.productType) } transceive(session) { result -> when (result) { diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/ReadIssuerExtraDataCommand.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/ReadIssuerExtraDataCommand.kt index e3f878d42..10cce8655 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/ReadIssuerExtraDataCommand.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/ReadIssuerExtraDataCommand.kt @@ -123,7 +123,12 @@ class ReadIssuerExtraDataCommand( private fun readData(session: CardSession, callback: CompletionCallback) { if (issuerDataSize != 0) { - session.viewDelegate.onDelay(issuerDataSize, offset, WriteIssuerExtraDataCommand.SINGLE_WRITE_SIZE) + session.viewDelegate.onDelay( + total = issuerDataSize, + current = offset, + step = WriteIssuerExtraDataCommand.SINGLE_WRITE_SIZE, + productType = session.environment.config.productType, + ) } super.run(session) { result -> when (result) { diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/WriteIssuerExtraDataCommand.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/WriteIssuerExtraDataCommand.kt index 592dd3c7e..9b8449427 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/WriteIssuerExtraDataCommand.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/issuerAndUserData/WriteIssuerExtraDataCommand.kt @@ -92,7 +92,12 @@ class WriteIssuerExtraDataCommand( private fun writeData(session: CardSession, callback: CompletionCallback) { if (mode == IssuerExtraDataMode.WritePart) { - session.viewDelegate.onDelay(issuerData.size, offset, SINGLE_WRITE_SIZE) + session.viewDelegate.onDelay( + total = issuerData.size, + current = offset, + step = SINGLE_WRITE_SIZE, + productType = session.environment.config.productType, + ) } transceive(session) { result -> when (result) { From f6fdc7852f7823f4ebb7bd002bcdd822193f8346 Mon Sep 17 00:00:00 2001 From: Mama1emon Date: Thu, 10 Oct 2024 15:33:03 +0400 Subject: [PATCH 4/4] Fix detekt --- .../tangem/operations/backup/BackupService.kt | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt index 4d3838d80..4f02154d2 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/operations/backup/BackupService.kt @@ -313,12 +313,9 @@ class BackupService( if (handleErrors && repo.data.accessCode == null && repo.data.passcode == null) { throw TangemSdkError.AccessCodeOrPasscodeRequired() } - val accessCode = - repo.data.accessCode ?: UserCodeType.AccessCode.defaultValue.calculateSha256() - val passcode = - repo.data.passcode ?: UserCodeType.Passcode.defaultValue.calculateSha256() - val primaryCard = - repo.data.primaryCard.guard { throw TangemSdkError.MissingPrimaryCard() } + val accessCode = repo.data.accessCode ?: UserCodeType.AccessCode.defaultValue.calculateSha256() + val passcode = repo.data.passcode ?: UserCodeType.Passcode.defaultValue.calculateSha256() + val primaryCard = repo.data.primaryCard.guard { throw TangemSdkError.MissingPrimaryCard() } // val linkableBackupCards = repo.data.backupCards.map { card -> // val certificate = repo.data.certificates[card.cardId] @@ -328,9 +325,7 @@ class BackupService( if (handleErrors) { if (repo.data.backupCards.isEmpty()) throw TangemSdkError.EmptyBackupCards() - if (repo.data.backupCards.size > MAX_BACKUP_CARDS_COUNT) { - throw TangemSdkError.TooMuchBackupCards() - } + if (repo.data.backupCards.size > MAX_BACKUP_CARDS_COUNT) throw TangemSdkError.TooMuchBackupCards() } val task = FinalizePrimaryCardTask( @@ -340,10 +335,7 @@ class BackupService( readBackupStartIndex = repo.data.backupData.size, attestSignature = repo.data.attestSignature, onLink = { - repo.data = repo.data.copy( - attestSignature = it, - primaryCardFinalized = false, - ) + repo.data = repo.data.copy(attestSignature = it, primaryCardFinalized = false) }, onRead = { cardId, data -> repo.data = repo.data.copy( @@ -352,9 +344,7 @@ class BackupService( ) }, onFinalize = { - repo.data = repo.data.copy( - primaryCardFinalized = true, - ) + repo.data = repo.data.copy(primaryCardFinalized = true) }, )