Updated on 2026-08-14
This commit is contained in:
parent
6578d7c8c2
commit
89a6e55bab
16 changed files with 259 additions and 359 deletions
|
|
@ -16,7 +16,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.ActivityCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.tangem.presentation.dialog.NFCEnableDialog;
|
||||
import com.tangem.presentation.dialog.NfcEnableDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public class NfcManager {
|
|||
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 NFCEnableDialog mEnableNfcDialog;
|
||||
private NfcEnableDialog mEnableNfcDialog;
|
||||
private Activity mActivity;
|
||||
private NfcAdapter.ReaderCallback mReaderCallback;
|
||||
|
||||
|
|
@ -96,8 +96,8 @@ public class NfcManager {
|
|||
}
|
||||
|
||||
private void showNFCEnableDialog() {
|
||||
mEnableNfcDialog = new NFCEnableDialog();
|
||||
mEnableNfcDialog.show(mActivity.getFragmentManager(), NFCEnableDialog.TAG);
|
||||
mEnableNfcDialog = new NfcEnableDialog();
|
||||
mEnableNfcDialog.show(mActivity.getFragmentManager(), NfcEnableDialog.Companion.getTAG());
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ public class CreateNewWalletActivity extends AppCompatActivity implements NfcAda
|
|||
} else {
|
||||
progressBar.post(() -> {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.TAG);
|
||||
if (!NoExtendedLengthSupportDialog.Companion.getAllReadyShowed()) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.Companion.getTAG());
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getBaseContext(), R.string.try_to_scan_again, Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -232,8 +232,8 @@ public class EmptyWalletActivity extends AppCompatActivity implements NfcAdapter
|
|||
progressBar.post(() -> {
|
||||
lastReadSuccess = false;
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.TAG);
|
||||
if (!NoExtendedLengthSupportDialog.Companion.getAllReadyShowed()) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.Companion.getTAG());
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(EmptyWalletActivity.this, R.string.try_to_scan_again, Toast.LENGTH_LONG).show();
|
||||
|
|
|
|||
|
|
@ -148,11 +148,10 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
}
|
||||
|
||||
if (requestCode == REQUEST_CODE_ENTER_PIN_ACTIVITY) {
|
||||
if (resultCode == Activity.RESULT_OK && lastTag != null) {
|
||||
if (resultCode == Activity.RESULT_OK && lastTag != null)
|
||||
onTagDiscovered(lastTag!!)
|
||||
} else {
|
||||
ReadCardInfoTask.resetLastReadInfo();
|
||||
}
|
||||
else
|
||||
ReadCardInfoTask.resetLastReadInfo()
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,89 +34,6 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
private ProgressBar progressBar;
|
||||
private PurgeTask purgeTask;
|
||||
|
||||
// private class PurgeTask extends Thread {
|
||||
// private String txOutAddress;
|
||||
//
|
||||
// IsoDep mIsoDep;
|
||||
// CardProtocol.Notifications mNotifications;
|
||||
// private boolean isCancelled = false;
|
||||
//
|
||||
// PurgeTask(IsoDep isoDep, CardProtocol.Notifications notifications) {
|
||||
// mIsoDep = isoDep;
|
||||
// mNotifications = notifications;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (mIsoDep == null) {
|
||||
// return;
|
||||
// }
|
||||
// CardProtocol protocol = new CardProtocol(getBaseContext(), mIsoDep, mCard, mNotifications);
|
||||
//
|
||||
// mNotifications.OnReadStart(protocol);
|
||||
// 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 {
|
||||
// mNotifications.OnReadProgress(protocol, 5);
|
||||
//
|
||||
// Log.i(TAG, "[-- Start purge --]");
|
||||
//
|
||||
// if (isCancelled) return;
|
||||
//
|
||||
// if (mCard.getPauseBeforePIN2() > 0) {
|
||||
// mNotifications.OnReadWait(mCard.getPauseBeforePIN2());
|
||||
// }
|
||||
//
|
||||
//// try {
|
||||
// protocol.run_PurgeWallet(PINStorage.getPIN2());
|
||||
//// } finally {
|
||||
//// mNotifications.OnReadWait(0);
|
||||
//// }
|
||||
//
|
||||
// mNotifications.OnReadProgress(protocol, 50);
|
||||
//
|
||||
// protocol.run_Read();
|
||||
//
|
||||
// mNotifications.OnReadProgress(protocol, 100);
|
||||
//
|
||||
// if (isCancelled) return;
|
||||
//
|
||||
// } finally {
|
||||
// mNfcManager.ignoreTag(mIsoDep.getTag());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// protocol.setError(e);
|
||||
//
|
||||
// } finally {
|
||||
// Log.i(TAG, "[-- Finish purge --]");
|
||||
// mNotifications.OnReadFinish(protocol);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void cancel(Boolean AllowInterrupt) {
|
||||
// try {
|
||||
// if (this.isAlive()) {
|
||||
// isCancelled = true;
|
||||
// join(500);
|
||||
// }
|
||||
// if (this.isAlive() && AllowInterrupt) {
|
||||
// interrupt();
|
||||
// mNotifications.OnReadCancel();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -181,7 +98,6 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
} else {
|
||||
// Log.d(TAG, "Mismatch card UID (" + sUID + " instead of " + mCard.getUID() + ")");
|
||||
mNfcManager.ignoreTag(isoDep.getTag());
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
@ -252,8 +168,8 @@ public class PurgeActivity extends AppCompatActivity implements NfcAdapter.Reade
|
|||
} else {
|
||||
progressBar.post(() -> {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.TAG);
|
||||
if (!NoExtendedLengthSupportDialog.Companion.getAllReadyShowed()) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.Companion.getTAG());
|
||||
}
|
||||
} else
|
||||
Toast.makeText(getBaseContext(), R.string.try_to_scan_again, Toast.LENGTH_LONG).show();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -157,8 +157,8 @@ public class SwapPINActivity extends AppCompatActivity implements NfcAdapter.Rea
|
|||
|
||||
progressBar.post(() -> {
|
||||
if (cardProtocol.getError() instanceof CardProtocol.TangemException_ExtendedLengthNotSupported) {
|
||||
if (!NoExtendedLengthSupportDialog.allReadyShowed) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.TAG);
|
||||
if (!NoExtendedLengthSupportDialog.Companion.getAllReadyShowed()) {
|
||||
new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.Companion.getTAG());
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getBaseContext(), R.string.try_to_scan_again, Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -155,10 +155,10 @@ public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardVi
|
|||
holder.tvType.setVisibility(View.VISIBLE);
|
||||
holder.tvTypeBg.setVisibility(View.VISIBLE);
|
||||
if (card.isReusable()) {
|
||||
holder.tvType.setText(R.string.reusable_reusable);
|
||||
// holder.tvType.setText(R.string.reusable_reusable);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.type_wallet));
|
||||
} else {
|
||||
holder.tvType.setText(R.string.banknote_banknote);
|
||||
// holder.tvType.setText(R.string.banknote_banknote);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.type_banknote));
|
||||
}
|
||||
holder.tvVoid.setVisibility(View.INVISIBLE);
|
||||
|
|
@ -182,7 +182,7 @@ public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardVi
|
|||
holder.tvCardID.setError(null);
|
||||
holder.tvType.setVisibility(View.VISIBLE);
|
||||
holder.tvTypeBg.setVisibility(View.VISIBLE);
|
||||
holder.tvType.setText(R.string.banknote_banknote);
|
||||
// holder.tvType.setText(R.string.banknote_banknote);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.type_banknote));
|
||||
holder.tvVoid.setVisibility(View.INVISIBLE);
|
||||
break;
|
||||
|
|
@ -288,11 +288,11 @@ public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardVi
|
|||
holder.tvType.setVisibility(View.VISIBLE);
|
||||
holder.tvTypeBg.setVisibility(View.VISIBLE);
|
||||
if (card.isReusable()) {
|
||||
holder.tvType.setText(R.string.reusable_reusable);
|
||||
// holder.tvType.setText(R.string.reusable_reusable);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.type_wallet));
|
||||
holder.tvVoid.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
holder.tvType.setText(R.string.banknote_banknote);
|
||||
// holder.tvType.setText(R.string.banknote_banknote);
|
||||
if (card.getRemainingSignatures() != card.getMaxSignatures()) {
|
||||
holder.tvVoid.setVisibility(View.VISIBLE);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.msg_err));
|
||||
|
|
@ -305,7 +305,7 @@ public class CardListAdapter extends RecyclerView.Adapter<CardListAdapter.CardVi
|
|||
}
|
||||
|
||||
if (card.useDevelopersFirmware()) {
|
||||
holder.tvType.setText(R.string.developer_kit_spaces);
|
||||
// holder.tvType.setText(R.string.developer_kit_spaces);
|
||||
holder.tvTypeBg.setBackgroundColor(ContextCompat.getColor(mContext, R.color.fab));
|
||||
holder.tvVoid.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
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.v7.app.AlertDialog;
|
||||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
/**
|
||||
* Created by dvol on 18.02.2018.
|
||||
*/
|
||||
|
||||
public class NFCEnableDialog extends DialogFragment {
|
||||
public static final String TAG = NFCEnableDialog.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
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,
|
||||
(dialog, id) -> {
|
||||
// take user to wireless settings
|
||||
getActivity().startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
|
||||
})
|
||||
.setNegativeButton(R.string.dialog_quit,
|
||||
(dialog, id) -> {
|
||||
dialog.cancel();
|
||||
getActivity().finish();
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
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.v7.app.AlertDialog
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class NfcEnableDialog : DialogFragment() {
|
||||
|
||||
companion object {
|
||||
val TAG: String = NfcEnableDialog::class.java.simpleName
|
||||
}
|
||||
|
||||
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
|
||||
) { _, _ ->
|
||||
// take user to wireless settings
|
||||
activity.startActivity(Intent(Settings.ACTION_WIRELESS_SETTINGS))
|
||||
}
|
||||
.setNegativeButton(R.string.dialog_quit
|
||||
) { dialog, _ ->
|
||||
dialog.cancel()
|
||||
activity.finish()
|
||||
}
|
||||
return builder.create()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
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 com.tangem.wallet.R;
|
||||
|
||||
public class NoExtendedLengthSupportDialog extends DialogFragment {
|
||||
public static final String TAG = NoExtendedLengthSupportDialog.class.getSimpleName();
|
||||
|
||||
public static boolean allReadyShowed = false;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.the_nfc_adapter_length_apdu)
|
||||
.setPositiveButton(R.string.got_it, (dialog, whichButton) -> NoExtendedLengthSupportDialog.allReadyShowed = true)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.tangem.presentation.dialog
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.app.DialogFragment
|
||||
import android.os.Bundle
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class NoExtendedLengthSupportDialog : DialogFragment() {
|
||||
|
||||
companion object {
|
||||
val TAG: String = NoExtendedLengthSupportDialog::class.java.simpleName
|
||||
var allReadyShowed = false
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.the_nfc_adapter_length_apdu)
|
||||
.setPositiveButton(R.string.got_it) { _, _ -> NoExtendedLengthSupportDialog.allReadyShowed = true }
|
||||
.create()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.tangem.presentation.dialog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
public class RootFoundDialog extends DialogFragment {
|
||||
public static final String TAG = RootFoundDialog.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.device_is_rooted)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.got_it, null)
|
||||
.create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.tangem.presentation.dialog
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.app.DialogFragment
|
||||
import android.os.Bundle
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class RootFoundDialog : DialogFragment() {
|
||||
|
||||
companion object {
|
||||
val TAG: String = RootFoundDialog::class.java.simpleName
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.device_is_rooted)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.got_it, null)
|
||||
.create()
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue