Updated on 2026-08-14
This commit is contained in:
commit
bdd27a5dfd
28 changed files with 390 additions and 193 deletions
|
|
@ -3,10 +3,13 @@ package com.tangem;
|
|||
import android.app.Application;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
|
||||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.di.DaggerNavigatorComponent;
|
||||
import com.tangem.di.DaggerNetworkComponent;
|
||||
import com.tangem.di.NavigatorComponent;
|
||||
import com.tangem.di.NetworkComponent;
|
||||
import com.tangem.domain.cardReader.Firmwares;
|
||||
import com.tangem.domain.wallet.Issuer;
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
|
|
@ -38,6 +41,16 @@ public class App extends Application {
|
|||
|
||||
networkComponent = DaggerNetworkComponent.create();
|
||||
navigatorComponent = buildNavigatorComponent();
|
||||
|
||||
// common init
|
||||
if (PINStorage.needInit())
|
||||
PINStorage.init(getApplicationContext());
|
||||
|
||||
if (Issuer.needInit())
|
||||
Issuer.init(getApplicationContext());
|
||||
|
||||
if (Firmwares.needInit())
|
||||
Firmwares.init(getApplicationContext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem
|
|||
|
||||
object Constant {
|
||||
|
||||
|
||||
const val EXTRA_BLOCKCHAIN_DATA = "BLOCKCHAIN_DATA"
|
||||
|
||||
const val MESSAGE = "Message"
|
||||
|
|
@ -10,4 +9,35 @@ object Constant {
|
|||
|
||||
const val EXTRA_MODIFICATION = "modification"
|
||||
|
||||
// LoadedWallet, VerifyCard
|
||||
const val REQUEST_CODE_SEND_PAYMENT = 1
|
||||
const val REQUEST_CODE_PURGE = 2
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3
|
||||
const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
const val REQUEST_CODE_ENTER_NEW_PIN = 5
|
||||
const val REQUEST_CODE_ENTER_NEW_PIN2 = 6
|
||||
const val REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7
|
||||
const val REQUEST_CODE_SWAP_PIN = 8
|
||||
const val REQUEST_CODE_RECEIVE_PAYMENT = 9
|
||||
|
||||
// MainActivity
|
||||
const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
const val REQUEST_CODE_ENTER_PIN_ACTIVITY = 2
|
||||
const val REQUEST_CODE_SEND_EMAIL = 3
|
||||
const val REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3
|
||||
|
||||
const val EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"
|
||||
const val EXTRA_PIN2 = "PIN2"
|
||||
|
||||
// LogoActivity
|
||||
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"
|
||||
|
||||
}
|
||||
67
app/src/main/java/com/tangem/data/nfc/ReadCardInfoTask.java
Normal file
67
app/src/main/java/com/tangem/data/nfc/ReadCardInfoTask.java
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
package com.tangem.data.nfc;
|
||||
|
||||
import android.content.Context;
|
||||
import android.nfc.tech.IsoDep;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.NfcManager;
|
||||
import com.tangem.data.db.PINStorage;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReadCardInfoTask extends Thread {
|
||||
public static final String TAG = ReadCardInfoTask.class.getSimpleName();
|
||||
|
||||
private IsoDep mIsoDep;
|
||||
private CardProtocol.Notifications mNotifications;
|
||||
private boolean isCancelled = false;
|
||||
private Context mContext;
|
||||
private NfcManager mNfcManager;
|
||||
|
||||
// this fields are static to optimize process when need enter pin and scan card again
|
||||
private static ArrayList<String> lastRead_UnsuccessfullPINs = new ArrayList<>();
|
||||
private static TangemCard.EncryptionMode lastRead_Encryption = null;
|
||||
private static String lastRead_UID;
|
||||
|
||||
public static void resetLastReadInfo() {
|
||||
lastRead_UID = "";
|
||||
lastRead_Encryption = null;
|
||||
lastRead_UnsuccessfullPINs.clear();
|
||||
}
|
||||
|
||||
public ReadCardInfoTask(Context context, NfcManager nfcManager, IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
mContext = context;
|
||||
mIsoDep = isoDep;
|
||||
mNotifications = notifications;
|
||||
mNfcManager = nfcManager;
|
||||
// ReadCardInfoTask.lastRead_UID = lastRead_UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mIsoDep == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// for Samsung's bugs -
|
||||
// Workaround for the Samsung Galaxy S5 (since the
|
||||
// first connection always hangs on transceive).
|
||||
int timeout = mIsoDep.getTimeout();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.close();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.setTimeout(timeout);
|
||||
try {
|
||||
CardProtocol protocol = new CardProtocol(mContext, mIsoDep, mNotifications);
|
||||
mNotifications.onReadStart(protocol);
|
||||
try {
|
||||
mNotifications.onReadProgress(protocol, 5);
|
||||
|
||||
byte[] UID = mIsoDep.getTag().getId();
|
||||
String sUID = Util.byteArrayToHexString(UID);
|
||||
if (!lastRead_UID.equals(sUID)) {
|
||||
resetLastReadInfo();
|
||||
}
|
||||
103
app/src/main/java/com/tangem/data/nfc/VerifyCardTask.java
Normal file
103
app/src/main/java/com/tangem/data/nfc/VerifyCardTask.java
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
/**
|
||||
* Created by dvol on 04.02.2018.
|
||||
*/
|
||||
|
||||
public class VerifyCardTask extends Thread {
|
||||
public static final String TAG = VerifyCardTask.class.getSimpleName();
|
||||
|
||||
private IsoDep mIsoDep;
|
||||
private CardProtocol.Notifications mNotifications;
|
||||
private boolean isCancelled = false;
|
||||
private Context mContext;
|
||||
private TangemCard mCard;
|
||||
private NfcManager mNfcManager;
|
||||
|
||||
public VerifyCardTask(Context context, TangemCard card, NfcManager nfcManager, IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
mCard = card;
|
||||
mContext = context;
|
||||
mIsoDep = isoDep;
|
||||
mNotifications = notifications;
|
||||
mNfcManager = nfcManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (mIsoDep == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// for Samsung's bugs -
|
||||
// Workaround for the Samsung Galaxy S5 (since the
|
||||
// first connection always hangs on transceive).
|
||||
int timeout = mIsoDep.getTimeout();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.close();
|
||||
mIsoDep.connect();
|
||||
mIsoDep.setTimeout(timeout);
|
||||
try {
|
||||
CardProtocol protocol = new CardProtocol(mContext, mIsoDep, mCard, mNotifications);
|
||||
mNotifications.onReadStart(protocol);
|
||||
try {
|
||||
mNotifications.onReadProgress(protocol, 5);
|
||||
|
||||
Log.i(TAG, "[-- Start verify card --]");
|
||||
|
||||
if (isCancelled) return;
|
||||
|
||||
String PIN = mCard.getPIN();
|
||||
protocol.setPIN(PIN);
|
||||
protocol.run_Read(false);
|
||||
PINStorage.setLastUsedPIN(PIN);
|
||||
mNotifications.onReadProgress(protocol, 20);
|
||||
if (isCancelled) return;
|
||||
protocol.run_VerifyCard();
|
||||
mNotifications.onReadProgress(protocol, 50);
|
||||
Log.i(TAG, "Manufacturer: " + protocol.getCard().getManufacturer().getOfficialName());
|
||||
if (isCancelled) return;
|
||||
if (protocol.getCard().getStatus() == TangemCard.Status.Loaded) {
|
||||
protocol.run_CheckWalletWithSignatureVerify();
|
||||
mNotifications.onReadProgress(protocol, 80);
|
||||
}
|
||||
if (isCancelled) return;
|
||||
Firmwares.VerifyCodeRecord record = Firmwares.selectRandomVerifyCodeBlock(mCard.getFirmwareVersion());
|
||||
if (isCancelled) return;
|
||||
if (record != null) {
|
||||
byte[] returnedDigest = protocol.run_VerifyCode(record.hashAlg, record.blockIndex, record.blockCount, record.challenge);
|
||||
mCard.setCodeConfirmed(Arrays.equals(returnedDigest, record.digest));
|
||||
} else {
|
||||
mCard.setCodeConfirmed(null);
|
||||
}
|
||||
mNotifications.onReadProgress(protocol, 90);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
protocol.setError(e);
|
||||
|
||||
} finally {
|
||||
Log.i(TAG, "[-- Finish verify card --]");
|
||||
mNotifications.onReadFinish(protocol);
|
||||
}
|
||||
} finally {
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel(Boolean AllowInterrupt) {
|
||||
try {
|
||||
if (isAlive()) {
|
||||
isCancelled = true;
|
||||
join(500);
|
||||
}
|
||||
if (isAlive() && AllowInterrupt) {
|
||||
interrupt();
|
||||
mNotifications.onReadCancel();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,14 +3,16 @@ package com.tangem.di
|
|||
import android.app.Activity
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import com.tangem.Constant
|
||||
import com.tangem.domain.wallet.CoinData
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
import com.tangem.presentation.activity.EmptyWalletActivity
|
||||
import com.tangem.presentation.activity.LoadedWalletActivity
|
||||
import com.tangem.presentation.activity.MainActivity
|
||||
import com.tangem.presentation.activity.VerifyCardActivity
|
||||
import com.tangem.presentation.fragment.LoadedWallet
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
import com.tangem.presentation.activity.*
|
||||
|
||||
class Navigator {
|
||||
|
||||
|
|
@ -18,8 +20,21 @@ class Navigator {
|
|||
context.startActivity(MainActivity.callingIntent(context))
|
||||
}
|
||||
|
||||
fun showLogo(context: Activity, autoHide: Boolean) {
|
||||
context.startActivity(LogoActivity.callingIntent(context, autoHide))
|
||||
}
|
||||
|
||||
fun showPinSave(context: Activity, hasPin2: Boolean) {
|
||||
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, ctx: TangemContext) {
|
||||
context.startActivityForResult(LoadedWalletActivity.callingIntent(context, lastTag, ctx), MainActivity.REQUEST_CODE_SHOW_CARD_ACTIVITY)
|
||||
context.startActivityForResult(LoadedWalletActivity.callingIntent(context, lastTag, ctx), Constant.REQUEST_CODE_SHOW_CARD_ACTIVITY)
|
||||
}
|
||||
|
||||
fun showEmptyWallet(context: Activity, ctx: TangemContext) {
|
||||
|
|
@ -27,19 +42,25 @@ class Navigator {
|
|||
}
|
||||
|
||||
fun showVerifyCard(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(VerifyCardActivity.callingIntent(context, ctx), LoadedWallet.REQUEST_CODE_VERIFY_CARD)
|
||||
context.startActivityForResult(VerifyCardActivity.callingIntent(context, ctx), 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 showVerifyCard(context: Activity, ctx: TangemContext) {
|
||||
context.startActivityForResult(VerifyCardActivity.callingIntent(context, ctx), Constant.REQUEST_CODE_VERIFY_CARD)
|
||||
}
|
||||
|
||||
fun showPurge(context: Activity) {
|
||||
|
||||
}
|
||||
|
||||
// fun showPreparePayment(context: Activity) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// fun showCreateNewWallet(context: Activity) {
|
||||
//
|
||||
// }
|
||||
fun showPreparePayment(context: Activity) {
|
||||
|
||||
}
|
||||
|
||||
fun showCreateNewWallet(context: Activity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_confirm_payment)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_create_new_wallet)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_empty_wallet)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.nfc.Tag
|
|||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.fragment.LoadedWallet
|
||||
|
|
@ -21,7 +22,7 @@ class LoadedWalletActivity : AppCompatActivity() {
|
|||
companion object {
|
||||
fun callingIntent(context: Context, lastTag: Tag, ctx: TangemContext): Intent {
|
||||
val intent = Intent(context, LoadedWalletActivity::class.java)
|
||||
intent.putExtra(MainActivity.EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
||||
intent.putExtra(Constant.EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
||||
ctx.saveToIntent(intent)
|
||||
return intent
|
||||
}
|
||||
|
|
@ -33,7 +34,7 @@ class LoadedWalletActivity : AppCompatActivity() {
|
|||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
if (intent.extras!!.containsKey(NfcAdapter.EXTRA_TAG)) {
|
||||
val tag = intent.getParcelableExtra<Tag>(NfcAdapter.EXTRA_TAG)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.wallet.BuildConfig
|
||||
import com.tangem.wallet.R
|
||||
|
|
@ -15,8 +18,11 @@ class LogoActivity : AppCompatActivity() {
|
|||
companion object {
|
||||
val TAG: String = LogoActivity::class.java.simpleName
|
||||
|
||||
const val EXTRA_AUTO_HIDE = "extra_auto_hide"
|
||||
const val MILLIS_AUTO_HIDE = 1000
|
||||
fun callingIntent(context: Context, autoHide: Boolean): Intent {
|
||||
val intent = Intent(context, LogoActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_AUTO_HIDE, autoHide)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
private val hideRunnable = Runnable { this.hide() }
|
||||
|
|
@ -42,8 +48,8 @@ class LogoActivity : AppCompatActivity() {
|
|||
else
|
||||
tvAppVersion.text = "BETA v." + BuildConfig.VERSION_NAME
|
||||
|
||||
if (intent.getBooleanExtra(EXTRA_AUTO_HIDE, true))
|
||||
ivLogo.postDelayed(hideRunnable, MILLIS_AUTO_HIDE.toLong())
|
||||
if (intent.getBooleanExtra(Constant.EXTRA_AUTO_HIDE, true))
|
||||
ivLogo.postDelayed(hideRunnable, Constant.MILLIS_AUTO_HIDE.toLong())
|
||||
}
|
||||
|
||||
private fun hide() {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import android.widget.RelativeLayout
|
|||
import android.widget.Toast
|
||||
import com.scottyab.rootbeer.RootBeer
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.Logger
|
||||
import com.tangem.tangemcard.data.local.PINStorage
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
|
|
@ -55,25 +56,18 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
companion object {
|
||||
val TAG: String = MainActivity::class.java.simpleName
|
||||
|
||||
private const val REQUEST_CODE_SEND_EMAIL = 3
|
||||
private const val REQUEST_CODE_ENTER_PIN_ACTIVITY = 2
|
||||
const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
private const val REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3
|
||||
|
||||
const val EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"
|
||||
|
||||
fun callingIntent(context: Context) = Intent(context, MainActivity::class.java)
|
||||
|
||||
fun commonInit(context: Context) {
|
||||
if (PINStorage.needInit())
|
||||
PINStorage.init(context)
|
||||
|
||||
if (Issuer.needInit())
|
||||
Issuer.init(context)
|
||||
|
||||
if (Firmwares.needInit())
|
||||
Firmwares.init(context)
|
||||
}
|
||||
// fun commonInit(context: Context) {
|
||||
// if (PINStorage.needInit())
|
||||
// PINStorage.init(context)
|
||||
//
|
||||
// if (Issuer.needInit())
|
||||
// Issuer.init(context)
|
||||
//
|
||||
// if (Firmwares.needInit())
|
||||
// Firmwares.init(context)
|
||||
// }
|
||||
}
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
|
@ -110,7 +104,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
|
||||
|
||||
commonInit(applicationContext)
|
||||
// commonInit(applicationContext)
|
||||
|
||||
setNfcAdapterReaderCallback(this)
|
||||
|
||||
|
|
@ -158,7 +152,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
// check if root device
|
||||
val rootBeer = RootBeer(this)
|
||||
if (rootBeer.isRootedWithoutBusyBoxCheck && !BuildConfig.DEBUG)
|
||||
RootFoundDialog().show(fragmentManager, RootFoundDialog.TAG)
|
||||
RootFoundDialog().show(supportFragmentManager, RootFoundDialog.TAG)
|
||||
|
||||
// set listeners
|
||||
fab.setOnClickListener { showMenu(it) }
|
||||
|
|
@ -183,19 +177,19 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
NfcManager.verifyPermissions(this)
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.e("QRScanActivity", "User hasn't granted permission to use camera")
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS)
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), Constant.REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_SEND_EMAIL -> {
|
||||
Constant.REQUEST_CODE_SEND_EMAIL -> {
|
||||
if (zipFile != null) {
|
||||
zipFile!!.delete()
|
||||
zipFile = null
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_ENTER_PIN_ACTIVITY -> {
|
||||
Constant.REQUEST_CODE_ENTER_PIN_ACTIVITY -> {
|
||||
if (resultCode == Activity.RESULT_OK && lastTag != null)
|
||||
onTagDiscovered(lastTag!!)
|
||||
else
|
||||
|
|
@ -219,7 +213,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val id = item.itemId
|
||||
|
||||
when (id) {
|
||||
R.id.sendLogs -> {
|
||||
var f: File? = null
|
||||
|
|
@ -240,17 +233,17 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
return true
|
||||
}
|
||||
R.id.managePIN -> {
|
||||
showSavePinActivity()
|
||||
navigator.showPinSave(this, false)
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.managePIN2 -> {
|
||||
showSavePin2Activity()
|
||||
navigator.showPinSave(this, true)
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.about -> {
|
||||
showLogoActivity()
|
||||
navigator.showLogo(this, false)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -311,6 +304,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
}
|
||||
|
||||
override fun onReadProgress(protocol: CardProtocol, progress: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onReadFinish(cardProtocol: CardProtocol?) {
|
||||
|
|
@ -355,7 +349,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)
|
||||
|
|
@ -406,13 +400,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
onNfcReaderCallback = callback
|
||||
}
|
||||
|
||||
private fun showLogoActivity() {
|
||||
val intent = Intent(baseContext, LogoActivity::class.java)
|
||||
intent.putExtra(LogoActivity.TAG, true)
|
||||
intent.putExtra(LogoActivity.EXTRA_AUTO_HIDE, false)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun animate() {
|
||||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
|
|
@ -433,18 +420,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
llHand.startAnimation(a)
|
||||
}
|
||||
|
||||
private fun showSavePinActivity() {
|
||||
val intent = Intent(baseContext, PinSaveActivity::class.java)
|
||||
intent.putExtra("PIN2", false)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun showSavePin2Activity() {
|
||||
val intent = Intent(baseContext, PinSaveActivity::class.java)
|
||||
intent.putExtra("PIN2", true)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun showMenu(v: View) {
|
||||
val popup = PopupMenu(this, v)
|
||||
val inflater = popup.menuInflater
|
||||
|
|
@ -460,10 +435,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, REQUEST_CODE_ENTER_PIN_ACTIVITY)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ 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.tangemcard.reader.NfcManager
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
|
|
@ -34,6 +35,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
|
||||
|
|
@ -53,7 +60,7 @@ class PinRequestActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Finge
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pin_request)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.annotation.TargetApi
|
|||
import android.app.Dialog
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.hardware.fingerprint.FingerprintManager
|
||||
import android.os.Build
|
||||
|
|
@ -19,6 +20,7 @@ import android.text.TextUtils
|
|||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import com.tangem.Constant
|
||||
import com.tangem.data.fingerprint.ConfirmWithFingerprintTask
|
||||
import com.tangem.data.fingerprint.FingerprintHelper
|
||||
import com.tangem.tangemcard.data.local.PINStorage
|
||||
|
|
@ -38,6 +40,16 @@ import javax.crypto.spec.IvParameterSpec
|
|||
|
||||
class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelperListener {
|
||||
|
||||
companion object {
|
||||
val TAG: String = PinSaveActivity::class.java.simpleName
|
||||
|
||||
fun callingIntent(context: Context, hasPin2: Boolean): Intent {
|
||||
val intent = Intent(context, PinSaveActivity::class.java)
|
||||
intent.putExtra(Constant.EXTRA_PIN2, hasPin2)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
private var confirmWithFingerprintTask: ConfirmWithFingerprintTask? = null
|
||||
private var keyStore: KeyStore? = null
|
||||
private var cipher: Cipher? = null
|
||||
|
|
@ -56,9 +68,9 @@ class PinSaveActivity : AppCompatActivity(), FingerprintHelper.FingerprintHelper
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pin_save)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
usePIN2 = intent.getBooleanExtra("PIN2", false)
|
||||
usePIN2 = intent.getBooleanExtra(Constant.EXTRA_PIN2, false)
|
||||
|
||||
if (usePIN2)
|
||||
tvPinPrompt.text = getString(R.string.enter_pin2_and_use_fingerprint_to_save_it)
|
||||
|
|
|
|||
|
|
@ -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,6 +13,7 @@ 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.tangemcard.tasks.SwapPINTask
|
||||
import com.tangem.tangemcard.reader.CardProtocol
|
||||
import com.tangem.tangemcard.reader.NfcManager
|
||||
|
|
@ -27,6 +29,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
|
||||
}
|
||||
|
||||
|
|
@ -44,15 +53,15 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_pin_swap)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_cryptonit_other_api_withdrawal)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
tvCurrency.text = engine!!.balanceCurrency
|
||||
|
||||
etAmount.setText(engine.convertToAmount(engine.convertToInternalAmount(ctx.card!!.denomination)).toValueString())
|
||||
etAmount.filters=engine.amountInputFilters
|
||||
etAmount.filters = engine.amountInputFilters
|
||||
|
||||
// set listeners
|
||||
btnLoad.setOnClickListener {
|
||||
|
|
@ -66,7 +66,7 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
val strAmount: String = etAmount.text.toString().replace(",", ".")
|
||||
// if (!engine.checkAmount(card, strAmount))
|
||||
// etAmount.error = getString(R.string.unknown_amount_format)
|
||||
var dblAmount: Double = strAmount.toDouble()
|
||||
val dblAmount: Double = strAmount.toDouble()
|
||||
|
||||
rlProgressBar.visibility = View.VISIBLE
|
||||
tvProgressDescription.text = getString(R.string.cryptonit_request_withdrawal)
|
||||
|
|
@ -177,8 +177,8 @@ class PrepareCryptonitOtherApiWithdrawalActivity : AppCompatActivity(), NfcAdapt
|
|||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if( resultCode == Activity.RESULT_OK && data != null && data.extras!!.containsKey("QRCode") ) {
|
||||
when(requestCode) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null && data.extras!!.containsKey("QRCode")) {
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_SCAN_QR_KEY -> {
|
||||
cryptonit!!.key = data.getStringExtra("QRCode")
|
||||
tvKey!!.text = cryptonit!!.key
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class PrepareCryptonitWithdrawalActivity : AppCompatActivity(), NfcAdapter.Reade
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_cryptonit_withdrawal)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class PrepareKrakenWithdrawalActivity : AppCompatActivity(), NfcAdapter.ReaderCa
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_kraken_withdrawal)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class PreparePaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_prepare_payment)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
ctx = TangemContext.loadFromBundle(this, intent.extras)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class SendTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_send_transaction)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import com.tangem.tangemcard.util.Util
|
|||
import com.tangem.wallet.R
|
||||
import kotlinx.android.synthetic.main.activity_sign_payment.*
|
||||
|
||||
|
||||
class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
companion object {
|
||||
|
|
@ -61,7 +60,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_sign_payment)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class VerifyCardActivity : AppCompatActivity() {
|
|||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
MainActivity.commonInit(applicationContext)
|
||||
// MainActivity.commonInit(applicationContext)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package com.tangem.presentation.dialog
|
|||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.app.DialogFragment
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.DialogFragment
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
|
||||
if (msec == 0) {
|
||||
if (instance != null) {
|
||||
// TODO java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentManager.beginTransaction()' on a null object reference
|
||||
instance.dismiss();
|
||||
instance = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import com.tangem.Constant
|
||||
import com.tangem.tangemcard.data.local.LocalStorage
|
||||
import com.tangem.tangemcard.data.local.PINStorage
|
||||
import com.tangem.data.network.ElectrumRequest
|
||||
|
|
@ -57,15 +58,6 @@ import java.util.*
|
|||
class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
companion object {
|
||||
val TAG: String = LoadedWallet::class.java.simpleName
|
||||
private const val REQUEST_CODE_SEND_PAYMENT = 1
|
||||
const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
private const val REQUEST_CODE_PURGE = 2
|
||||
private const val REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3
|
||||
private const val REQUEST_CODE_ENTER_NEW_PIN = 5
|
||||
private const val REQUEST_CODE_ENTER_NEW_PIN2 = 6
|
||||
private const val REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7
|
||||
private const val REQUEST_CODE_SWAP_PIN = 8
|
||||
private const val REQUEST_CODE_RECEIVE_PAYMENT = 9
|
||||
}
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
|
@ -98,7 +90,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
|
||||
ctx = TangemContext.loadFromBundle(activity, activity?.intent?.extras)
|
||||
|
||||
lastTag = activity?.intent?.getParcelableExtra(MainActivity.EXTRA_LAST_DISCOVERED_TAG)
|
||||
lastTag = activity?.intent?.getParcelableExtra(Constant.EXTRA_LAST_DISCOVERED_TAG)
|
||||
|
||||
localStorage = activity?.let { LocalStorage(it) }!!
|
||||
}
|
||||
|
|
@ -167,12 +159,12 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
getString(R.string.via_cryptonit) -> {
|
||||
val intent = Intent(activity, PrepareCryptonitWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
}
|
||||
getString(R.string.via_kraken) -> {
|
||||
val intent = Intent(activity, PrepareKrakenWithdrawalActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_RECEIVE_PAYMENT)
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
|
|
@ -212,7 +204,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
else {
|
||||
val intent = Intent(activity, PreparePaymentActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_SEND_PAYMENT)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_PAYMENT)
|
||||
}
|
||||
} else
|
||||
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
|
||||
|
|
@ -502,46 +494,46 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
var data = data
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_VERIFY_CARD ->
|
||||
Constant.REQUEST_CODE_VERIFY_CARD ->
|
||||
// action when erase wallet
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (activity != null)
|
||||
activity?.finish()
|
||||
}
|
||||
|
||||
REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.extras != null && data.extras!!.containsKey("confirmPIN")) {
|
||||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
newPIN = data.getStringExtra("newPIN")
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
} else {
|
||||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("newPIN", data.getStringExtra("newPIN"))
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.ConfirmNewPIN.toString())
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN)
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_ENTER_NEW_PIN2 -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN2 -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.extras != null && data.extras!!.containsKey("confirmPIN2")) {
|
||||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
newPIN2 = data.getStringExtra("newPIN2")
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
} else {
|
||||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("newPIN2", data.getStringExtra("newPIN2"))
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.ConfirmNewPIN2.toString())
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (newPIN == "")
|
||||
newPIN = ctx.card!!.pin
|
||||
|
||||
|
|
@ -549,7 +541,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))
|
||||
|
|
@ -559,13 +551,13 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
|
||||
}
|
||||
|
||||
REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
data = Intent()
|
||||
ctx.saveToIntent(data)
|
||||
data.putExtra("modification", "delete")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "delete")
|
||||
} else
|
||||
data.putExtra("modification", "update")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
|
||||
activity?.setResult(Activity.RESULT_OK, data)
|
||||
activity?.finish()
|
||||
|
|
@ -581,7 +573,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
return
|
||||
} else {
|
||||
if (data != null && data.extras!!.containsKey("message")) {
|
||||
|
|
@ -589,18 +581,18 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_REQUEST_PIN2_FOR_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
val intent = Intent(activity, PurgeActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_PURGE)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_PURGE)
|
||||
}
|
||||
REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
data = Intent()
|
||||
ctx.saveToIntent(data)
|
||||
data.putExtra("modification", "delete")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "delete")
|
||||
} else {
|
||||
data.putExtra("modification", "update")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
}
|
||||
|
||||
activity?.setResult(Activity.RESULT_OK, data)
|
||||
|
|
@ -617,7 +609,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
val intent = Intent(activity, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
return
|
||||
} else {
|
||||
if (data != null && data.extras!!.containsKey("message")) {
|
||||
|
|
@ -626,7 +618,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
|
|||
}
|
||||
updateViews()
|
||||
}
|
||||
REQUEST_CODE_SEND_PAYMENT, REQUEST_CODE_RECEIVE_PAYMENT -> {
|
||||
Constant.REQUEST_CODE_SEND_PAYMENT, Constant.REQUEST_CODE_RECEIVE_PAYMENT -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
ctx.coinData?.clearInfo()
|
||||
srl?.postDelayed({ this.refresh() }, 5000)
|
||||
|
|
@ -887,17 +879,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) {
|
||||
|
|
@ -955,14 +940,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, REQUEST_CODE_SWAP_PIN)
|
||||
}
|
||||
|
||||
private var showTime: Date = Date()
|
||||
|
||||
private fun showSingleToast(text: Int) {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,9 @@ import android.widget.PopupMenu
|
|||
import android.widget.Toast
|
||||
import com.tangem.tangemcard.data.local.PINStorage
|
||||
import com.tangem.tangemcard.reader.NfcManager
|
||||
import com.tangem.Constant
|
||||
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.tangemcard.data.Blockchain
|
||||
import com.tangem.tangemcard.data.TangemCard
|
||||
|
|
@ -34,14 +32,6 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
companion object {
|
||||
val TAG: String = VerifyCard::class.java.simpleName
|
||||
|
||||
private const val REQUEST_CODE_SEND_PAYMENT = 1
|
||||
private const val REQUEST_CODE_PURGE = 2
|
||||
private const val REQUEST_CODE_REQUEST_PIN2_FOR_PURGE = 3
|
||||
private const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
private const val REQUEST_CODE_ENTER_NEW_PIN = 5
|
||||
private const val REQUEST_CODE_ENTER_NEW_PIN2 = 6
|
||||
private const val REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7
|
||||
private const val REQUEST_CODE_SWAP_PIN = 8
|
||||
}
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
|
@ -74,7 +64,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
fabMenu.setOnClickListener { showMenu(fabMenu) }
|
||||
btnOk.setOnClickListener {
|
||||
val data = prepareResultIntent()
|
||||
data.putExtra("modification", "update")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
activity?.finish()
|
||||
}
|
||||
}
|
||||
|
|
@ -98,45 +88,45 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
var data = data
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
when (requestCode) {
|
||||
REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.extras!!.containsKey("confirmPIN")) {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
newPIN = data.getStringExtra("newPIN")
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
} else {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("newPIN", data.getStringExtra("newPIN"))
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.ConfirmNewPIN.toString())
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN)
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_ENTER_NEW_PIN2 -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_ENTER_NEW_PIN2 -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.extras!!.containsKey("confirmPIN2")) {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
newPIN2 = data.getStringExtra("newPIN2")
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
} else {
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("newPIN2", data.getStringExtra("newPIN2"))
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.ConfirmNewPIN2.toString())
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (newPIN == "") newPIN = ctx.card!!.pin
|
||||
|
||||
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))
|
||||
|
|
@ -146,7 +136,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
|
||||
}
|
||||
|
||||
REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
data = Intent()
|
||||
ctx.saveToIntent(data)
|
||||
|
|
@ -166,7 +156,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
return
|
||||
} else {
|
||||
if (data != null && data.extras!!.containsKey("message")) {
|
||||
|
|
@ -174,18 +164,18 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_REQUEST_PIN2_FOR_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
val intent = Intent(context, PurgeActivity::class.java)
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_PURGE)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_PURGE)
|
||||
}
|
||||
REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
Constant.REQUEST_CODE_PURGE -> if (resultCode == Activity.RESULT_OK) {
|
||||
if (data == null) {
|
||||
data = Intent()
|
||||
ctx.saveToIntent(data)
|
||||
data.putExtra("modification", "delete")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "delete")
|
||||
} else {
|
||||
data.putExtra("modification", "update")
|
||||
data.putExtra(Constant.EXTRA_MODIFICATION, "update")
|
||||
}
|
||||
activity!!.setResult(Activity.RESULT_OK, data)
|
||||
activity!!.finish()
|
||||
|
|
@ -198,9 +188,9 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
if (resultCode == CreateNewWalletActivity.RESULT_INVALID_PIN && requestPIN2Count < 2) {
|
||||
requestPIN2Count++
|
||||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
intent.putExtra(Constant.EXTRA_MODE, PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
return
|
||||
} else {
|
||||
if (data != null && data.extras!!.containsKey("message")) {
|
||||
|
|
@ -209,7 +199,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
}
|
||||
updateViews()
|
||||
}
|
||||
REQUEST_CODE_SEND_PAYMENT -> {
|
||||
Constant.REQUEST_CODE_SEND_PAYMENT -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
srlVerifyCard.isRefreshing = true
|
||||
ctx.coinData!!.clearInfo()
|
||||
|
|
@ -424,7 +414,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
intent.putExtra("mode", PinRequestActivity.Mode.RequestNewPIN.toString())
|
||||
newPIN = ""
|
||||
newPIN2 = ""
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN)
|
||||
}
|
||||
|
||||
private fun doResetPin() {
|
||||
|
|
@ -434,7 +424,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
ctx.saveToIntent(intent)
|
||||
newPIN = PINStorage.getDefaultPIN()
|
||||
newPIN2 = ""
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
}
|
||||
|
||||
private fun doResetPin2() {
|
||||
|
|
@ -444,7 +434,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
ctx.saveToIntent(intent)
|
||||
newPIN = ""
|
||||
newPIN2 = PINStorage.getDefaultPIN2()
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
}
|
||||
|
||||
private fun doResetPins() {
|
||||
|
|
@ -454,7 +444,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
ctx.saveToIntent(intent)
|
||||
newPIN = PINStorage.getDefaultPIN()
|
||||
newPIN2 = PINStorage.getDefaultPIN2()
|
||||
startActivityForResult(intent, REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN)
|
||||
}
|
||||
|
||||
private fun doSetPin2() {
|
||||
|
|
@ -463,7 +453,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
intent.putExtra("mode", PinRequestActivity.Mode.RequestNewPIN2.toString())
|
||||
newPIN = ""
|
||||
newPIN2 = ""
|
||||
startActivityForResult(intent, REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_ENTER_NEW_PIN2)
|
||||
}
|
||||
|
||||
private fun doPurge() {
|
||||
|
|
@ -479,15 +469,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
|
|||
val intent = Intent(context, PinRequestActivity::class.java)
|
||||
intent.putExtra("mode", PinRequestActivity.Mode.RequestPIN2.toString())
|
||||
ctx.saveToIntent(intent)
|
||||
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)
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_REQUEST_PIN2_FOR_PURGE)
|
||||
}
|
||||
|
||||
fun prepareResultIntent(): Intent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue