Skip to content

Commit

Permalink
fix: hide invites
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Oct 3, 2024
1 parent 30af1f7 commit 1975164
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
2 changes: 2 additions & 0 deletions wallet/src/de/schildbach/wallet/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<MasternodeSync.SYNC_FLAGS> SYNC_FLAGS = MasternodeSync.SYNC_DEFAULT_SPV;
public static final EnumSet<MasternodeSync.VERIFY_FLAGS> VERIFY_FLAGS = MasternodeSync.VERIFY_DEFAULT_SPV;
Expand Down
6 changes: 6 additions & 0 deletions wallet/src/de/schildbach/wallet/ui/InviteHandlerViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions wallet/src/de/schildbach/wallet/ui/SearchUserActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ 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
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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,9 +44,12 @@ open class NotificationsLiveData(
scope.launch(Dispatchers.IO) {
val results = arrayListOf<NotificationItem>()

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)
Expand Down
13 changes: 6 additions & 7 deletions wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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
Expand All @@ -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
}
}

0 comments on commit 1975164

Please sign in to comment.