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..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 @@ -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 @@ -65,7 +67,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) } } 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 ) diff --git a/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt b/wallet/test/de/schildbach/wallet/util/viewModels/MainViewModelTest.kt index 83be1d235a..ae9a8d3b4e 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 @@ -45,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 @@ -55,6 +57,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 +138,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 @@ -149,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 { @@ -169,7 +177,7 @@ class MainViewModelTest { 0 ) } - + every { exchangeRatesMock.observeStaleRates(any()) } returns flow { RateRetrievalState(false, false, false) } mockkStatic(WalletApplication::class) every { WalletApplication.getInstance() } returns walletApp @@ -195,12 +203,13 @@ class MainViewModelTest { @Test fun observeBlockchainState_replaying_notSynced() { every { blockchainStateMock.observeState() } returns MutableStateFlow(BlockchainState(replaying = true)) + val viewModel = spyk( MainViewModel( 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() ) )