Updated on 2026-08-14
This commit is contained in:
parent
052fb21dab
commit
a7d764c0af
4 changed files with 287 additions and 332 deletions
|
|
@ -17,113 +17,31 @@ import android.widget.Toast;
|
|||
|
||||
import com.tangem.domain.cardReader.CardProtocol;
|
||||
import com.tangem.domain.cardReader.NfcManager;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.util.Util;
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog;
|
||||
import com.tangem.domain.wallet.PINStorage;
|
||||
import com.tangem.wallet.R;
|
||||
import com.tangem.domain.wallet.TangemCard;
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog;
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog;
|
||||
import com.tangem.util.Util;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
public class PurgeActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
public static final String TAG = PurgeActivity.class.getSimpleName();
|
||||
|
||||
public static final int RESULT_INVALID_PIN = Activity.RESULT_FIRST_USER;
|
||||
|
||||
private TangemCard mCard;
|
||||
private TextView tvCardID;
|
||||
private NfcManager mNfcManager;
|
||||
private static final String logTag = "Purge";
|
||||
private ProgressBar progressBar;
|
||||
private PurgeTask purgeTask;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_purge);
|
||||
|
||||
MainActivity.commonInit(getApplicationContext());
|
||||
|
||||
mCard = new TangemCard(getIntent().getStringExtra("UID"));
|
||||
mCard.LoadFromBundle(getIntent().getExtras().getBundle("Card"));
|
||||
|
||||
tvCardID = findViewById(R.id.tvCardID);
|
||||
tvCardID.setText(mCard.getCIDDescription());
|
||||
|
||||
mNfcManager = new NfcManager(this, this);
|
||||
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
// get IsoDep handle and run cardReader thread
|
||||
final IsoDep isoDep = IsoDep.get(tag);
|
||||
if (isoDep == null) {
|
||||
throw new CardProtocol.TangemException(getString(R.string.wrong_tag_err));
|
||||
}
|
||||
byte UID[] = tag.getId();
|
||||
String sUID = Util.byteArrayToHexString(UID);
|
||||
Log.v(logTag, "UID: " + sUID);
|
||||
|
||||
if (sUID.equals(mCard.getUID())) {
|
||||
isoDep.setTimeout(mCard.getPauseBeforePIN2() + 65000);
|
||||
purgeTask = new PurgeTask(isoDep, this);
|
||||
|
||||
purgeTask.start();
|
||||
} else {
|
||||
Log.d(logTag, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mNfcManager.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mNfcManager.onPause();
|
||||
if (purgeTask != null) {
|
||||
purgeTask.cancel(true);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
// dismiss enable NFC dialog
|
||||
mNfcManager.onStop();
|
||||
if (purgeTask != null) {
|
||||
purgeTask.cancel(true);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Dialog CreateNFCDialog(int id, AlertDialogWrapper.Builder builder, LayoutInflater li) {
|
||||
// return mNfcManager.onCreateDialog(id, builder, li);
|
||||
// }
|
||||
|
||||
private class PurgeTask extends Thread {
|
||||
|
||||
|
||||
private String txOutAddress;
|
||||
|
||||
IsoDep mIsoDep;
|
||||
CardProtocol.Notifications mNotifications;
|
||||
private boolean isCancelled = false;
|
||||
|
||||
public PurgeTask(IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
PurgeTask(IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
mIsoDep = isoDep;
|
||||
mNotifications = notifications;
|
||||
}
|
||||
|
|
@ -138,19 +56,16 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
mNotifications.OnReadStart(protocol);
|
||||
try {
|
||||
|
||||
// for Samsung's bugs -
|
||||
// Workaround for the Samsung Galaxy S5 (since the
|
||||
// first connection always hangs on transceive).
|
||||
// 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 {
|
||||
|
||||
mNotifications.OnReadProgress(protocol, 5);
|
||||
|
||||
Log.i("PurgeTask", "[-- Start purge --]");
|
||||
Log.i(TAG, "[-- Start purge --]");
|
||||
|
||||
if (isCancelled) return;
|
||||
|
||||
|
|
@ -180,7 +95,7 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
protocol.setError(e);
|
||||
|
||||
} finally {
|
||||
Log.i("PurgeTask", "[-- Finish purge --]");
|
||||
Log.i(TAG, "[-- Finish purge --]");
|
||||
mNotifications.OnReadFinish(protocol);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,121 +117,78 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void OnReadStart(CardProtocol cardProtocol) {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(5);
|
||||
}
|
||||
});
|
||||
}
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_purge);
|
||||
|
||||
public void OnReadFinish(final CardProtocol cardProtocol) {
|
||||
mNfcManager = new NfcManager(this, this);
|
||||
|
||||
purgeTask = null;
|
||||
MainActivity.commonInit(getApplicationContext());
|
||||
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.getError() == null) {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN));
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("UID", cardProtocol.getCard().getUID());
|
||||
intent.putExtra("Card", cardProtocol.getCard().getAsBundle());
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_InvalidPIN) {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
|
||||
}
|
||||
});
|
||||
progressBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
TextView tvCardID = findViewById(R.id.tvCardID);
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
tvCardID.setText(mCard.getCIDDescription());
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("UID", cardProtocol.getCard().getUID());
|
||||
intent.putExtra("Card", cardProtocol.getCard().getAsBundle());
|
||||
intent.putExtra("message", "Cannot erase wallet. Make sure you enter correct PIN2!");
|
||||
setResult(RESULT_INVALID_PIN, intent);
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
mCard = new TangemCard(getIntent().getStringExtra("UID"));
|
||||
mCard.LoadFromBundle(getIntent().getExtras().getBundle("Card"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mNfcManager.onResume();
|
||||
}
|
||||
}, 500);
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mNfcManager.onPause();
|
||||
if (purgeTask != null) {
|
||||
purgeTask.cancel(true);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
// dismiss enable NFC dialog
|
||||
mNfcManager.onStop();
|
||||
if (purgeTask != null) {
|
||||
purgeTask.cancel(true);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTagDiscovered(Tag tag) {
|
||||
try {
|
||||
// get IsoDep handle and run cardReader thread
|
||||
final IsoDep isoDep = IsoDep.get(tag);
|
||||
if (isoDep == null) {
|
||||
throw new CardProtocol.TangemException(getString(R.string.wrong_tag_err));
|
||||
}
|
||||
byte UID[] = tag.getId();
|
||||
String sUID = Util.byteArrayToHexString(UID);
|
||||
Log.v(TAG, "UID: " + sUID);
|
||||
|
||||
if (sUID.equals(mCard.getUID())) {
|
||||
isoDep.setTimeout(mCard.getPauseBeforePIN2() + 65000);
|
||||
purgeTask = new PurgeTask(isoDep, this);
|
||||
|
||||
purgeTask.start();
|
||||
} else {
|
||||
Log.d(TAG, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
} else {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allreadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), "NoExtendedLengthSupportDialog");
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getBaseContext(), "Try to scan again", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
progressBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
public void OnReadProgress(CardProtocol protocol, final int progress) {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setProgress(progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void OnReadCancel() {
|
||||
|
||||
purgeTask = null;
|
||||
|
||||
progressBar.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -334,5 +206,92 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
WaitSecurityDelayDialog.onReadAfterRequest(this);
|
||||
}
|
||||
|
||||
}
|
||||
public void OnReadStart(CardProtocol cardProtocol) {
|
||||
progressBar.post(() -> {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress(5);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnReadFinish(final CardProtocol cardProtocol) {
|
||||
|
||||
purgeTask = null;
|
||||
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.getError() == null) {
|
||||
progressBar.post(() -> {
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN));
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("UID", cardProtocol.getCard().getUID());
|
||||
intent.putExtra("Card", cardProtocol.getCard().getAsBundle());
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
});
|
||||
} else {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_InvalidPIN) {
|
||||
progressBar.post(() -> {
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
|
||||
});
|
||||
progressBar.postDelayed(() -> {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("UID", cardProtocol.getCard().getUID());
|
||||
intent.putExtra("Card", cardProtocol.getCard().getAsBundle());
|
||||
intent.putExtra("message", getString(R.string.cannot_erase_wallet));
|
||||
setResult(RESULT_INVALID_PIN, intent);
|
||||
finish();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 500);
|
||||
return;
|
||||
} else {
|
||||
progressBar.post(() -> {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allreadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.TAG);
|
||||
}
|
||||
} else
|
||||
Toast.makeText(getBaseContext(), R.string.try_to_scan_again, Toast.LENGTH_LONG).show();
|
||||
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
progressBar.postDelayed(() -> {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
public void OnReadProgress(CardProtocol protocol, final int progress) {
|
||||
progressBar.post(() -> progressBar.setProgress(progress));
|
||||
}
|
||||
|
||||
public void OnReadCancel() {
|
||||
purgeTask = null;
|
||||
progressBar.postDelayed(() -> {
|
||||
try {
|
||||
progressBar.setProgress(0);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY));
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardVi
|
|||
}
|
||||
|
||||
if (card.useDevelopersFirmware()) {
|
||||
holder.tvType.setText(R.string.developer_kit);
|
||||
holder.tvType.setText(R.string.developer_kit_spaces);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.fab));
|
||||
holder.tvVoid.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,6 +544,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
|
||||
public static class PINSwapWarningDialog extends DialogFragment {
|
||||
public static final String TAG = PINSwapWarningDialog.class.getSimpleName();
|
||||
|
||||
LoadedWallet activityFragment = null;
|
||||
String message;
|
||||
|
|
@ -553,22 +554,15 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle("Your money is at risk!")
|
||||
.setTitle(R.string.your_money_is_at_risk)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
PINSwapWarningDialog.this.dismiss();
|
||||
}
|
||||
})
|
||||
.setPositiveButton("Continue",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> PINSwapWarningDialog.this.dismiss())
|
||||
.setPositiveButton(R.string.contin,
|
||||
(dialog, whichButton) -> {
|
||||
if (activityFragment != null)
|
||||
activityFragment.startSwapPINActivity();
|
||||
}
|
||||
}
|
||||
)
|
||||
.create();
|
||||
}
|
||||
|
|
@ -650,7 +644,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
|
||||
try {
|
||||
ivQR.setImageBitmap(generateQrCode(engine.getShareWalletURI(mCard).toString()));
|
||||
ivQR.setImageBitmap(generateQrCode(Objects.requireNonNull(engine).getShareWalletURI(mCard).toString()));
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -664,7 +658,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain());
|
||||
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard));
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Objects.requireNonNull(engineClick).getShareWalletURIExplorer(mCard));
|
||||
startActivity(browserIntent);
|
||||
});
|
||||
|
||||
|
|
@ -677,7 +671,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
CoinEngine engineClick = CoinEngineFactory.Create(mCard.getBlockchain());
|
||||
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, engineClick.getShareWalletURIExplorer(mCard));
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Objects.requireNonNull(engineClick).getShareWalletURIExplorer(mCard));
|
||||
startActivity(browserIntent);
|
||||
});
|
||||
}
|
||||
|
|
@ -686,7 +680,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
tvSend.setOnClickListener(v13 -> {
|
||||
if (!mCard.hasBalanceInfo()) {
|
||||
return;
|
||||
} else if (!engine.IsBalanceNotZero(mCard)) {
|
||||
} else if (!Objects.requireNonNull(engine).IsBalanceNotZero(mCard)) {
|
||||
Toast.makeText(getContext(), R.string.wallet_empty, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
} else if (!engine.IsBalanceAlterNotZero(mCard)) {
|
||||
|
|
@ -710,10 +704,8 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
tvPurge.setOnClickListener(v16 -> showMenu(tvPurge));
|
||||
|
||||
|
||||
updateViews();
|
||||
|
||||
if (!mCard.hasBalanceInfo()) {
|
||||
|
|
@ -751,7 +743,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
case REQUEST_CODE_ENTER_NEW_PIN:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.getExtras().containsKey("confirmPIN")) {
|
||||
if (Objects.requireNonNull(data.getExtras()).containsKey("confirmPIN")) {
|
||||
Intent intent = new Intent(getContext(), RequestPINActivity.class);
|
||||
intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString());
|
||||
intent.putExtra("UID", mCard.getUID());
|
||||
|
|
@ -770,7 +762,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
case REQUEST_CODE_ENTER_NEW_PIN2:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data != null) {
|
||||
if (data.getExtras().containsKey("confirmPIN2")) {
|
||||
if (Objects.requireNonNull(data.getExtras()).containsKey("confirmPIN2")) {
|
||||
Intent intent = new Intent(getContext(), RequestPINActivity.class);
|
||||
intent.putExtra("mode", RequestPINActivity.Mode.RequestPIN2.toString());
|
||||
intent.putExtra("UID", mCard.getUID());
|
||||
|
|
@ -788,21 +780,19 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
break;
|
||||
case REQUEST_CODE_REQUEST_PIN2_FOR_SWAP_PIN:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (newPIN.equals("")) {
|
||||
if (newPIN.equals(""))
|
||||
newPIN = mCard.getPIN();
|
||||
}
|
||||
if (newPIN2.equals("")) {
|
||||
|
||||
if (newPIN2.equals(""))
|
||||
newPIN2 = PINStorage.getPIN2();
|
||||
}
|
||||
|
||||
PINSwapWarningDialog dialog = (new PINSwapWarningDialog());
|
||||
dialog.activityFragment = this;
|
||||
if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2)) {
|
||||
dialog.message = "If you forget your new PIN you will lose your money forever!";
|
||||
} else {
|
||||
dialog.message = "If you use default PIN someone can steal your money!";
|
||||
}
|
||||
dialog.show(getActivity().getFragmentManager(), "PINSwapWarningDialog");
|
||||
if (!PINStorage.isDefaultPIN(newPIN) || !PINStorage.isDefaultPIN2(newPIN2))
|
||||
dialog.message = getString(R.string.if_you_forget);
|
||||
else
|
||||
dialog.message = getString(R.string.if_you_use_default);
|
||||
dialog.show(Objects.requireNonNull(getActivity()).getFragmentManager(), PINSwapWarningDialog.TAG);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -912,8 +902,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
|
||||
public void onRefresh() {
|
||||
//Update
|
||||
// Showing refresh animation before making http call
|
||||
// update, showing refresh animation before making http call
|
||||
if (updateTasks.size() > 0) return;
|
||||
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
|
|
@ -1050,7 +1039,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
|
||||
public void ErrorOnUpdate(String message) {
|
||||
mCard.setError("Cannot obtain data from blockchain");
|
||||
mCard.setError(getString(R.string.cannot_obtain_data_from_blockchain));
|
||||
updateViews();
|
||||
}
|
||||
|
||||
|
|
@ -1087,7 +1076,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
new NoExtendedLengthSupportDialog().show(getActivity().getFragmentManager(), "NoExtendedLengthSupportDialog");
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getContext(), "Try to scan again", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(getContext(), R.string.try_to_scan_again, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
progressBar.setProgress(100);
|
||||
progressBar.setProgressTintList(ColorStateList.valueOf(Color.RED));
|
||||
|
|
@ -1251,7 +1240,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
if (!mCard.hasBalanceInfo()) {
|
||||
return;
|
||||
} else if (engine.IsBalanceNotZero(mCard)) {
|
||||
Toast.makeText(getContext(), "Cannot erase wallet with non-zero balance", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(getContext(), R.string.cannot_erase_wallet_with_non_zero_balance, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1285,7 +1274,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
tvMessage.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (needResendTX) {
|
||||
tvMessage.setText("Sending cached transaction...");
|
||||
tvMessage.setText(R.string.sending_cached_transaction);
|
||||
} else {
|
||||
tvMessage.setText(mCard.getMessage());
|
||||
}
|
||||
|
|
@ -1307,7 +1296,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
} else {
|
||||
String offlineAmount = engine.ConvertByteArrayToAmount(mCard, mCard.getOfflineBalance());
|
||||
if (mCard.getBlockchain() == Blockchain.Token) {
|
||||
tvBalance.setText("NOT IMPLEMENTED");
|
||||
tvBalance.setText(R.string.not_implemented);
|
||||
} else {
|
||||
tvBalance.setText(engine.GetAmountDescription(mCard, offlineAmount));
|
||||
}
|
||||
|
|
@ -1352,10 +1341,10 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
|
||||
if (mCard.useDefaultPIN1()) {
|
||||
ivPIN.setImageResource(R.drawable.unlock_pin1);
|
||||
ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by default PIN1 code", Toast.LENGTH_LONG).show());
|
||||
ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), R.string.this_banknote_protected_default_PIN1_code, Toast.LENGTH_LONG).show());
|
||||
} else {
|
||||
ivPIN.setImageResource(R.drawable.lock_pin1);
|
||||
ivPIN.setOnClickListener(v -> Toast.makeText(getContext(), "This banknote is protected by user's PIN1 code", Toast.LENGTH_LONG).show());
|
||||
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())) {
|
||||
|
|
@ -1364,57 +1353,36 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
|
||||
} else if (mCard.useDefaultPIN2()) {
|
||||
ivPIN2orSecurityDelay.setImageResource(R.drawable.unlock_pin2);
|
||||
ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getContext(), "This banknote is protected by default PIN2 code", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), R.string.this_banknote_protected_default_PIN2_code, Toast.LENGTH_LONG).show());
|
||||
} else {
|
||||
ivPIN2orSecurityDelay.setImageResource(R.drawable.lock_pin2);
|
||||
ivPIN2orSecurityDelay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getContext(), "This banknote is protected by user's PIN2 code", Toast.LENGTH_LONG).show();
|
||||
ivPIN2orSecurityDelay.setOnClickListener(v -> Toast.makeText(getContext(), R.string.this_banknote_protected_user_PIN2_code, Toast.LENGTH_LONG).show());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (mCard.useDevelopersFirmware()) {
|
||||
ivDeveloperVersion.setImageResource(R.drawable.ic_developer_version);
|
||||
ivDeveloperVersion.setVisibility(View.VISIBLE);
|
||||
ivDeveloperVersion.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getContext(), "Unlocked banknote, only for development use", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
ivDeveloperVersion.setOnClickListener(v -> Toast.makeText(getContext(), R.string.unlocked_banknote_only_development_use, Toast.LENGTH_LONG).show());
|
||||
} else {
|
||||
ivDeveloperVersion.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (tvSend != null) {
|
||||
if (mCard.hasBalanceInfo()) {
|
||||
if (tvSend != null)
|
||||
if (mCard.hasBalanceInfo())
|
||||
tvSend.setEnabled(true);
|
||||
} else {
|
||||
else
|
||||
tvSend.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (tvPurge != null) {
|
||||
if (mCard.hasBalanceInfo()) {
|
||||
if (tvPurge != null)
|
||||
if (mCard.hasBalanceInfo())
|
||||
tvPurge.setEnabled(true);
|
||||
} else {
|
||||
else
|
||||
tvPurge.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
tvIssuer.setText(mCard.getIssuerDescription());
|
||||
|
||||
timerHideErrorAndMessage = new Timer();
|
||||
|
||||
|
||||
timerHideErrorAndMessage.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -1428,20 +1396,20 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}, 5000);
|
||||
|
||||
if (mCard.isReusable()) {
|
||||
tvHeader.setText("REUSABLE WALLET");
|
||||
tvHeader.setText(R.string.reusable_wallet);
|
||||
tvCaution.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (mCard.getMaxSignatures() == mCard.getRemainingSignatures()) {
|
||||
tvHeader.setText("BANKNOTE");
|
||||
tvHeader.setText(R.string.banknote);
|
||||
tvCaution.setVisibility(View.GONE);
|
||||
} else {
|
||||
tvHeader.setText("NON-TRANSFERABLE BANKNOTE");
|
||||
tvHeader.setText(R.string.not_transferable_banknote);
|
||||
tvCaution.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (mCard.useDevelopersFirmware()) {
|
||||
tvHeader.setText("DEVELOPER KIT");
|
||||
tvHeader.setText(R.string.developer_kit);
|
||||
tvCaution.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
|
@ -1459,13 +1427,14 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
intent.putExtra(Intent.EXTRA_SUBJECT, "Wallet address");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, txtShare);
|
||||
|
||||
PackageManager packageManager = getActivity().getPackageManager();
|
||||
PackageManager packageManager = Objects.requireNonNull(getActivity()).getPackageManager();
|
||||
List activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL);
|
||||
boolean isIntentSafe = activities.size() > 0;
|
||||
|
||||
if (isIntentSafe) {
|
||||
String title = "Share wallet address with:";
|
||||
// Create intent to show chooser
|
||||
String title = getString(R.string.share_wallet_address_with);
|
||||
|
||||
// create intent to show chooser
|
||||
Intent chooser = Intent.createChooser(intent, title);
|
||||
// Verify the intent will resolve to at least one activity
|
||||
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||
|
|
@ -1473,14 +1442,14 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
} else {
|
||||
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare));
|
||||
Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show();
|
||||
Objects.requireNonNull(clipboard).setPrimaryClip(ClipData.newPlainText(txtShare, txtShare));
|
||||
Toast.makeText(getContext(), R.string.copied_clipboard, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
String txtShare = mCard.getWallet();
|
||||
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(txtShare, txtShare));
|
||||
Toast.makeText(getContext(), "Copied to clipboard", Toast.LENGTH_LONG).show();
|
||||
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(getActivity()).getSystemService(CLIPBOARD_SERVICE);
|
||||
Objects.requireNonNull(clipboard).setPrimaryClip(ClipData.newPlainText(txtShare, txtShare));
|
||||
Toast.makeText(getContext(), R.string.copied_clipboard, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1517,7 +1486,7 @@ public class LoadedWallet extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
|
||||
private static Bitmap generateQrCode(String myCodeText) throws WriterException {
|
||||
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
|
||||
Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<>();
|
||||
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); // H = 30% damage
|
||||
|
||||
QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="contin">Continue</string>
|
||||
<string name="not_found">Not found</string>
|
||||
<string name="wrong_tag_err">Not ISO tag!</string>
|
||||
<string name="msgCardMustBeLoaded">Card must be loaded first!</string>
|
||||
|
|
@ -34,12 +36,15 @@
|
|||
<string name="verified_offline">verified offline</string>
|
||||
<string name="blockchain">Blockchain</string>
|
||||
<string name="last_withdrawal">Last withdrawal</string>
|
||||
<string name="try_to_scan_again">Try to scan again</string>
|
||||
<string name="cannot_erase_wallet_with_non_zero_balance">Cannot erase wallet with non-zero balance</string>
|
||||
|
||||
<!-- dialogs -->
|
||||
<string name="device_is_rooted">Your Android device is rooted. Security at risk!</string>
|
||||
<string name="got_it">Got it</string>
|
||||
<string name="warning">Warning</string>
|
||||
<string name="the_nfc_adapter_length_apdu">The NFC adapter of the device does not support extended length APDU, it\'s possible that some functions will not work!</string>
|
||||
<string name="your_money_is_at_risk">Your money is at risk!</string>
|
||||
|
||||
<!-- menu main -->
|
||||
<string name="clean_up">Clean up</string>
|
||||
|
|
@ -59,7 +64,6 @@
|
|||
<!-- MainActivity, Main -->
|
||||
<string name="tap_tangem_card">Tap Tangem card with your smartphone</string>
|
||||
<string name="scan_banknote">Scan a banknote with your \n smartphone as shown above</string>
|
||||
<string name="try_to_scan_again">Try to scan again</string>
|
||||
|
||||
<string name="wallet">Wallet</string>
|
||||
<string name="last_unspent">Last unspent</string>
|
||||
|
|
@ -68,7 +72,7 @@
|
|||
<string name="erased_wallet">ERASED WALLET</string>
|
||||
<string name="invalid_card">INVALID CARD</string>
|
||||
|
||||
<string name="developer_kit">           DEVELOPER     KIT     </string>
|
||||
<string name="developer_kit_spaces">           DEVELOPER     KIT     </string>
|
||||
<string name="banknote_banknote">  BANKNOTE        BANKNOTE</string>
|
||||
<string name="reusable_reusable">   REUSABLE       REUSABLE   </string>
|
||||
|
||||
|
|
@ -78,7 +82,10 @@
|
|||
<string name="please_wait_while_previous">Please wait while previous transaction is confirmed in blockchain</string>
|
||||
<string name="please_wait_for_confirmation">Please wait for confirmation of incoming transaction!</string>
|
||||
<string name="card_hasn_t_remaining_signature">Card hasn\'t remaining signature!</string>
|
||||
<string name="reusable_wallet">REUSABLE WALLET</string>
|
||||
<string name="banknote">BANKNOTE</string>
|
||||
<string name="not_transferable_banknote">NON-TRANSFERABLE BANKNOTE</string>
|
||||
<string name="developer_kit">DEVELOPER KIT</string>
|
||||
<string name="do_not_accept">DO NOT ACCEPT</string>
|
||||
<string name="explore_in_blockchain">EXPLORE IN \n BLOCKCHAIN \n ON WEB</string>
|
||||
<string name="unspents">Unspents</string>
|
||||
|
|
@ -89,6 +96,18 @@
|
|||
<string name="error">Error!</string>
|
||||
<string name="scan_again_to_verify_the_card">Scan again to verify the card</string>
|
||||
<string name="send">SEND</string>
|
||||
<string name="if_you_forget">If you forget your new PIN you will lose your money forever!</string>
|
||||
<string name="if_you_use_default">If you use default PIN someone can steal your money!</string>
|
||||
<string name="cannot_obtain_data_from_blockchain">Cannot obtain data from blockchain</string>
|
||||
<string name="sending_cached_transaction">Sending cached transaction…</string>
|
||||
<string name="not_implemented">NOT IMPLEMENTED</string>
|
||||
<string name="this_banknote_protected_default_PIN1_code">This banknote is protected by default PIN1 code</string>
|
||||
<string name="this_banknote_protected_user_PIN1_code">This banknote is protected by user\'s PIN1 code</string>
|
||||
<string name="this_banknote_protected_default_PIN2_code">This banknote is protected by default PIN2 code</string>
|
||||
<string name="this_banknote_protected_user_PIN2_code">This banknote is protected by user\'s PIN2 code</string>
|
||||
<string name="unlocked_banknote_only_development_use">Unlocked banknote, only for development use</string>
|
||||
<string name="share_wallet_address_with">Share wallet address with:</string>
|
||||
<string name="copied_clipboard">Copied to clipboard</string>
|
||||
|
||||
<!-- LogoActivity -->
|
||||
<string name="beta">BETA</string>
|
||||
|
|
@ -119,6 +138,14 @@
|
|||
<!-- SendTransactionActivity -->
|
||||
<string name="please_wait">Please wait while the payment is sent…</string>
|
||||
|
||||
<!-- PurgeActivity -->
|
||||
<string name="cannot_erase_wallet">Cannot erase wallet. Make sure you enter correct PIN2!</string>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue