diff --git a/app/src/main/java/com/tangem/domain/cardReader/NfcManager.java b/app/src/main/java/com/tangem/domain/cardReader/NfcManager.java index 50feddb35e..0fd4a34840 100644 --- a/app/src/main/java/com/tangem/domain/cardReader/NfcManager.java +++ b/app/src/main/java/com/tangem/domain/cardReader/NfcManager.java @@ -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() { diff --git a/app/src/main/java/com/tangem/presentation/activity/CreateNewWalletActivity.java b/app/src/main/java/com/tangem/presentation/activity/CreateNewWalletActivity.java index 11fe8c6bb3..bfa6df1a22 100644 --- a/app/src/main/java/com/tangem/presentation/activity/CreateNewWalletActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/CreateNewWalletActivity.java @@ -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(); diff --git a/app/src/main/java/com/tangem/presentation/activity/EmptyWalletActivity.java b/app/src/main/java/com/tangem/presentation/activity/EmptyWalletActivity.java index 1c901ac8e0..dc955365f4 100644 --- a/app/src/main/java/com/tangem/presentation/activity/EmptyWalletActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/EmptyWalletActivity.java @@ -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(); diff --git a/app/src/main/java/com/tangem/presentation/activity/MainActivity.kt b/app/src/main/java/com/tangem/presentation/activity/MainActivity.kt index 306f229df0..026361207e 100644 --- a/app/src/main/java/com/tangem/presentation/activity/MainActivity.kt +++ b/app/src/main/java/com/tangem/presentation/activity/MainActivity.kt @@ -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) } diff --git a/app/src/main/java/com/tangem/presentation/activity/PurgeActivity.java b/app/src/main/java/com/tangem/presentation/activity/PurgeActivity.java index 2171e00266..039d3c6e1e 100644 --- a/app/src/main/java/com/tangem/presentation/activity/PurgeActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/PurgeActivity.java @@ -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(); diff --git a/app/src/main/java/com/tangem/presentation/activity/SignPaymentActivity.java b/app/src/main/java/com/tangem/presentation/activity/SignPaymentActivity.java index aa9aca1012..9e2ca87b24 100644 --- a/app/src/main/java/com/tangem/presentation/activity/SignPaymentActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/SignPaymentActivity.java @@ -1 +1 @@ -package com.tangem.presentation.activity; import android.app.Activity; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.nfc.NfcAdapter; import android.nfc.Tag; import android.nfc.tech.IsoDep; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.tangem.data.nfc.SignPaymentTask; import com.tangem.domain.cardReader.CardProtocol; import com.tangem.domain.cardReader.NfcManager; 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 SignPaymentActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback, CardProtocol.Notifications { public static final String EXTRA_AMOUNT = "Amount"; public static final int REQUEST_CODE_SEND_PAYMENT = 1; 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 = "SignPayment"; private ProgressBar progressBar; private SignPaymentTask signPaymentTask; private String amountStr; private String feeStr; private String outAddressStr; private boolean lastReadSuccess = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_payment); MainActivity.Companion.commonInit(getApplicationContext()); mCard = new TangemCard(getIntent().getStringExtra("UID")); mCard.LoadFromBundle(getIntent().getExtras().getBundle("Card")); amountStr = getIntent().getStringExtra(EXTRA_AMOUNT); feeStr = getIntent().getStringExtra("Fee"); outAddressStr = getIntent().getStringExtra("Wallet"); 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())) { if (lastReadSuccess) { isoDep.setTimeout(mCard.getPauseBeforePIN2() + 5000); } else { isoDep.setTimeout(mCard.getPauseBeforePIN2() + 65000); } signPaymentTask = new SignPaymentTask(this, mCard, mNfcManager, isoDep, this, amountStr, feeStr, outAddressStr); signPaymentTask.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 (signPaymentTask != null) { signPaymentTask.cancel(true); } super.onPause(); } @Override public void onStop() { // dismiss enable NFC dialog mNfcManager.onStop(); if (signPaymentTask != null) { signPaymentTask.cancel(true); } super.onStop(); } public void OnReadStart(CardProtocol cardProtocol) { progressBar.post(() -> { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(5); }); } public void OnReadFinish(final CardProtocol cardProtocol) { signPaymentTask = null; if (cardProtocol != null) { if (cardProtocol.getError() == null) { progressBar.post(() -> { progressBar.setProgress(100); progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN)); }); } else { lastReadSuccess = false; if (cardProtocol.getError().getClass().equals(CardProtocol.TangemException_InvalidPIN.class)) { 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("message", "Cannot sign transaction. Make sure you enter correct PIN2!"); intent.putExtra("UID", cardProtocol.getCard().getUID()); intent.putExtra("Card", cardProtocol.getCard().getAsBundle()); 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() { signPaymentTask = null; progressBar.postDelayed(() -> { try { progressBar.setProgress(0); progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); progressBar.setVisibility(View.INVISIBLE); } catch (Exception e) { e.printStackTrace(); } }, 500); } @Override public void OnReadWait(final int msec) { WaitSecurityDelayDialog.OnReadWait(this, msec); } @Override public void OnReadBeforeRequest(int timeout) { WaitSecurityDelayDialog.onReadBeforeRequest(this, timeout); } @Override public void OnReadAfterRequest() { WaitSecurityDelayDialog.onReadAfterRequest(this); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Intent intent = new Intent(); // intent.putExtra("message", "Operation canceled"); setResult(Activity.RESULT_CANCELED, intent); finish(); return true; } return super.onKeyDown(keyCode, event); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_SEND_PAYMENT) { setResult(resultCode, data); finish(); return; } super.onActivityResult(requestCode, resultCode, data); } } \ No newline at end of file +package com.tangem.presentation.activity; import android.app.Activity; import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Color; import android.nfc.NfcAdapter; import android.nfc.Tag; import android.nfc.tech.IsoDep; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.tangem.data.nfc.SignPaymentTask; import com.tangem.domain.cardReader.CardProtocol; import com.tangem.domain.cardReader.NfcManager; 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 SignPaymentActivity extends AppCompatActivity implements NfcAdapter.ReaderCallback, CardProtocol.Notifications { public static final String EXTRA_AMOUNT = "Amount"; public static final int REQUEST_CODE_SEND_PAYMENT = 1; 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 = "SignPayment"; private ProgressBar progressBar; private SignPaymentTask signPaymentTask; private String amountStr; private String feeStr; private String outAddressStr; private boolean lastReadSuccess = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_payment); MainActivity.Companion.commonInit(getApplicationContext()); mCard = new TangemCard(getIntent().getStringExtra("UID")); mCard.LoadFromBundle(getIntent().getExtras().getBundle("Card")); amountStr = getIntent().getStringExtra(EXTRA_AMOUNT); feeStr = getIntent().getStringExtra("Fee"); outAddressStr = getIntent().getStringExtra("Wallet"); 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())) { if (lastReadSuccess) { isoDep.setTimeout(mCard.getPauseBeforePIN2() + 5000); } else { isoDep.setTimeout(mCard.getPauseBeforePIN2() + 65000); } signPaymentTask = new SignPaymentTask(this, mCard, mNfcManager, isoDep, this, amountStr, feeStr, outAddressStr); signPaymentTask.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 (signPaymentTask != null) { signPaymentTask.cancel(true); } super.onPause(); } @Override public void onStop() { // dismiss enable NFC dialog mNfcManager.onStop(); if (signPaymentTask != null) { signPaymentTask.cancel(true); } super.onStop(); } public void OnReadStart(CardProtocol cardProtocol) { progressBar.post(() -> { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(5); }); } public void OnReadFinish(final CardProtocol cardProtocol) { signPaymentTask = null; if (cardProtocol != null) { if (cardProtocol.getError() == null) { progressBar.post(() -> { progressBar.setProgress(100); progressBar.setProgressTintList(ColorStateList.valueOf(Color.GREEN)); }); } else { lastReadSuccess = false; if (cardProtocol.getError().getClass().equals(CardProtocol.TangemException_InvalidPIN.class)) { 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("message", "Cannot sign transaction. Make sure you enter correct PIN2!"); intent.putExtra("UID", cardProtocol.getCard().getUID()); intent.putExtra("Card", cardProtocol.getCard().getAsBundle()); 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.Companion.getAllReadyShowed()) { new NoExtendedLengthSupportDialog().show(getFragmentManager(), NoExtendedLengthSupportDialog.Companion.getTAG()); } } 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() { signPaymentTask = null; progressBar.postDelayed(() -> { try { progressBar.setProgress(0); progressBar.setProgressTintList(ColorStateList.valueOf(Color.DKGRAY)); progressBar.setVisibility(View.INVISIBLE); } catch (Exception e) { e.printStackTrace(); } }, 500); } @Override public void OnReadWait(final int msec) { WaitSecurityDelayDialog.OnReadWait(this, msec); } @Override public void OnReadBeforeRequest(int timeout) { WaitSecurityDelayDialog.onReadBeforeRequest(this, timeout); } @Override public void OnReadAfterRequest() { WaitSecurityDelayDialog.onReadAfterRequest(this); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Intent intent = new Intent(); // intent.putExtra("message", "Operation canceled"); setResult(Activity.RESULT_CANCELED, intent); finish(); return true; } return super.onKeyDown(keyCode, event); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_SEND_PAYMENT) { setResult(resultCode, data); finish(); return; } super.onActivityResult(requestCode, resultCode, data); } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/activity/SwapPINActivity.java b/app/src/main/java/com/tangem/presentation/activity/SwapPINActivity.java index 44bfdf8ad7..a2d62af23f 100644 --- a/app/src/main/java/com/tangem/presentation/activity/SwapPINActivity.java +++ b/app/src/main/java/com/tangem/presentation/activity/SwapPINActivity.java @@ -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(); diff --git a/app/src/main/java/com/tangem/presentation/adapter/CardListAdapter.java b/app/src/main/java/com/tangem/presentation/adapter/CardListAdapter.java index f90687b268..5eafa3eaa2 100644 --- a/app/src/main/java/com/tangem/presentation/adapter/CardListAdapter.java +++ b/app/src/main/java/com/tangem/presentation/adapter/CardListAdapter.java @@ -155,10 +155,10 @@ public class CardListAdapter extends RecyclerView.Adapter { - // 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(); - } - -} diff --git a/app/src/main/java/com/tangem/presentation/dialog/NfcEnableDialog.kt b/app/src/main/java/com/tangem/presentation/dialog/NfcEnableDialog.kt new file mode 100644 index 0000000000..f62ccb9786 --- /dev/null +++ b/app/src/main/java/com/tangem/presentation/dialog/NfcEnableDialog.kt @@ -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() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.java b/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.java deleted file mode 100644 index f3ecbbb069..0000000000 --- a/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.java +++ /dev/null @@ -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); - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.kt b/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.kt new file mode 100644 index 0000000000..95d73006ed --- /dev/null +++ b/app/src/main/java/com/tangem/presentation/dialog/NoExtendedLengthSupportDialog.kt @@ -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() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.java b/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.java deleted file mode 100644 index b21e2ad791..0000000000 --- a/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.java +++ /dev/null @@ -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(); - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.kt b/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.kt new file mode 100644 index 0000000000..b49551d716 --- /dev/null +++ b/app/src/main/java/com/tangem/presentation/dialog/RootFoundDialog.kt @@ -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() + } + +} \ 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 c90a272d08..54a36f8f14 100644 --- a/app/src/main/res/layout/fr_loaded_wallet.xml +++ b/app/src/main/res/layout/fr_loaded_wallet.xml @@ -23,182 +23,176 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"> - + android:layout_height="wrap_content" + android:layout_alignParentBottom="false" + android:background="@color/white" + android:gravity="center" + android:orientation="vertical"> + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:orientation="horizontal"> - + - + + + + + + + + + + + + + + + + + android:fontFamily="@font/montserrat_light" + android:textAlignment="center" + android:textColor="@android:color/black" + android:textSize="@dimen/text_size_1_small" + android:textStyle="normal|bold" + tools:text="1DoQdnSYshhZ5Tqt5Sk6svZt29jqoYVwQY"/> - + - - - - - + - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 206d94aaeb..d32b41b9ab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -82,9 +82,6 @@ NO WALLET ERASED WALLET INVALID CARD -            DEVELOPER     KIT      -   BANKNOTE        BANKNOTE -    REUSABLE       REUSABLE    The wallet is empty @@ -122,7 +119,6 @@ EXTRACT LOAD - BETA