From ae3fcc0e13fc6aa9ab2372be4033db9553a9601c Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 1 Nov 2019 10:55:12 +0300 Subject: [PATCH] Updated on 2026-08-14 --- tangemtest/src/main/AndroidManifest.xml | 1 - .../com/tangem/tangemtest/MainActivity.kt | 63 ++++++++----------- .../java/com/tangem/tangemtest/TestApp.kt | 28 --------- 3 files changed, 27 insertions(+), 65 deletions(-) delete mode 100644 tangemtest/src/main/java/com/tangem/tangemtest/TestApp.kt diff --git a/tangemtest/src/main/AndroidManifest.xml b/tangemtest/src/main/AndroidManifest.xml index 051383031e..2235a4e852 100644 --- a/tangemtest/src/main/AndroidManifest.xml +++ b/tangemtest/src/main/AndroidManifest.xml @@ -10,7 +10,6 @@ cardManager.scanCard { @@ -36,7 +37,7 @@ class MainActivity : AppCompatActivity() { cid = (it.data as ScanEvent.OnReadEvent).result.cardId } is ScanEvent.OnVerifyEvent -> { - postUI { + runOnUiThread { tv_card_cid?.text = cid btn_sign.isEnabled = true } @@ -46,42 +47,32 @@ class MainActivity : AppCompatActivity() { } } btn_sign?.setOnClickListener { _ -> - val hash1 = ByteArray(32) - for (i in 0 until 32) { - hash1[i] = 1 - } - val hash2 = ByteArray(32) - for (i in 0 until 32) { - hash2[i] = 2 - } cardManager.sign( - arrayOf(hash1, hash2), + createSampleHashes(), cid) { when (it) { is TaskEvent.Completion -> { - if (it.error != null) postUI { tv_card_cid?.text = it.error!!::class.simpleName } + if (it.error != null) runOnUiThread { tv_card_cid?.text = it.error!!::class.simpleName } } - is TaskEvent.Event -> postUI { tv_card_cid?.text = cid + " used to sign sample hashes." } + is TaskEvent.Event -> runOnUiThread { tv_card_cid?.text = cid + " used to sign sample hashes." } } - } } } - override fun onResume() { - super.onResume() - nfcManager.onResume() + private fun createSampleHashes(): Array { + val hash1 = ByteArray(32) + for (i in 0 until 32) { + hash1[i] = 1 + } + val hash2 = ByteArray(32) + for (i in 0 until 32) { + hash2[i] = 2 + } + return arrayOf(hash1, hash2) } - - override fun onPause() { - super.onPause() - nfcManager.onPause() - } - - - override fun onDestroy() { - super.onDestroy() - nfcManager.onDestroy() + override fun onTagDiscovered(tag: Tag?) { + nfcManager.onTagDiscovered(tag) } } \ No newline at end of file diff --git a/tangemtest/src/main/java/com/tangem/tangemtest/TestApp.kt b/tangemtest/src/main/java/com/tangem/tangemtest/TestApp.kt deleted file mode 100644 index 39bdd77875..0000000000 --- a/tangemtest/src/main/java/com/tangem/tangemtest/TestApp.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.tangem.tangemtest - -import android.app.Application -import com.tangem.Log -import com.tangem.LoggerInterface - -class TestApp : Application() { - - override fun onCreate() { - super.onCreate() - - Log.setLogger( - object : LoggerInterface { - override fun i(logTag: String, message: String) { - android.util.Log.i(logTag, message) - } - - override fun e(logTag: String, message: String) { - android.util.Log.e(logTag, message) - } - - override fun v(logTag: String, message: String) { - android.util.Log.v(logTag, message) - } - } - ) - } -} \ No newline at end of file