From 3f9ec5f4b82976a99fde2501799d533f31eda665 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Sat, 7 Sep 2024 20:04:56 -0700 Subject: [PATCH 1/6] fix: specify foreground service type on Android 10 and higher --- .../crowdnode/api/CrowdNodeWorker.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt index 3811f83af2..d0ba16ac6a 100644 --- a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt +++ b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt @@ -65,7 +65,22 @@ class CrowdNodeWorker @AssistedInject constructor( intent = crowdNodeApi.notificationIntent ) log.info("calling setForeground") - setForeground(ForegroundInfo(operation.hashCode(), notification)) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + setForeground( + ForegroundInfo( + operation.hashCode(), + notification, + ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC + ) + ) + } else { + setForeground( + ForegroundInfo( + operation.hashCode(), + notification, + ) + ) + } crowdNodeApi.signUp(address) } } From 7fe610f05794b6b58c2141cd596b8e74f630a4ca Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Sat, 7 Sep 2024 20:05:07 -0700 Subject: [PATCH 2/6] fix: specify foreground service type on Android 10 and higher --- .../dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt index d0ba16ac6a..44baabe874 100644 --- a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt +++ b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt @@ -18,6 +18,8 @@ package org.dash.wallet.integrations.crowdnode.api import android.content.Context +import android.content.pm.ServiceInfo +import android.os.Build import androidx.hilt.work.HiltWorker import androidx.work.CoroutineWorker import androidx.work.ForegroundInfo From 39204766e226a1dd7e48d2b444846db1fb906e8c Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Mon, 9 Sep 2024 06:20:15 -0700 Subject: [PATCH 3/6] style: ktlint --- .../dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt index 44baabe874..6afe0c0ea5 100644 --- a/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt +++ b/integrations/crowdnode/src/main/java/org/dash/wallet/integrations/crowdnode/api/CrowdNodeWorker.kt @@ -79,7 +79,7 @@ class CrowdNodeWorker @AssistedInject constructor( setForeground( ForegroundInfo( operation.hashCode(), - notification, + notification ) ) } From e20a73cef39286a161382bccc7d5239d0d45dc00 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Wed, 2 Oct 2024 15:10:47 -0700 Subject: [PATCH 4/6] fix: show send button --- wallet/src/de/schildbach/wallet/ui/widget/ShortcutsPane.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/src/de/schildbach/wallet/ui/widget/ShortcutsPane.kt b/wallet/src/de/schildbach/wallet/ui/widget/ShortcutsPane.kt index d8db1435fb..df204f1784 100644 --- a/wallet/src/de/schildbach/wallet/ui/widget/ShortcutsPane.kt +++ b/wallet/src/de/schildbach/wallet/ui/widget/ShortcutsPane.kt @@ -104,7 +104,7 @@ class ShortcutsPane(context: Context, attrs: AttributeSet) : FlexboxLayout(conte secureNowButton, explore, receiveButton, - payToContactButton, + if (Constants.SUPPORTS_PLATFORM) payToContactButton else payToAddressButton, buySellButton, scanToPayButton ) From f127447751220195ee74b8d79699c4c252275b57 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Wed, 2 Oct 2024 15:11:00 -0700 Subject: [PATCH 5/6] tests: fix MainViewModelTest --- .../wallet/util/viewModels/MainViewModelTest.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt b/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt index 83be1d235a..0654c57d7f 100644 --- a/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt +++ b/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt @@ -32,6 +32,7 @@ import de.schildbach.wallet.database.dao.InvitationsDao import de.schildbach.wallet.ui.dashpay.utils.DashPayConfig import de.schildbach.wallet.transactions.TxFilterType import androidx.datastore.preferences.core.Preferences +import de.schildbach.wallet.database.dao.UserAlertDao import de.schildbach.wallet.database.entity.BlockchainIdentityBaseData import de.schildbach.wallet.database.entity.BlockchainIdentityConfig import de.schildbach.wallet.database.entity.BlockchainIdentityData @@ -55,6 +56,7 @@ import org.dash.wallet.common.data.entity.BlockchainState import org.dash.wallet.common.data.entity.ExchangeRate import org.dash.wallet.common.services.BlockchainStateProvider import org.dash.wallet.common.services.ExchangeRatesProvider +import org.dash.wallet.common.services.RateRetrievalState import org.dash.wallet.common.services.TransactionMetadataProvider import org.dash.wallet.common.services.analytics.AnalyticsService import org.junit.Before @@ -135,6 +137,10 @@ class MainViewModelTest { every { observe(WalletUIConfig.SELECTED_CURRENCY) } returns MutableStateFlow("USD") } + private val userAgentDaoMock = mockk { + every { observe(any()) } returns flow { } + } + private val platformRepo = mockk() @get:Rule @@ -169,7 +175,8 @@ class MainViewModelTest { 0 ) } - + every { exchangeRatesMock.observeStaleRates(any())} returns flow { RateRetrievalState(false, false, false) } + every { } mockkStatic(WalletApplication::class) every { WalletApplication.getInstance() } returns walletApp @@ -200,7 +207,7 @@ class MainViewModelTest { analyticsService, configMock, uiConfigMock, exchangeRatesMock, walletDataMock, walletApp, platformRepo, mockk(), mockk(), blockchainIdentityConfigMock, savedStateMock, transactionMetadataMock, - blockchainStateMock, mockk(), mockk(), mockk(), mockk(), mockk(), mockDashPayConfig, mockk(), mockk() + blockchainStateMock, mockk(), mockk(), mockk(), userAgentDaoMock, mockk(), mockDashPayConfig, mockk(), mockk() ) ) From 016fe501ce02a30a6d44436258faa895a65c1b10 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Wed, 2 Oct 2024 20:29:38 -0700 Subject: [PATCH 6/6] tests: fix MainViewModelTest --- .../schildbach/wallet/util/viewModels/MainViewModelTest.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt b/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt index 0654c57d7f..ae9a8d3b4e 100644 --- a/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt +++ b/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt @@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.* import org.bitcoinj.core.Coin +import org.bitcoinj.core.PeerGroup import org.bitcoinj.core.Transaction import org.bitcoinj.params.TestNet3Params import org.bitcoinj.utils.MonetaryFormat @@ -155,6 +156,7 @@ class MainViewModelTest { every { configMock.registerOnSharedPreferenceChangeListener(any()) } just runs every { blockchainStateMock.observeState() } returns flow { BlockchainState() } + every { blockchainStateMock.observeSyncStage() } returns MutableStateFlow(PeerGroup.SyncStage.BLOCKS) every { exchangeRatesMock.observeExchangeRate(any()) } returns flow { ExchangeRate("USD", "100") } every { walletDataMock.observeBalance() } returns flow { Coin.COIN } every { walletDataMock.observeMostRecentTransaction() } returns flow { @@ -175,8 +177,7 @@ class MainViewModelTest { 0 ) } - every { exchangeRatesMock.observeStaleRates(any())} returns flow { RateRetrievalState(false, false, false) } - every { } + every { exchangeRatesMock.observeStaleRates(any()) } returns flow { RateRetrievalState(false, false, false) } mockkStatic(WalletApplication::class) every { WalletApplication.getInstance() } returns walletApp @@ -202,6 +203,7 @@ class MainViewModelTest { @Test fun observeBlockchainState_replaying_notSynced() { every { blockchainStateMock.observeState() } returns MutableStateFlow(BlockchainState(replaying = true)) + val viewModel = spyk( MainViewModel( analyticsService, configMock, uiConfigMock,