Updated on 2026-08-14
This commit is contained in:
parent
1c82ef2c7b
commit
fd23ba7da7
5 changed files with 95 additions and 25 deletions
|
|
@ -20,7 +20,7 @@ public enum Blockchain {
|
|||
Rootstock("RSK", "RBTC", 1.0, R.drawable.tangem2, "RSK"),
|
||||
RootstockToken("RskToken", "RBTC", 1.0, R.drawable.tangem2, "RSK"),
|
||||
Cardano("CARDANO", "ADA", 1000000.0, R.drawable.tangem2, "Cardano"),
|
||||
Ripple("XRP", "XRP", 1000000.0, R.drawable.ic_logo_xrp, "XRP"),
|
||||
Ripple("XRP", "XRP", 1000000.0, R.drawable.ic_logo_xrp, "XRP Ledger"),
|
||||
Binance("BINANCE", "BNB", 100000000.0, R.drawable.ic_logo_binance, "Binance"),
|
||||
BinanceTestNet("BINANCE/test", "BNB", 100000000.0, R.drawable.ic_logo_binance, "Binance Testnet"),
|
||||
BinanceAsset("BinanceAsset", "BNB", 100000000.0, R.drawable.ic_logo_binance, "Binance"),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.tangem.App
|
|||
import com.tangem.Constant
|
||||
import com.tangem.data.Blockchain
|
||||
import com.tangem.data.dp.PrefsManager
|
||||
import com.tangem.server_android.PayIdResponse
|
||||
import com.tangem.server_android.Result
|
||||
import com.tangem.server_android.ServerApiTangem
|
||||
import com.tangem.server_android.model.CardVerifyAndGetInfo
|
||||
|
|
@ -67,6 +66,7 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
|
|||
companion object {
|
||||
val TAG: String = LoadedWalletFragment::class.java.simpleName
|
||||
const val PAY_ID_TANGEM = "\$payid.tangem.com"
|
||||
val payIdSupported = setOf(Blockchain.Ripple, Blockchain.Ethereum, Blockchain.Bitcoin)
|
||||
}
|
||||
|
||||
override val layoutId = R.layout.fr_loaded_wallet
|
||||
|
|
@ -149,21 +149,26 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
|
|||
btnExtract.backgroundTintList = inactiveColor
|
||||
|
||||
tvWallet.text = ctx.coinData.wallet
|
||||
btnLoadItems = mutableListOf<CharSequence>(
|
||||
|
||||
btnLoadItems = mutableListOf(
|
||||
getString(R.string.loaded_wallet_load_via_app),
|
||||
getString(R.string.loaded_wallet_load_via_share_address),
|
||||
getString(R.string.loaded_wallet_load_via_qr)
|
||||
)
|
||||
if (ctx.blockchain == Blockchain.Ripple) {
|
||||
|
||||
if (payIdSupported.contains(ctx.blockchain)) {
|
||||
ivPayId.visibility = View.VISIBLE
|
||||
ivPayId.imageAlpha = 100
|
||||
ivPayId.setOnClickListener { createPayIdDialog() }
|
||||
|
||||
viewModel.getPayId(
|
||||
Util.byteArrayToHexString(ctx.card?.cid!!),
|
||||
Util.byteArrayToHexString(ctx.card?.cardPublicKey!!))
|
||||
Util.byteArrayToHexString(ctx.card.cid!!),
|
||||
Util.byteArrayToHexString(ctx.card.cardPublicKey!!))
|
||||
.observe(
|
||||
viewLifecycleOwner, Observer<Result<PayIdResponse>> { result ->
|
||||
viewLifecycleOwner, Observer { result ->
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
payId = result.data.payId
|
||||
btnLoadItems.add(result.data.payId)
|
||||
onPayIdFound(result.data.payId)
|
||||
}
|
||||
is Result.Failure -> {
|
||||
(result.error as? HttpException)?.let {
|
||||
|
|
@ -365,21 +370,21 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
|
|||
}
|
||||
|
||||
private fun createPayId(payId: String) {
|
||||
val network = if (ctx.blockchain == Blockchain.Ripple) "XRPL" else ctx.blockchain.id
|
||||
viewModel.setPayId(
|
||||
Util.byteArrayToHexString(ctx.card!!.cid!!),
|
||||
Util.byteArrayToHexString(ctx.card!!.cardPublicKey!!),
|
||||
payId,
|
||||
ctx.coinData.wallet,
|
||||
ctx.blockchain.id
|
||||
network
|
||||
)
|
||||
.observe(viewLifecycleOwner, Observer { result ->
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
this.payId = payId
|
||||
if (btnLoadItems.last() == getString(R.string.loaded_wallet_create_pay_id)) {
|
||||
btnLoadItems.removeAt(btnLoadItems.lastIndex)
|
||||
}
|
||||
btnLoadItems.add(payId)
|
||||
onPayIdFound(payId)
|
||||
Toast.makeText(context, getString(R.string.create_pay_id_success), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
is Result.Failure -> {
|
||||
|
|
@ -389,6 +394,13 @@ class LoadedWalletFragment : BaseFragment(), NavigationResultListener, NfcAdapte
|
|||
})
|
||||
}
|
||||
|
||||
private fun onPayIdFound(payId: String) {
|
||||
ivPayId.imageAlpha = 255
|
||||
this.payId = payId
|
||||
btnLoadItems.add(payId)
|
||||
ivPayId.setOnClickListener { copyText(payId) }
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
if (timerHideErrorAndMessage != null) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.server_android.PayIdService
|
|||
import com.tangem.server_android.Result
|
||||
import com.tangem.server_android.SetPayIdResponse
|
||||
import com.tangem.wallet.TangemContext
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
|
||||
class LoadedWalletViewModel : ViewModel() {
|
||||
private val serverApiCommon: ServerApiCommon = ServerApiCommon()
|
||||
|
|
@ -20,7 +21,9 @@ class LoadedWalletViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
private val payId: LiveData<Result<PayIdResponse>> = MutableLiveData()
|
||||
private val scope = viewModelScope.coroutineContext + CoroutineExceptionHandler { _, ex ->
|
||||
throw ex
|
||||
}
|
||||
|
||||
fun getRateInfo(): LiveData<Float> {
|
||||
return rate
|
||||
|
|
@ -62,7 +65,7 @@ class LoadedWalletViewModel : ViewModel() {
|
|||
address: String,
|
||||
network: String
|
||||
): LiveData<Result<SetPayIdResponse>> {
|
||||
return liveData(viewModelScope.coroutineContext) {
|
||||
return liveData(scope) {
|
||||
emit(
|
||||
payIdService.setPayId(
|
||||
cardId, publicKey, payId, address, network
|
||||
|
|
|
|||
37
app/src/main/res/drawable/ic_payid_logo_dark.xml
Normal file
37
app/src/main/res/drawable/ic_payid_logo_dark.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="80dp"
|
||||
android:height="25dp"
|
||||
android:viewportWidth="314"
|
||||
android:viewportHeight="100">
|
||||
<group>
|
||||
<clip-path
|
||||
android:pathData="M0.192,0h313v99.168h-313z"/>
|
||||
<path
|
||||
android:pathData="M109.98,26.948H130.523C143.582,26.948 149.462,34.196 149.462,44.072C149.462,53.948 143.582,61.221 130.523,61.221H119.832V77.426H109.98V26.948ZM130.676,52.111C137.218,52.111 139.458,48.716 139.458,44.072C139.458,39.428 137.218,36.136 130.676,36.136H119.832V52.111H130.676Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M152.008,58.746C152.008,46.624 160.484,38.279 172.55,38.279C184.489,38.279 192.787,46.369 192.787,58.644V77.375H184.413V69.898C182.096,75.537 176.954,78.396 170.972,78.396C161.732,78.421 152.008,71.786 152.008,58.746ZM183.674,58.388C183.674,51.651 179.194,46.879 172.474,46.879C165.754,46.879 161.274,51.651 161.274,58.388C161.274,65.126 165.805,69.898 172.474,69.898C179.143,69.898 183.674,65.074 183.674,58.388Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M200.45,81.611H209.614C211.167,85.158 214.17,86.766 218.778,86.766C225.015,86.766 228.553,83.78 228.553,76.354V71.556C226.236,75.716 222.24,77.962 217.251,77.962C208.468,77.962 200.17,72.245 200.17,58.669V39.3H209.308V58.669C209.308,65.916 213.152,69.387 218.931,69.387C224.556,69.387 228.553,65.763 228.553,58.669V39.3H237.717V76.124C237.717,89.394 229.317,94.728 218.778,94.728C209.919,94.702 202.588,90.594 200.45,81.611Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M248.204,26.948H258.081V77.426H248.204V26.948Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M268.441,26.948H286.311C303.926,26.948 313.192,37.054 313.192,52.187C313.192,67.32 303.952,77.426 286.311,77.426H268.441V26.948ZM286.311,68.315C297.944,68.315 303.163,61.987 303.163,52.187C303.163,42.388 297.944,36.136 286.311,36.136H278.318V68.341L286.311,68.315Z"
|
||||
android:fillColor="#000E33"/>
|
||||
</group>
|
||||
<path
|
||||
android:pathData="M53.687,79.504C60.442,78.606 66.698,75.461 71.447,70.575V70.575L99.1,42.231C97.34,41.943 95.558,41.809 93.774,41.832C88.916,41.862 84.136,43.063 79.842,45.334C77.133,46.781 74.665,48.637 72.524,50.838L62.325,61.287C62.264,61.354 62.198,61.42 62.132,61.49C58.926,64.777 54.553,66.667 49.963,66.751C45.372,66.835 40.933,65.105 37.61,61.936L48.262,72.329C50.423,74.432 52.252,76.851 53.687,79.504V79.504Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M28.525,71.246L56.871,98.898C57.952,92.255 56.834,85.44 53.686,79.491C52.252,76.841 50.424,74.424 48.265,72.322L37.613,61.93C35.941,60.339 34.602,58.432 33.673,56.319C32.743,54.207 32.243,51.931 32.2,49.623C32.157,47.316 32.572,45.023 33.422,42.877C34.272,40.732 35.539,38.776 37.151,37.124L26.764,47.773C24.624,49.973 22.155,51.828 19.447,53.273C20.338,60.123 23.541,66.463 28.525,71.246V71.246Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M0.192,56.395C1.951,56.681 3.732,56.813 5.515,56.791C10.373,56.759 15.152,55.557 19.447,53.285C22.156,51.841 24.625,49.986 26.765,47.785L37.161,37.13C38.759,35.488 40.666,34.178 42.771,33.273C44.876,32.369 47.139,31.888 49.43,31.859C51.721,31.83 53.995,32.252 56.123,33.102C58.251,33.952 60.19,35.213 61.831,36.813L51.321,26.56C49.079,24.381 47.196,21.863 45.738,19.097C38.937,19.973 32.633,23.128 27.854,28.045L0.192,56.395Z"
|
||||
android:fillColor="#000E33"/>
|
||||
<path
|
||||
android:pathData="M62.328,61.293L72.527,50.844C74.668,48.644 77.136,46.787 79.845,45.341C78.973,38.63 75.881,32.403 71.061,27.653L42.711,0C42.424,1.759 42.291,3.54 42.316,5.323C42.346,10.124 43.52,14.849 45.739,19.107C47.196,21.872 49.08,24.391 51.321,26.57L61.831,36.823C65.109,40.02 66.998,44.378 67.091,48.956C67.184,53.535 65.473,57.966 62.328,61.293V61.293Z"
|
||||
android:fillColor="#000E33"/>
|
||||
</vector>
|
||||
|
|
@ -123,19 +123,37 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHeight_min="wrap"
|
||||
app:layout_constraintTop_toBottomOf="@+id/guideline">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBlockchain"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:fontFamily="@font/maaxmedium"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary_dark"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="normal"
|
||||
tools:text="Bitcoin" />
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBlockchain"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:fontFamily="@font/maaxmedium"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/primary_dark"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="normal"
|
||||
tools:text="Bitcoin" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivPayId"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:src="@drawable/ic_payid_logo_dark"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWallet"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue