diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 642a612dbf..c5feb60116 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java index bdcca7c32c..b0fad673b0 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java +++ b/app/src/main/java/com/tangem/presentation/fragment/LoadedWallet.java @@ -109,10 +109,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre private TextView tvValidationNode; private TextView tvHeader, tvCaution; private ProgressBar progressBar; - private ImageView ivBlockchain; - private ImageView ivPIN; - private ImageView ivPIN2orSecurityDelay; - private ImageView ivDeveloperVersion; + private ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion; private SwipeRefreshLayout mSwipeRefreshLayout; private List updateTasks = new ArrayList<>(); private NfcManager mNfcManager; @@ -571,7 +568,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre mCard = new TangemCard(Objects.requireNonNull(getActivity()).getIntent().getStringExtra(TangemCard.EXTRA_CARD)); mCard.LoadFromBundle(Objects.requireNonNull(getActivity().getIntent().getExtras()).getBundle(TangemCard.EXTRA_CARD)); - lastTag = getActivity().getIntent().getParcelableExtra("lastTag123"); + lastTag = getActivity().getIntent().getParcelableExtra(Main.EXTRA_LAST_DISCOVERED_TAG); } @Override diff --git a/app/src/main/java/com/tangem/presentation/fragment/Main.java b/app/src/main/java/com/tangem/presentation/fragment/Main.java index cdcac5adc2..ffd7be13cf 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/Main.java +++ b/app/src/main/java/com/tangem/presentation/fragment/Main.java @@ -65,6 +65,8 @@ import java.util.Objects; public class Main extends Fragment implements NfcAdapter.ReaderCallback, CardListAdapter.UiCallbacks, CardProtocol.Notifications, MainActivity.OnCardsClean { public static final String TAG = Main.class.getSimpleName(); + public static final String EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"; + private static final int REQUEST_CODE_SHOW_CARD_ACTIVITY = 1; private static final int REQUEST_CODE_ENTER_PIN_ACTIVITY = 2; private static final int REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3; @@ -624,11 +626,10 @@ public class Main extends Fragment implements NfcAdapter.ReaderCallback, CardLis Log.i(TAG, "onViewCard " + "else"); } - intent.putExtra("lastTag123", lastTag); + intent.putExtra(EXTRA_LAST_DISCOVERED_TAG, lastTag); intent.putExtras(cardInfo); startActivityForResult(intent, REQUEST_CODE_SHOW_CARD_ACTIVITY); - mCardListAdapter.clearCards(); slCardUIDs.clear(); for (RequestWalletInfoTask rt : requestTasks) { diff --git a/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java b/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java index b2b7ba8899..38b94bd0de 100644 --- a/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java +++ b/app/src/main/java/com/tangem/presentation/fragment/VerifyCard.java @@ -11,7 +11,6 @@ import android.support.design.widget.FloatingActionButton; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Log; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; @@ -52,19 +51,16 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { private static final int REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN = 7; private static final int REQUEST_CODE_SWAP_PIN = 8; - private String newPIN = "", newPIN2 = ""; - private NfcManager mNfcManager; private TangemCard mCard; - private int requestPIN2Count = 0; - - private Timer timerHideErrorAndMessage = null; - - private TextView tvCardID, tvManufacturer, tvRegistrationDate, tvCardIdentity, tvLastSigned, tvRemainingSignatures, tvReusable, tvError, tvMessage, - tvIssuer, tvIssuerData, tvFeatures, tvBlockchain, tvSignedTx, tvSigningMethod, tvFirmware, tvWalletIdentity, tvWallet; - private ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion; private SwipeRefreshLayout mSwipeRefreshLayout; + private TextView tvCardID, tvManufacturer, tvRegistrationDate, tvCardIdentity, tvLastSigned, tvRemainingSignatures, tvReusable, tvError, tvMessage, tvIssuer, tvIssuerData, tvFeatures, tvBlockchain, tvSignedTx, tvSigningMethod, tvFirmware, tvWalletIdentity, tvWallet; + private ImageView ivBlockchain, ivPIN, ivPIN2orSecurityDelay, ivDeveloperVersion; + + private int requestPIN2Count = 0; + private Timer timerHideErrorAndMessage = null; + private String newPIN = "", newPIN2 = ""; public VerifyCard() { @@ -85,58 +81,44 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { View v = inflater.inflate(R.layout.fr_verify_card, container, false); mSwipeRefreshLayout = v.findViewById(R.id.swipe_container); - tvCardID = v.findViewById(R.id.tvCardID); - tvLastSigned = v.findViewById(R.id.tvLastSigned); tvRemainingSignatures = v.findViewById(R.id.tvRemainingSignatures); - tvReusable = v.findViewById(R.id.tvReusable); - tvManufacturer = v.findViewById(R.id.tvManufacturerInfo); - tvCardIdentity = v.findViewById(R.id.tvCardIdentity); - tvRegistrationDate = v.findViewById(R.id.tvCardRegistredDate); - ivBlockchain = v.findViewById(R.id.imgBlockchain); ivPIN = v.findViewById(R.id.imgPIN); ivPIN2orSecurityDelay = v.findViewById(R.id.imgPIN2orSecurityDelay); ivDeveloperVersion = v.findViewById(R.id.imgDeveloperVersion); - tvError = v.findViewById(R.id.tvError); tvMessage = v.findViewById(R.id.tvMessage); - tvIssuer = v.findViewById(R.id.tvIssuer); tvIssuerData = v.findViewById(R.id.tvIssuerData); - tvFirmware = v.findViewById(R.id.tvFirmware); tvFeatures = v.findViewById(R.id.tvFeatures); tvBlockchain = v.findViewById(R.id.tvBlockchain); - tvSignedTx = v.findViewById(R.id.tvSignedTx); tvSigningMethod = v.findViewById(R.id.tvSigningMethod); - Button btnOk = v.findViewById(R.id.btnOk); - FloatingActionButton fabMenu = v.findViewById(R.id.fabMenu); - tvWallet = v.findViewById(R.id.tvWallet); tvWalletIdentity = v.findViewById(R.id.tvWalletIdentity); + updateViews(); + btnOk.setOnClickListener(v1 -> { Intent data = prepareResultIntent(); data.putExtra("modification", "update"); - getActivity().finish(); + if (getActivity() != null) + getActivity().finish(); }); mSwipeRefreshLayout.setOnRefreshListener(() -> mSwipeRefreshLayout.setRefreshing(false)); fabMenu.setOnClickListener(v16 -> showMenu(fabMenu)); - - updateViews(); - return v; } @@ -326,7 +308,7 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { @Override public void onTagDiscovered(Tag tag) { try { - Log.w(getClass().getName(), "Ignore discovered tag!"); +// Log.w(getClass().getName(), "Ignore discovered tag!"); mNfcManager.ignoreTag(tag); } catch (IOException e) { e.printStackTrace(); @@ -372,12 +354,10 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { tvRegistrationDate.setText(mCard.getPersonalizationDateTimeDescription()); - //tvBlockchain.setText(mCard.getBlockchain().getOfficialName()); tvBlockchain.setText(mCard.getBlockchainName()); ivBlockchain.setImageResource(mCard.getBlockchain().getImageResource(getContext(), mCard.getTokenSymbol())); - Log.i(TAG, "getTokenSymbol " + mCard.getTokenSymbol()); if (mCard.isReusable()) tvReusable.setText(R.string.reusable); @@ -454,10 +434,10 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), R.string.this_banknote_protected_user_PIN1_code, Toast.LENGTH_LONG).show()); } + if (mCard.getPauseBeforePIN2() > 0 && (mCard.useDefaultPIN2() || !mCard.useSmartSecurityDelay())) { ivPIN2orSecurityDelay.setImageResource(R.drawable.timer); ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), String.format("This banknote will enforce %.0f seconds security delay for all operations requiring PIN2 code", mCard.getPauseBeforePIN2() / 1000.0), Toast.LENGTH_LONG).show()); - } else if (mCard.useDefaultPIN2()) { ivPIN2orSecurityDelay.setImageResource(R.drawable.unlock_pin2); ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), R.string.this_banknote_protected_default_PIN2_code, Toast.LENGTH_LONG).show()); @@ -563,7 +543,7 @@ public class VerifyCard extends Fragment implements NfcAdapter.ReaderCallback { final CoinEngine engine = CoinEngineFactory.Create(mCard.getBlockchain()); if (!mCard.hasBalanceInfo()) { return; - } else if (engine.IsBalanceNotZero(mCard)) { + } else if (engine != null && engine.IsBalanceNotZero(mCard)) { Toast.makeText(getContext(), R.string.cannot_erase_wallet_with_non_zero_balance, Toast.LENGTH_LONG).show(); return; } diff --git a/app/src/main/java/com/tangem/util/UtilHelper.kt b/app/src/main/java/com/tangem/util/UtilHelper.kt index 5616781282..1611ccf26e 100644 --- a/app/src/main/java/com/tangem/util/UtilHelper.kt +++ b/app/src/main/java/com/tangem/util/UtilHelper.kt @@ -31,25 +31,4 @@ object UtilHelper { return bmp } - // private static Bitmap generateQrCode(String myCodeText) throws WriterException { -// Hashtable hintMap = new Hashtable<>(); -// hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // H = 30% damage -// -// QRCodeWriter qrCodeWriter = new QRCodeWriter(); -// -// int size = 256; -// -// BitMatrix bitMatrix = qrCodeWriter.encode(myCodeText, BarcodeFormat.QR_CODE, size, size, hintMap); -// int width = bitMatrix.getWidth(); -// Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.RGB_565); -// for (int x = 0; x < width; x++) { -// for (int y = 0; y < width; y++) { -// bmp.setPixel(y, x, bitMatrix.get(x, y) ? Color.BLACK : Color.WHITE); -// } -// } -// return bmp; -// } - - - } \ No newline at end of file diff --git a/app/src/main/res/layout/fr_loaded_wallet.xml b/app/src/main/res/layout/fr_loaded_wallet.xml index 0de9652881..308da97029 100644 --- a/app/src/main/res/layout/fr_loaded_wallet.xml +++ b/app/src/main/res/layout/fr_loaded_wallet.xml @@ -391,6 +391,7 @@