Updated on 2026-08-14

This commit is contained in:
Tangem 2022-11-08 16:45:06 +05:00
commit d7db2c77f5
10 changed files with 70 additions and 30 deletions

View file

@ -132,7 +132,7 @@ class MainActivity : AppCompatActivity(), SnackbarHandler, ActivityResultCallbac
}
override fun onDestroy() {
store.dispatch(NavigationAction.ActivityDestroyed)
store.dispatch(NavigationAction.ActivityDestroyed(WeakReference(this)))
super.onDestroy()
}

View file

@ -1,7 +1,7 @@
package com.tangem.tap.common.redux.navigation
import android.net.Uri
import androidx.fragment.app.FragmentActivity
import androidx.appcompat.app.AppCompatActivity
import org.rekotlin.Action
import java.lang.ref.WeakReference
@ -9,7 +9,7 @@ sealed class NavigationAction : Action {
data class NavigateTo(
val screen: AppScreen,
val fragmentShareTransition: FragmentShareTransition? = null,
val addToBackstack: Boolean = true
val addToBackstack: Boolean = true,
) : NavigationAction()
data class PopBackTo(val screen: AppScreen? = null) : NavigationAction()
@ -20,6 +20,6 @@ sealed class NavigationAction : Action {
data class Share(val data: String) : NavigationAction()
data class ActivityCreated(val activity: WeakReference<FragmentActivity>) : NavigationAction()
object ActivityDestroyed : NavigationAction()
data class ActivityCreated(val activity: WeakReference<AppCompatActivity>) : NavigationAction()
data class ActivityDestroyed(val activity: WeakReference<AppCompatActivity>) : NavigationAction()
}

View file

@ -25,7 +25,14 @@ private fun internalReduce(action: Action, state: AppState): NavigationState {
state.navigationState.copy(backStack = navState.backStack.subList(0, index))
}
is NavigationAction.ActivityCreated -> navState.copy(activity = navigationAction.activity)
is NavigationAction.ActivityDestroyed -> navState.copy(activity = null)
is NavigationAction.ActivityDestroyed -> {
when {
// Destroy the activity if it invoked for the same activity. Prevents overwriting to null if there is a
// new scan from the background [REDACTED_TASK_KEY]
navState.activity?.get() == navigationAction.activity.get() -> navState.copy(activity = null)
else -> navState
}
}
else -> navState
}
}

View file

@ -1,12 +1,12 @@
package com.tangem.tap.common.redux.navigation
import androidx.fragment.app.FragmentActivity
import androidx.appcompat.app.AppCompatActivity
import org.rekotlin.StateType
import java.lang.ref.WeakReference
data class NavigationState(
val backStack: List<AppScreen> = listOf(AppScreen.Home),
val activity: WeakReference<FragmentActivity>? = null
val activity: WeakReference<AppCompatActivity>? = null,
) : StateType
enum class AppScreen {

View file

@ -7,6 +7,7 @@ import com.tangem.tap.features.send.redux.SendScreenAction
import com.tangem.tap.features.send.redux.states.FeeState
import com.tangem.tap.features.send.redux.states.FeeType
import com.tangem.tap.features.send.redux.states.SendState
import com.tangem.tap.features.wallet.redux.ProgressState
/**
[REDACTED_AUTHOR]
@ -36,7 +37,7 @@ class FeeReducer : SendInternalReducer {
private fun handleAction(action: FeeAction, sendState: SendState, state: FeeState): SendState {
val result = when (action) {
is FeeAction.RequestFee -> {
state
state.copy(progressState = ProgressState.Loading)
}
is FeeAction.ChangeLayoutVisibility -> {
fun getVisibility(current: Boolean, proposed: Boolean?): Boolean = proposed ?: current
@ -68,12 +69,15 @@ class FeeReducer : SendInternalReducer {
currentFee = currentFee,
feeIsApproximate = isFeeApproximate(sendState),
)
}
}.copy(
progressState = ProgressState.Done,
)
}
FeeAction.FeeCalculation.ClearResult -> {
state.copy(
feeList = null,
currentFee = null,
progressState = ProgressState.Done,
)
}
}

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.send.redux.states
import com.tangem.blockchain.common.Amount
import com.tangem.tap.features.wallet.redux.ProgressState
import java.math.BigDecimal
/**
@ -20,6 +21,7 @@ data class FeeState(
val controlsLayoutIsVisible: Boolean = false,
val feeChipGroupIsVisible: Boolean = true,
val includeFeeSwitcherIsEnabled: Boolean = true,
val progressState: ProgressState = ProgressState.Done
) : SendScreenState {
override val stateId: StateId = StateId.FEE

View file

@ -11,6 +11,7 @@ import com.tangem.tap.common.extensions.beginDelayedTransition
import com.tangem.tap.common.extensions.enableError
import com.tangem.tap.common.extensions.getColor
import com.tangem.tap.common.extensions.getString
import com.tangem.tap.common.extensions.hide
import com.tangem.tap.common.extensions.show
import com.tangem.tap.common.extensions.update
import com.tangem.tap.common.redux.getMessageString
@ -35,6 +36,7 @@ import com.tangem.tap.features.send.ui.SendFragment
import com.tangem.tap.features.send.ui.dialogs.RequestFeeErrorDialog
import com.tangem.tap.features.send.ui.dialogs.SendTransactionFailsDialog
import com.tangem.tap.features.send.ui.dialogs.TezosWarningDialog
import com.tangem.tap.features.wallet.redux.ProgressState
import com.tangem.tap.features.wallet.redux.WalletState.Companion.ROUGH_SIGN
import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN
import com.tangem.tap.features.wallet.ui.adapters.WarningMessagesAdapter
@ -62,7 +64,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
StateId.TRANSACTION_EXTRAS -> handleTransactionExtrasState(fg, state.transactionExtrasState)
StateId.AMOUNT -> handleAmountState(fg, state.amountState)
StateId.FEE -> handleFeeState(fg, state.feeState)
StateId.RECEIPT -> handleReceiptState(fg, state.receiptState)
StateId.RECEIPT -> handleReceiptState(fg, state.receiptState, state.feeState.progressState)
}
}
}
@ -263,7 +265,11 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
if (chipGroup.checkedChipId != chipId && chipId != View.NO_ID) chipGroup.check(chipId)
}
private fun handleReceiptState(fg: SendFragment, state: ReceiptState) = with(fg.binding.clReceiptContainer) {
private fun handleReceiptState(
fg: SendFragment,
state: ReceiptState,
feeProgressState: ProgressState,
) = with(fg.binding.clReceiptContainer) {
val mainLayout = clReceiptContainer as ViewGroup
val totalLayout = llTotalContainer.llTotal as ViewGroup
val totalTokenLayout = llTotalContainer.flTotalTokenCrypto as ViewGroup
@ -274,11 +280,22 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
return if (value == UNKNOWN_AMOUNT_SIGN) value else "$ROUGH_SIGN $value"
}
when (feeProgressState) {
ProgressState.Loading -> {
tvReceiptFeeValue.hide()
pbReceiptFee.show()
}
ProgressState.Done -> {
pbReceiptFee.hide()
tvReceiptFeeValue.show()
}
}
when (state.visibleTypeOfReceipt) {
ReceiptLayoutType.FIAT -> {
val receipt = state.fiat ?: return
llTotalContainer.tvTotalValue
totalLayout.show(true)
totalTokenLayout.show(false)
tvReceiptAmountValue.update("${receipt.amountFiat} ${receipt.symbols.fiat}")
@ -290,7 +307,6 @@ class SendStateSubscriber(fragment: BaseStoreFragment) :
receipt.willSentCrypto, receipt.symbols.crypto,
)
llTotalContainer.tvWillBeSentValue.update(willSent)
}
ReceiptLayoutType.CRYPTO -> {
val receipt = state.crypto ?: return

View file

@ -10,7 +10,6 @@ import com.tangem.common.extensions.toMapKey
import com.tangem.common.hdWallet.DerivationPath
import com.tangem.common.services.Result
import com.tangem.domain.DomainWrapped
import com.tangem.domain.common.KeyWalletPublicKey
import com.tangem.domain.common.ScanResponse
import com.tangem.domain.common.TapWorkarounds.derivationStyle
import com.tangem.domain.common.TapWorkarounds.isTestCard
@ -208,19 +207,17 @@ class TokensMiddleware {
when (result) {
is CompletionResult.Success -> {
val newDerivedKeys = result.data.entries
val updatedDerivedKeys =
mutableMapOf<KeyWalletPublicKey, ExtendedPublicKeysMap>()
val oldDerivedKeys = scanResponse.derivedKeys
newDerivedKeys.forEach { entry ->
val derivationData = derivationDataList.find {
it.mapKeyOfWalletPublicKey == entry.key
} ?: return@forEach
updatedDerivedKeys[entry.key] =
ExtendedPublicKeysMap(derivationData.alreadyDerivedKeys + entry.value)
val walletKeys = (newDerivedKeys.keys + oldDerivedKeys.keys).toSet()
val updatedDerivedKeys = walletKeys.associateWith { walletKey ->
val oldDerivations = ExtendedPublicKeysMap(oldDerivedKeys[walletKey] ?: emptyMap())
val newDerivations = newDerivedKeys[walletKey] ?: ExtendedPublicKeysMap(emptyMap())
ExtendedPublicKeysMap(oldDerivations + newDerivations)
}
val updatedScanResponse = scanResponse.copy(
derivedKeys = updatedDerivedKeys
derivedKeys = updatedDerivedKeys,
)
store.dispatchOnMain(GlobalAction.SaveScanNoteResponse(updatedScanResponse))
delay(DELAY_SDK_DIALOG_CLOSE)

View file

@ -22,10 +22,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textAllCaps="true"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="75.00 usd" />
<TextView
@ -39,16 +39,30 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvReceiptAmount" />
<ProgressBar
android:id="@+id/pbReceiptFee"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:elevation="18dp"
android:indeterminate="true"
android:indeterminateTint="@color/accent"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/tvReceiptFee"
app:layout_constraintEnd_toEndOf="@+id/tvReceiptFeeValue"
app:layout_constraintTop_toTopOf="@+id/tvReceiptFee" />
<TextView
android:id="@+id/tvReceiptFeeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvReceiptFee"
android:textAllCaps="true"
android:textColor="@color/darkGray1"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvReceiptFee"
tools:text="0.03 usd" />
<View

View file

@ -3,7 +3,7 @@ ext.versions = [
build_gradle : '7.1.3',
tangem_card_sdk : 'develop-165',
// tangem_card_sdk : '0.0.1',
tangem_blockchain_sdk: 'develop-130',
tangem_blockchain_sdk: 'develop-132',
// tangem_blockchain_sdk: '0.0.1',
]