diff --git a/wallet/src/de/schildbach/wallet/Constants.java b/wallet/src/de/schildbach/wallet/Constants.java index b27e5d4f99..9dd1c7b070 100644 --- a/wallet/src/de/schildbach/wallet/Constants.java +++ b/wallet/src/de/schildbach/wallet/Constants.java @@ -61,6 +61,8 @@ public final class Constants { public static final boolean IS_PROD_BUILD; public static boolean SUPPORTS_PLATFORM; + // TODO: remove all references to this when invites are enabled and functional + public static boolean SUPPORTS_INVITES; public static final EnumSet SYNC_FLAGS = MasternodeSync.SYNC_DEFAULT_SPV; public static final EnumSet VERIFY_FLAGS = MasternodeSync.VERIFY_DEFAULT_SPV; diff --git a/wallet/src/de/schildbach/wallet/ui/InviteHandlerViewModel.kt b/wallet/src/de/schildbach/wallet/ui/InviteHandlerViewModel.kt index dbdd8339be..0f05295c10 100644 --- a/wallet/src/de/schildbach/wallet/ui/InviteHandlerViewModel.kt +++ b/wallet/src/de/schildbach/wallet/ui/InviteHandlerViewModel.kt @@ -21,6 +21,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import com.google.firebase.dynamiclinks.FirebaseDynamicLinks import dagger.hilt.android.lifecycle.HiltViewModel +import de.schildbach.wallet.Constants import de.schildbach.wallet.database.dao.DashPayProfileDao import de.schildbach.wallet.data.InvitationLinkData import de.schildbach.wallet.database.entity.BlockchainIdentityConfig @@ -60,6 +61,11 @@ class InviteHandlerViewModel @Inject constructor( } fun handleInvite(invite: InvitationLinkData) { + // TODO: remove this if block when Invite functionality is restored + if (!Constants.SUPPORTS_INVITES) { + log.info("invite ignored since they are currently disabled with Constants.SUPPORTS_INVITES = false") + return + } inviteData.value = Resource.loading() viewModelScope.launch(Dispatchers.IO) { try { diff --git a/wallet/src/de/schildbach/wallet/ui/SearchUserActivity.kt b/wallet/src/de/schildbach/wallet/ui/SearchUserActivity.kt index 778c931526..b1561fbf73 100644 --- a/wallet/src/de/schildbach/wallet/ui/SearchUserActivity.kt +++ b/wallet/src/de/schildbach/wallet/ui/SearchUserActivity.kt @@ -33,6 +33,7 @@ import androidx.activity.viewModels import androidx.constraintlayout.widget.ConstraintSet import androidx.core.content.res.ResourcesCompat import androidx.core.text.HtmlCompat +import androidx.core.view.isVisible import androidx.core.widget.doAfterTextChanged import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager @@ -40,6 +41,7 @@ import androidx.transition.ChangeBounds import androidx.transition.Transition import androidx.transition.TransitionManager import dagger.hilt.android.AndroidEntryPoint +import de.schildbach.wallet.Constants import de.schildbach.wallet.Constants.USERNAME_MIN_LENGTH import org.dash.wallet.common.data.entity.BlockchainState import de.schildbach.wallet.data.UsernameSearchResult @@ -162,9 +164,13 @@ class SearchUserActivity : LockScreenActivity(), OnItemClickListener, OnContactR inviteFriendHintViewDashpayProfile1.root.setOnClickListener { startInviteFlow() } + //TODO: remove this line when INVITES are supported + inviteFriendHintViewDashpayProfile1.root.isVisible = Constants.SUPPORTS_INVITES userSearchEmptyResult.inviteFriendHintViewEmptyResult.root.setOnClickListener { startInviteFlow() } + //TODO: remove this line when INVITES are supported + userSearchEmptyResult.inviteFriendHintViewEmptyResult.root.isVisible = Constants.SUPPORTS_INVITES } binding.networkUnavailable.networkErrorSubtitle.setText(R.string.network_error_user_search) diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/ContactsFragment.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/ContactsFragment.kt index 2a0d1b6f07..548e77286d 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/ContactsFragment.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/ContactsFragment.kt @@ -57,6 +57,7 @@ import org.dash.wallet.common.services.analytics.AnalyticsConstants import org.dash.wallet.common.ui.dialogs.AdaptiveDialog import org.dash.wallet.common.ui.observeOnDestroy import org.dash.wallet.common.ui.viewBinding +import org.dash.wallet.common.util.Constants import org.dash.wallet.common.util.KeyboardUtil import org.dash.wallet.common.util.observe import org.dash.wallet.common.util.safeNavigate @@ -161,6 +162,7 @@ class ContactsFragment : Fragment(), // Developer Mode Feature // Hide the invite UI + emptyStatePane.inviteHintLayout.root.isVisible = de.schildbach.wallet.Constants.SUPPORTS_INVITES emptyStatePane.inviteHintLayout.inviteFriendHint.setOnClickListener { lifecycleScope.launch { val inviteHistory = dashPayViewModel.getInviteHistory() diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/NotificationsLiveData.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/NotificationsLiveData.kt index 891d1020a2..54631afa9e 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/NotificationsLiveData.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/NotificationsLiveData.kt @@ -16,6 +16,7 @@ package de.schildbach.wallet.ui.dashpay +import de.schildbach.wallet.Constants import de.schildbach.wallet.WalletApplication import de.schildbach.wallet.data.* import de.schildbach.wallet.database.dao.UserAlertDao @@ -43,9 +44,12 @@ open class NotificationsLiveData( scope.launch(Dispatchers.IO) { val results = arrayListOf() - val userAlert = userAlertDao.load(0L) - if (userAlert != null && platformRepo.shouldShowAlert()) { - results.add(NotificationItemUserAlert(userAlert.stringResourceId, userAlert.iconResourceId)) + //TODO: remove the if when INVITES are supported + if (Constants.SUPPORTS_INVITES) { + val userAlert = userAlertDao.load(0L) + if (userAlert != null && platformRepo.shouldShowAlert()) { + results.add(NotificationItemUserAlert(userAlert.stringResourceId, userAlert.iconResourceId)) + } } val contactRequests = platformRepo.searchContacts(query, UsernameSortOrderBy.DATE_ADDED) diff --git a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt index 2ec057eebb..5aec19e281 100644 --- a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt +++ b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt @@ -378,7 +378,8 @@ class MoreFragment : Fragment(R.layout.fragment_more) { // show the invite section only after the profile section is visible // to avoid flickering if (binding.editUpdateSwitcher.isVisible) { - binding.invite.isVisible = showInviteSection + //TODO: remove && Constants.SUPPORTS_INVITES when INVITES are supported + binding.invite.isVisible = showInviteSection && Constants.SUPPORTS_INVITES } } @@ -402,7 +403,8 @@ class MoreFragment : Fragment(R.layout.fragment_more) { } // if the invite section is not visible, show/hide it if (!binding.invite.isVisible) { - binding.invite.isVisible = showInviteSection + //TODO: remove && Constants.SUPPORTS_INVITES when INVITES are supported + binding.invite.isVisible = showInviteSection && Constants.SUPPORTS_INVITES } } else { binding.editUpdateSwitcher.isVisible = false @@ -412,10 +414,7 @@ class MoreFragment : Fragment(R.layout.fragment_more) { override fun onResume() { super.onResume() - // Developer Mode Feature - binding.invite.isVisible = showInviteSection - lifecycleScope.launchWhenResumed { - - } + //TODO: remove && Constants.SUPPORTS_INVITES when INVITES are supported + binding.invite.isVisible = showInviteSection && Constants.SUPPORTS_INVITES } }