Updated on 2026-08-14
This commit is contained in:
parent
449840473a
commit
64ddaa4541
63 changed files with 128 additions and 164 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package com.tangem.ui.dialog
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
import com.tangem.wallet.R
|
||||
|
||||
class NoExtendedLengthSupportDialog : DialogFragment() {
|
||||
|
||||
companion object {
|
||||
val TAG: String = NoExtendedLengthSupportDialog::class.java.simpleName
|
||||
var allReadyShowed = false
|
||||
var message = ""// = R.string.the_nfc_adapter_length_apdu
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return AlertDialog.Builder(activity)
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.got_it) { _, _ -> NoExtendedLengthSupportDialog.allReadyShowed = false }
|
||||
.create()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.tangem.ui.dialog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
public class PINSwapWarningDialog extends DialogFragment {
|
||||
public static final String TAG = PINSwapWarningDialog.class.getSimpleName();
|
||||
|
||||
public static final String EXTRA_MESSAGE = "message";
|
||||
private String message;
|
||||
private OnPositiveButton mOnPositiveButton;
|
||||
|
||||
public interface OnPositiveButton {
|
||||
void onRefresh();
|
||||
}
|
||||
|
||||
public void setOnRefreshPage(OnPositiveButton listener) {
|
||||
mOnPositiveButton = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
message = getArguments().getString(EXTRA_MESSAGE);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.your_money_is_at_risk)
|
||||
.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(R.string.cancel, (dialog, which) -> dismiss())
|
||||
.setPositiveButton(R.string.contin, (dialog, whichButton) -> mOnPositiveButton.onRefresh())
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
}
|
||||
25
app/src/main/java/com/tangem/ui/dialog/RootFoundDialog.kt
Normal file
25
app/src/main/java/com/tangem/ui/dialog/RootFoundDialog.kt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package com.tangem.ui.dialog
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
||||
78
app/src/main/java/com/tangem/ui/dialog/ShowQRCodeDialog.java
Normal file
78
app/src/main/java/com/tangem/ui/dialog/ShowQRCodeDialog.java
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
package com.tangem.ui.dialog;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.tangem.util.UtilHelper;
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
/**
|
||||
* Created by dvol on 06.03.2018.
|
||||
*/
|
||||
public class ShowQRCodeDialog extends DialogFragment {
|
||||
private ImageView ivQR;
|
||||
private TextView tvQRaddress;
|
||||
private Bitmap bmQR;
|
||||
private String addr;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
|
||||
// Inflate and set the layout for the dialog
|
||||
// Pass null as the parent view because its going in the dialog layout
|
||||
View v = inflater.inflate(R.layout.dialog_show_qr, null);
|
||||
ivQR = v.findViewById(R.id.ivQR);
|
||||
ivQR.setImageBitmap(bmQR);
|
||||
tvQRaddress = v.findViewById(R.id.tvQRaddress);
|
||||
tvQRaddress.setText(addr);
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.show_wallet_qr_code)
|
||||
.setView(v)
|
||||
.setPositiveButton(R.string.ok, (dialog,which)->dismiss() )
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
public void setup(String content) {
|
||||
try {
|
||||
bmQR = UtilHelper.INSTANCE.generateQrCode(content);
|
||||
addr = content;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void show(final AppCompatActivity activity, final String content) {
|
||||
activity.runOnUiThread(() -> {
|
||||
ShowQRCodeDialog instance = new ShowQRCodeDialog();
|
||||
instance.setup(content);
|
||||
instance.show(activity.getSupportFragmentManager(), "ShowQRCodeDialog");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
package com.tangem.ui.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.tangem.wallet.R;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
/**
|
||||
* Created by dvol on 06.03.2018.
|
||||
*/
|
||||
public class WaitSecurityDelayDialog extends DialogFragment {
|
||||
public static final String TAG = WaitSecurityDelayDialog.class.getSimpleName();
|
||||
|
||||
private ProgressBar progressBar;
|
||||
private int msTimeout = 60000, msProgress = 0;
|
||||
private Timer timer;
|
||||
|
||||
private static Timer timerToShowDelayDialog = null;
|
||||
private static WaitSecurityDelayDialog instance = null;
|
||||
|
||||
private final static int minRemainingDelayToShowDialog = 1000;
|
||||
private final static int delayBeforeShowDialog = 5000;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
|
||||
View v = inflater.inflate(R.layout.dialog_wait_pin2, null);
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
progressBar.setMax(msTimeout);
|
||||
progressBar.setProgress(msProgress);
|
||||
|
||||
timer = new Timer();
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.post(() -> {
|
||||
int progress = WaitSecurityDelayDialog.this.progressBar.getProgress();
|
||||
if (progress < WaitSecurityDelayDialog.this.progressBar.getMax()) {
|
||||
WaitSecurityDelayDialog.this.progressBar.setProgress(progress + 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 1000, 1000);
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.security_delay)
|
||||
.setView(v)
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(@NonNull DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
public static void onReadBeforeRequest(final AppCompatActivity activity, final int timeout) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (timerToShowDelayDialog != null || timeout < delayBeforeShowDialog + minRemainingDelayToShowDialog)
|
||||
return;
|
||||
timerToShowDelayDialog = new Timer();
|
||||
timerToShowDelayDialog.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (WaitSecurityDelayDialog.instance != null) return;
|
||||
instance = new WaitSecurityDelayDialog();
|
||||
instance.setup(timeout, delayBeforeShowDialog);
|
||||
instance.setCancelable(false);
|
||||
instance.show(activity.getSupportFragmentManager(), TAG);
|
||||
}
|
||||
}, delayBeforeShowDialog);
|
||||
});
|
||||
}
|
||||
|
||||
public static void onReadAfterRequest(final Activity activity) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (timerToShowDelayDialog == null) return;
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
});
|
||||
}
|
||||
|
||||
public static void onReadWait(final AppCompatActivity activity, final int msec) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
}
|
||||
|
||||
if (msec == 0) {
|
||||
if (instance != null && instance.isAdded()) {
|
||||
instance.dismiss();
|
||||
instance = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance == null) {
|
||||
if (msec > minRemainingDelayToShowDialog) {
|
||||
instance = new WaitSecurityDelayDialog();
|
||||
// 1000ms - card delay notification interval
|
||||
instance.setup(msec + 1000, 1000);
|
||||
instance.setCancelable(false);
|
||||
instance.show(activity.getSupportFragmentManager(), TAG);
|
||||
}
|
||||
} else
|
||||
instance.setRemainingTimeout(msec);
|
||||
});
|
||||
}
|
||||
|
||||
private void setup(int msTimeout, int msProgress) {
|
||||
this.msTimeout = msTimeout;
|
||||
this.msProgress = msProgress;
|
||||
}
|
||||
|
||||
private void setRemainingTimeout(final int msec) {
|
||||
progressBar.post(() -> {
|
||||
int progress = WaitSecurityDelayDialog.this.progressBar.getProgress();
|
||||
if (timer != null) {
|
||||
// we get delay latency from card for first time - don't change progress by timer, only by card answer
|
||||
progressBar.setMax(progress + msec);
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
} else {
|
||||
int newProgress = progressBar.getMax() - msec;
|
||||
if (newProgress > progress)
|
||||
progressBar.setProgress(newProgress);
|
||||
else
|
||||
progressBar.setMax(progress + msec);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
package com.tangem.ui.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import android.widget.ProgressBar
|
||||
import com.tangem.ui.event.ReadAfterRequest
|
||||
import com.tangem.ui.event.ReadBeforeRequest
|
||||
import com.tangem.ui.event.ReadWait
|
||||
import com.tangem.util.LOG
|
||||
import com.tangem.wallet.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import java.util.*
|
||||
|
||||
class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
||||
|
||||
companion object {
|
||||
val TAG: String = WaitSecurityDelayDialogNew::class.java.simpleName
|
||||
|
||||
private const val MIN_REMAINING_DELAY_TO_SHOW_DIALOG = 1000
|
||||
private const val DELAY_BEFORE_SHOW_DIALOG = 5000
|
||||
}
|
||||
|
||||
private lateinit var pb: ProgressBar
|
||||
|
||||
private var msTimeout = 60000
|
||||
private var msProgress = 0
|
||||
private var timer: Timer? = null
|
||||
private var timerToShowDelayDialog: Timer? = null
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val inflater = activity!!.layoutInflater
|
||||
val v = inflater.inflate(R.layout.dialog_wait_pin2, null)
|
||||
|
||||
pb = v.findViewById(R.id.progressBar)
|
||||
|
||||
pb.max = msTimeout
|
||||
pb.progress = msProgress
|
||||
|
||||
timer = Timer()
|
||||
timer!!.scheduleAtFixedRate(object : TimerTask() {
|
||||
override fun run() {
|
||||
pb.post {
|
||||
val progress = pb.progress
|
||||
if (progress < pb.max)
|
||||
pb.progress = progress + 1000
|
||||
}
|
||||
}
|
||||
}, 1000, 1000)
|
||||
|
||||
return AlertDialog.Builder(activity)
|
||||
.setIcon(R.drawable.tangem_logo_small_new)
|
||||
.setTitle(R.string.security_delay)
|
||||
.setView(v)
|
||||
.setCancelable(false)
|
||||
.create()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readBeforeRequest(readBeforeRequest: ReadBeforeRequest) {
|
||||
LOG.i(TAG, "readBeforeRequest 111")
|
||||
|
||||
if (timerToShowDelayDialog != null || readBeforeRequest.timeout!! < DELAY_BEFORE_SHOW_DIALOG + MIN_REMAINING_DELAY_TO_SHOW_DIALOG)
|
||||
return
|
||||
|
||||
timerToShowDelayDialog = Timer()
|
||||
timerToShowDelayDialog!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
setup(readBeforeRequest.timeout!!, DELAY_BEFORE_SHOW_DIALOG)
|
||||
isCancelable = false
|
||||
|
||||
// if (!isAdded)
|
||||
show(activity!!.supportFragmentManager, TAG)
|
||||
|
||||
// if (isHidden)
|
||||
// activity?.supportFragmentManager?.let { show(it, TAG) }
|
||||
}
|
||||
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readAfterRequest(readAfterRequest: ReadAfterRequest) {
|
||||
LOG.i(TAG, "readAfterRequest 222")
|
||||
|
||||
if (timerToShowDelayDialog == null)
|
||||
return
|
||||
|
||||
timerToShowDelayDialog!!.cancel()
|
||||
timerToShowDelayDialog = null
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun readWait(readWait: ReadWait) {
|
||||
LOG.i(TAG, "readWait 333")
|
||||
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog!!.cancel()
|
||||
timerToShowDelayDialog = null
|
||||
}
|
||||
|
||||
if (readWait.msec == 0) {
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
|
||||
if (readWait.msec!! > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
|
||||
// 1000ms - card delay notification interval
|
||||
setup(readWait.msec!! + 1000, 1000)
|
||||
isCancelable = false
|
||||
|
||||
if (isHidden)
|
||||
activity?.supportFragmentManager?.let { show(it, TAG) }
|
||||
|
||||
} else
|
||||
setRemainingTimeout(readWait.msec!!)
|
||||
}
|
||||
|
||||
private fun setup(msTimeout: Int, msProgress: Int) {
|
||||
this.msTimeout = msTimeout
|
||||
this.msProgress = msProgress
|
||||
}
|
||||
|
||||
private fun setRemainingTimeout(msec: Int) {
|
||||
pb.post {
|
||||
val progress = pb.progress
|
||||
if (timer != null) {
|
||||
|
||||
// we get delay latency from card for first time - don't change progress by timer, only by card answer
|
||||
pb.max = progress + msec
|
||||
timer!!.cancel()
|
||||
timer = null
|
||||
} else {
|
||||
val newProgress = pb.max - msec
|
||||
if (pb.max > progress)
|
||||
pb.progress = newProgress
|
||||
else
|
||||
pb.max = progress + msec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue