Updated on 2026-08-14

This commit is contained in:
Tangem 2018-11-27 00:28:00 +03:00
parent 3910e5011d
commit 08df7c0fc3
16 changed files with 101 additions and 108 deletions

View file

@ -28,12 +28,12 @@ class Navigator {
context.startActivityForResult(VerifyCardActivity.callingIntent(context, card), LoadedWallet.REQUEST_CODE_VERIFY_CARD)
}
fun showPreparePayment(context: Activity) {
}
fun showCreateNewWallet(context: Activity) {
}
// fun showPreparePayment(context: Activity) {
//
// }
//
// fun showCreateNewWallet(context: Activity) {
//
// }
}

View file

@ -14,7 +14,7 @@ import android.nfc.tech.IsoDep;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.support.v4.app.FragmentActivity;
import com.tangem.presentation.dialog.NfcEnableDialog;
@ -26,36 +26,34 @@ public class NfcManager {
// reader mode flags: listen for type A (not B), skipping ndef check
private static final int READER_FLAGS = NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS;
private NfcAdapter mNfcAdapter;
private NfcAdapter nfcAdapter;
private NfcEnableDialog mEnableNfcDialog;
private Activity mActivity;
private FragmentActivity activity;
private NfcAdapter.ReaderCallback mReaderCallback;
private boolean broadcomWorkaround = false;
private static final int DELAY_PRESENCE = 1500;
public NfcManager(Activity activity, NfcAdapter.ReaderCallback readerCallback) {
mActivity = activity;
public NfcManager(FragmentActivity activity, NfcAdapter.ReaderCallback readerCallback) {
this.activity = activity;
mReaderCallback = readerCallback;
mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
}
public void onResume() {
// register broadcast receiver
IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED);
mActivity.registerReceiver(mBroadcastReceiver, filter);
activity.registerReceiver(mBroadcastReceiver, filter);
if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) {
if (nfcAdapter == null || !nfcAdapter.isEnabled())
showNFCEnableDialog();
} else {
else
enableReaderMode();
}
}
public void onPause() {
mActivity.unregisterReceiver(mBroadcastReceiver);
activity.unregisterReceiver(mBroadcastReceiver);
disableReaderMode();
}
@ -67,7 +65,7 @@ public class NfcManager {
public void ignoreTag(Tag tag) throws IOException {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// mNfcAdapter.ignore(tag, 500, null, null);
// nfcAdapter.ignore(tag, 500, null, null);
// }else{
IsoDep isoDep = IsoDep.get(tag);
if (isoDep != null) {
@ -86,10 +84,10 @@ public class NfcManager {
// }
// if (errorCount >= 3) {
// disableReaderMode();
// mNfcAdapter = null;
//// Toast.makeText(mActivity,"NFC restarted!",Toast.LENGTH_SHORT).show();
// mActivity.runOnUiThread(() -> {
// mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
// nfcAdapter = null;
//// Toast.makeText(activity,"NFC restarted!",Toast.LENGTH_SHORT).show();
// activity.runOnUiThread(() -> {
// nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
// enableReaderMode();
// });
// }
@ -97,7 +95,7 @@ public class NfcManager {
private void showNFCEnableDialog() {
mEnableNfcDialog = new NfcEnableDialog();
mEnableNfcDialog.show(mActivity.getFragmentManager(), NfcEnableDialog.Companion.getTAG());
mEnableNfcDialog.show(activity.getSupportFragmentManager(), NfcEnableDialog.Companion.getTAG());
}
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@ -110,7 +108,7 @@ public class NfcManager {
if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) {
int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_ON);
if (state == NfcAdapter.STATE_ON || state == NfcAdapter.STATE_TURNING_ON) {
Log.d(TAG, "state: " + state + " , dialog: " + mEnableNfcDialog);
// Log.d(TAG, "state: " + state + " , dialog: " + mEnableNfcDialog);
if (mEnableNfcDialog != null) {
mEnableNfcDialog.dismiss();
}
@ -136,13 +134,13 @@ public class NfcManager {
*/
options.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, DELAY_PRESENCE);
}
mNfcAdapter.enableReaderMode(mActivity, mReaderCallback, READER_FLAGS, options);
nfcAdapter.enableReaderMode(activity, mReaderCallback, READER_FLAGS, options);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void disableReaderMode() {
if (mNfcAdapter != null) {
mNfcAdapter.disableReaderMode(mActivity);
if (nfcAdapter != null) {
nfcAdapter.disableReaderMode(activity);
}
}
@ -151,8 +149,7 @@ public class NfcManager {
Manifest.permission.NFC
};
//Checks if the app has NFC permission
//If the app does not has permission then the user will be prompted to grant permissions
// checks if the app has NFC permission if the app does not has permission then the user will be prompted to grant permissions
public static void verifyPermissions(Activity activity) {
// Check if we have write permission
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.NFC);

View file

@ -416,11 +416,11 @@ class ConfirmPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback {
}
// get first unspent
val outPut = unspentOutputs[0]
val outPutIndex = outPut.outputIndex
// val outPut = unspentOutputs[0]
// val outPutIndex = outPut.outputIndex
// get prev TX id;
val prevTXID = rawTxList[0].txID//"f67b838d6e2c0c587f476f583843e93ff20368eaf96a798bdc25e01f53f8f5d2";
// val prevTXID = rawTxList[0].txID//"f67b838d6e2c0c587f476f583843e93ff20368eaf96a798bdc25e01f53f8f5d2";
val fees = FormatUtil.ConvertStringToLong(outFee)
var amount = FormatUtil.ConvertStringToLong(outAmount)

View file

@ -149,7 +149,7 @@ class CreateNewWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
progressBar!!.post {
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
}
} else {
Toast.makeText(baseContext, R.string.try_to_scan_again, Toast.LENGTH_SHORT).show()

View file

@ -204,7 +204,7 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
lastReadSuccess = false
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
}
} else {
Toast.makeText(this@EmptyWalletActivity, R.string.try_to_scan_again, Toast.LENGTH_LONG).show()

View file

@ -350,7 +350,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
else {
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported)
if (!NoExtendedLengthSupportDialog.allReadyShowed)
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
lastTag = null
ReadCardInfoTask.resetLastReadInfo()

View file

@ -105,9 +105,9 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
}
override fun onReadStart(cardProtocol: CardProtocol) {
progressBar!!.post {
progressBar!!.visibility = View.VISIBLE
progressBar!!.progress = 5
progressBar?.post {
progressBar?.visibility = View.VISIBLE
progressBar?.progress = 5
}
}
@ -149,7 +149,7 @@ class PinSwapActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProt
else -> progressBar!!.post {
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
}
} else {
Toast.makeText(baseContext, R.string.try_to_scan_again, Toast.LENGTH_SHORT).show()

View file

@ -150,7 +150,7 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
progressBar!!.post {
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed)
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
} else
Toast.makeText(baseContext, R.string.try_to_scan_again, Toast.LENGTH_LONG).show()

View file

@ -200,7 +200,7 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported) {
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
NoExtendedLengthSupportDialog.message = getText(R.string.the_nfc_adapter_length_apdu).toString() + "\n" + getText(R.string.the_nfc_adapter_length_apdu_advice).toString()
NoExtendedLengthSupportDialog().show(fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
}
} else {
Toast.makeText(baseContext, R.string.try_to_scan_again, Toast.LENGTH_LONG).show()

View file

@ -1,10 +1,11 @@
package com.tangem.presentation.dialog
import android.app.Dialog
import android.app.DialogFragment
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import android.support.v4.app.DialogFragment
import android.support.v7.app.AlertDialog
import com.tangem.wallet.R
@ -17,22 +18,22 @@ class NfcEnableDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(activity)
builder.setCancelable(false)
.setIcon(R.drawable.ic_action_nfc_gray)
.setTitle(R.string.nfc_disabled)
.setMessage(R.string.enable_nfc)
.setPositiveButton(R.string.dialog_ok
val builder = context?.let { AlertDialog.Builder(it) }
builder?.setCancelable(false)
?.setIcon(R.drawable.ic_action_nfc_gray)
?.setTitle(R.string.nfc_disabled)
?.setMessage(R.string.enable_nfc)
?.setPositiveButton(R.string.dialog_ok
) { _, _ ->
// take user to wireless settings
activity.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
activity?.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
}
.setNegativeButton(R.string.dialog_quit
?.setNegativeButton(R.string.dialog_quit
) { dialog, _ ->
dialog.cancel()
activity.finish()
activity?.finish()
}
return builder.create()
return builder!!.create()
}
}

View file

@ -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

View file

@ -2,9 +2,9 @@ package com.tangem.presentation.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import com.tangem.wallet.R;

View file

@ -3,9 +3,9 @@ package com.tangem.presentation.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
@ -20,6 +20,8 @@ import java.util.TimerTask;
* Created by dvol on 06.03.2018.
*/
public class WaitSecurityDelayDialog extends DialogFragment {
private static final String TAG = WaitSecurityDelayDialog.class.getSimpleName();
private ProgressBar progressBar;
private int msTimeout = 60000, msProgress = 0;
private Timer timer;
@ -35,7 +37,7 @@ public class WaitSecurityDelayDialog extends DialogFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Inflate and set t he layout for the dialog
// Pass null as the parent view because its going in the dialog layout
View v = inflater.inflate(R.layout.dialog_wait_pin2, null);
@ -117,7 +119,8 @@ public class WaitSecurityDelayDialog extends DialogFragment {
instance = new WaitSecurityDelayDialog();
instance.setup(timeout, DelayBeforeShowDialog);
instance.setCancelable(false);
instance.show(activity.getFragmentManager(), "WaitSecurityDelayDialog");
if (instance.getFragmentManager() != null)
instance.show(instance.getFragmentManager(), TAG);
}
}, DelayBeforeShowDialog);
});
@ -152,11 +155,11 @@ public class WaitSecurityDelayDialog extends DialogFragment {
// 1000ms - card delay notification interval
instance.setup(msec + 1000, 1000);
instance.setCancelable(false);
instance.show(activity.getFragmentManager(), "WaitSecurityDelayDialog");
if (instance.getFragmentManager() != null)
instance.show(instance.getFragmentManager(), TAG);
}
} else {
} else
instance.setRemainingTimeout(msec);
}
});
}

View file

@ -2,7 +2,6 @@ package com.tangem.presentation.fragment
import android.app.Activity
import android.app.AlertDialog
import android.app.Fragment
import android.content.*
import android.content.Context.CLIPBOARD_SERVICE
import android.content.pm.PackageManager
@ -11,6 +10,7 @@ import android.nfc.NfcAdapter
import android.nfc.Tag
import android.nfc.tech.IsoDep
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.text.Html
import android.util.Log
@ -28,15 +28,14 @@ import com.tangem.data.network.ServerApiInfura
import com.tangem.data.network.model.CardVerifyAndGetInfo
import com.tangem.data.network.model.InfuraResponse
import com.tangem.data.nfc.VerifyCardTask
import com.tangem.di.Navigator
import com.tangem.domain.cardReader.CardProtocol
import com.tangem.domain.cardReader.NfcManager
import com.tangem.domain.wallet.*
import com.tangem.domain.wallet.bch.BtcCashEngine
import com.tangem.domain.wallet.btc.BtcData
import com.tangem.domain.wallet.eth.EthData
import com.tangem.domain.wallet.token.TokenData
import com.tangem.domain.wallet.token.TokenEngine
import com.tangem.domain.wallet.bch.BtcCashEngine
import com.tangem.presentation.activity.*
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
import com.tangem.presentation.dialog.PINSwapWarningDialog
@ -50,7 +49,6 @@ import org.json.JSONException
import java.io.InputStream
import java.math.BigInteger
import java.util.*
import javax.inject.Inject
class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, SharedPreferences.OnSharedPreferenceChangeListener {
companion object {
@ -93,11 +91,11 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
super.onCreate(savedInstanceState)
nfcManager = NfcManager(activity, this)
ctx = TangemContext.loadFromBundle(activity, activity.intent.extras)
ctx = TangemContext.loadFromBundle(activity, activity?.intent?.extras)
lastTag = activity.intent.getParcelableExtra(MainActivity.EXTRA_LAST_DISCOVERED_TAG)
lastTag = activity?.intent?.getParcelableExtra(MainActivity.EXTRA_LAST_DISCOVERED_TAG)
localStorage = LocalStorage(activity)
localStorage = activity?.let { LocalStorage(it) }!!
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -122,7 +120,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
tvWallet.text = ctx.card!!.wallet
// set listeners
srl!!.setOnRefreshListener { refresh() }
srl.setOnRefreshListener { refresh() }
btnLookup.setOnClickListener {
val engine = CoinEngineFactory.create(ctx)
val browserIntent = Intent(Intent.ACTION_VIEW, engine!!.shareWalletUriExplorer)
@ -198,10 +196,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
else
showSingleToast(R.string.need_attach_card_again)
}
btnScanAgain.setOnClickListener { (activity as LoadedWalletActivity).navigator.showMain(activity) }
btnScanAgain.setOnClickListener { (activity as LoadedWalletActivity).navigator.showMain(context as Activity) }
btnExtract.setOnClickListener {
val engine = CoinEngineFactory.create(ctx)
if (UtilHelper.isOnline(activity)) {
if (UtilHelper.isOnline(context as Activity)) {
if (!engine!!.isExtractPossible)
showSingleToast(ctx.message)
else if (ctx.card!!.remainingSignatures == 0)
@ -503,7 +501,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
// action when erase wallet
if (resultCode == Activity.RESULT_OK) {
if (activity != null)
activity.finish()
activity?.finish()
}
REQUEST_CODE_ENTER_NEW_PIN -> if (resultCode == Activity.RESULT_OK) {
@ -553,7 +551,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
else
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_use_default))
pinSwapWarningDialog.arguments = bundle
pinSwapWarningDialog.show(activity.fragmentManager, PINSwapWarningDialog.TAG)
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
}
REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
@ -564,10 +562,9 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
} else
data.putExtra("modification", "update")
if (activity != null) {
activity.setResult(Activity.RESULT_OK, data)
activity.finish()
}
activity?.setResult(Activity.RESULT_OK, data)
activity?.finish()
} else {
if (data != null && data.extras != null && data.extras!!.containsKey(TangemCard.EXTRA_UID) && data.extras!!.containsKey(TangemCard.EXTRA_CARD)) {
val updatedCard = TangemCard(data.getStringExtra(TangemCard.EXTRA_UID))
@ -600,10 +597,10 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
} else {
data.putExtra("modification", "update")
}
if (activity != null) {
activity.setResult(Activity.RESULT_OK, data)
activity.finish()
}
activity?.setResult(Activity.RESULT_OK, data)
activity?.finish()
} else {
if (data != null && data.extras != null && data.extras!!.containsKey(TangemCard.EXTRA_UID) && data.extras!!.containsKey(TangemCard.EXTRA_CARD)) {
val updatedCard = TangemCard(data.getStringExtra(TangemCard.EXTRA_UID))
@ -682,7 +679,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
lastReadSuccess = false
if (cardProtocol.error is CardProtocol.TangemException_ExtendedLengthNotSupported)
if (!NoExtendedLengthSupportDialog.allReadyShowed)
NoExtendedLengthSupportDialog().show(activity.fragmentManager, NoExtendedLengthSupportDialog.TAG)
NoExtendedLengthSupportDialog().show(activity?.supportFragmentManager, NoExtendedLengthSupportDialog.TAG)
else
Toast.makeText(activity, R.string.try_to_scan_again, Toast.LENGTH_SHORT).show()
}
@ -756,7 +753,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
} else {
val validator = BalanceValidator()
validator.Check(ctx, false)
tvBalanceLine1.setTextColor(ContextCompat.getColor(activity, validator.color))
context?.let { ContextCompat.getColor(it, validator.color) }?.let { tvBalanceLine1.setTextColor(it) }
tvBalanceLine1.text = validator.firstLine
tvBalanceLine2.text = validator.getSecondLine(false)
}
@ -765,16 +762,13 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
if (engine!!.hasBalanceInfo() || ctx.card!!.offlineBalance == null) {
val html = Html.fromHtml(engine.balanceHTML)
tvBalance.text = html
// TODO???
tvBalanceEquivalent.text = engine.balanceEquivalent
} else {
// TODO
val html = Html.fromHtml(engine.offlineBalanceHTML)
tvBalance.text = html
}
tvWallet.text = ctx.card!!.wallet
// tvBlockchain.text = card!!.blockchainName
if (ctx.card!!.tokenSymbol.length > 1) {
val html = Html.fromHtml(ctx.card!!.blockchainName)
@ -844,7 +838,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
}
private fun requestElectrum(electrumRequest: ElectrumRequest) {
if (UtilHelper.isOnline(activity)) {
if (UtilHelper.isOnline(context as Activity)) {
requestCounter++
serverApiElectrum.electrumRequestData(ctx.card, electrumRequest)
} else {
@ -854,7 +848,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
}
private fun requestInfura(method: String, contract: String) {
if (UtilHelper.isOnline(activity)) {
if (UtilHelper.isOnline(context as Activity)) {
requestCounter++
serverApiInfura.infura(method, 67, ctx.card!!.wallet, contract, "")
} else {
@ -864,7 +858,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
}
private fun requestVerifyAndGetInfo() {
if (UtilHelper.isOnline(activity)) {
if (UtilHelper.isOnline(context as Activity)) {
if ((ctx.card!!.isOnlineVerified == null || !ctx.card!!.isOnlineVerified)) {
serverApiCommon.cardVerifyAndGetInfo(ctx.card)
}
@ -875,7 +869,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
}
private fun requestRateInfo(cryptoId: String) {
if (UtilHelper.isOnline(activity)) {
if (UtilHelper.isOnline(context as Activity)) {
serverApiCommon.rateInfoData(cryptoId)
} else {
Toast.makeText(activity, getString(R.string.no_connection), Toast.LENGTH_SHORT).show()
@ -891,8 +885,7 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
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) {
@ -925,26 +918,26 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
intent.putExtra(Intent.EXTRA_SUBJECT, "Wallet address")
intent.putExtra(Intent.EXTRA_TEXT, txtShare)
val packageManager = activity.packageManager
val activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL)
val isIntentSafe = activities.size > 0
val packageManager = activity?.packageManager
val activities = packageManager?.queryIntentActivities(intent, PackageManager.MATCH_ALL)
val isIntentSafe = activities?.size!! > 0
if (isIntentSafe) {
// create intent to show chooser
val chooser = Intent.createChooser(intent, getString(R.string.share_wallet_address_with))
// verify the intent will resolve to at least one activity
if (intent.resolveActivity(activity.packageManager) != null) {
if (intent.resolveActivity(activity!!.packageManager) != null) {
startActivity(chooser)
}
} else {
val clipboard = activity.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val clipboard = activity?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
clipboard.primaryClip = ClipData.newPlainText(txtShare, txtShare)
Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_LONG).show()
}
} else {
val txtShare = ctx.card!!.wallet
val clipboard = activity.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val txtShare = ctx.card.wallet
val clipboard = activity?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
clipboard.primaryClip = ClipData.newPlainText(txtShare, txtShare)
Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_LONG).show()
}
@ -979,4 +972,5 @@ class LoadedWallet : Fragment(), NfcAdapter.ReaderCallback, CardProtocol.Notific
showTime = Date()
}
}
}

View file

@ -54,7 +54,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
super.onCreate(savedInstanceState)
nfcManager = NfcManager(activity, this)
ctx = TangemContext.loadFromBundle(activity, activity!!.intent.extras)
ctx = TangemContext.loadFromBundle(activity, activity?.intent?.extras)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -73,8 +73,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
btnOk.setOnClickListener {
val data = prepareResultIntent()
data.putExtra("modification", "update")
if (activity != null)
activity!!.finish()
activity?.finish()
}
}
@ -142,7 +141,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
else
bundle.putString(PINSwapWarningDialog.EXTRA_MESSAGE, getString(R.string.if_you_use_default))
pinSwapWarningDialog.arguments = bundle
pinSwapWarningDialog.show(activity!!.fragmentManager, PINSwapWarningDialog.TAG)
pinSwapWarningDialog.show(activity?.supportFragmentManager, PINSwapWarningDialog.TAG)
}
REQUEST_CODE_SWAP_PIN -> if (resultCode == Activity.RESULT_OK) {
@ -279,8 +278,8 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
tvIssuer.text = ctx.card!!.issuerDescription
tvCardRegistredDate.text = ctx.card!!.personalizationDateTimeDescription
val html = Html.fromHtml(ctx.card!!.blockchainName)
tvBlockchain.text = html
val html = Html.fromHtml(ctx.card!!.blockchainName)
tvBlockchain.text = html
tvValidationNode.text = ctx.coinData!!.validationNodeDescription
@ -467,7 +466,7 @@ class VerifyCard : Fragment(), NfcAdapter.ReaderCallback {
private fun doPurge() {
requestPIN2Count = 0
val engine=CoinEngineFactory.create(ctx)
val engine = CoinEngineFactory.create(ctx)
if (!engine!!.hasBalanceInfo()) {
return
} else if (engine.isBalanceNotZero) {

View file

@ -41,7 +41,6 @@
<string name="with_balance">with balance</string>
<string name="send_to_wallet">Send to wallet</string>
<string name="amount">Amount</string>
<!--<string name="including_fee">(including fee)</string>-->
<string name="m_btc">BTC</string>
<string name="scan_again_to_verify_the_card">Scan again to verify the card</string>
<string name="smart_cash_ag">Smart Cash AG</string>