Updated on 2026-08-14
This commit is contained in:
parent
95021a0600
commit
30c4c0b425
15 changed files with 74 additions and 105 deletions
|
|
@ -11,6 +11,7 @@ import android.security.keystore.KeyProperties;
|
|||
import com.tangem.Constant;
|
||||
import com.tangem.tangemcard.android.data.PINStorage;
|
||||
import com.tangem.presentation.activity.PinRequestActivity;
|
||||
import com.tangem.util.LOG;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
|
@ -26,6 +27,8 @@ import javax.crypto.SecretKey;
|
|||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
||||
public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
||||
public static final String TAG = StartFingerprintReaderTask.class.getSimpleName();
|
||||
|
||||
private WeakReference<PinRequestActivity> reference;
|
||||
|
||||
private KeyStore keyStore;
|
||||
|
|
@ -64,16 +67,14 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean success) {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
onCancelled();
|
||||
|
||||
if (!success) {
|
||||
pinRequestActivity.doLog("Authentication failed!");
|
||||
LOG.i(TAG, "Authentication failed!");
|
||||
} else {
|
||||
fingerprintHelper.startAuth(fingerprintManager, cryptoObject);
|
||||
pinRequestActivity.doLog("Authenticate using fingerprint!");
|
||||
|
||||
LOG.i(TAG, "Authenticate using fingerprint!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +86,7 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
}
|
||||
|
||||
private boolean getKeyStore() {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
pinRequestActivity.doLog("Getting keystore...");
|
||||
LOG.i(TAG, "Getting keystore...");
|
||||
try {
|
||||
keyStore = KeyStore.getInstance(Constant.KEYSTORE);
|
||||
keyStore.load(null); // Create empty keystore
|
||||
|
|
@ -101,9 +100,7 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public boolean createNewKey(boolean forceCreate) {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
pinRequestActivity.doLog("Creating new key...");
|
||||
LOG.i(TAG, "Creating new key...");
|
||||
try {
|
||||
if (forceCreate)
|
||||
keyStore.deleteEntry(Constant.KEY_ALIAS);
|
||||
|
|
@ -120,9 +117,9 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
);
|
||||
|
||||
generator.generateKey();
|
||||
pinRequestActivity.doLog("Key created.");
|
||||
LOG.i(TAG, "Key created.");
|
||||
} else
|
||||
pinRequestActivity.doLog("Key exists.");
|
||||
LOG.i(TAG, "Key exists.");
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -133,9 +130,7 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
}
|
||||
|
||||
private boolean getCipher() {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
pinRequestActivity.doLog("Getting cipher...");
|
||||
LOG.i(TAG, "Getting cipher...");
|
||||
try {
|
||||
cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);
|
||||
return true;
|
||||
|
|
@ -150,7 +145,7 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
private boolean initCipher(int mode) {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
pinRequestActivity.doLog("Initializing cipher...");
|
||||
LOG.i(TAG, "Initializing cipher...");
|
||||
try {
|
||||
keyStore.load(null);
|
||||
SecretKey keyspec = (SecretKey) keyStore.getKey(Constant.KEY_ALIAS, null);
|
||||
|
|
@ -181,9 +176,7 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
private boolean initCryptObject() {
|
||||
PinRequestActivity pinRequestActivity = reference.get();
|
||||
|
||||
pinRequestActivity.doLog("Initializing crypt object...");
|
||||
LOG.i(TAG, "Initializing crypt object...");
|
||||
try {
|
||||
cryptoObject = new FingerprintManager.CryptoObject(cipher);
|
||||
return true;
|
||||
|
|
@ -193,5 +186,4 @@ public class StartFingerprintReaderTask extends AsyncTask<Void, Void, Boolean> {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ import java.util.*
|
|||
|
||||
class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
private lateinit var amount: CoinEngine.Amount
|
||||
|
||||
|
|
@ -183,17 +182,17 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
nfcManager.onResume()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager!!.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager!!.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
@ -249,7 +248,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.activity_create_new_wallet.*
|
||||
|
||||
class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, CreateNewWalletActivity::class.java)
|
||||
|
|
@ -38,8 +37,8 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
}
|
||||
}
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var createNewWalletTask: CreateNewWalletTask? = null
|
||||
private var lastReadSuccess = true
|
||||
|
|
|
|||
|
|
@ -33,10 +33,8 @@ import kotlinx.android.synthetic.main.activity_empty_wallet.*
|
|||
import javax.inject.Inject
|
||||
|
||||
class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
val TAG: String = EmptyWalletActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, EmptyWalletActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
|
|
@ -44,15 +42,16 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var lastReadSuccess = true
|
||||
private var verifyCardTask: VerifyCardTask? = null
|
||||
private var requestPIN2Count = 0
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_empty_wallet)
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ import kotlinx.android.synthetic.main.activity_logo.*
|
|||
import javax.inject.Inject
|
||||
|
||||
class LogoActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
fun callingIntent(context: Context, autoHide: Boolean): Intent {
|
||||
val intent = Intent(context, LogoActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_AUTO_HIDE, autoHide)
|
||||
|
|
@ -24,11 +22,11 @@ class LogoActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private val hideRunnable = Runnable { this.hide() }
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
private val hideRunnable = Runnable { this.hide() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_logo)
|
||||
|
|
|
|||
|
|
@ -56,11 +56,14 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
companion object {
|
||||
val TAG: String = MainActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Context) = Intent(context, MainActivity::class.java)
|
||||
}
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
|
||||
private var zipFile: File? = null
|
||||
private var antenna: DeviceNFCAntennaLocation? = null
|
||||
private var unsuccessReadCount = 0
|
||||
|
|
@ -68,9 +71,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
private var readCardInfoTask: ReadCardInfoTask? = null
|
||||
private var onNfcReaderCallback: NfcAdapter.ReaderCallback? = null
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED == intent.action || NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action)) {
|
||||
|
|
|
|||
|
|
@ -29,14 +29,16 @@ import com.tangem.tangemcard.data.TangemCard
|
|||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
import com.tangem.tangemcard.data.EXTRA_TANGEM_CARD
|
||||
import com.tangem.tangemcard.data.EXTRA_TANGEM_CARD_UID
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_pin_request.*
|
||||
import kotlinx.android.synthetic.main.layout_pin_buttons.*
|
||||
import java.io.IOException
|
||||
|
||||
class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, FingerprintHelper.FingerprintHelperListener {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PinRequestActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Activity, mode: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
|
|
@ -81,12 +83,11 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
}
|
||||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
|
||||
lateinit var mode: Mode
|
||||
private var allowFingerprint = false
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
var startFingerprintReaderTask: StartFingerprintReaderTask? = null
|
||||
|
||||
private var fingerprintManager: FingerprintManager? = null
|
||||
private var fingerprintHelper: FingerprintHelper? = null
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
startFingerprintReaderTask = null
|
||||
}
|
||||
|
||||
nfcManager!!.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
|
@ -192,12 +193,12 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
startFingerprintReaderTask = null
|
||||
}
|
||||
|
||||
nfcManager!!.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
nfcManager.onResume()
|
||||
if (allowFingerprint)
|
||||
startFingerprintReader()
|
||||
}
|
||||
|
|
@ -205,19 +206,19 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
Log.w(javaClass.name, "Ignore discovered tag!")
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun authenticationFailed(error: String) {
|
||||
doLog(error)
|
||||
LOG.w(TAG, error)
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
override fun authenticationSucceeded(result: FingerprintManager.AuthenticationResult) {
|
||||
doLog("Authentication succeeded!")
|
||||
LOG.i(TAG,"Authentication succeeded!")
|
||||
val cipher = result.cryptoObject.cipher
|
||||
|
||||
if (mode == Mode.RequestNewPIN || mode == Mode.ConfirmNewPIN) {
|
||||
|
|
@ -245,10 +246,6 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
finish()
|
||||
}
|
||||
|
||||
fun doLog(text: String) {
|
||||
// Log.e("FP", text);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun buttonClick(button: Button) {
|
||||
tvPin!!.text = tvPin!!.text.toString() + button.text as String
|
||||
|
|
@ -256,27 +253,27 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
|
||||
@SuppressLint("NewApi")
|
||||
private fun testFingerPrintSettings(): Boolean {
|
||||
doLog("Testing Fingerprint Settings")
|
||||
LOG.i(TAG,"Testing Fingerprint Settings")
|
||||
|
||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
||||
fingerprintManager = getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager
|
||||
|
||||
if (!keyguardManager.isKeyguardSecure) {
|
||||
doLog("User hasn't enabled Lock Screen")
|
||||
LOG.i(TAG,"User hasn't enabled Lock Screen")
|
||||
return false
|
||||
}
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
|
||||
doLog("User hasn't granted permission to use Fingerprint")
|
||||
LOG.i(TAG,"User hasn't granted permission to use Fingerprint")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!fingerprintManager!!.hasEnrolledFingerprints()) {
|
||||
doLog("User hasn't registered any fingerprints")
|
||||
LOG.i(TAG,"User hasn't registered any fingerprints")
|
||||
return false
|
||||
}
|
||||
|
||||
doLog("Fingerprint authentication is set.\n")
|
||||
LOG.i(TAG,"Fingerprint authentication is set.\n")
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import javax.crypto.SecretKey
|
|||
import javax.crypto.spec.IvParameterSpec
|
||||
|
||||
class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelperListener {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PinSaveActivity::class.java.simpleName
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.activity_pin_swap.*
|
||||
|
||||
class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PinSwapActivity::class.java.simpleName
|
||||
|
||||
|
|
@ -43,8 +42,8 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
|
|||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private var card: TangemCard? = null
|
||||
|
||||
private var card: TangemCard? = null
|
||||
private var newPIN: String? = null
|
||||
private var newPIN2: String? = null
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
val TAG: String = PrepareCryptonitOtherApiWithdrawalActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
private var cryptonit: CryptonitOtherApi? = null
|
||||
|
||||
@Inject
|
||||
|
|
@ -156,17 +157,17 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
nfcManager.onResume()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager!!.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager!!.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
@ -193,8 +194,7 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
// Log.w(javaClass.name, "Ignore discovered tag!")
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
val TAG: String = PrepareCryptonitWithdrawalActivity::class.java.simpleName
|
||||
}
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
private var nfcManager: NfcManager? = null
|
||||
private var cryptonit: Cryptonit? = null
|
||||
|
||||
private var cryptonit: Cryptonit? = null
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -150,22 +150,22 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
nfcManager.onResume()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager!!.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager!!.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,8 @@ import java.io.IOException
|
|||
import javax.inject.Inject
|
||||
|
||||
class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PreparePaymentActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, PreparePaymentActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
|
|
@ -36,12 +34,12 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private lateinit var nfcManager: NfcManager
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -60,7 +58,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
tvBalance.text = html
|
||||
|
||||
//TODO - to engine
|
||||
if (ctx.blockchain == Blockchain.Token && engine.balance.currency!=Blockchain.Ethereum.currency) {
|
||||
if (ctx.blockchain == Blockchain.Token && engine.balance.currency != Blockchain.Ethereum.currency) {
|
||||
rgIncFee!!.visibility = View.INVISIBLE
|
||||
} else {
|
||||
rgIncFee!!.visibility = View.VISIBLE
|
||||
|
|
@ -87,7 +85,6 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
btnVerify.setOnClickListener {
|
||||
|
||||
val engine1 = CoinEngineFactory.create(ctx)
|
||||
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
|
@ -102,29 +99,18 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
etAmount.error = getString(R.string.unknown_amount_format)
|
||||
}
|
||||
|
||||
var checkAddress = false
|
||||
// if (engine1 != null)
|
||||
checkAddress = engine1.validateAddress(etWallet.text.toString())
|
||||
|
||||
// check wallet address
|
||||
if (!checkAddress) {
|
||||
if (!engine1.validateAddress(etWallet.text.toString())) {
|
||||
etWallet.error = getString(R.string.incorrect_destination_wallet_address)
|
||||
return@setOnClickListener
|
||||
} else {
|
||||
} else
|
||||
etWallet.error = null
|
||||
}
|
||||
|
||||
if (etWallet.text.toString() == ctx.coinData!!.wallet) {
|
||||
etWallet.error = getString(R.string.destination_wallet_address_equal_source_address)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
// check enough funds
|
||||
// TODO - double with engin.checkAmount
|
||||
// if (etAmount.text.toString().replace(",", ".").toDouble() > engine.getBalanceValue(card).replace(",", ".").toDouble()) {
|
||||
// etAmount.error = getString(R.string.not_enough_funds_on_your_card)
|
||||
// return@setOnClickListener
|
||||
// }
|
||||
if (!etAmount.error.isNullOrEmpty() || !etWallet.error.isNullOrEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
|
@ -143,17 +129,17 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
nfcManager!!.onResume()
|
||||
nfcManager.onResume()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
nfcManager!!.onPause()
|
||||
nfcManager.onPause()
|
||||
}
|
||||
|
||||
public override fun onStop() {
|
||||
super.onStop()
|
||||
nfcManager!!.onStop()
|
||||
nfcManager.onStop()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
@ -188,11 +174,10 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
|
||||
override fun onTagDiscovered(tag: Tag) {
|
||||
try {
|
||||
nfcManager!!.ignoreTag(tag)
|
||||
nfcManager.ignoreTag(tag)
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,17 +31,19 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
companion object {
|
||||
val TAG: String = PurgeActivity::class.java.simpleName
|
||||
const val RESULT_INVALID_PIN = Activity.RESULT_FIRST_USER
|
||||
|
||||
fun callingIntent(context: Context, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, PurgeActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
|
||||
const val RESULT_INVALID_PIN = Activity.RESULT_FIRST_USER
|
||||
}
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var purgeTask: PurgeTask? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.tangem.Constant
|
|||
import me.dm7.barcodescanner.zxing.ZXingScannerView
|
||||
|
||||
class QrScanActivity : AppCompatActivity(), ZXingScannerView.ResultHandler {
|
||||
|
||||
companion object {
|
||||
fun callingIntent(context: Context): Intent {
|
||||
return Intent(context, QrScanActivity::class.java)
|
||||
|
|
|
|||
|
|
@ -21,9 +21,10 @@ import java.io.IOException
|
|||
|
||||
class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
||||
|
||||
private lateinit var ctx: TangemContext
|
||||
private var tx: ByteArray? = null
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private var tx: ByteArray? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue