Updated on 2026-08-14
This commit is contained in:
parent
1d03efbef0
commit
d588893224
5 changed files with 88 additions and 9 deletions
|
|
@ -11,7 +11,11 @@ import android.os.Bundle
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.Transformation
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import com.tangem.App
|
||||
import com.tangem.Constant
|
||||
|
|
@ -20,6 +24,7 @@ import com.tangem.domain.wallet.CoinEngineFactory
|
|||
import com.tangem.domain.wallet.TangemContext
|
||||
import com.tangem.presentation.dialog.NoExtendedLengthSupportDialog
|
||||
import com.tangem.presentation.dialog.WaitSecurityDelayDialog
|
||||
import com.tangem.tangemcard.android.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.tangemcard.android.reader.NfcManager
|
||||
import com.tangem.tangemcard.android.reader.NfcReader
|
||||
import com.tangem.tangemcard.data.asBundle
|
||||
|
|
@ -29,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_transaction.*
|
||||
import kotlinx.android.synthetic.main.layout_touch_card.*
|
||||
|
||||
class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications {
|
||||
|
||||
|
|
@ -39,6 +45,8 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
private lateinit var nfcManager: NfcManager
|
||||
private lateinit var ctx: TangemContext
|
||||
|
||||
private lateinit var antenna: DeviceNFCAntennaLocation
|
||||
|
||||
private var signTransactionTask: SignTask? = null
|
||||
|
||||
private lateinit var amount: CoinEngine.Amount
|
||||
|
|
@ -67,6 +75,31 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
progressBar = findViewById(R.id.progressBar)
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.DKGRAY)
|
||||
progressBar!!.visibility = View.INVISIBLE
|
||||
|
||||
// get NFC Antenna
|
||||
antenna = DeviceNFCAntennaLocation()
|
||||
antenna.getAntennaLocation()
|
||||
|
||||
// set card orientation
|
||||
when (antenna.orientation) {
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_HORIZONTAL -> {
|
||||
ivHandCardHorizontal.visibility = View.VISIBLE
|
||||
ivHandCardVertical.visibility = View.GONE
|
||||
}
|
||||
|
||||
DeviceNFCAntennaLocation.CARD_ORIENTATION_VERTICAL -> {
|
||||
ivHandCardVertical.visibility = View.VISIBLE
|
||||
ivHandCardHorizontal.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
// set card z position
|
||||
when (antenna.z) {
|
||||
DeviceNFCAntennaLocation.CARD_ON_BACK -> llHand.elevation = 0.0f
|
||||
DeviceNFCAntennaLocation.CARD_ON_FRONT -> llHand.elevation = 30.0f
|
||||
}
|
||||
|
||||
animate()
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
|
|
@ -159,6 +192,8 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
}
|
||||
|
||||
override fun onReadStart(cardProtocol: CardProtocol) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.VISIBLE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.visibility = View.VISIBLE
|
||||
progressBar!!.progress = 5
|
||||
|
|
@ -173,6 +208,8 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
signTransactionTask = null
|
||||
if (cardProtocol != null) {
|
||||
if (cardProtocol.error == null) {
|
||||
rlProgressBar.post { rlProgressBar.visibility = View.GONE }
|
||||
|
||||
progressBar!!.post {
|
||||
progressBar!!.progress = 100
|
||||
progressBar!!.progressTintList = ColorStateList.valueOf(Color.GREEN)
|
||||
|
|
@ -228,6 +265,14 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
}
|
||||
}
|
||||
|
||||
rlProgressBar.postDelayed({
|
||||
try {
|
||||
rlProgressBar.visibility = View.GONE
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 500)
|
||||
|
||||
progressBar!!.postDelayed({
|
||||
try {
|
||||
progressBar!!.progress = 0
|
||||
|
|
@ -289,5 +334,25 @@ class SignTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallback,
|
|||
|
||||
}
|
||||
|
||||
private fun animate() {
|
||||
val lp = llHand.layoutParams as RelativeLayout.LayoutParams
|
||||
val lp2 = llNfc.layoutParams as RelativeLayout.LayoutParams
|
||||
val dp = resources.displayMetrics.density
|
||||
val lm = dp * (69 + antenna.x * 75)
|
||||
lp.topMargin = (dp * (-100 + antenna.y * 250)).toInt()
|
||||
lp2.topMargin = (dp * (-125 + antenna.y * 250)).toInt()
|
||||
llNfc.layoutParams = lp2
|
||||
|
||||
val a = object : Animation() {
|
||||
override fun applyTransformation(interpolatedTime: Float, t: Transformation) {
|
||||
lp.leftMargin = (lm * interpolatedTime).toInt()
|
||||
llHand.layoutParams = lp
|
||||
}
|
||||
}
|
||||
a.duration = 2000
|
||||
a.interpolator = DecelerateInterpolator()
|
||||
llHand.startAnimation(a)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue