Updated on 2026-08-14
This commit is contained in:
parent
0bc2d0a1d1
commit
49c3ff4427
18 changed files with 78 additions and 90 deletions
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
|
|
@ -86,7 +86,7 @@ public class VerifyCardTask extends Thread {
|
|||
mNotifications.OnReadFinish(protocol);
|
||||
}
|
||||
} finally {
|
||||
mNfcManager.IgnoreTag(mIsoDep.getTag());
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ import com.tangem.presentation.dialog.NFCEnableDialog;
|
|||
import java.io.IOException;
|
||||
|
||||
public class NfcManager {
|
||||
|
||||
private static final String TAG = "NfcManager";
|
||||
public static final String TAG = NfcManager.class.getSimpleName();
|
||||
|
||||
// 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;
|
||||
|
|
@ -40,7 +39,7 @@ public class NfcManager {
|
|||
//
|
||||
// }
|
||||
|
||||
// @Inject
|
||||
// @Inject
|
||||
public NfcManager(Activity activity, NfcAdapter.ReaderCallback readerCallback) {
|
||||
mActivity = activity;
|
||||
mReaderCallback = readerCallback;
|
||||
|
|
@ -53,18 +52,13 @@ public class NfcManager {
|
|||
mActivity.registerReceiver(mBroadcastReceiver, filter);
|
||||
|
||||
if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) {
|
||||
ShowNFCEnableDialog();
|
||||
showNFCEnableDialog();
|
||||
|
||||
} else {
|
||||
enableReaderMode();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowNFCEnableDialog() {
|
||||
mEnableNfcDialog = new NFCEnableDialog();
|
||||
mEnableNfcDialog.show(mActivity.getFragmentManager(), "NFCEnableDialog");
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
mActivity.unregisterReceiver(mBroadcastReceiver);
|
||||
disableReaderMode();
|
||||
|
|
@ -76,7 +70,7 @@ public class NfcManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void IgnoreTag(Tag tag) throws IOException {
|
||||
public void ignoreTag(Tag tag) throws IOException {
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
// mNfcAdapter.ignore(tag, 500, null, null);
|
||||
// }else{
|
||||
|
|
@ -87,6 +81,11 @@ public class NfcManager {
|
|||
// }
|
||||
}
|
||||
|
||||
private void showNFCEnableDialog() {
|
||||
mEnableNfcDialog = new NFCEnableDialog();
|
||||
mEnableNfcDialog.show(mActivity.getFragmentManager(), NFCEnableDialog.TAG);
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
|
@ -95,12 +94,9 @@ public class NfcManager {
|
|||
if (action == null)
|
||||
return;
|
||||
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);
|
||||
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);
|
||||
if (mEnableNfcDialog != null) {
|
||||
mEnableNfcDialog.dismiss();
|
||||
}
|
||||
|
|
@ -109,7 +105,7 @@ public class NfcManager {
|
|||
}
|
||||
} else {
|
||||
if (mEnableNfcDialog == null || !mEnableNfcDialog.isVisible()) {
|
||||
ShowNFCEnableDialog();
|
||||
showNFCEnableDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ public class ConfirmPaymentActivity extends AppCompatActivity implements NfcAdap
|
|||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
Log.w(getClass().getName(), "Ignore discovered tag!");
|
||||
mNfcManager.IgnoreTag(tag);
|
||||
mNfcManager.ignoreTag(tag);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class CreateNewWalletActivity extends AppCompatActivity implements NfcAda
|
|||
createNewWalletTask.start();
|
||||
} else {
|
||||
Log.d(logTag, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ public class CreateNewWalletActivity extends AppCompatActivity implements NfcAda
|
|||
protocol.run_Read();
|
||||
|
||||
} finally {
|
||||
mNfcManager.IgnoreTag(mIsoDep.getTag());
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class EmptyWalletActivity extends AppCompatActivity implements NfcAdapter
|
|||
String sUID = Util.byteArrayToHexString(UID);
|
||||
if (!mCard.getUID().equals(sUID)) {
|
||||
Log.d(logTag, "Invalid UID: " + sUID);
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
} else {
|
||||
Log.v(logTag, "UID: " + sUID);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.nfc.Tag;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
|
@ -92,7 +91,6 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
|
|||
lp.topMargin = (int) (dp * (-100 + antenna.Y * 250));
|
||||
lp2.topMargin = (int) (dp * (-125 + antenna.Y * 250));
|
||||
nfc.setLayoutParams(lp2);
|
||||
|
||||
Animation a = new Animation() {
|
||||
@Override
|
||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
||||
|
|
@ -115,13 +113,13 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
|
|||
hideCleanButton();
|
||||
|
||||
// NFC
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction()) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()))) {
|
||||
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
||||
if (tag != null && onNFCReaderCallback != null) {
|
||||
onNFCReaderCallback.onTagDiscovered(tag);
|
||||
}
|
||||
}
|
||||
// Intent intent = getIntent();
|
||||
// if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction()) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()))) {
|
||||
// Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
||||
// if (tag != null && onNFCReaderCallback != null) {
|
||||
// onNFCReaderCallback.onTagDiscovered(tag);
|
||||
// }
|
||||
// }
|
||||
|
||||
// check if device root
|
||||
RootBeer rootBeer = new RootBeer(this);
|
||||
|
|
@ -129,16 +127,16 @@ public class MainActivity extends AppCompatActivity implements PopupMenu.OnMenuI
|
|||
new RootFoundDialog().show(getFragmentManager(), RootFoundDialog.TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction()) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()))) {
|
||||
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
||||
if (tag != null && onNFCReaderCallback != null) {
|
||||
onNFCReaderCallback.onTagDiscovered(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// protected void onNewIntent(Intent intent) {
|
||||
// super.onNewIntent(intent);
|
||||
// if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction()) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction()))) {
|
||||
// Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
|
||||
// if (tag != null && onNFCReaderCallback != null) {
|
||||
// onNFCReaderCallback.onTagDiscovered(tag);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keycode, KeyEvent e) {
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ public class PreparePaymentActivity extends AppCompatActivity implements NfcAdap
|
|||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
Log.w(getClass().getName(), "Ignore discovered tag!");
|
||||
mNfcManager.IgnoreTag(tag);
|
||||
mNfcManager.ignoreTag(tag);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
purgeTask.start();
|
||||
} else {
|
||||
Log.d(logTag, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
if (isCancelled) return;
|
||||
|
||||
} finally {
|
||||
mNfcManager.IgnoreTag(mIsoDep.getTag());
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ public class RequestPINActivity extends AppCompatActivity implements NfcAdapter.
|
|||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
Log.w(getClass().getName(), "Ignore discovered tag!");
|
||||
mNfcManager.IgnoreTag(tag);
|
||||
mNfcManager.ignoreTag(tag);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -76,7 +76,7 @@ public class SwapPINActivity extends AppCompatActivity implements NfcAdapter.Rea
|
|||
swapPinTask.start();
|
||||
} else {
|
||||
Log.d(logTag, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
@ -166,7 +166,7 @@ public class SwapPINActivity extends AppCompatActivity implements NfcAdapter.Rea
|
|||
mNotifications.OnReadProgress(protocol, 100);
|
||||
|
||||
} finally {
|
||||
mNfcManager.IgnoreTag(mIsoDep.getTag());
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class CardUnspentListAdapter extends BaseAdapter {
|
|||
|
||||
TangemCard.UnspentTransaction unspentTransaction = (TangemCard.UnspentTransaction) getItem(position);
|
||||
|
||||
String html=String.format("<b>%d mBTC</b><br>%s", unspentTransaction.Amount, unspentTransaction.txID);
|
||||
String html = String.format("<b>%d mBTC</b><br>%s", unspentTransaction.Amount, unspentTransaction.txID);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
tvItem.setText(Html.fromHtml(html, FROM_HTML_MODE_COMPACT));
|
||||
|
|
@ -76,11 +76,12 @@ public class CardUnspentListAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
public void UpdateUnspent(String tx_hash, int value, int height) {
|
||||
TangemCard.UnspentTransaction newUT=new TangemCard.UnspentTransaction();
|
||||
newUT.txID=tx_hash;
|
||||
newUT.Amount=value;
|
||||
newUT.Height=height;
|
||||
TangemCard.UnspentTransaction newUT = new TangemCard.UnspentTransaction();
|
||||
newUT.txID = tx_hash;
|
||||
newUT.Amount = value;
|
||||
newUT.Height = height;
|
||||
mCard.getUnspentTransactions().add(newUT);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.tangem.presentation.dialog;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
|
|
@ -15,6 +14,7 @@ import com.tangem.wallet.R;
|
|||
*/
|
||||
|
||||
public class NFCEnableDialog extends DialogFragment {
|
||||
public static final String TAG = NFCEnableDialog.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
|
@ -25,21 +25,16 @@ public class NFCEnableDialog extends DialogFragment {
|
|||
.setTitle(R.string.nfc_disabled)
|
||||
.setMessage(R.string.enable_nfc)
|
||||
.setPositiveButton(R.string.dialog_ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
// take user to wireless settings
|
||||
getActivity().startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
|
||||
}
|
||||
(dialog, id) -> {
|
||||
// take user to wireless settings
|
||||
getActivity().startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_quit,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int id) {
|
||||
dialog.cancel();
|
||||
getActivity().finish();
|
||||
}
|
||||
(dialog, id) -> {
|
||||
dialog.cancel();
|
||||
getActivity().finish();
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import android.text.Spanned;
|
|||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
|
@ -40,34 +39,34 @@ import com.google.zxing.common.BitMatrix;
|
|||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.tangem.data.network.request.ElectrumRequest;
|
||||
import com.tangem.data.network.request.ExchangeRequest;
|
||||
import com.tangem.data.network.request.InfuraRequest;
|
||||
import com.tangem.data.network.task.ElectrumTask;
|
||||
import com.tangem.data.network.task.ExchangeTask;
|
||||
import com.tangem.data.network.task.InfuraTask;
|
||||
import com.tangem.data.network.task.VerifyCardTask;
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.NfcManager;
|
||||
import com.tangem.domain.wallet.BitcoinException;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.CoinEngineFactory;
|
||||
import com.tangem.domain.wallet.LastSignStorage;
|
||||
import com.tangem.domain.wallet.PINStorage;
|
||||
import com.tangem.domain.wallet.SharedData;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.util.Util;
|
||||
import com.tangem.presentation.activity.CreateNewWalletActivity;
|
||||
import com.tangem.presentation.activity.PreparePaymentActivity;
|
||||
import com.tangem.presentation.activity.PurgeActivity;
|
||||
import com.tangem.presentation.activity.RequestPINActivity;
|
||||
import com.tangem.presentation.activity.SwapPINActivity;
|
||||
import com.tangem.presentation.activity.VerifyCardActivity;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.domain.wallet.BitcoinException;
|
||||
import com.tangem.domain.wallet.Blockchain;
|
||||
import com.tangem.domain.wallet.CoinEngine;
|
||||
import com.tangem.domain.wallet.CoinEngineFactory;
|
||||
import com.tangem.data.network.task.ElectrumTask;
|
||||
import com.tangem.data.network.request.ExchangeRequest;
|
||||
import com.tangem.data.network.task.ExchangeTask;
|
||||
import com.tangem.data.network.request.InfuraRequest;
|
||||
import com.tangem.data.network.task.InfuraTask;
|
||||
import com.tangem.domain.wallet.LastSignStorage;
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog;
|
||||
import com.tangem.domain.wallet.PINStorage;
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog;
|
||||
import com.tangem.util.BTCUtils;
|
||||
import com.tangem.util.Util;
|
||||
import com.tangem.wallet.BuildConfig;
|
||||
import com.tangem.wallet.R;
|
||||
import com.tangem.domain.wallet.SharedData;
|
||||
import com.tangem.data.network.task.VerifyCardTask;
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
|
@ -1022,7 +1021,7 @@ public class LoadedWalletFragment extends Fragment implements SwipeRefreshLayout
|
|||
String sUID = Util.byteArrayToHexString(UID);
|
||||
if (!mCard.getUID().equals(sUID)) {
|
||||
Log.d(logTag, "Invalid UID: " + sUID);
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
} else {
|
||||
Log.v(logTag, "UID: " + sUID);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ public class MainFragment extends Fragment implements NfcAdapter.ReaderCallback,
|
|||
|
||||
if (getActivity() instanceof MainActivity) {
|
||||
((MainActivity) getActivity()).setOnCardsClean(this);
|
||||
// ((MainActivity) getActivity()).setOnCreateNFCDialog(this);
|
||||
((MainActivity) getActivity()).setNfcAdapterReaderCallback(this);
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +194,7 @@ public class MainFragment extends Fragment implements NfcAdapter.ReaderCallback,
|
|||
String sUID = Util.byteArrayToHexString(UID);
|
||||
if (slCardUIDs.indexOf(sUID) != -1) {
|
||||
Log.d(logTag, "Repeat UID: " + sUID);
|
||||
mNfcManager.IgnoreTag(isoDep.getTag());
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
} else {
|
||||
Log.v(logTag, "UID: " + sUID);
|
||||
|
|
@ -631,7 +630,7 @@ public class MainFragment extends Fragment implements NfcAdapter.ReaderCallback,
|
|||
mNotifications.OnReadFinish(protocol);
|
||||
}
|
||||
} finally {
|
||||
mNfcManager.IgnoreTag(mIsoDep.getTag());
|
||||
mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ public class VerifyCardFragment extends Fragment implements SwipeRefreshLayout.O
|
|||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
Log.w(getClass().getName(), "Ignore discovered tag!");
|
||||
mNfcManager.IgnoreTag(tag);
|
||||
mNfcManager.ignoreTag(tag);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue