From beb05ffb87831b4cee7a522195b6f6ed2cbf3d65 Mon Sep 17 00:00:00 2001 From: Angelos Veglektsis Date: Wed, 4 Sep 2024 14:06:53 -0400 Subject: [PATCH] Increment to version 4.0.34 --- CHANGELOG.md | 8 +++++ .../common/extensions/PreviewExtensions.kt | 3 +- .../com/blockstream/common/gdk/GdkSession.kt | 3 +- .../looks/transaction/TransactionLook.kt | 8 ++--- .../looks/transaction/TransactionStatus.kt | 18 +++++++---- .../models/add/AddAccountViewModelAbstract.kt | 18 +++++------ .../transaction/TransactionViewModel.kt | 2 +- compose/build.gradle.kts | 3 +- .../components/GreenTransaction.android.kt | 3 +- .../TransactionStatusIcon.android.kt | 4 +-- .../compose/components/GreenTransaction.kt | 2 +- .../compose/extensions/Resources.kt | 2 +- .../screens/add/ChooseAccountTypeScreen.kt | 11 ++----- .../screens/add/ReviewAddAccountScreen.kt | 19 ++++++++++- .../compose/screens/receive/ReceiveScreen.kt | 5 +++ .../compose/screens/send/SendConfirmScreen.kt | 2 -- .../screens/settings/TwoFactorSetupScreen.kt | 2 +- .../screens/settings/WatchOnlyScreen.kt | 21 ++++++------ .../compose/sheets/AssetsBottomSheet.kt | 2 +- .../compose/sheets/CountriesBottomSheet.kt | 6 +--- gradle.properties | 2 -- gradle/libs.versions.toml | 14 ++++---- green/build.gradle.kts | 4 +-- .../green/ui/add/ChooseAccountTypeFragment.kt | 32 ------------------- .../green/ui/add/ReviewAddAccountFragment.kt | 22 ------------- .../green/ui/receive/ReceiveFragment.kt | 12 ------- .../green/ui/send/SendConfirmFragment.kt | 15 --------- 27 files changed, 94 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e18d78db5..7d0bcdbce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [4.0.34] - 2024-09-04 + +### Changed +- Update dependencies +- +- ### Fixed +- Various bug fixes + ## [4.0.33] - 2024-08-15 - ### Fixed diff --git a/common/src/commonMain/kotlin/com/blockstream/common/extensions/PreviewExtensions.kt b/common/src/commonMain/kotlin/com/blockstream/common/extensions/PreviewExtensions.kt index 8baff382f..2ebf6c0b3 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/extensions/PreviewExtensions.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/extensions/PreviewExtensions.kt @@ -17,6 +17,7 @@ import com.blockstream.common.gdk.data.Network import com.blockstream.common.gdk.data.Transaction import com.blockstream.common.looks.transaction.Completed import com.blockstream.common.looks.transaction.TransactionLook +import com.blockstream.common.looks.transaction.TransactionStatus import com.blockstream.common.looks.wallet.WalletListLook import kotlinx.datetime.Clock @@ -129,4 +130,4 @@ fun previewTransaction() = Transaction( it.accountInjected = previewAccount() } -fun previewTransactionLook() = TransactionLook(Completed, 1, previewTransaction(), listOf("12311.123 BTC")) \ No newline at end of file +fun previewTransactionLook(status: TransactionStatus = Completed()) = TransactionLook(status, previewTransaction(), listOf("12311.123 BTC")) \ No newline at end of file diff --git a/common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt b/common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt index b3c49cc0d..af135144c 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt @@ -1498,7 +1498,8 @@ class GdkSession constructor( // Init SDK initLightningSdk(lightningMnemonic) - if (hasLightning || ((isRestore || isSmartDiscovery) && settingsManager.isLightningEnabled())) { + // SmartDiscovery only for SW wallets, on HW ln mnemonic is not available + if (hasLightning || ((isRestore || (isSmartDiscovery && !isHardwareWallet)) && settingsManager.isLightningEnabled())) { // Make it async to speed up login process val job = scope.async { try { diff --git a/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionLook.kt b/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionLook.kt index 511cb6427..939c9694a 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionLook.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionLook.kt @@ -14,9 +14,8 @@ import com.blockstream.common.utils.Loggable import com.blockstream.common.utils.toAmountLookOrNa import org.jetbrains.compose.resources.StringResource -data class TransactionLook( +data class TransactionLook constructor( val status: TransactionStatus, - val confirmations: Long, val transaction: Transaction, val assets: List ) { @@ -27,11 +26,11 @@ data class TransactionLook( val directionText: StringResource get() = when { transaction.txType == Transaction.Type.IN -> { - if (confirmations > 0) Res.string.id_received else Res.string.id_receiving + if (status.confirmations > 0) Res.string.id_received else Res.string.id_receiving } transaction.txType == Transaction.Type.OUT -> { - if (confirmations > 0) Res.string.id_sent else Res.string.id_sending + if (status.confirmations > 0) Res.string.id_sent else Res.string.id_sending } transaction.txType == Transaction.Type.REDEPOSIT -> Res.string.id_redeposited @@ -45,7 +44,6 @@ data class TransactionLook( return TransactionLook( transaction = transaction, - confirmations = transaction.getConfirmations(session), status = TransactionStatus.create(transaction, session), assets = transaction.assets.map { session.starsOrNull ?: it.second.toAmountLookOrNa( diff --git a/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionStatus.kt b/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionStatus.kt index ad5c12eb1..33d7d7fa0 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionStatus.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/looks/transaction/TransactionStatus.kt @@ -5,6 +5,8 @@ import com.blockstream.common.gdk.data.Transaction sealed interface TransactionStatus { + val confirmations: Long + val onProgress: Boolean get() = this is Unconfirmed || this is Confirmed @@ -16,7 +18,7 @@ sealed interface TransactionStatus { Failed() } confirmations == 0L -> { - Unconfirmed(transaction.network.confirmationsRequired) + Unconfirmed(confirmationsRequired = transaction.network.confirmationsRequired) } confirmations < transaction.network.confirmationsRequired -> { @@ -24,7 +26,7 @@ sealed interface TransactionStatus { } confirmations >= transaction.network.confirmationsRequired -> { - Completed + Completed(confirmations = confirmations) } else -> { @@ -35,7 +37,11 @@ sealed interface TransactionStatus { } } -class Unconfirmed(val confirmationsRequired: Long = 6) : TransactionStatus -class Confirmed(val confirmations: Long, val confirmationsRequired : Long = 6) : TransactionStatus -object Completed : TransactionStatus -class Failed(val error: String = "") : TransactionStatus \ No newline at end of file +data class Unconfirmed(val confirmationsRequired: Long = 6): TransactionStatus { + override val confirmations: Long= 0 +} +data class Confirmed(override val confirmations: Long, val confirmationsRequired : Long = 6) : TransactionStatus +data class Completed(override val confirmations: Long = Long.MAX_VALUE) : TransactionStatus +data class Failed(val error: String = "") : TransactionStatus { + override val confirmations: Long= 0 +} \ No newline at end of file diff --git a/common/src/commonMain/kotlin/com/blockstream/common/models/add/AddAccountViewModelAbstract.kt b/common/src/commonMain/kotlin/com/blockstream/common/models/add/AddAccountViewModelAbstract.kt index 38bdbb902..1ad3ddceb 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/models/add/AddAccountViewModelAbstract.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/models/add/AddAccountViewModelAbstract.kt @@ -98,15 +98,15 @@ abstract class AddAccountViewModelAbstract(greenWallet: GreenWallet, val assetId } - if (appInfo.isDevelopmentOrDebug) { - logger.i { "Development/Debug feature setCloseToAddress" } - session.accounts.value.filter { it.isBitcoin }.let { accounts -> - accounts.find { it.type == AccountType.BIP84_SEGWIT } - ?: accounts.find { it.type == AccountType.BIP49_SEGWIT_WRAPPED } - }?.also { - session.lightningSdk.setCloseToAddress(session.getReceiveAddress(it).address) - } - } +// if (appInfo.isDevelopmentOrDebug) { +// logger.i { "Development/Debug feature setCloseToAddress" } +// session.accounts.value.filter { it.isBitcoin }.let { accounts -> +// accounts.find { it.type == AccountType.BIP84_SEGWIT } +// ?: accounts.find { it.type == AccountType.BIP49_SEGWIT_WRAPPED } +// }?.also { +// session.lightningSdk.setCloseToAddress(session.getReceiveAddress(it).address) +// } +// } // If wallet is new and LN is created, default to Satoshi if (isEmptyWallet) { diff --git a/common/src/commonMain/kotlin/com/blockstream/common/models/transaction/TransactionViewModel.kt b/common/src/commonMain/kotlin/com/blockstream/common/models/transaction/TransactionViewModel.kt index b11224ba8..c963ab634 100644 --- a/common/src/commonMain/kotlin/com/blockstream/common/models/transaction/TransactionViewModel.kt +++ b/common/src/commonMain/kotlin/com/blockstream/common/models/transaction/TransactionViewModel.kt @@ -403,7 +403,7 @@ class TransactionViewModelPreview(status : TransactionStatus) : TransactionViewM companion object { fun previewUnconfirmed() = TransactionViewModelPreview(Unconfirmed()) fun previewConfirmed() = TransactionViewModelPreview(Confirmed(confirmations = 3, confirmationsRequired = 6)) - fun previewCompleted() = TransactionViewModelPreview(Completed) + fun previewCompleted() = TransactionViewModelPreview(Completed(Long.MAX_VALUE)) fun previewFailed() = TransactionViewModelPreview(Failed()) } } \ No newline at end of file diff --git a/compose/build.gradle.kts b/compose/build.gradle.kts index 09ed3e5cf..e9ee42067 100644 --- a/compose/build.gradle.kts +++ b/compose/build.gradle.kts @@ -1,6 +1,6 @@ + import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework plugins { @@ -112,6 +112,7 @@ kotlin { /** ----------------------------------------------------------------------------------------- */ /** --- Material --------------------------------------------------------------------------- */ + implementation(libs.compose.material3) implementation(libs.compose.material3.android) /** ----------------------------------------------------------------------------------------- */ diff --git a/compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenTransaction.android.kt b/compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenTransaction.android.kt index b33a0e404..44d404c94 100644 --- a/compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenTransaction.android.kt +++ b/compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenTransaction.android.kt @@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.tooling.preview.Preview import com.blockstream.common.extensions.previewTransactionLook +import com.blockstream.common.looks.transaction.Confirmed import com.blockstream.compose.theme.GreenThemePreview @@ -16,7 +17,7 @@ fun GreenTransactionPreview() { } - GreenTransaction(transactionLook = previewTransactionLook(), showAccount = false) { + GreenTransaction(transactionLook = previewTransactionLook(status = Confirmed(1, 2)), showAccount = false) { } } diff --git a/compose/src/androidMain/kotlin/com/blockstream/compose/components/TransactionStatusIcon.android.kt b/compose/src/androidMain/kotlin/com/blockstream/compose/components/TransactionStatusIcon.android.kt index 8dc8999b7..283275b38 100644 --- a/compose/src/androidMain/kotlin/com/blockstream/compose/components/TransactionStatusIcon.android.kt +++ b/compose/src/androidMain/kotlin/com/blockstream/compose/components/TransactionStatusIcon.android.kt @@ -18,11 +18,11 @@ fun TransactionStatusIconPreview() { Column { TransactionStatusIcon( - transactionStatus = Completed, + transactionStatus = Completed(), icons = listOf(painterResource(id = R.drawable.bitcoin)) ) TransactionStatusIcon( - transactionStatus = Completed, + transactionStatus = Completed(), icons = listOf(painterResource(id = R.drawable.bitcoin), painterResource(id = R.drawable.liquid)), isSwap = true ) diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/components/GreenTransaction.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/components/GreenTransaction.kt index a526e6125..1a8c58424 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/components/GreenTransaction.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/components/GreenTransaction.kt @@ -206,7 +206,7 @@ fun GreenTransaction( ) { if (status is Confirmed) { LinearProgressIndicator(progress = { - (status.confirmations / status.confirmationsRequired).toFloat() + status.confirmations / status.confirmationsRequired.toFloat() }, modifier = Modifier.fillMaxWidth()) } else { LinearProgressIndicator( diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/extensions/Resources.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/extensions/Resources.kt index e9a133a4d..bbeda646c 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/extensions/Resources.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/extensions/Resources.kt @@ -157,7 +157,7 @@ fun TransactionStatus.color() = when (this) { fun TransactionStatus.title() = when (this) { is Unconfirmed -> stringResource(Res.string.id_transaction_confirmed_ss, "0", confirmationsRequired.toString()) is Confirmed -> stringResource(Res.string.id_transaction_confirmed_ss, confirmations.toString(), confirmationsRequired.toString()) - Completed -> stringResource(Res.string.id_transaction_completed) + is Completed -> stringResource(Res.string.id_transaction_completed) is Failed -> stringResource(Res.string.id_transaction_failed) } diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ChooseAccountTypeScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ChooseAccountTypeScreen.kt index 92f5b3edc..529469a81 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ChooseAccountTypeScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ChooseAccountTypeScreen.kt @@ -67,7 +67,6 @@ import com.blockstream.compose.components.GreenRow import com.blockstream.compose.components.ScreenContainer import com.blockstream.compose.dialogs.LightningShortcutDialog import com.blockstream.compose.extensions.drawDiagonalLabel -import com.blockstream.compose.navigation.setNavigationResult import com.blockstream.compose.screens.jade.JadeQRScreen import com.blockstream.compose.sheets.AssetsBottomSheet import com.blockstream.compose.sideeffects.OpenDialogData @@ -110,10 +109,7 @@ data class ChooseAccountTypeScreen( } companion object { - @Composable - fun getNavigationResult(fn: (AccountAsset) -> Unit) = com.blockstream.compose.navigation.getNavigationResult(this::class, fn) - - internal fun setNavigationResult(result: AccountAsset) = setNavigationResult(this::class, result) + internal fun setResult(result: AccountAsset) = ReviewAddAccountScreen.setResult(result) } } @@ -137,8 +133,7 @@ fun ChooseAccountTypeScreen( HandleSideEffect(viewModel) { when(it) { is SideEffects.AccountCreated -> { - // TODO make it unique - ChooseAccountTypeScreen.setNavigationResult(it.accountAsset) + ChooseAccountTypeScreen.setResult(it.accountAsset) } is SideEffects.LightningShortcut -> { lightningShortcutViewModel = SimpleGreenViewModel(viewModel.greenWallet) @@ -180,7 +175,7 @@ fun ChooseAccountTypeScreen( } } - AssetsBottomSheet.getNavigationResult { + AssetsBottomSheet.getResult { viewModel.asset.value = it } diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ReviewAddAccountScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ReviewAddAccountScreen.kt index e445a0181..936d14e96 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ReviewAddAccountScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/add/ReviewAddAccountScreen.kt @@ -29,11 +29,15 @@ import com.blockstream.common.data.GreenWallet import com.blockstream.common.data.SetupArgs import com.blockstream.common.events.Events import com.blockstream.common.extensions.isNotBlank +import com.blockstream.common.gdk.data.AccountAsset import com.blockstream.common.models.add.ReviewAddAccountViewModel import com.blockstream.common.models.add.ReviewAddAccountViewModelAbstract +import com.blockstream.common.sideeffects.SideEffects import com.blockstream.compose.components.GreenButton import com.blockstream.compose.components.GreenColumn import com.blockstream.compose.components.ScreenContainer +import com.blockstream.compose.navigation.getNavigationResult +import com.blockstream.compose.navigation.setNavigationResult import com.blockstream.compose.theme.MonospaceFont import com.blockstream.compose.theme.displayMedium import com.blockstream.compose.theme.labelLarge @@ -61,6 +65,13 @@ data class ReviewAddAccountScreen( ReviewAddAccountScreen(viewModel = viewModel) } + + companion object { + @Composable + fun getResult(fn: (AccountAsset) -> Unit) = getNavigationResult(this::class, fn) + + internal fun setResult(result: AccountAsset) = setNavigationResult(this::class, result) + } } @Composable @@ -68,7 +79,13 @@ fun ReviewAddAccountScreen( viewModel: ReviewAddAccountViewModelAbstract ) { - HandleSideEffect(viewModel) + HandleSideEffect(viewModel) { + when(it) { + is SideEffects.AccountCreated -> { + ReviewAddAccountScreen.setResult(it.accountAsset) + } + } + } val onProgress by viewModel.onProgress.collectAsStateWithLifecycle() val onProgressDescription by viewModel.onProgressDescription.collectAsStateWithLifecycle() diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/receive/ReceiveScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/receive/ReceiveScreen.kt index 0e822b4fe..66c69bea8 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/receive/ReceiveScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/receive/ReceiveScreen.kt @@ -80,6 +80,7 @@ import com.blockstream.compose.components.GreenRow import com.blockstream.compose.components.LearnMoreButton import com.blockstream.compose.extensions.onValueChange import com.blockstream.compose.managers.rememberPlatformManager +import com.blockstream.compose.screens.add.ReviewAddAccountScreen import com.blockstream.compose.sheets.ChooseAssetAccountBottomSheet import com.blockstream.compose.sheets.DenominationBottomSheet import com.blockstream.compose.sheets.LocalBottomSheetNavigatorM3 @@ -133,6 +134,10 @@ fun ReceiveScreen( viewModel: ReceiveViewModelAbstract ) { + ReviewAddAccountScreen.getResult { + viewModel.postEvent(Events.SetAccountAsset(it)) + } + ChooseAssetAccountBottomSheet.getResult { viewModel.accountAsset.value = it } diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/send/SendConfirmScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/send/SendConfirmScreen.kt index 089c44b38..f8a74d299 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/send/SendConfirmScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/send/SendConfirmScreen.kt @@ -35,7 +35,6 @@ import com.blockstream.common.data.Denomination import com.blockstream.common.data.GreenWallet import com.blockstream.common.extensions.isNotBlank import com.blockstream.common.gdk.data.AccountAsset -import com.blockstream.common.models.add.ChooseAccountTypeViewModel import com.blockstream.common.models.send.CreateTransactionViewModelAbstract import com.blockstream.common.models.send.SendConfirmViewModel import com.blockstream.common.models.send.SendConfirmViewModelAbstract @@ -87,7 +86,6 @@ fun SendConfirmScreen( viewModel: SendConfirmViewModelAbstract ) { val look by viewModel.transactionConfirmLook.collectAsStateWithLifecycle() - val onProgress by viewModel.onProgress.collectAsStateWithLifecycle() val onProgressSending by viewModel.onProgressSending.collectAsStateWithLifecycle() val onProgressDescription by viewModel.onProgressDescription.collectAsStateWithLifecycle() diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/TwoFactorSetupScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/TwoFactorSetupScreen.kt index 52fcb2864..5f9c81fd5 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/TwoFactorSetupScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/TwoFactorSetupScreen.kt @@ -98,7 +98,7 @@ fun TwoFactorSetupScreen( ) { val focusRequester = remember { FocusRequester() } - CountriesBottomSheet.getNavigationResult { + CountriesBottomSheet.getResult { viewModel.country.value = it.dialCodeString focusRequester.requestFocus() } diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/WatchOnlyScreen.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/WatchOnlyScreen.kt index b65b4810e..118ac7f1e 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/WatchOnlyScreen.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/screens/settings/WatchOnlyScreen.kt @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material3.Card import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -317,15 +316,17 @@ fun Descriptor( ) } - GreenRow(space = 0, padding = 0, verticalAlignment = Alignment.Top) { - SelectionContainer(modifier = Modifier.weight(1f)) { - Text( - text = descriptor, - style = bodyMedium, - color = whiteMedium, - fontFamily = MonospaceFont() - ) - } + Row(verticalAlignment = Alignment.Top, modifier = Modifier.fillMaxWidth()) { + // Disabled SelectionContainer as it fills all space, propably aa bug + // SelectionContainer(modifier = Modifier.weight(1f)) { + Text( + text = descriptor, + style = bodyMedium, + color = whiteMedium, + fontFamily = MonospaceFont(), + modifier = Modifier.weight(1f) + ) + // } Row { IconButton(onCopy) { diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/AssetsBottomSheet.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/AssetsBottomSheet.kt index 6c2ac1727..37738adb6 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/AssetsBottomSheet.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/AssetsBottomSheet.kt @@ -57,7 +57,7 @@ data class AssetsBottomSheet( companion object { @Composable - fun getNavigationResult(fn: (AssetBalance) -> Unit) = getNavigationResult(this::class, fn) + fun getResult(fn: (AssetBalance) -> Unit) = getNavigationResult(this::class, fn) internal fun setResult(result: AssetBalance) = setNavigationResult(this::class, result) diff --git a/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/CountriesBottomSheet.kt b/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/CountriesBottomSheet.kt index f0fc105ac..dbaccbb2f 100644 --- a/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/CountriesBottomSheet.kt +++ b/compose/src/commonMain/kotlin/com/blockstream/compose/sheets/CountriesBottomSheet.kt @@ -8,8 +8,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Text import androidx.compose.material3.rememberModalBottomSheetState @@ -32,10 +30,8 @@ import com.blockstream.common.data.Countries import com.blockstream.common.data.Country import com.blockstream.common.data.GreenWallet import com.blockstream.common.extensions.isBlank -import com.blockstream.common.gdk.data.AssetBalance import com.blockstream.common.models.GreenViewModel import com.blockstream.common.models.SimpleGreenViewModel -import com.blockstream.compose.components.GreenAsset import com.blockstream.compose.components.GreenBottomSheet import com.blockstream.compose.components.GreenCard import com.blockstream.compose.components.GreenColumn @@ -64,7 +60,7 @@ data class CountriesBottomSheet( companion object { @Composable - fun getNavigationResult(fn: (Country) -> Unit) = getNavigationResult(this::class, fn) + fun getResult(fn: (Country) -> Unit) = getNavigationResult(this::class, fn) internal fun setResult(result: Country) = setNavigationResult(this::class, result) diff --git a/gradle.properties b/gradle.properties index 798c2986b..31ef74b00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,8 +29,6 @@ kotlin.mpp.enableCInteropCommonization=true #For KSP compilation error https://github.com/google/ksp/issues/1422 #kotlin.jvm.target.validation.mode=warning - -kotlin.native.ignoreIncorrectDependencies=true kotlin.native.ignoreDisabledTargets=true kotlin.native.distribution.downloadFromMaven=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 47e77b422..fca6c3cf1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ kotlinx-coroutines = "1.9.0-RC.2" kotlinx-datetime = "0.6.1" kotlinx-serialization = "1.7.2" kotlin-ksp = "2.0.20-1.0.24" -android-gradle-plugin = "8.5.2" +android-gradle-plugin = "8.6.0" androidCompileSdk = "34" androidTargetSdk = "34" androidMinSdk = "24" @@ -36,7 +36,7 @@ koin-compose = "1.1.5" koin-annotations = "1.3.1" koin-ksp-compiler = "1.3.1" ksoupEntites = "0.1.2" -lifecycle = "2.8.0" +lifecycle = "2.8.2" middleEllipsisText3 = "1.2.0" mpfilepicker = "3.1.0" multiplatformSettings = "1.1.1" @@ -72,17 +72,17 @@ swiperefreshlayout = "1.1.0" turbine = "1.0.0" usb-serial = "6.0.6" uuid = "0.8.4" -desugar = "2.1.1" +desugar = "2.1.2" viewpager2 = "1.1.0" zxing-android-embedded = "4.3.0" kmp-nativecoroutines = "1.0.0-ALPHA-31" -compose-material3 = "1.2.1" -compose-tooling-preview = "1.6.8" +compose-material3 = "1.3.0" +compose-tooling-preview = "1.7.1" compose-constraint = "1.0.1" -jetbrains-compose = "1.7.0-alpha03" +jetbrains-compose = "1.7.0-beta02" voyager = "1.1.0-beta02" google-services = "4.4.2" -firebase-bom = "33.2.0" +firebase-bom = "33.3.0" jna = "5.14.0" [libraries] diff --git a/green/build.gradle.kts b/green/build.gradle.kts index cd8b151ee..bd3df19d7 100644 --- a/green/build.gradle.kts +++ b/green/build.gradle.kts @@ -42,8 +42,8 @@ android { defaultConfig { minSdk = libs.versions.androidMinSdk.get().toInt() targetSdk = libs.versions.androidTargetSdk.get().toInt() - versionCode = 433 - versionName = "4.0.33" + versionCode = 434 + versionName = "4.0.34" setProperty("archivesBaseName", "BlockstreamGreen-v$versionName") proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") diff --git a/green/src/main/java/com/blockstream/green/ui/add/ChooseAccountTypeFragment.kt b/green/src/main/java/com/blockstream/green/ui/add/ChooseAccountTypeFragment.kt index 06bc32cc8..8c78df06c 100644 --- a/green/src/main/java/com/blockstream/green/ui/add/ChooseAccountTypeFragment.kt +++ b/green/src/main/java/com/blockstream/green/ui/add/ChooseAccountTypeFragment.kt @@ -3,22 +3,15 @@ package com.blockstream.green.ui.add import android.os.Bundle import android.view.View import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.blockstream.common.gdk.data.AssetBalance import com.blockstream.common.models.GreenViewModel import com.blockstream.common.models.add.ChooseAccountTypeViewModel -import com.blockstream.common.sideeffects.SideEffect -import com.blockstream.common.sideeffects.SideEffects import com.blockstream.compose.AppFragmentBridge import com.blockstream.compose.screens.add.ChooseAccountTypeScreen import com.blockstream.green.R import com.blockstream.green.databinding.ComposeViewBinding -import com.blockstream.green.extensions.clearNavigationResult -import com.blockstream.green.extensions.getNavigationResult -import com.blockstream.green.extensions.setNavigationResult import com.blockstream.green.ui.AppFragment -import com.blockstream.green.ui.jade.JadeQRFragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf @@ -33,34 +26,9 @@ class ChooseAccountTypeFragment : AppFragment(R.layout.compo override val useCompose: Boolean = true - override suspend fun handleSideEffect(sideEffect: SideEffect) { - super.handleSideEffect(sideEffect) - - if (sideEffect is SideEffects.AccountCreated){ - // Find if there is a Receive screen in the backstack or a Network overview - val destinationId = findNavController().currentBackStack.value.let { backQueue -> - (backQueue.find { it.destination.id == R.id.receiveFragment } ?: backQueue.find { it.destination.id == R.id.walletOverviewFragment })!!.destination.id - } - setNavigationResult( - result = sideEffect.accountAsset, key = ReviewAddAccountFragment.SET_ACCOUNT, destinationId = destinationId - ) - } - } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - getNavigationResult(JadeQRFragment.MNEMONIC_RESULT)?.observe(viewLifecycleOwner) { mnemonic -> - if (mnemonic != null) { - clearNavigationResult(JadeQRFragment.MNEMONIC_RESULT) - viewModel.postEvent( - ChooseAccountTypeViewModel.LocalEvents.CreateLightningAccount( - mnemonic - ) - ) - } - } - binding.composeView.apply { setViewCompositionStrategy( ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed diff --git a/green/src/main/java/com/blockstream/green/ui/add/ReviewAddAccountFragment.kt b/green/src/main/java/com/blockstream/green/ui/add/ReviewAddAccountFragment.kt index 2a6ad2687..ee9c89a10 100644 --- a/green/src/main/java/com/blockstream/green/ui/add/ReviewAddAccountFragment.kt +++ b/green/src/main/java/com/blockstream/green/ui/add/ReviewAddAccountFragment.kt @@ -3,17 +3,13 @@ package com.blockstream.green.ui.add import android.os.Bundle import android.view.View import androidx.compose.ui.platform.ViewCompositionStrategy -import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.blockstream.common.models.GreenViewModel import com.blockstream.common.models.add.ReviewAddAccountViewModel -import com.blockstream.common.sideeffects.SideEffect -import com.blockstream.common.sideeffects.SideEffects import com.blockstream.compose.AppFragmentBridge import com.blockstream.compose.screens.add.ReviewAddAccountScreen import com.blockstream.green.R import com.blockstream.green.databinding.ComposeViewBinding -import com.blockstream.green.extensions.setNavigationResult import com.blockstream.green.ui.AppFragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf @@ -29,20 +25,6 @@ class ReviewAddAccountFragment : AppFragment( parametersOf(args.setupArgs) } - override suspend fun handleSideEffect(sideEffect: SideEffect) { - super.handleSideEffect(sideEffect) - - if (sideEffect is SideEffects.AccountCreated){ - // Find if there is a Receive screen in the backstack or a Network overview - val destinationId = findNavController().currentBackStack.value.let { backQueue -> - (backQueue.find { it.destination.id == R.id.receiveFragment } ?: backQueue.find { it.destination.id == R.id.walletOverviewFragment })!!.destination.id - } - setNavigationResult( - result = sideEffect.accountAsset, key = SET_ACCOUNT, destinationId = destinationId - ) - } - } - override fun getGreenViewModel(): GreenViewModel = viewModel override val useCompose: Boolean = true @@ -61,8 +43,4 @@ class ReviewAddAccountFragment : AppFragment( } } } - - companion object { - const val SET_ACCOUNT = "SET_ACCOUNT" - } } \ No newline at end of file diff --git a/green/src/main/java/com/blockstream/green/ui/receive/ReceiveFragment.kt b/green/src/main/java/com/blockstream/green/ui/receive/ReceiveFragment.kt index 531b0e5c0..a7ead9796 100644 --- a/green/src/main/java/com/blockstream/green/ui/receive/ReceiveFragment.kt +++ b/green/src/main/java/com/blockstream/green/ui/receive/ReceiveFragment.kt @@ -9,9 +9,7 @@ import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.navArgs import com.blockstream.common.Urls -import com.blockstream.common.events.Events import com.blockstream.common.extensions.isNotBlank -import com.blockstream.common.gdk.data.AccountAsset import com.blockstream.common.models.GreenViewModel import com.blockstream.common.models.receive.ReceiveViewModel import com.blockstream.common.models.sheets.NoteType @@ -20,11 +18,8 @@ import com.blockstream.compose.AppFragmentBridge import com.blockstream.compose.screens.receive.ReceiveScreen import com.blockstream.green.R import com.blockstream.green.databinding.ComposeViewBinding -import com.blockstream.green.extensions.clearNavigationResult -import com.blockstream.green.extensions.getNavigationResult import com.blockstream.green.ui.AppFragment import com.blockstream.green.ui.MainActivity -import com.blockstream.green.ui.add.ReviewAddAccountFragment import com.blockstream.green.utils.openBrowser import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -57,13 +52,6 @@ class ReceiveFragment : AppFragment( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - getNavigationResult(ReviewAddAccountFragment.SET_ACCOUNT)?.observe(viewLifecycleOwner) { - it?.let { - viewModel.postEvent(Events.SetAccountAsset(it)) - clearNavigationResult(ReviewAddAccountFragment.SET_ACCOUNT) - } - } - binding.composeView.apply { setViewCompositionStrategy( ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed diff --git a/green/src/main/java/com/blockstream/green/ui/send/SendConfirmFragment.kt b/green/src/main/java/com/blockstream/green/ui/send/SendConfirmFragment.kt index e8d0806d0..1dffb5442 100644 --- a/green/src/main/java/com/blockstream/green/ui/send/SendConfirmFragment.kt +++ b/green/src/main/java/com/blockstream/green/ui/send/SendConfirmFragment.kt @@ -7,25 +7,17 @@ import android.view.View import androidx.activity.OnBackPressedCallback import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.lifecycle.lifecycleScope -import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.blockstream.common.models.GreenViewModel -import com.blockstream.common.models.add.ChooseAccountTypeViewModel import com.blockstream.common.models.send.CreateTransactionViewModelAbstract import com.blockstream.common.models.send.SendConfirmViewModel -import com.blockstream.common.sideeffects.SideEffect -import com.blockstream.common.sideeffects.SideEffects import com.blockstream.common.utils.Loggable import com.blockstream.compose.AppFragmentBridge import com.blockstream.compose.screens.send.SendConfirmScreen import com.blockstream.green.R import com.blockstream.green.databinding.ComposeViewBinding -import com.blockstream.green.extensions.clearNavigationResult -import com.blockstream.green.extensions.dialog -import com.blockstream.green.extensions.getNavigationResult import com.blockstream.green.ui.AppFragment import com.blockstream.green.ui.MainActivity -import com.blockstream.green.ui.jade.JadeQRFragment import com.blockstream.green.utils.isDevelopmentOrDebug import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -59,13 +51,6 @@ class SendConfirmFragment : AppFragment( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - getNavigationResult(JadeQRFragment.PSBT)?.observe(viewLifecycleOwner) { psbt -> - if (psbt != null) { - clearNavigationResult(JadeQRFragment.PSBT) - viewModel.postEvent(CreateTransactionViewModelAbstract.LocalEvents.BroadcastTransaction(broadcastTransaction = false, psbt = psbt)) - } - } - binding.composeView.apply { setViewCompositionStrategy( ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed