From ce16205299112a61f062809f6791e4bf78764245 Mon Sep 17 00:00:00 2001 From: HashEngineering Date: Wed, 14 Feb 2024 09:00:29 -0800 Subject: [PATCH] fix(dashpay): hide all entrypoints to dashpay related features --- wallet/src/de/schildbach/wallet/Constants.java | 1 + .../service/platform/PlatformSyncService.kt | 6 ++++++ .../de/schildbach/wallet/ui/SettingsActivity.kt | 5 +++++ .../de/schildbach/wallet/ui/main/MainViewModel.kt | 15 ++++++++++----- .../wallet/ui/main/WalletActivityExt.kt | 4 ++++ .../de/schildbach/wallet/ui/more/MoreFragment.kt | 5 +++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/wallet/src/de/schildbach/wallet/Constants.java b/wallet/src/de/schildbach/wallet/Constants.java index a1ddb2619b..a7c22c15c8 100644 --- a/wallet/src/de/schildbach/wallet/Constants.java +++ b/wallet/src/de/schildbach/wallet/Constants.java @@ -128,6 +128,7 @@ public final class Constants { /** Bitcoinj global context. */ public static final Context CONTEXT = new Context(NETWORK_PARAMETERS); + public static final boolean DASHPAY_DISABLED = true; public final static class Files { diff --git a/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt b/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt index d04122de63..1464386825 100644 --- a/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt +++ b/wallet/src/de/schildbach/wallet/service/platform/PlatformSyncService.kt @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions import com.google.common.base.Stopwatch import com.google.common.util.concurrent.SettableFuture import com.google.zxing.BarcodeFormat +import de.schildbach.wallet.Constants import de.schildbach.wallet.WalletApplication import de.schildbach.wallet.database.dao.DashPayContactRequestDao import de.schildbach.wallet.database.dao.DashPayProfileDao @@ -1020,6 +1021,7 @@ class PlatformSynchronizationService @Inject constructor( // this will enable notifications, since platform information has been synced config.set(DashPayConfig.LAST_SEEN_NOTIFICATION_TIME, System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7)) } + log.info("PreBlockDownload: $preDownloadBlocksFuture") preDownloadBlocksFuture?.set(true) preDownloadBlocks.set(false) } @@ -1062,6 +1064,10 @@ class PlatformSynchronizationService @Inject constructor( lastPreBlockStage = PreBlockStage.None preDownloadBlocksFuture = future log.info("PreDownloadBlocks: starting") + if (Constants.DASHPAY_DISABLED) { + finishPreBlockDownload() + return@launch + } // first check to see if there is a blockchain identity if (blockchainIdentityDataDao.load() == null) { diff --git a/wallet/src/de/schildbach/wallet/ui/SettingsActivity.kt b/wallet/src/de/schildbach/wallet/ui/SettingsActivity.kt index 4fc3ef36b6..c446d98477 100644 --- a/wallet/src/de/schildbach/wallet/ui/SettingsActivity.kt +++ b/wallet/src/de/schildbach/wallet/ui/SettingsActivity.kt @@ -27,6 +27,7 @@ import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import de.schildbach.wallet.Constants import de.schildbach.wallet.WalletBalanceWidgetProvider import de.schildbach.wallet.service.CoinJoinMode import de.schildbach.wallet.service.MixingStatus @@ -173,6 +174,10 @@ class SettingsActivity : LockScreenActivity() { } } } + + if (Constants.DASHPAY_DISABLED) { + binding.votingDashPay.isVisible = false + } } private fun setBatteryOptimizationText() { diff --git a/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt b/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt index 5ea27f5ae8..e3af3f1f89 100644 --- a/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt +++ b/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt @@ -678,11 +678,16 @@ class MainViewModel @Inject constructor( suspend fun getInviteHistory() = invitationsDao.loadAll() private fun combineLatestData(): Boolean { - val isPlatformAvailable = isPlatformAvailableData.value ?: false - val isSynced = _isBlockchainSynced.value ?: false - val noIdentityCreatedOrInProgress = (blockchainIdentity.value == null) || blockchainIdentity.value!!.creationState == BlockchainIdentityData.CreationState.NONE - val canAffordIdentityCreation = walletData.canAffordIdentityCreation() - return isSynced && isPlatformAvailable && noIdentityCreatedOrInProgress && canAffordIdentityCreation + return if (Constants.DASHPAY_DISABLED) { + false + } else { + val isPlatformAvailable = isPlatformAvailableData.value ?: false + val isSynced = _isBlockchainSynced.value ?: false + val noIdentityCreatedOrInProgress = + (blockchainIdentity.value == null) || blockchainIdentity.value!!.creationState == BlockchainIdentityData.CreationState.NONE + val canAffordIdentityCreation = walletData.canAffordIdentityCreation() + return isSynced && isPlatformAvailable && noIdentityCreatedOrInProgress && canAffordIdentityCreation + } } private fun startContactRequestTimer() { diff --git a/wallet/src/de/schildbach/wallet/ui/main/WalletActivityExt.kt b/wallet/src/de/schildbach/wallet/ui/main/WalletActivityExt.kt index 28e1a68115..dcaeed11be 100644 --- a/wallet/src/de/schildbach/wallet/ui/main/WalletActivityExt.kt +++ b/wallet/src/de/schildbach/wallet/ui/main/WalletActivityExt.kt @@ -37,6 +37,7 @@ import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.NavigationUI.onNavDestinationSelected import androidx.navigation.ui.NavigationUI.setupWithNavController import com.google.android.material.bottomnavigation.BottomNavigationView +import de.schildbach.wallet.Constants import de.schildbach.wallet.WalletBalanceWidgetProvider import de.schildbach.wallet.service.CoinJoinMode import de.schildbach.wallet_test.R @@ -93,6 +94,9 @@ object WalletActivityExt { navController.addOnDestinationChangedListener { _, _, arguments -> navView.isVisible = arguments?.getBoolean("ShowNavBar", false) == true } + if (Constants.DASHPAY_DISABLED) { + navView.menu.findItem(R.id.contactsFragment).isEnabled = false + } } fun MainActivity.checkTimeSkew(viewModel: MainViewModel) { diff --git a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt index c0de106fdd..090633244c 100644 --- a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt +++ b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt @@ -31,6 +31,7 @@ import androidx.navigation.NavOptions import androidx.navigation.fragment.findNavController import com.google.android.material.transition.MaterialFadeThrough import dagger.hilt.android.AndroidEntryPoint +import de.schildbach.wallet.Constants import de.schildbach.wallet.WalletApplication import de.schildbach.wallet.database.entity.DashPayProfile import de.schildbach.wallet.livedata.Status @@ -173,6 +174,10 @@ class MoreFragment : Fragment(R.layout.fragment_more) { } initViewModel() + + if (Constants.DASHPAY_DISABLED) { + binding.usernameVoting.isVisible = false + } } private fun dismissProfileError() {