From 28ce6b5a0842bda3e3256d57fe5f4309c5e21dd7 Mon Sep 17 00:00:00 2001 From: Honza Date: Tue, 23 Jul 2024 16:21:32 +0200 Subject: [PATCH 1/7] Adopt TEX addresses related changes --- .../electriccoin/zcash/ui/common/extension/AddressTypeExt.kt | 2 ++ .../zcash/ui/common/model/SerializableAddress.kt | 1 + .../electriccoin/zcash/ui/screen/receive/view/ReceiveView.kt | 2 ++ .../zcash/ui/screen/send/ext/WalletAddressExt.kt | 1 + .../zcash/ui/screen/send/model/RecipientAddressState.kt | 5 +++-- .../co/electriccoin/zcash/ui/screen/send/view/SendView.kt | 3 ++- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/extension/AddressTypeExt.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/extension/AddressTypeExt.kt index 7d4b41275..ac69c1410 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/extension/AddressTypeExt.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/extension/AddressTypeExt.kt @@ -13,6 +13,7 @@ fun AddressType.toSerializableName(): String = AddressType.Transparent -> "transparent" AddressType.Shielded -> "shielded" AddressType.Unified -> "unified" + AddressType.Tex -> "tex" // Improve this with serializing reason is AddressType.Invalid -> "invalid" } @@ -22,6 +23,7 @@ fun fromSerializableName(typeName: String): AddressType = "transparent" -> AddressType.Transparent "shielded" -> AddressType.Shielded "unified" -> AddressType.Unified + "tex" -> AddressType.Tex // Improve this with deserializing reason "invalid" -> AddressType.Invalid() else -> error("Unsupported AddressType: $typeName") diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/model/SerializableAddress.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/model/SerializableAddress.kt index 2fe60aee5..c0ecf8f99 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/model/SerializableAddress.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/model/SerializableAddress.kt @@ -29,6 +29,7 @@ data class SerializableAddress( AddressType.Unified -> WalletAddress.Unified.new(address) AddressType.Shielded -> WalletAddress.Sapling.new(address) AddressType.Transparent -> WalletAddress.Transparent.new(address) + AddressType.Tex -> WalletAddress.Tex.new(address) is AddressType.Invalid -> error("Invalid address type") } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveView.kt index 4a55c31c1..a6e373237 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveView.kt @@ -230,6 +230,7 @@ private fun ReceiveContents( is WalletAddress.Unified -> R.string.receive_wallet_address_unified is WalletAddress.Sapling -> R.string.receive_wallet_address_sapling is WalletAddress.Transparent -> R.string.receive_wallet_address_transparent + else -> error("Unsupported address type") } ) }.toPersistentList(), @@ -304,6 +305,7 @@ private fun ColumnScope.QrCode( is WalletAddress.Unified -> R.string.receive_unified_content_description is WalletAddress.Sapling -> R.string.receive_sapling_content_description is WalletAddress.Transparent -> R.string.receive_transparent_content_description + else -> error("Unsupported address type") } ), modifier = diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/ext/WalletAddressExt.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/ext/WalletAddressExt.kt index 57d44ea5b..9783de532 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/ext/WalletAddressExt.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/ext/WalletAddressExt.kt @@ -39,5 +39,6 @@ internal fun WalletAddress.toSerializableAddress() = is WalletAddress.Unified -> AddressType.Unified is WalletAddress.Sapling -> AddressType.Shielded is WalletAddress.Transparent -> AddressType.Transparent + is WalletAddress.Tex -> AddressType.Tex } ) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/model/RecipientAddressState.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/model/RecipientAddressState.kt index 662d4baeb..c217e9f2e 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/model/RecipientAddressState.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/model/RecipientAddressState.kt @@ -14,6 +14,7 @@ data class RecipientAddressState( private const val TYPE_INVALID = "invalid" // $NON-NLS private const val TYPE_SHIELDED = "shielded" // $NON-NLS private const val TYPE_TRANSPARENT = "transparent" // $NON-NLS + private const val TYPE_TEX = "tex" // $NON-NLS private const val TYPE_UNIFIED = "unified" // $NON-NLS fun new( @@ -42,6 +43,7 @@ data class RecipientAddressState( TYPE_SHIELDED -> AddressType.Shielded TYPE_UNIFIED -> AddressType.Unified TYPE_TRANSPARENT -> AddressType.Transparent + TYPE_TEX -> AddressType.Tex else -> null } ) @@ -62,14 +64,13 @@ data class RecipientAddressState( saverMap[KEY_INVALID_REASON] = this.type.reason TYPE_INVALID } - AddressType.Unified -> TYPE_UNIFIED AddressType.Transparent -> TYPE_TRANSPARENT AddressType.Shielded -> TYPE_SHIELDED + AddressType.Tex -> TYPE_TEX else -> error("Unsupported type: ${this.type}") } } - return saverMap } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/view/SendView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/view/SendView.kt index 86982cb72..a1ae0cf4a 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/view/SendView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/send/view/SendView.kt @@ -386,7 +386,8 @@ private fun SendForm( recipientAddressState.type is AddressType.Invalid || ( recipientAddressState.type is AddressType.Valid && - recipientAddressState.type !is AddressType.Transparent + recipientAddressState.type !is AddressType.Transparent && + recipientAddressState.type !is AddressType.Tex ) ), scrollState = scrollState, From 2a8c5e600fdc512a5ccbf0f347d87baf1c6b2abc Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 19 Aug 2024 13:06:42 +0200 Subject: [PATCH 2/7] [#1416] Shielded transaction UI --- gradle.properties | 2 +- .../ui/screen/account/view/HistoryView.kt | 85 ++++++++++++------- .../drawable/ic_trx_shielded_funds.xml | 16 ++++ .../main/res/ui/account/values/strings.xml | 3 + 4 files changed, 74 insertions(+), 32 deletions(-) create mode 100644 ui-lib/src/main/res/ui/account/drawable/ic_trx_shielded_funds.xml diff --git a/gradle.properties b/gradle.properties index e3dff4594..d66a0481c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -131,7 +131,7 @@ ZCASH_EMULATOR_WTF_API_KEY= # Optional absolute path to a Zcash SDK checkout. # When blank, it pulls the SDK from Maven. # When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project. -SDK_INCLUDED_BUILD_PATH= +SDK_INCLUDED_BUILD_PATH=/Users/milancerovsky/Developer/zcash/zcash-android-wallet-sdk # When blank, it pulls the BIP-39 library from Maven. # When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project. diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt index bddd8bc93..a188fd8c0 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt @@ -359,6 +359,27 @@ private fun HistoryItem( textColor = ZcashTheme.colors.historyRedColor textStyle = ZcashTheme.extendedTypography.transactionItemStyles.titleFailed } + + TransactionExtendedState.SHIELDED -> { + typeText = stringResource(id = R.string.account_history_item_shielded_funds) + typeIcon = ImageVector.vectorResource(R.drawable.ic_trx_shielded_funds) + textColor = MaterialTheme.colorScheme.onBackground + textStyle = ZcashTheme.extendedTypography.transactionItemStyles.titleRegular + } + + TransactionExtendedState.SHIELDING -> { + typeText = stringResource(id = R.string.account_history_item_shielding_funds) + typeIcon = ImageVector.vectorResource(R.drawable.ic_trx_shielded_funds) + textColor = ZcashTheme.colors.textDescription + textStyle = ZcashTheme.extendedTypography.transactionItemStyles.titleRunning + } + + TransactionExtendedState.SHIELDING_FAILED -> { + typeText = stringResource(id = R.string.account_history_item_shielding_failed) + typeIcon = ImageVector.vectorResource(R.drawable.ic_trx_shielded_funds) + textColor = ZcashTheme.colors.historyRedColor + textStyle = ZcashTheme.extendedTypography.transactionItemStyles.titleFailed + } } Row( @@ -487,8 +508,12 @@ private fun HistoryItemCollapsedMainPart( stringResource(id = R.string.account_history_item_received_prefix) } - StyledBalance( - balanceParts = + if (transaction.expandableState.isInAnyExtendedState() && + transaction.overview.getExtendedState().isShielding()) { + // do not show anything in this case + } else { + StyledBalance( + balanceParts = if (transaction.expandableState.isInAnyExtendedState()) { transaction.overview.netValue.toZecStringFull().asZecAmountTriple(prefix) } else { @@ -496,14 +521,15 @@ private fun HistoryItemCollapsedMainPart( suffix = stringResource(id = R.string.general_etc) ).asZecAmountTriple(prefix) }, - isHideBalances = isHideBalances, - textStyle = + isHideBalances = isHideBalances, + textStyle = StyledBalanceDefaults.textStyles( mostSignificantPart = valueTextStyle, leastSignificantPart = ZcashTheme.extendedTypography.transactionItemStyles.valueSecondPart ), - textColor = valueTextColor, - ) + textColor = valueTextColor, + ) + } } } @@ -727,7 +753,7 @@ private fun HistoryItemTransactionIdPart( onAction: (TrxItemAction) -> Unit, modifier: Modifier = Modifier ) { - val txIdString = transaction.overview.txIdString() + val txIdString = transaction.overview.txIdString() ?: return Column(modifier = modifier) { if (transaction.expandableState == TrxItemState.EXPANDED_ID || @@ -929,41 +955,38 @@ internal enum class TransactionExtendedState { SEND_FAILED, RECEIVED, RECEIVING, - RECEIVE_FAILED; + RECEIVE_FAILED, + SHIELDED, + SHIELDING, + SHIELDING_FAILED; + + fun isShielding() = this in listOf(SHIELDED, RECEIVE_FAILED, SHIELDING_FAILED) - fun isFailed(): Boolean = this == SEND_FAILED || this == RECEIVE_FAILED + fun isFailed(): Boolean = this in listOf(SEND_FAILED, RECEIVE_FAILED, SHIELDING_FAILED) - fun isSendType(): Boolean = this == SENDING || this == SENT || this == SEND_FAILED + fun isSendType(): Boolean = this in listOf(SENDING, SENT, SEND_FAILED, SHIELDED, SHIELDING_FAILED, SHIELDING) } private fun TransactionOverview.getExtendedState(): TransactionExtendedState { return when (transactionState) { - TransactionState.Expired -> { - if (isSentTransaction) { - TransactionExtendedState.SEND_FAILED - } else { - TransactionExtendedState.RECEIVE_FAILED - } + TransactionState.Expired -> when { + isShielding -> TransactionExtendedState.SHIELDING_FAILED + isSentTransaction -> TransactionExtendedState.SEND_FAILED + else -> TransactionExtendedState.RECEIVE_FAILED } - TransactionState.Confirmed -> { - if (isSentTransaction) { - TransactionExtendedState.SENT - } else { - TransactionExtendedState.RECEIVED - } + TransactionState.Confirmed -> when { + isShielding -> TransactionExtendedState.SHIELDED + isSentTransaction -> TransactionExtendedState.SENT + else -> TransactionExtendedState.RECEIVED } - TransactionState.Pending -> { - if (isSentTransaction) { - TransactionExtendedState.SENDING - } else { - TransactionExtendedState.RECEIVING - } + TransactionState.Pending -> when { + isShielding -> TransactionExtendedState.SHIELDING + isSentTransaction -> TransactionExtendedState.SENDING + else -> TransactionExtendedState.RECEIVING } - else -> { - error("Unexpected transaction state found while calculating its extended state.") - } + else -> error("Unexpected transaction state found while calculating its extended state.") } } diff --git a/ui-lib/src/main/res/ui/account/drawable/ic_trx_shielded_funds.xml b/ui-lib/src/main/res/ui/account/drawable/ic_trx_shielded_funds.xml new file mode 100644 index 000000000..e414d3932 --- /dev/null +++ b/ui-lib/src/main/res/ui/account/drawable/ic_trx_shielded_funds.xml @@ -0,0 +1,16 @@ + + + + + + + diff --git a/ui-lib/src/main/res/ui/account/values/strings.xml b/ui-lib/src/main/res/ui/account/values/strings.xml index 025109288..a11ffad0a 100644 --- a/ui-lib/src/main/res/ui/account/values/strings.xml +++ b/ui-lib/src/main/res/ui/account/values/strings.xml @@ -3,6 +3,9 @@ No transaction history Sent + Shielded Funds + Shielding Funds... + Shielding Failed... Received Sending… Receiving… From b679d9b19a637cc3bba74c55e7adbc2f659dd8f5 Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Wed, 21 Aug 2024 08:47:27 +0200 Subject: [PATCH 3/7] Shielded transaction design update --- .../ui/screen/account/view/HistoryView.kt | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt index a188fd8c0..e8cf9d54c 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt @@ -148,9 +148,9 @@ internal fun HistoryContainer( testTag = BalancesTag.STATUS, walletSnapshot = walletSnapshot, modifier = - Modifier - .padding(horizontal = ZcashTheme.dimens.spacingDefault) - .animateContentSize() + Modifier + .padding(horizontal = ZcashTheme.dimens.spacingDefault) + .animateContentSize() ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault)) @@ -576,13 +576,13 @@ private fun HistoryItemCollapsedAddressPart( maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = - Modifier - .fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO) - .then(clickModifier) + Modifier + .fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO) + .then(clickModifier) ) } } - } else { + } else if (!transaction.overview.isShielding) { Icon( imageVector = ImageVector.vectorResource(R.drawable.ic_trx_shielded), contentDescription = stringResource(id = R.string.account_history_item_shielded) @@ -622,10 +622,10 @@ private fun HistoryItemExpandedAddressPart( iconVector = ImageVector.vectorResource(R.drawable.ic_trx_copy), iconTintColor = ZcashTheme.colors.secondaryColor, modifier = - Modifier - .clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner)) - .clickable { onAction(TrxItemAction.AddressClick(recipient)) } - .padding(all = ZcashTheme.dimens.spacingTiny) + Modifier + .clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner)) + .clickable { onAction(TrxItemAction.AddressClick(recipient)) } + .padding(all = ZcashTheme.dimens.spacingTiny) ) } } @@ -706,9 +706,25 @@ private fun HistoryItemExpandedPart( onAction = onAction ) + if (transaction.overview.getExtendedState().isShielding()) { + Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingDefault))) + + val prefix = + if (transaction.overview.isSentTransaction) { + stringResource(id = R.string.account_history_item_sent_prefix) + } else { + stringResource(id = R.string.account_history_item_received_prefix) + } + + + Text(text = + "Amount: ${transaction.overview.netValue.toZecStringFull().asZecAmountTriple(prefix)}" + ) + } + Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingDefault))) - HistoryItemTransactionFeePart(fee = transaction.overview.feePaid) + HistoryItemTransactionFeePart(transaction = transaction, fee = transaction.overview.feePaid) Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingLarge))) @@ -836,6 +852,7 @@ private fun HistoryItemTransactionIdPart( @Composable private fun HistoryItemTransactionFeePart( + transaction: TransactionUi, fee: Zatoshi?, modifier: Modifier = Modifier ) { @@ -843,7 +860,11 @@ private fun HistoryItemTransactionFeePart( Text( text = stringResource(id = R.string.account_history_item_transaction_fee), style = ZcashTheme.extendedTypography.transactionItemStyles.content, - color = ZcashTheme.colors.textDescription, + color = if (transaction.overview.getExtendedState().isShielding()) { + ZcashTheme.colors.historyRedColor + } else { + ZcashTheme.colors.textDescription + }, ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny)) From 9838a34c97361d0644f9976488ca1dc78fe18ee1 Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 9 Sep 2024 10:35:37 +0200 Subject: [PATCH 4/7] [#1416] Design updates Closes #1416 --- .../ui/screen/account/view/HistoryView.kt | 107 ++++++++---------- 1 file changed, 45 insertions(+), 62 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt index e8cf9d54c..cd9f47a0f 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt @@ -148,9 +148,9 @@ internal fun HistoryContainer( testTag = BalancesTag.STATUS, walletSnapshot = walletSnapshot, modifier = - Modifier - .padding(horizontal = ZcashTheme.dimens.spacingDefault) - .animateContentSize() + Modifier + .padding(horizontal = ZcashTheme.dimens.spacingDefault) + .animateContentSize() ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault)) @@ -306,7 +306,7 @@ private fun ComposableHistoryListItemsPreview() { const val ADDRESS_IN_TITLE_WIDTH_RATIO = 0.5f @Composable -@Suppress("LongMethod") +@Suppress("LongMethod", "CyclomaticComplexMethod") private fun HistoryItem( transaction: TransactionUi, isHideBalances: Boolean, @@ -508,12 +508,8 @@ private fun HistoryItemCollapsedMainPart( stringResource(id = R.string.account_history_item_received_prefix) } - if (transaction.expandableState.isInAnyExtendedState() && - transaction.overview.getExtendedState().isShielding()) { - // do not show anything in this case - } else { - StyledBalance( - balanceParts = + StyledBalance( + balanceParts = if (transaction.expandableState.isInAnyExtendedState()) { transaction.overview.netValue.toZecStringFull().asZecAmountTriple(prefix) } else { @@ -521,15 +517,14 @@ private fun HistoryItemCollapsedMainPart( suffix = stringResource(id = R.string.general_etc) ).asZecAmountTriple(prefix) }, - isHideBalances = isHideBalances, - textStyle = + isHideBalances = isHideBalances, + textStyle = StyledBalanceDefaults.textStyles( mostSignificantPart = valueTextStyle, leastSignificantPart = ZcashTheme.extendedTypography.transactionItemStyles.valueSecondPart ), - textColor = valueTextColor, - ) - } + textColor = valueTextColor, + ) } } @@ -576,9 +571,9 @@ private fun HistoryItemCollapsedAddressPart( maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = - Modifier - .fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO) - .then(clickModifier) + Modifier + .fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO) + .then(clickModifier) ) } } @@ -622,10 +617,10 @@ private fun HistoryItemExpandedAddressPart( iconVector = ImageVector.vectorResource(R.drawable.ic_trx_copy), iconTintColor = ZcashTheme.colors.secondaryColor, modifier = - Modifier - .clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner)) - .clickable { onAction(TrxItemAction.AddressClick(recipient)) } - .padding(all = ZcashTheme.dimens.spacingTiny) + Modifier + .clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner)) + .clickable { onAction(TrxItemAction.AddressClick(recipient)) } + .padding(all = ZcashTheme.dimens.spacingTiny) ) } } @@ -662,7 +657,7 @@ private fun HistoryItemExpandedPart( modifier: Modifier = Modifier ) { Column(modifier = modifier) { - if (transaction.messages.containsValidMemo()) { + if (transaction.overview.isShielding.not() && transaction.messages.containsValidMemo()) { Text( text = pluralStringResource( @@ -688,8 +683,8 @@ private fun HistoryItemExpandedPart( ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault)) } - } else if (transaction.recipientAddressType == null || - transaction.recipientAddressType == AddressType.Shielded + } else if (transaction.overview.isShielding.not() && + (transaction.recipientAddressType == null || transaction.recipientAddressType == AddressType.Shielded) ) { Text( text = stringResource(id = R.string.account_history_item_no_message), @@ -706,22 +701,6 @@ private fun HistoryItemExpandedPart( onAction = onAction ) - if (transaction.overview.getExtendedState().isShielding()) { - Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingDefault))) - - val prefix = - if (transaction.overview.isSentTransaction) { - stringResource(id = R.string.account_history_item_sent_prefix) - } else { - stringResource(id = R.string.account_history_item_received_prefix) - } - - - Text(text = - "Amount: ${transaction.overview.netValue.toZecStringFull().asZecAmountTriple(prefix)}" - ) - } - Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingDefault))) HistoryItemTransactionFeePart(transaction = transaction, fee = transaction.overview.feePaid) @@ -769,7 +748,7 @@ private fun HistoryItemTransactionIdPart( onAction: (TrxItemAction) -> Unit, modifier: Modifier = Modifier ) { - val txIdString = transaction.overview.txIdString() ?: return + val txIdString = transaction.overview.txIdString().orEmpty() Column(modifier = modifier) { if (transaction.expandableState == TrxItemState.EXPANDED_ID || @@ -860,11 +839,12 @@ private fun HistoryItemTransactionFeePart( Text( text = stringResource(id = R.string.account_history_item_transaction_fee), style = ZcashTheme.extendedTypography.transactionItemStyles.content, - color = if (transaction.overview.getExtendedState().isShielding()) { - ZcashTheme.colors.historyRedColor - } else { - ZcashTheme.colors.textDescription - }, + color = + if (transaction.overview.getExtendedState().isShielding()) { + ZcashTheme.colors.historyRedColor + } else { + ZcashTheme.colors.textDescription + }, ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny)) @@ -990,23 +970,26 @@ internal enum class TransactionExtendedState { private fun TransactionOverview.getExtendedState(): TransactionExtendedState { return when (transactionState) { - TransactionState.Expired -> when { - isShielding -> TransactionExtendedState.SHIELDING_FAILED - isSentTransaction -> TransactionExtendedState.SEND_FAILED - else -> TransactionExtendedState.RECEIVE_FAILED - } + TransactionState.Expired -> + when { + isShielding -> TransactionExtendedState.SHIELDING_FAILED + isSentTransaction -> TransactionExtendedState.SEND_FAILED + else -> TransactionExtendedState.RECEIVE_FAILED + } - TransactionState.Confirmed -> when { - isShielding -> TransactionExtendedState.SHIELDED - isSentTransaction -> TransactionExtendedState.SENT - else -> TransactionExtendedState.RECEIVED - } + TransactionState.Confirmed -> + when { + isShielding -> TransactionExtendedState.SHIELDED + isSentTransaction -> TransactionExtendedState.SENT + else -> TransactionExtendedState.RECEIVED + } - TransactionState.Pending -> when { - isShielding -> TransactionExtendedState.SHIELDING - isSentTransaction -> TransactionExtendedState.SENDING - else -> TransactionExtendedState.RECEIVING - } + TransactionState.Pending -> + when { + isShielding -> TransactionExtendedState.SHIELDING + isSentTransaction -> TransactionExtendedState.SENDING + else -> TransactionExtendedState.RECEIVING + } else -> error("Unexpected transaction state found while calculating its extended state.") } From 49de54dba20830e66c08e26472739226d32eeca1 Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 9 Sep 2024 10:37:03 +0200 Subject: [PATCH 5/7] [#1416] Code cleanup Closes #1416 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 134f1686b..7abfbaa6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -131,7 +131,7 @@ ZCASH_EMULATOR_WTF_API_KEY= # Optional absolute path to a Zcash SDK checkout. # When blank, it pulls the SDK from Maven. # When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project. -SDK_INCLUDED_BUILD_PATH=/Users/milancerovsky/Developer/zcash/zcash-android-wallet-sdk +SDK_INCLUDED_BUILD_PATH= # When blank, it pulls the BIP-39 library from Maven. # When set, it uses the path for a Gradle included build. Path can either be absolute or relative to the root of this app's Gradle project. From 8fc3533318c7633461abbe3abe5b90c581530bea Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Mon, 9 Sep 2024 10:38:25 +0200 Subject: [PATCH 6/7] [#1416] Documentation update Closes #1416 --- CHANGELOG.md | 3 +++ docs/whatsNew/WHATS_NEW_EN.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff05b41c4..016cb4a7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2 ## [Unreleased] +### Added +- Shielded transactions are properly indicated in transaction history + ## [1.1.7 (718)] - 2024-09-06 ### Added diff --git a/docs/whatsNew/WHATS_NEW_EN.md b/docs/whatsNew/WHATS_NEW_EN.md index 60ed6bd0f..9489c887c 100644 --- a/docs/whatsNew/WHATS_NEW_EN.md +++ b/docs/whatsNew/WHATS_NEW_EN.md @@ -9,6 +9,9 @@ directly impact users rather than highlighting other key architectural updates.* ## [Unreleased] +### Added +- Shielded transactions are properly indicated in transaction history + ## [1.1.7 (718)] - 2024-09-06 ### Added From 3ca17f752a96b6e0244a45eacdabe14db05bfa0b Mon Sep 17 00:00:00 2001 From: Milan Cerovsky Date: Fri, 13 Sep 2024 08:18:02 +0200 Subject: [PATCH 7/7] [#1416] Code cleanup Closes #1416 --- .../zcash/ui/screen/account/view/HistoryView.kt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt index cd9f47a0f..e607bd9f3 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/account/view/HistoryView.kt @@ -703,7 +703,7 @@ private fun HistoryItemExpandedPart( Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingDefault))) - HistoryItemTransactionFeePart(transaction = transaction, fee = transaction.overview.feePaid) + HistoryItemTransactionFeePart(fee = transaction.overview.feePaid) Spacer(modifier = (Modifier.height(ZcashTheme.dimens.spacingLarge))) @@ -748,7 +748,7 @@ private fun HistoryItemTransactionIdPart( onAction: (TrxItemAction) -> Unit, modifier: Modifier = Modifier ) { - val txIdString = transaction.overview.txIdString().orEmpty() + val txIdString = transaction.overview.txIdString() Column(modifier = modifier) { if (transaction.expandableState == TrxItemState.EXPANDED_ID || @@ -831,7 +831,6 @@ private fun HistoryItemTransactionIdPart( @Composable private fun HistoryItemTransactionFeePart( - transaction: TransactionUi, fee: Zatoshi?, modifier: Modifier = Modifier ) { @@ -839,12 +838,7 @@ private fun HistoryItemTransactionFeePart( Text( text = stringResource(id = R.string.account_history_item_transaction_fee), style = ZcashTheme.extendedTypography.transactionItemStyles.content, - color = - if (transaction.overview.getExtendedState().isShielding()) { - ZcashTheme.colors.historyRedColor - } else { - ZcashTheme.colors.textDescription - }, + color = ZcashTheme.colors.textDescription, ) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny))