Updated on 2026-08-14
This commit is contained in:
commit
36b764c88e
8 changed files with 144 additions and 136 deletions
12
.idea/misc.xml
generated
12
.idea/misc.xml
generated
|
|
@ -7,10 +7,10 @@
|
|||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="7">
|
||||
<list size="10">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
|
|
@ -18,18 +18,24 @@
|
|||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="6">
|
||||
<list size="9">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class AppModule {
|
||||
private Context appContext;
|
||||
|
||||
public AppModule(@NotNull Context context) {
|
||||
appContext = context;
|
||||
}
|
||||
|
||||
Context provideContext() {
|
||||
return appContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import com.tangem.presentation.activity.MainActivity;
|
|||
import com.tangem.presentation.activity.PrepareCryptonitOtherApiWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PrepareKrakenWithdrawalActivity;
|
||||
import com.tangem.presentation.activity.PrepareTransactionActivity;
|
||||
import com.tangem.presentation.activity.PurgeActivity;
|
||||
import com.tangem.presentation.activity.VerifyCardActivity;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -14,15 +15,15 @@ import javax.inject.Singleton;
|
|||
import dagger.Component;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {
|
||||
// AppModule.class,
|
||||
NavigatorModule.class})
|
||||
@Component(modules = {NavigatorModule.class})
|
||||
public interface NavigatorComponent {
|
||||
|
||||
void inject(LogoActivity activity);
|
||||
|
||||
void inject(MainActivity activity);
|
||||
|
||||
void inject(PurgeActivity activity);
|
||||
|
||||
void inject(PrepareTransactionActivity activity);
|
||||
|
||||
void inject(PrepareCryptonitOtherApiWithdrawalActivity activity);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialogNew;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
|
|
@ -14,4 +16,10 @@ class NavigatorModule {
|
|||
return new Navigator();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
WaitSecurityDelayDialogNew provideWaitSecurityDelayDialogNew() {
|
||||
return new WaitSecurityDelayDialogNew();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ import com.tangem.domain.wallet.TangemContext
|
|||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.RootFoundDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialogNew
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@ import com.tangem.tangemcard.android.reader.NfcManager
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialogNew
|
||||
import com.tangem.presentation.event.DeletingWalletFinish
|
||||
import com.tangem.presentation.event.ReadAfterRequest
|
||||
import com.tangem.presentation.event.ReadBeforeRequest
|
||||
import com.tangem.presentation.event.ReadWait
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
|
|
@ -34,6 +38,7 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.activity_purge.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
companion object {
|
||||
|
|
@ -48,6 +53,9 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
const val RESULT_INVALID_PIN = Activity.RESULT_FIRST_USER
|
||||
}
|
||||
|
||||
@Inject
|
||||
internal lateinit var waitSecurityDelayDialogNew: WaitSecurityDelayDialogNew
|
||||
|
||||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
|
|
@ -59,6 +67,8 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_purge)
|
||||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
|
@ -137,14 +147,29 @@ class PurgeActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoc
|
|||
|
||||
override fun onReadWait(msec: Int) {
|
||||
WaitSecurityDelayDialog.onReadWait(this, msec)
|
||||
|
||||
// val readWait = ReadWait()
|
||||
// readWait.msec = msec
|
||||
// EventBus.getDefault().post(readWait)
|
||||
}
|
||||
|
||||
override fun onReadBeforeRequest(timeout: Int) {
|
||||
WaitSecurityDelayDialog.onReadBeforeRequest(this, timeout)
|
||||
|
||||
// if (!waitSecurityDelayDialogNew.isAdded)
|
||||
// waitSecurityDelayDialogNew.show(supportFragmentManager, WaitSecurityDelayDialogNew.TAG)
|
||||
//
|
||||
//
|
||||
// val readBeforeRequest = ReadBeforeRequest()
|
||||
// readBeforeRequest.timeout = timeout
|
||||
// EventBus.getDefault().post(readBeforeRequest)
|
||||
}
|
||||
|
||||
override fun onReadAfterRequest() {
|
||||
WaitSecurityDelayDialog.onReadAfterRequest(this)
|
||||
|
||||
// val readAfterRequest = ReadAfterRequest()
|
||||
// EventBus.getDefault().post(readAfterRequest)
|
||||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import android.app.Activity;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
||||
import android.content.Context;
|
||||
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;
|
||||
|
|
@ -15,6 +17,8 @@ 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;
|
||||
|
||||
|
|
@ -22,17 +26,28 @@ import androidx.fragment.app.DialogFragment;
|
|||
* Created by dvol on 06.03.2018.
|
||||
*/
|
||||
public class WaitSecurityDelayDialog extends DialogFragment {
|
||||
ProgressBar progressBar;
|
||||
int msTimeout = 60000, msProgress = 0;
|
||||
Timer timer;
|
||||
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();
|
||||
|
||||
// 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_wait_pin2, null);
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
|
|
@ -43,131 +58,102 @@ public class WaitSecurityDelayDialog extends DialogFragment {
|
|||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int progress = WaitSecurityDelayDialog.this.progressBar.getProgress();
|
||||
if (progress < WaitSecurityDelayDialog.this.progressBar.getMax()) {
|
||||
WaitSecurityDelayDialog.this.progressBar.setProgress(progress + 1000);
|
||||
}
|
||||
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("Security delay")
|
||||
.setTitle(R.string.security_delay)
|
||||
.setView(v)
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
public void onCancel(@NonNull DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
public void setup(int msTimeout, int msProgress) {
|
||||
this.msTimeout = msTimeout;
|
||||
this.msProgress = msProgress;
|
||||
}
|
||||
|
||||
public void setRemainingTimeout(final int msec) {
|
||||
progressBar.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Timer timerToShowDelayDialog = null;
|
||||
static WaitSecurityDelayDialog instance = null;
|
||||
|
||||
// public static WaitSecurityDelayDialog getInstance() {
|
||||
// if (instance == null) {
|
||||
// instance = new WaitSecurityDelayDialog();
|
||||
// }
|
||||
// return instance;
|
||||
// }
|
||||
|
||||
private final static int MinRemainingDelayToShowDialog = 1000;
|
||||
private final static int DelayBeforeShowDialog = 5000;
|
||||
|
||||
public static void onReadBeforeRequest(final AppCompatActivity activity, final int timeout) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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(), "WaitSecurityDelayDialog");
|
||||
}
|
||||
}, DelayBeforeShowDialog);
|
||||
}
|
||||
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(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (timerToShowDelayDialog == null) return;
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
}
|
||||
activity.runOnUiThread(() -> {
|
||||
if (timerToShowDelayDialog == null) return;
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
});
|
||||
}
|
||||
|
||||
public static void onReadWait(final AppCompatActivity activity, final int msec) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
}
|
||||
activity.runOnUiThread(() -> {
|
||||
if (timerToShowDelayDialog != null) {
|
||||
timerToShowDelayDialog.cancel();
|
||||
timerToShowDelayDialog = null;
|
||||
}
|
||||
|
||||
if (msec == 0) {
|
||||
if (instance != null) {
|
||||
//TODO remove onNext java.lang.IllegalStateException: Fragment WaitSecurityDelayDialog{ba2c429 (2368a785-523e-4c3d-b46a-402d2c4f102b)} not associated with a fragment manager.
|
||||
instance.dismiss();
|
||||
instance = null;
|
||||
}
|
||||
return;
|
||||
if (msec == 0) {
|
||||
if (instance != null && instance.isAdded()) {
|
||||
instance.dismiss();
|
||||
instance = null;
|
||||
}
|
||||
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(), "WaitSecurityDelayDialog");
|
||||
}
|
||||
} else {
|
||||
instance.setRemainingTimeout(msec);
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -83,10 +83,11 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
setup(readBeforeRequest.timeout!!, DELAY_BEFORE_SHOW_DIALOG)
|
||||
isCancelable = false
|
||||
|
||||
|
||||
|
||||
// if (!isAdded)
|
||||
// show(activity?.supportFragmentManager, TAG)
|
||||
show(activity!!.supportFragmentManager, TAG)
|
||||
|
||||
// if (isHidden)
|
||||
// activity?.supportFragmentManager?.let { show(it, TAG) }
|
||||
}
|
||||
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
|
||||
}
|
||||
|
|
@ -120,8 +121,9 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
|
|||
// 1000ms - card delay notification interval
|
||||
setup(readWait.msec!! + 1000, 1000)
|
||||
isCancelable = false
|
||||
// if (!isAdded)
|
||||
// show(activity?.supportFragmentManager, TAG)
|
||||
|
||||
if (isHidden)
|
||||
activity?.supportFragmentManager?.let { show(it, TAG) }
|
||||
|
||||
} else
|
||||
setRemainingTimeout(readWait.msec!!)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue