Updated on 2026-08-14

This commit is contained in:
Tangem 2018-12-27 16:19:48 +03:00
parent c01895f6ab
commit aac014439b
5 changed files with 124 additions and 22 deletions

View file

@ -21,6 +21,10 @@ 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.ReadAfterRequest
import com.tangem.presentation.event.ReadBeforeRequest
import com.tangem.presentation.event.ReadWait
import com.tangem.presentation.event.TransactionFinishWithError
import com.tangem.tangemcard.reader.CardProtocol
import com.tangem.tangemcard.android.reader.NfcManager
import com.tangem.tangemcard.android.reader.NfcReader
@ -30,6 +34,7 @@ import com.tangem.tangemcard.util.Util
import com.tangem.util.LOG
import com.tangem.wallet.R
import kotlinx.android.synthetic.main.activity_sign_payment.*
import org.greenrobot.eventbus.EventBus
class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
@ -257,26 +262,38 @@ class SignPaymentActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
private val waitSecurityDelayDialogNew = WaitSecurityDelayDialogNew()
override fun onReadBeforeRequest(timeout: Int) {
LOG.i(TAG, "onReadBeforeRequest timeout $timeout")
WaitSecurityDelayDialog.onReadBeforeRequest(this, timeout)
// LOG.i(TAG, "onReadBeforeRequest timeout $timeout")
// 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() {
LOG.i(TAG, "onReadAfterRequest")
WaitSecurityDelayDialog.onReadAfterRequest(this)
// LOG.i(TAG, "onReadAfterRequest")
// WaitSecurityDelayDialog.onReadAfterRequest(this)
val readAfterRequest = ReadAfterRequest()
EventBus.getDefault().post(readAfterRequest)
}
override fun onReadWait(msec: Int) {
LOG.i(TAG, "onReadWait msec $msec")
WaitSecurityDelayDialog.onReadWait(this, msec)
// LOG.i(TAG, "onReadWait msec $msec")
// WaitSecurityDelayDialog.onReadWait(this, msec)
val readWait = ReadWait()
readWait.msec = msec
EventBus.getDefault().post(readWait)
}
}

View file

@ -6,7 +6,15 @@ import android.app.Dialog
import android.os.Bundle
import android.support.v7.app.AppCompatDialogFragment
import android.widget.ProgressBar
import com.tangem.presentation.activity.SignPaymentActivity
import com.tangem.presentation.event.ReadAfterRequest
import com.tangem.presentation.event.ReadBeforeRequest
import com.tangem.presentation.event.ReadWait
import com.tangem.presentation.event.TransactionFinishWithSuccess
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() {
@ -54,23 +62,38 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
.create()
}
fun onReadBeforeRequest(timeout: Int) {
if (timerToShowDelayDialog != null || timeout < DELAY_BEFORE_SHOW_DIALOG + MIN_REMAINING_DELAY_TO_SHOW_DIALOG)
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(timeout, DELAY_BEFORE_SHOW_DIALOG)
setup(readBeforeRequest.timeout!!, DELAY_BEFORE_SHOW_DIALOG)
isCancelable = false
// if (!isVisible)
if (!isAdded)
show(activity?.supportFragmentManager, TAG)
}
}, DELAY_BEFORE_SHOW_DIALOG.toLong())
}
fun onReadAfterRequest() {
@Subscribe
fun readAfterRequest(readAfterRequest: ReadAfterRequest) {
LOG.i(TAG, "readAfterRequest 222")
if (timerToShowDelayDialog == null)
return
@ -78,26 +101,74 @@ class WaitSecurityDelayDialogNew : AppCompatDialogFragment() {
timerToShowDelayDialog = null
}
fun onReadWait(msec: Int) {
@Subscribe
fun readWait(readWait: ReadWait) {
LOG.i(TAG, "readWait 333")
if (timerToShowDelayDialog != null) {
timerToShowDelayDialog!!.cancel()
timerToShowDelayDialog = null
}
if (msec == 0) {
if (readWait.msec == 0) {
dismiss()
return
}
if (msec > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
if (readWait.msec!! > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
// 1000ms - card delay notification interval
setup(msec + 1000, 1000)
setup(readWait.msec!! + 1000, 1000)
isCancelable = false
// if (!isVisible)
show(activity?.supportFragmentManager, TAG)
// if (!isAdded)
// show(activity?.supportFragmentManager, TAG)
} else
setRemainingTimeout(msec)
setRemainingTimeout(readWait.msec!!)
}
fun onReadBeforeRequest(timeout: Int) {
// if (timerToShowDelayDialog != null || timeout < DELAY_BEFORE_SHOW_DIALOG + MIN_REMAINING_DELAY_TO_SHOW_DIALOG)
// return
//
// timerToShowDelayDialog = Timer()
// timerToShowDelayDialog!!.schedule(object : TimerTask() {
// override fun run() {
// setup(timeout, DELAY_BEFORE_SHOW_DIALOG)
// isCancelable = false
// if (!isVisible)
// show(activity?.supportFragmentManager, TAG)
// }
// }, DELAY_BEFORE_SHOW_DIALOG.toLong())
}
fun onReadAfterRequest() {
// if (timerToShowDelayDialog == null)
// return
//
// timerToShowDelayDialog!!.cancel()
// timerToShowDelayDialog = null
}
fun onReadWait(msec: Int) {
// if (timerToShowDelayDialog != null) {
// timerToShowDelayDialog!!.cancel()
// timerToShowDelayDialog = null
// }
//
// if (msec == 0) {
// dismiss()
// return
// }
//
// if (msec > MIN_REMAINING_DELAY_TO_SHOW_DIALOG) {
// // 1000ms - card delay notification interval
// setup(msec + 1000, 1000)
// isCancelable = false
//// if (!isVisible)
// show(activity?.supportFragmentManager, TAG)
//
// } else
// setRemainingTimeout(msec)
}
private fun setup(msTimeout: Int, msProgress: Int) {

View file

@ -0,0 +1,4 @@
package com.tangem.presentation.event
class ReadAfterRequest {
}

View file

@ -0,0 +1,5 @@
package com.tangem.presentation.event
class ReadBeforeRequest {
var timeout: Int? = null
}

View file

@ -0,0 +1,5 @@
package com.tangem.presentation.event
class ReadWait {
var msec: Int? = null
}