From d07ea21d771363763530be807a56742fae3d9976 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 16 Dec 2020 22:54:00 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../features/send/redux/SendScreenAction.kt | 24 +- .../middlewares/AddressPayIdMiddleware.kt | 11 +- .../send/redux/middlewares/SendMiddleware.kt | 16 +- .../send/redux/reducers/SendScreenReducer.kt | 1 + .../reducers/TransactionExtrasReducer.kt | 105 ++++++++ .../send/redux/states/AddressPayIdState.kt | 33 ++- .../features/send/redux/states/SendState.kt | 3 +- .../tap/features/send/ui/SendFragment.kt | 53 ++++- .../stateSubscribers/SendStateSubscriber.kt | 50 ++-- .../tap/network/payid/PayIdVerifyApi.kt | 4 +- app/src/main/res/layout/fragment_send.xml | 1 + .../res/layout/layout_send_address_payid.xml | 225 ++++++++++++++---- .../main/res/values/strings_untranslated.xml | 3 + 13 files changed, 441 insertions(+), 88 deletions(-) create mode 100644 app/src/main/java/com/tangem/tap/features/send/redux/reducers/TransactionExtrasReducer.kt diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/SendScreenAction.kt b/app/src/main/java/com/tangem/tap/features/send/redux/SendScreenAction.kt index e54f0f07dc..6cbe7787d9 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/SendScreenAction.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/SendScreenAction.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.send.redux import com.tangem.Message import com.tangem.blockchain.common.Amount +import com.tangem.blockchain.common.Blockchain import com.tangem.tap.common.redux.ErrorAction import com.tangem.tap.common.redux.ToastNotificationAction import com.tangem.tap.domain.TapError @@ -33,7 +34,27 @@ sealed class AddressPayIdActionUi : SendScreenActionUi { object CheckAddressPayId : AddressPayIdActionUi() data class SetTruncateHandler(val handler: (String) -> String) : AddressPayIdActionUi() data class TruncateOrRestore(val truncate: Boolean) : AddressPayIdActionUi() - data class ChangePayIdState(val walletPayIdEnabled: Boolean): AddressPayIdActionUi() + data class ChangePayIdState(val walletPayIdEnabled: Boolean) : AddressPayIdActionUi() +} + + +sealed class TransactionExtrasAction : SendScreenActionUi { + data class Prepare( + val blockchain: Blockchain, + val walletAddress: String, + val xrpTag: String?, + ) : TransactionExtrasAction() + + object Release : TransactionExtrasAction() + + sealed class XlmMemo : TransactionExtrasAction() { +// data class ChangeSelectedMemo(val memoType: XlmMemoType) : XlmMemo() + data class HandleUserInput(val data: String) : XlmMemo() + } + + sealed class XrpDestinationTag : TransactionExtrasAction() { + data class HandleUserInput(val data: String) : XrpDestinationTag() + } } sealed class AddressPayIdVerifyAction : SendScreenAction { @@ -122,6 +143,7 @@ sealed class SendAction : SendScreenAction { val sendAllCallback: () -> Unit, val reduceAmount: BigDecimal, ) : Dialog() + object Hide : Dialog() } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt index 74fdac0d5d..d82a747a4c 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt @@ -13,6 +13,7 @@ import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.Error import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.PayIdVerification.SetPayIdError import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.PayIdVerification.SetPayIdWalletAddress import com.tangem.tap.features.send.redux.FeeAction +import com.tangem.tap.features.send.redux.TransactionExtrasAction import com.tangem.tap.scope import com.tangem.tap.store import kotlinx.coroutines.Dispatchers @@ -82,22 +83,26 @@ internal class AddressPayIdMiddleware { withContext(Dispatchers.Main) { when (result) { is Result.Success -> { - val address = result.data.getAddress() - if (address == null) { + val addressDetails = result.data.getAddressDetails() + if (addressDetails == null) { dispatch(SetPayIdError(Error.PAY_ID_NOT_REGISTERED)) return@withContext } + val address = addressDetails.address val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(wallet, address) if (failReason == null) { dispatch(SetPayIdWalletAddress(payId, address, isUserInput)) + dispatch(TransactionExtrasAction.Prepare(wallet.blockchain, address, addressDetails.tag)) dispatch(FeeAction.RequestFee) } else { dispatch(SetAddressError(failReason)) + dispatch(TransactionExtrasAction.Release) } } is Result.Failure -> { dispatch(SetPayIdError(Error.PAY_ID_REQUEST_FAILED)) + dispatch(TransactionExtrasAction.Release) } } } @@ -110,8 +115,10 @@ internal class AddressPayIdMiddleware { val failReason = isValidBlockchainAddressAndNotTheSameAsWallet(wallet, supposedAddress) if (failReason == null) { dispatch(SetWalletAddress(supposedAddress, isUserInput)) + dispatch(TransactionExtrasAction.Prepare(wallet.blockchain, address, null)) } else { dispatch(SetAddressError(failReason)) + dispatch(TransactionExtrasAction.Release) } } diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt index 9c61d7dab9..52735189af 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt @@ -1,6 +1,8 @@ package com.tangem.tap.features.send.redux.middlewares import com.google.firebase.crashlytics.FirebaseCrashlytics +import com.tangem.blockchain.blockchains.stellar.StellarTransactionExtras +import com.tangem.blockchain.blockchains.xrp.XrpTransactionBuilder import com.tangem.blockchain.common.* import com.tangem.blockchain.extensions.Result import com.tangem.blockchain.extensions.Signer @@ -17,6 +19,7 @@ import com.tangem.tap.domain.extensions.minimalAmount import com.tangem.tap.features.send.redux.* import com.tangem.tap.features.send.redux.FeeAction.RequestFee import com.tangem.tap.features.send.redux.states.SendButtonState +import com.tangem.tap.features.send.redux.states.TransactionExtrasState import com.tangem.tap.scope import com.tangem.tap.tangemSdk import kotlinx.coroutines.Dispatchers @@ -66,14 +69,16 @@ private fun verifyAndSendTransaction( dispatch(AmountAction.SetAmount(typedAmount.value!!.minus(reduceAmount), false)) dispatch(AmountActionUi.CheckAmountToSend) }, sendAllCallback = { - sendTransaction(action, walletManager, amountToSend, feeAmount, destinationAddress, card, dispatch) + sendTransaction(action, walletManager, amountToSend, feeAmount, destinationAddress, + sendState.transactionExtrasState, card, dispatch) }, reduceAmount)) } transactionErrors.isNotEmpty() -> { dispatch(SendAction.SendError(createValidateTransactionError(transactionErrors, walletManager))) } else -> { - sendTransaction(action, walletManager, amountToSend, feeAmount, destinationAddress, card, dispatch) + sendTransaction(action, walletManager, amountToSend, feeAmount, destinationAddress, + sendState.transactionExtrasState, card, dispatch) } } } @@ -84,11 +89,16 @@ private fun sendTransaction( amountToSend: Amount, feeAmount: Amount, destinationAddress: String, + transactionExtras: TransactionExtrasState, card: Card, dispatch: (Action) -> Unit ) { dispatch(SendAction.ChangeSendButtonState(SendButtonState.PROGRESS)) - val txData = walletManager.createTransaction(amountToSend, feeAmount, destinationAddress) + var txData = walletManager.createTransaction(amountToSend, feeAmount, destinationAddress) + + transactionExtras.xlmMemo?.memo?.let { txData = txData.copy(extras = StellarTransactionExtras(it)) } + transactionExtras.xrpDestinationTag?.tag?.let { txData = txData.copy(extras = XrpTransactionBuilder.XrpTransactionExtras(it)) } + scope.launch { walletManager.update() val isLinkedTerminal = tangemSdk.config.linkedTerminal diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/SendScreenReducer.kt b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/SendScreenReducer.kt index e7454abcc1..16da618931 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/SendScreenReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/SendScreenReducer.kt @@ -25,6 +25,7 @@ class SendScreenReducer { val reducer: SendInternalReducer = when (action) { is PrepareSendScreen -> PrepareSendScreenStatesReducer() is AddressPayIdActionUi, is AddressPayIdVerifyAction -> AddressPayIdReducer() + is TransactionExtrasAction -> TransactionExtrasReducer() is AmountActionUi, is AmountAction -> AmountReducer() is FeeActionUi, is FeeAction -> FeeReducer() is ReceiptAction -> ReceiptReducer() diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/TransactionExtrasReducer.kt b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/TransactionExtrasReducer.kt new file mode 100644 index 0000000000..7688e47496 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/TransactionExtrasReducer.kt @@ -0,0 +1,105 @@ +package com.tangem.tap.features.send.redux.reducers + +import com.tangem.blockchain.blockchains.stellar.StellarMemo +import com.tangem.blockchain.common.Blockchain +import com.tangem.tap.features.send.redux.SendScreenAction +import com.tangem.tap.features.send.redux.TransactionExtrasAction.* +import com.tangem.tap.features.send.redux.states.* + +/** +[REDACTED_AUTHOR] + */ +class TransactionExtrasReducer : SendInternalReducer { + override fun handle(action: SendScreenAction, sendState: SendState): SendState { + return when (action) { + is Prepare -> handleInitialization(action, sendState) + Release -> handleRelease(action, sendState) + is XlmMemo -> handleMemo(action, sendState, sendState.transactionExtrasState) + is XrpDestinationTag -> handleXrpTag(action, sendState, sendState.transactionExtrasState) + else -> sendState + } + } + + private fun handleInitialization(action: Prepare, sendState: SendState): SendState { + val emptyResult = TransactionExtrasState() + val result = when (action.blockchain) { + Blockchain.XRP -> { + // 'r' - without tag, 'x' - with tag + if (action.walletAddress.startsWith("r", true)) { + val tag = action.xrpTag?.toLongOrNull() + if (tag == null) { + TransactionExtrasState(xrpDestinationTag = XrpDestinationTagState()) + } else { + TransactionExtrasState(xrpDestinationTag = XrpDestinationTagState( + InputViewValue("$tag", false), tag) + ) + } + } else { + emptyResult + } + } + Blockchain.Stellar -> TransactionExtrasState(xlmMemo = XlmMemoState()) + else -> emptyResult + } + return updateLastState(sendState.copy(transactionExtrasState = result), result) + } + + private fun handleRelease(action: SendScreenAction, sendState: SendState): SendState { + val result = TransactionExtrasState() + return updateLastState(sendState.copy(transactionExtrasState = result), result) + } + + private fun handleMemo( + action: XlmMemo, + sendState: SendState, + infoState: TransactionExtrasState, + ): SendState { + fun clearMemo(memo: XlmMemoState): XlmMemoState = memo.copy(text = null, id = null) + + val result = when (action) { +// is XlmMemo.ChangeSelectedMemo -> { +// val inputViewValue = InputViewValue("", false) +// val memo = infoState.xlmMemo?.copy( +// viewFieldValue = inputViewValue, +// selectedMemoType = action.memoType, +// ) ?: XlmMemoState(inputViewValue, action.memoType) +// +// infoState.copy(xlmMemo = clearMemo(memo)) +// } + is XlmMemo.HandleUserInput -> { + val inputViewValue = InputViewValue(action.data, true) + var memo = infoState.xlmMemo?.copy(viewFieldValue = inputViewValue) ?: XlmMemoState(inputViewValue) + memo = clearMemo(memo) + memo = when (infoState.xlmMemo?.selectedMemoType) { + XlmMemoType.TEXT -> memo.copy(text = StellarMemo.Text(action.data)) + XlmMemoType.ID -> { + val id = action.data.toIntOrNull()?.toBigInteger() + if (id != null) memo.copy(id = StellarMemo.Id(id)) else memo + } + null -> memo + } + infoState.copy(xlmMemo = memo) + } + } + return updateLastState(sendState.copy(transactionExtrasState = result), result) + } + + private fun handleXrpTag( + action: XrpDestinationTag, + sendState: SendState, + infoState: TransactionExtrasState, + ): SendState { + val result = when (action) { + is XrpDestinationTag.HandleUserInput -> { + val tag = action.data.toLongOrNull() + if (tag != null) { + val tagState = XrpDestinationTagState(InputViewValue(action.data, true), tag) + infoState.copy(xrpDestinationTag = tagState) + } else { + infoState + } + } + } + return updateLastState(sendState.copy(transactionExtrasState = result), result) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/states/AddressPayIdState.kt b/app/src/main/java/com/tangem/tap/features/send/redux/states/AddressPayIdState.kt index 9307694212..8bc5d09bc3 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/states/AddressPayIdState.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/states/AddressPayIdState.kt @@ -1,5 +1,6 @@ package com.tangem.tap.features.send.redux.states +import com.tangem.blockchain.blockchains.stellar.StellarMemo import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction data class AddressPayIdState( @@ -20,4 +21,34 @@ data class AddressPayIdState( fun isReady(): Boolean = error == null && destinationWalletAddress?.isNotEmpty() ?: false fun isPayIdState(): Boolean = destinationWalletAddress != null && destinationWalletAddress != normalFieldValue -} \ No newline at end of file +} + +data class TransactionExtrasState( + val xlmMemo: XlmMemoState? = null, + val xrpDestinationTag: XrpDestinationTagState? = null +) : IdStateHolder { + override val stateId: StateId = StateId.ADDRESS_EXTRAS +} + +enum class XlmMemoType { + TEXT, ID +} + +data class XlmMemoState( + val viewFieldValue: InputViewValue = InputViewValue(""), + val selectedMemoType: XlmMemoType = XlmMemoType.ID, + val text: StellarMemo.Text? = null, + val id: StellarMemo.Id? = null, +) { + val memo: StellarMemo? + get() = when (selectedMemoType) { + XlmMemoType.TEXT -> text + XlmMemoType.ID -> id + } +} + +// tag must contains only digits +data class XrpDestinationTagState( + val viewFieldValue: InputViewValue = InputViewValue(""), + val tag: Long? = null +) \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/states/SendState.kt b/app/src/main/java/com/tangem/tap/features/send/redux/states/SendState.kt index 2e3a6e4955..026f77c213 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/states/SendState.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/states/SendState.kt @@ -22,7 +22,7 @@ interface IdStateHolder { } enum class StateId { - SEND_SCREEN, ADDRESS_PAY_ID, AMOUNT, FEE, RECEIPT + SEND_SCREEN, ADDRESS_PAY_ID, ADDRESS_EXTRAS, AMOUNT, FEE, RECEIPT } interface SendScreenState : StateType, IdStateHolder @@ -33,6 +33,7 @@ data class SendState( val tokenConverter: CurrencyConverter? = null, val lastChangedStates: LinkedHashSet = linkedSetOf(), val addressPayIdState: AddressPayIdState = AddressPayIdState(), + val transactionExtrasState: TransactionExtrasState = TransactionExtrasState(), val amountState: AmountState = AmountState(), val feeState: FeeState = FeeState(), val receiptState: ReceiptState = ReceiptState(), diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt index 9714886b7b..874e744207 100644 --- a/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/send/ui/SendFragment.kt @@ -67,6 +67,7 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) { initSendButtonStates() setupAddressOrPayIdLayout() + setupTransactionExtrasLayout() setupAmountLayout() setupFeeLayout() @@ -106,6 +107,32 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) { } } + private fun setupTransactionExtrasLayout() { + etMemo.inputtedTextAsFlow() + .debounce(400) + .filter { + val info = store.state.sendState.transactionExtrasState + info.xlmMemo?.viewFieldValue?.value != it + } + .onEach { store.dispatch(TransactionExtrasAction.XlmMemo.HandleUserInput(it)) } + .launchIn(mainScope) + +// groupMemo.setOnCheckedChangeListener { group, checkedId -> +// if (checkedId == -1) return@setOnCheckedChangeListener +// +// store.dispatch(TransactionExtrasAction.XlmMemo.ChangeSelectedMemo(MemoUiHelper.toType(checkedId))) +// } + + etDestinationTag.inputtedTextAsFlow() + .debounce(400) + .filter { + val info = store.state.sendState.transactionExtrasState + info.xrpDestinationTag?.viewFieldValue?.value != it + } + .onEach { store.dispatch(TransactionExtrasAction.XrpDestinationTag.HandleUserInput(it)) } + .launchIn(mainScope) + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (requestCode != ScanQrCodeActivity.SCAN_QR_REQUEST_CODE) return @@ -191,7 +218,7 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) { chipGroup.setOnCheckedChangeListener { group, checkedId -> if (checkedId == -1) return@setOnCheckedChangeListener - store.dispatch(ChangeSelectedFee(FeeUiHelper.idToFee(checkedId))) + store.dispatch(ChangeSelectedFee(FeeUiHelper.toType(checkedId))) store.dispatch(CheckAmountToSend) } swIncludeFee.setOnCheckedChangeListener { btn, isChecked -> @@ -238,7 +265,7 @@ fun EditText.inputtedTextAsFlow(): Flow = callbackFlow { class FeeUiHelper { companion object { - fun feeToId(fee: FeeType): Int { + fun toId(fee: FeeType): Int { return when (fee) { FeeType.SINGLE -> View.NO_ID FeeType.LOW -> R.id.chipLow @@ -247,7 +274,7 @@ class FeeUiHelper { } } - fun idToFee(id: Int): FeeType { + fun toType(id: Int): FeeType { return when (id) { R.id.chipLow -> FeeType.LOW R.id.chipNormal -> FeeType.NORMAL @@ -258,6 +285,26 @@ class FeeUiHelper { } } + +//class MemoUiHelper { +// companion object { +// fun toId(memo: MemoType): Int { +// return when (memo) { +// MemoType.TEXT -> R.id.chipMemoText +// MemoType.ID -> R.id.chipMemoId +// } +// } +// +// fun toType(id: Int): MemoType { +// return when (id) { +// R.id.chipMemoText -> MemoType.TEXT +// R.id.chipMemoId -> MemoType.ID +// else -> MemoType.TEXT +// } +// } +// } +//} + private fun ToggleWidget.setupSendButtonStateModifiers(context: Context) { mainViewModifiers.clear() mainViewModifiers.add(ReplaceTextStateModifier(context.getString(R.string.send_title), "")) diff --git a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt index 07ddffa598..da81ad52c5 100644 --- a/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt +++ b/app/src/main/java/com/tangem/tap/features/send/ui/stateSubscribers/SendStateSubscriber.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.send.ui.stateSubscribers import android.app.Dialog import android.content.Context +import android.text.InputType import android.text.SpannableStringBuilder import android.view.View import android.view.ViewGroup @@ -43,10 +44,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber override fun updateWithNewState(fg: BaseStoreFragment, state: SendState) { val lastChangedStates = state.lastChangedStates.toList() state.lastChangedStates.clear() + fg.main_send_container.beginDelayedTransition() lastChangedStates.forEach { when (it) { StateId.SEND_SCREEN -> handleSendScreen(fg, state) StateId.ADDRESS_PAY_ID -> handleAddressPayIdState(fg, state.addressPayIdState) + StateId.ADDRESS_EXTRAS -> handleTransactionExtrasState(fg, state.transactionExtrasState) StateId.AMOUNT -> handleAmountState(fg, state.amountState) StateId.FEE -> handleFeeState(fg, state.feeState) StateId.RECEIPT -> handleReceiptState(fg, state.receiptState) @@ -54,6 +57,25 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber } } + private fun handleTransactionExtrasState(fg: BaseStoreFragment, infoState: TransactionExtrasState) { + fun showView(view: View, info: Any?) { + view.show(info != null) + } + showView(fg.xlmMemoContainer, infoState.xlmMemo) + showView(fg.xrpDestinationTagContainer, infoState.xrpDestinationTag) + + infoState.xlmMemo?.let { + fg.etMemo.inputType = when (it.selectedMemoType) { + XlmMemoType.TEXT -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS + XlmMemoType.ID -> InputType.TYPE_CLASS_NUMBER + } + if (!it.viewFieldValue.isFromUserInput) fg.etMemo.setText(it.viewFieldValue.value) + } + infoState.xrpDestinationTag?.let { + if (!it.viewFieldValue.isFromUserInput) fg.etDestinationTag.setText(it.viewFieldValue.value) + } + } + private fun handleSendScreen(fg: BaseStoreFragment, state: SendState) { val sendFragment = (fg as? SendFragment) ?: return @@ -106,11 +128,10 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber val hintResId = if (state.walletPayIdEnabled) { R.string.send_destination_hint_address_payid - }else { + } else { R.string.send_destination_hint_address } til.hint = til.getString(hintResId) - til.parent?.parent?.beginDelayedTransition() til.error = parsedError til.isErrorEnabled = parsedError != null til.helperText = state.destinationWalletAddress @@ -130,10 +151,8 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber } else -> context.getString(state.error.localizedMessage) } - fg.amountContainer.parent?.beginDelayedTransition() fg.tilAmountToSend.enableError(true, message) } else { - if (fg.tilAmountToSend.isErrorEnabled) fg.amountContainer.parent?.beginDelayedTransition() fg.tilAmountToSend.enableError(false) } @@ -168,27 +187,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber } private fun handleFeeState(fg: BaseStoreFragment, state: FeeState) { - var delayedTransitionScheduled = false fg.chipGroup.fitChipsByGroupWidth() - fg.view?.findViewById(R.id.clNetworkFee)?.let { - it.show(state.mainLayoutIsVisible) { - (it.parent as? ViewGroup)?.beginDelayedTransition() - delayedTransitionScheduled = true - } - } + fg.view?.findViewById(R.id.clNetworkFee)?.show(state.mainLayoutIsVisible) fg.imvExpandCollapse.rotation = if (state.controlsLayoutIsVisible) 0f else 180f - fg.llFeeControlsContainer.show(state.controlsLayoutIsVisible) { - if (!delayedTransitionScheduled) { - fg.llFeeControlsContainer.parent?.parent?.beginDelayedTransition() - } - } - - fg.chipGroup.show(state.feeChipGroupIsVisible) { - if (!delayedTransitionScheduled) { - fg.llFeeControlsContainer.parent?.parent?.beginDelayedTransition() - } - } + fg.llFeeControlsContainer.show(state.controlsLayoutIsVisible) + fg.chipGroup.show(state.feeChipGroupIsVisible) fg.swIncludeFee.isEnabled = state.includeFeeSwitcherIsEnabled if (fg.swIncludeFee.isChecked != state.feeIsIncluded) { @@ -201,7 +205,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber } } - val chipId = FeeUiHelper.feeToId(state.selectedFeeType) + val chipId = FeeUiHelper.toId(state.selectedFeeType) if (fg.chipGroup.checkedChipId != chipId && chipId != View.NO_ID) fg.chipGroup.check(chipId) } diff --git a/app/src/main/java/com/tangem/tap/network/payid/PayIdVerifyApi.kt b/app/src/main/java/com/tangem/tap/network/payid/PayIdVerifyApi.kt index e026dd8b11..a40231aaf5 100644 --- a/app/src/main/java/com/tangem/tap/network/payid/PayIdVerifyApi.kt +++ b/app/src/main/java/com/tangem/tap/network/payid/PayIdVerifyApi.kt @@ -23,9 +23,9 @@ data class VerifyPayIdResponse( val addresses: List = mutableListOf(), val payId: String? = null, ) { - fun getAddress(): String? { + fun getAddressDetails(): PayIdAddressDetails? { return if (addresses.isEmpty()) null - else addresses[0].addressDetails.address + else addresses[0].addressDetails } } diff --git a/app/src/main/res/layout/fragment_send.xml b/app/src/main/res/layout/fragment_send.xml index fca84784bc..86ec08548b 100644 --- a/app/src/main/res/layout/fragment_send.xml +++ b/app/src/main/res/layout/fragment_send.xml @@ -33,6 +33,7 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"> diff --git a/app/src/main/res/layout/layout_send_address_payid.xml b/app/src/main/res/layout/layout_send_address_payid.xml index 12a9d76915..00a5617a9d 100644 --- a/app/src/main/res/layout/layout_send_address_payid.xml +++ b/app/src/main/res/layout/layout_send_address_payid.xml @@ -1,76 +1,197 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + android:orientation="vertical" + android:visibility="gone" + tools:visibility="visible"> - + + + + + + + + + + + - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + android:visibility="gone" + tools:visibility="visible"> - + - + - + - + - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings_untranslated.xml b/app/src/main/res/values/strings_untranslated.xml index dd823ac37c..46a07e670f 100644 --- a/app/src/main/res/values/strings_untranslated.xml +++ b/app/src/main/res/values/strings_untranslated.xml @@ -27,4 +27,7 @@ this wallet. Start Back + Memo + Destination tag +