Updated on 2026-08-14
This commit is contained in:
parent
cd34e37675
commit
c1c91c9ed9
7 changed files with 47 additions and 47 deletions
|
|
@ -33,4 +33,11 @@ object Constant {
|
|||
const val EXTRA_AUTO_HIDE = "extra_auto_hide"
|
||||
const val MILLIS_AUTO_HIDE = 1000
|
||||
|
||||
// PinRequestActivity
|
||||
const val EXTRA_MODE = "mode"
|
||||
|
||||
// PinSwapActivity
|
||||
const val EXTRA_NEW_PIN = "newPIN"
|
||||
const val EXTRA_NEW_PIN_2 = "newPIN2"
|
||||
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ import com.tangem.Constant
|
|||
import com.tangem.domain.wallet.CoinData
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.presentation.activity.*
|
||||
import com.tangem.presentation.fragment.LoadedWallet
|
||||
|
||||
class Navigator {
|
||||
|
||||
|
|
@ -23,6 +22,10 @@ class Navigator {
|
|||
context.startActivity(PinSaveActivity.callingIntent(context, hasPin2))
|
||||
}
|
||||
|
||||
fun showPinRequest(context: Activity, mode: String) {
|
||||
context.startActivityForResult(PinRequestActivity.callingIntent(context, mode), Constant.REQUEST_CODE_ENTER_PIN_ACTIVITY)
|
||||
}
|
||||
|
||||
fun showLoadedWallet(context: Activity, lastTag: Tag, cardInfo: Bundle) {
|
||||
context.startActivityForResult(LoadedWalletActivity.callingIntent(context, lastTag, cardInfo), Constant.REQUEST_CODE_SHOW_CARD_ACTIVITY)
|
||||
}
|
||||
|
|
@ -35,8 +38,8 @@ class Navigator {
|
|||
context.startActivityForResult(VerifyCardActivity.callingIntent(context, card, coinData), Constant.REQUEST_CODE_VERIFY_CARD)
|
||||
}
|
||||
|
||||
fun showPinSwap(context: Activity) {
|
||||
|
||||
fun showPinSwap(context: Activity, newPIN: String, newPIN2: String) {
|
||||
context.startActivityForResult(PinSwapActivity.callingIntent(context, newPIN, newPIN2), Constant.REQUEST_CODE_SWAP_PIN)
|
||||
}
|
||||
|
||||
// fun showPreparePayment(context: Activity) {
|
||||
|
|
|
|||
|
|
@ -27,15 +27,13 @@ import com.scottyab.rootbeer.RootBeer
|
|||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.Logger
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.data.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.data.nfc.ReadCardInfoTask
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
import com.tangem.domain.cardReader.Firmwares
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.RootFoundDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
|
|
@ -339,7 +337,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
unsuccessReadCount++
|
||||
|
||||
if (cardProtocol.error is CardProtocol.TangemException_InvalidPIN)
|
||||
doEnterPIN()
|
||||
navigator.showPinRequest(this, PinRequestActivity.Mode.RequestPIN.toString())
|
||||
else {
|
||||
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported)
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed)
|
||||
|
|
@ -425,10 +423,4 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
popup.show()
|
||||
}
|
||||
|
||||
private fun doEnterPIN() {
|
||||
val intent = Intent(this, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN.toString())
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_PIN_ACTIVITY)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,10 +19,12 @@ import android.text.TextUtils
|
|||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.fingerprint.StartFingerprintReaderTask
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.domain.wallet.CoinData
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_pin_request.*
|
||||
|
|
@ -34,6 +36,12 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
companion object {
|
||||
const val KEY_ALIAS = "pinKey"
|
||||
const val KEYSTORE = "AndroidKeyStore"
|
||||
|
||||
fun callingIntent(context: Activity, mode: String): Intent {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_MODE, mode)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
lateinit var mode: Mode
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
|
|
@ -12,9 +13,11 @@ import android.support.v7.app.AppCompatActivity
|
|||
import android.view.View
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.Toast
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.nfc.SwapPINTask
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.CoinData
|
||||
import com.tangem.domain.wallet.TangemCard
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
|
|
@ -27,6 +30,13 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
|
|||
companion object {
|
||||
val TAG: String = PinSwapActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Context, newPIN: String, newPIN2: String): Intent {
|
||||
val intent = Intent(context, PinSwapActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_NEW_PIN, newPIN)
|
||||
intent.putExtra(Constant.EXTRA_NEW_PIN_2, newPIN2)
|
||||
return intent
|
||||
}
|
||||
|
||||
const val RESULT_INVALID_PIN = Activity.RESULT_FIRST_USER
|
||||
}
|
||||
|
||||
|
|
@ -51,8 +61,8 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
|
|||
card = TangemCard(intent.getStringExtra(TangemCard.EXTRA_UID))
|
||||
card!!.loadFromBundle(intent.extras!!.getBundle(TangemCard.EXTRA_CARD))
|
||||
|
||||
newPIN = intent.getStringExtra("newPIN")
|
||||
newPIN2 = intent.getStringExtra("newPIN2")
|
||||
newPIN = intent.getStringExtra(Constant.EXTRA_NEW_PIN)
|
||||
newPIN2 = intent.getStringExtra(Constant.EXTRA_NEW_PIN_2)
|
||||
|
||||
tvCardID.text = card!!.cidDescription
|
||||
|
||||
|
|
|
|||
|
|
@ -183,9 +183,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
btnDetails.setOnClickListener {
|
||||
if (cardProtocol != null)
|
||||
// openVerifyCard(cardProtocol!!)
|
||||
(activity as LoadedWalletActivity).navigator.showVerifyCard(context as Activity, ctx.card, ctx.coinData)
|
||||
|
||||
else
|
||||
showSingleToast(R.string.need_attach_card_again)
|
||||
}
|
||||
|
|
@ -537,7 +535,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
newPIN2 = PINStorage.getPIN2()
|
||||
|
||||
val pinSwapWarningDialog = PINSwapWarningDialog()
|
||||
pinSwapWarningDialog.setOnRefreshPage { startSwapPINActivity() }
|
||||
pinSwapWarningDialog.setOnRefreshPage { (activity as LoadedWalletActivity).navigator.showPinSwap(context as Activity, newPIN, newPIN2) }
|
||||
val bundle = Bundle()
|
||||
if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2))
|
||||
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_forget))
|
||||
|
|
@ -874,17 +872,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
|
||||
// private fun openVerifyCard(cardProtocol: CardProtocol) {
|
||||
// val intent = Intent(activity, VerifyCardActivity::class.java)
|
||||
// ctx.saveToIntent(intent)
|
||||
// startActivityForResult(intent, REQUEST_CODE_VERIFY_CARD)
|
||||
//
|
||||
// ctx.coinData
|
||||
// }
|
||||
|
||||
private fun startVerify(tag: Tag?) {
|
||||
try {
|
||||
val isoDep = IsoDep.get(tag) ?: throw CardProtocol.TangemException(getString(R.string.wrong_tag_err))
|
||||
val isoDep = IsoDep.get(tag)
|
||||
?: throw CardProtocol.TangemException(getString(R.string.wrong_tag_err))
|
||||
val uid = tag!!.id
|
||||
val sUID = Util.byteArrayToHexString(uid)
|
||||
if (ctx.card.uid != sUID) {
|
||||
|
|
@ -942,14 +933,6 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
|
||||
private fun startSwapPINActivity() {
|
||||
val intent = Intent(activity, PinSwapActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra("newPIN", newPIN)
|
||||
intent.putExtra("newPIN2", newPIN2)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SWAP_PIN)
|
||||
}
|
||||
|
||||
private var showTime: Date = Date()
|
||||
|
||||
private fun showSingleToast(text: Int) {
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ import com.tangem.Constant
|
|||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
import com.tangem.domain.wallet.*
|
||||
import com.tangem.presentation.activity.CreateNewWalletActivity
|
||||
import com.tangem.presentation.activity.PurgeActivity
|
||||
import com.tangem.presentation.activity.PinRequestActivity
|
||||
import com.tangem.presentation.activity.PinSwapActivity
|
||||
import com.tangem.presentation.activity.*
|
||||
import com.tangem.presentation.dialog.PINSwapWarningDialog
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
|
|
@ -135,7 +132,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
if (newPIN2 == "") newPIN2 = PINStorage.getPIN2()
|
||||
|
||||
val pinSwapWarningDialog = PINSwapWarningDialog()
|
||||
pinSwapWarningDialog.setOnRefreshPage { startSwapPINActivity() }
|
||||
pinSwapWarningDialog.setOnRefreshPage { (activity as VerifyCardActivity).navigator.showPinSwap(context as Activity, newPIN, newPIN2) }
|
||||
val bundle = Bundle()
|
||||
if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2))
|
||||
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_forget))
|
||||
|
|
@ -481,13 +478,13 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
}
|
||||
|
||||
private fun startSwapPINActivity() {
|
||||
val intent = Intent(context, PinSwapActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
intent.putExtra("newPIN", newPIN)
|
||||
intent.putExtra("newPIN2", newPIN2)
|
||||
startActivityForResult(intent, REQUEST_CODE_SWAP_PIN)
|
||||
}
|
||||
// private fun startSwapPINActivity() {
|
||||
// val intent = Intent(context, PinSwapActivity::class.java)
|
||||
// ctx.saveToIntent(intent)
|
||||
// intent.putExtra("newPIN", newPIN)
|
||||
// intent.putExtra("newPIN2", newPIN2)
|
||||
// startActivityForResult(intent, REQUEST_CODE_SWAP_PIN)
|
||||
// }
|
||||
|
||||
fun prepareResultIntent(): Intent {
|
||||
val data = Intent()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue