Updated on 2026-08-14
This commit is contained in:
commit
55ed35dab5
20 changed files with 205 additions and 175 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)
|
||||
|
|
|
|||
|
|
@ -28,20 +28,20 @@ import com.tangem.App
|
|||
import com.tangem.Constant
|
||||
import com.tangem.data.Logger
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.tasks.ReadCardInfoTask
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.RootFoundDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
import com.tangem.tangemcard.data.loadFromBundle
|
||||
import com.tangem.tangemcard.data.saveToBundle
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.tangemcard.tasks.ReadCardInfoTask
|
||||
import com.tangem.util.CommonUtil
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.util.PhoneUtility
|
||||
|
|
@ -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)
|
||||
|
|
@ -88,7 +86,6 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
btnVerify.setOnClickListener {
|
||||
|
||||
val engine1 = CoinEngineFactory.create(ctx)
|
||||
|
||||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
|
|
@ -103,29 +100,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
|
||||
}
|
||||
|
|
@ -144,17 +130,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?) {
|
||||
|
|
@ -189,11 +175,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)
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.tangemcard.tasks.SignTask
|
||||
import com.tangem.tangemcard.util.Util
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_sign_payment.*
|
||||
|
||||
|
|
@ -252,16 +253,41 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
}, 500)
|
||||
}
|
||||
|
||||
override fun onReadWait(msec: Int) {
|
||||
WaitSecurityDelayDialog.onReadWait(this, msec)
|
||||
}
|
||||
// private val waitSecurityDelayDialogNew = WaitSecurityDelayDialogNew()
|
||||
|
||||
override fun onReadBeforeRequest(timeout: Int) {
|
||||
LOG.i(TAG, "onReadBeforeRequest timeout $timeout")
|
||||
WaitSecurityDelayDialog.onReadBeforeRequest(this, timeout)
|
||||
|
||||
// if (!waitSecurityDelayDialogNew.isAdded)
|
||||
// waitSecurityDelayDialogNew.show(supportFragmentManager, WaitSecurityDelayDialogNew.TAG)
|
||||
|
||||
|
||||
// val readBeforeRequest = ReadBeforeRequest()
|
||||
// readBeforeRequest.timeout = timeout
|
||||
// EventBus.getDefault().post(readBeforeRequest)
|
||||
|
||||
}
|
||||
|
||||
override fun onReadAfterRequest() {
|
||||
LOG.i(TAG, "onReadAfterRequest")
|
||||
WaitSecurityDelayDialog.onReadAfterRequest(this)
|
||||
|
||||
// val readAfterRequest = ReadAfterRequest()
|
||||
// EventBus.getDefault().post(readAfterRequest)
|
||||
|
||||
}
|
||||
|
||||
override fun onReadWait(msec: Int) {
|
||||
LOG.i(TAG, "onReadWait msec $msec")
|
||||
WaitSecurityDelayDialog.onReadWait(this, msec)
|
||||
|
||||
// val readWait = ReadWait()
|
||||
// readWait.msec = msec
|
||||
// EventBus.getDefault().post(readWait)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,20 @@
|
|||
package com.tangem.presentation.dialog
|
||||
|
||||
import android.app.Activity
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatDialogFragment
|
||||
import android.widget.ProgressBar
|
||||
import com.tangem.presentation.activity.SignPaymentActivity
|
||||
import com.tangem.presentation.event.ReadAfterRequest
|
||||
import com.tangem.presentation.event.ReadBeforeRequest
|
||||
import com.tangem.presentation.event.ReadWait
|
||||
import com.tangem.presentation.event.TransactionFinishWithSuccess
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.dialog_wait_pin2.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import java.util.*
|
||||
|
||||
class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
||||
|
|
@ -18,27 +26,30 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
private const val DELAY_BEFORE_SHOW_DIALOG = 5000
|
||||
}
|
||||
|
||||
private lateinit var pb: ProgressBar
|
||||
|
||||
private var msTimeout = 60000
|
||||
private var msProgress = 0
|
||||
private var timer: Timer? = null
|
||||
private var timerToShowDelayDialog: Timer? = null
|
||||
private var instance: WaitSecurityDelayDialogNew? = null
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val inflater = activity!!.layoutInflater
|
||||
val v = inflater.inflate(R.layout.dialog_wait_pin2, null)
|
||||
|
||||
progressBar.max = msTimeout
|
||||
progressBar.progress = msProgress
|
||||
pb = v.findViewById(R.id.progressBar)
|
||||
|
||||
pb.max = msTimeout
|
||||
pb.progress = msProgress
|
||||
|
||||
timer = Timer()
|
||||
timer!!.scheduleAtFixedRate(object : TimerTask() {
|
||||
override fun run() {
|
||||
progressBar.post {
|
||||
val progress = this@WaitSecurityDelayDialogNew.progressBar.progress
|
||||
if (progress < this@WaitSecurityDelayDialogNew.progressBar.max) {
|
||||
this@WaitSecurityDelayDialogNew.progressBar.progress = progress + 1000
|
||||
}
|
||||
pb.post {
|
||||
val progress = pb.progress
|
||||
if (progress < pb.max)
|
||||
pb.progress = progress + 1000
|
||||
}
|
||||
}
|
||||
}, 1000, 1000)
|
||||
|
|
@ -51,59 +62,68 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
.create()
|
||||
}
|
||||
|
||||
fun onReadBeforeRequest(activity: Activity, timeout: Int) {
|
||||
activity.runOnUiThread(Runnable {
|
||||
if (timerToShowDelayDialog != null || timeout < DELAY_BEFORE_SHOW_DIALOG + MIN_REMAINING_DELAY_TO_SHOW_DIALOG)
|
||||
return@Runnable
|
||||
|
||||
timerToShowDelayDialog = Timer()
|
||||
timerToShowDelayDialog!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
if (instance != null) return
|
||||
instance = WaitSecurityDelayDialogNew()
|
||||
instance!!.setup(timeout, DELAY_BEFORE_SHOW_DIALOG)
|
||||
instance!!.isCancelable = false
|
||||
// instance.show(activity.fragmentManager, TAG)
|
||||
}
|
||||
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
|
||||
})
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
fun onReadAfterRequest(activity: Activity) {
|
||||
activity.runOnUiThread(Runnable {
|
||||
if (timerToShowDelayDialog == null) return@Runnable
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readBeforeRequest(readBeforeRequest: ReadBeforeRequest) {
|
||||
LOG.i(TAG, "readBeforeRequest 111")
|
||||
|
||||
if (timerToShowDelayDialog != null || readBeforeRequest.timeout!! < DELAY_BEFORE_SHOW_DIALOG + MIN_REMAINING_DELAY_TO_SHOW_DIALOG)
|
||||
return
|
||||
|
||||
timerToShowDelayDialog = Timer()
|
||||
timerToShowDelayDialog!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
setup(readBeforeRequest.timeout!!, DELAY_BEFORE_SHOW_DIALOG)
|
||||
isCancelable = false
|
||||
if (!isAdded)
|
||||
show(activity?.supportFragmentManager, TAG)
|
||||
}
|
||||
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readAfterRequest(readAfterRequest: ReadAfterRequest) {
|
||||
LOG.i(TAG, "readAfterRequest 222")
|
||||
|
||||
if (timerToShowDelayDialog == null)
|
||||
return
|
||||
|
||||
timerToShowDelayDialog!!.cancel()
|
||||
timerToShowDelayDialog = null
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readWait(readWait: ReadWait) {
|
||||
LOG.i(TAG, "readWait 333")
|
||||
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog!!.cancel()
|
||||
timerToShowDelayDialog = null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun onReadWait(activity: Activity, msec: Int) {
|
||||
activity.runOnUiThread(Runnable {
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog!!.cancel()
|
||||
timerToShowDelayDialog = null
|
||||
}
|
||||
if (readWait.msec == 0) {
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
|
||||
if (msec == 0) {
|
||||
if (instance != null) {
|
||||
instance!!.dismiss()
|
||||
instance = null
|
||||
}
|
||||
return@Runnable
|
||||
}
|
||||
if (readWait.msec!! > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
|
||||
// 1000ms - card delay notification interval
|
||||
setup(readWait.msec!! + 1000, 1000)
|
||||
isCancelable = false
|
||||
// if (!isAdded)
|
||||
// show(activity?.supportFragmentManager, TAG)
|
||||
|
||||
if (instance == null) {
|
||||
if (msec > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
|
||||
instance = WaitSecurityDelayDialogNew()
|
||||
// 1000ms - card delay notification interval
|
||||
instance!!.setup(msec + 1000, 1000)
|
||||
instance!!.isCancelable = false
|
||||
// instance.show(activity.fragmentManager, TAG)
|
||||
}
|
||||
} else {
|
||||
instance!!.setRemainingTimeout(msec)
|
||||
}
|
||||
})
|
||||
} else
|
||||
setRemainingTimeout(readWait.msec!!)
|
||||
}
|
||||
|
||||
private fun setup(msTimeout: Int, msProgress: Int) {
|
||||
|
|
@ -112,19 +132,20 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
}
|
||||
|
||||
private fun setRemainingTimeout(msec: Int) {
|
||||
progressBar.post {
|
||||
val progress = this@WaitSecurityDelayDialogNew.progressBar.progress
|
||||
pb.post {
|
||||
val progress = pb.progress
|
||||
if (timer != null) {
|
||||
|
||||
// we get delay latency from card for first time - don't change progress by timer, only by card answer
|
||||
progressBar.max = progress + msec
|
||||
pb.max = progress + msec
|
||||
timer!!.cancel()
|
||||
timer = null
|
||||
} else {
|
||||
val newProgress = progressBar.max - msec
|
||||
if (newProgress > progress)
|
||||
progressBar.progress = newProgress
|
||||
val newProgress = pb.max - msec
|
||||
if (pb.max > progress)
|
||||
pb.progress = newProgress
|
||||
else
|
||||
progressBar.max = progress + msec
|
||||
pb.max = progress + msec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
package com.tangem.presentation.event
|
||||
|
||||
class ReadAfterRequest {
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.tangem.presentation.event
|
||||
|
||||
class ReadBeforeRequest {
|
||||
var timeout: Int? = null
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.tangem.presentation.event
|
||||
|
||||
class ReadWait {
|
||||
var msec: Int? = null
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue