diff --git a/wallet/res/layout/fragment_more.xml b/wallet/res/layout/fragment_more.xml index 32799bae7..6a3a64d74 100644 --- a/wallet/res/layout/fragment_more.xml +++ b/wallet/res/layout/fragment_more.xml @@ -89,43 +89,7 @@ - - - - - - - - - - + + + + + + + + + + + + + + + R.string.processing_username_unavailable_subtitle blockchainIdentityData.restoring -> R.string.processing_home_step_3_restoring + blockchainIdentityData.requestedUsername != null -> R.string.processing_home_step_3_requesting else -> R.string.processing_home_step_3 } ) } + BlockchainIdentityData.CreationState.REQUESTED_NAME_CHECKING, + BlockchainIdentityData.CreationState.REQUESTED_NAME_CHECKED, + BlockchainIdentityData.CreationState.REQUESTED_NAME_LINK_SAVING, + BlockchainIdentityData.CreationState.REQUESTED_NAME_LINK_SAVED -> { + binding.identityCreation.progress.progress = 90 + } + BlockchainIdentityData.CreationState.VOTING -> { + binding.identityCreation.icon.visibility = View.GONE + binding.identityCreation.forwardArrow.visibility = View.VISIBLE + binding.identityCreation.progress.visibility = View.GONE + binding.identityCreation.title.text = binding.root.context.getString(R.string.processing_done_title, + blockchainIdentityData.username) + binding.identityCreation.subtitle.setText(R.string.processing_voting_subtitle) + } BlockchainIdentityData.CreationState.DONE -> { binding.identityCreation.icon.visibility = View.GONE binding.identityCreation.forwardArrow.visibility = View.VISIBLE diff --git a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt index d675e3172..5ba4fce12 100644 --- a/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt +++ b/wallet/src/de/schildbach/wallet/ui/dashpay/PlatformRepo.kt @@ -506,10 +506,20 @@ class PlatformRepo @Inject constructor( // // Step 2 is to create the credit funding transaction // - suspend fun createAssetLockTransactionAsync(blockchainIdentity: BlockchainIdentity, keyParameter: KeyParameter?, useCoinJoin: Boolean) { + suspend fun createAssetLockTransactionAsync( + blockchainIdentity: BlockchainIdentity, + username: String, + keyParameter: KeyParameter?, + useCoinJoin: Boolean) + { withContext(Dispatchers.IO) { Context.propagate(walletApplication.wallet!!.context) - val cftx = blockchainIdentity.createAssetLockTransaction(Constants.DASH_PAY_FEE, keyParameter, useCoinJoin, true) + val fee = if (Names.isUsernameContestable(username)) { + Constants.DASH_PAY_FEE_CONTESTED + } else { + Constants.DASH_PAY_FEE + } + val cftx = blockchainIdentity.createAssetLockTransaction(fee, keyParameter, useCoinJoin, true) blockchainIdentity.initializeAssetLockTransaction(cftx) } } @@ -537,11 +547,7 @@ class PlatformRepo @Inject constructor( assetLockTx.addAssetLockPublicKey(privateKey) // TODO: when all instantsend locks are deterministic, we don't need the catch block - val instantSendLock = try { - InstantSendLock(platform.params, Utils.HEX.decode(invite.instantSendLock), InstantSendLock.ISDLOCK_VERSION) - } catch (e: Exception) { - InstantSendLock(platform.params, Utils.HEX.decode(invite.instantSendLock), InstantSendLock.ISLOCK_VERSION) - } + val instantSendLock = InstantSendLock(platform.params, Utils.HEX.decode(invite.instantSendLock), InstantSendLock.ISDLOCK_VERSION) assetLockTx.confidence.setInstantSendLock(instantSendLock) blockchainIdentity.initializeAssetLockTransaction(assetLockTx) @@ -1202,4 +1208,5 @@ class PlatformRepo @Inject constructor( suspend fun getIdentityBalance(): CreditBalanceInfo { return CreditBalanceInfo(platform.client.getIdentityBalance(blockchainIdentity.uniqueIdentifier)) } + } \ No newline at end of file diff --git a/wallet/src/de/schildbach/wallet/ui/invite/CreateInviteViewModel.kt b/wallet/src/de/schildbach/wallet/ui/invite/CreateInviteViewModel.kt index 97ea8001d..581a7d15e 100644 --- a/wallet/src/de/schildbach/wallet/ui/invite/CreateInviteViewModel.kt +++ b/wallet/src/de/schildbach/wallet/ui/invite/CreateInviteViewModel.kt @@ -66,7 +66,7 @@ class CreateInviteViewModel @Inject constructor( private fun combineLatestData(): Boolean { val isSynced = blockchainStateData.value?.isSynced() ?: false val noIdentityCreatedOrInProgress = (blockchainIdentity.value == null) || blockchainIdentity.value!!.creationState == BlockchainIdentityData.CreationState.NONE - return isSynced && !noIdentityCreatedOrInProgress && canAffordIdentityCreation() + return isSynced && !noIdentityCreatedOrInProgress //&& canAffordIdentityCreation() } val invitationsLiveData = invitationsDao.observe().asLiveData() diff --git a/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt b/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt index 670e60aa7..d8add773f 100644 --- a/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt +++ b/wallet/src/de/schildbach/wallet/ui/main/MainViewModel.kt @@ -697,7 +697,7 @@ class MainViewModel @Inject constructor( } suspend fun getRequestedUsername(): String = - dashPayConfig.get(BlockchainIdentityConfig.REQUESTED_USERNAME) ?: "" + blockchainIdentityDataDao.get(BlockchainIdentityConfig.REQUESTED_USERNAME) ?: "" suspend fun getInviteHistory() = invitationsDao.loadAll() private fun combineLatestData(): Boolean { @@ -709,7 +709,7 @@ class MainViewModel @Inject constructor( val noIdentityCreatedOrInProgress = (blockchainIdentity.value == null) || blockchainIdentity.value!!.creationState == BlockchainIdentityData.CreationState.NONE val canAffordIdentityCreation = walletData.canAffordIdentityCreation() - return isSynced && isPlatformAvailable && noIdentityCreatedOrInProgress && canAffordIdentityCreation + return isSynced && isPlatformAvailable && noIdentityCreatedOrInProgress //&& canAffordIdentityCreation } } diff --git a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt index 090633244..2a6031136 100644 --- a/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt +++ b/wallet/src/de/schildbach/wallet/ui/more/MoreFragment.kt @@ -33,6 +33,7 @@ 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.BlockchainIdentityData import de.schildbach.wallet.database.entity.DashPayProfile import de.schildbach.wallet.livedata.Status import de.schildbach.wallet.service.PackageInfoProvider @@ -56,6 +57,7 @@ import org.dash.wallet.common.services.analytics.AnalyticsConstants import org.dash.wallet.common.services.analytics.AnalyticsService import org.dash.wallet.common.ui.avatar.ProfilePictureDisplay import org.dash.wallet.common.ui.viewBinding +import org.dash.wallet.common.util.observe import org.dash.wallet.common.util.safeNavigate import org.slf4j.LoggerFactory import javax.inject.Inject @@ -173,6 +175,30 @@ class MoreFragment : Fragment(R.layout.fragment_more) { startActivity(Intent(requireContext(), CreateUsernameActivity::class.java)) } + mainActivityViewModel.blockchainIdentityDataDao.observeBase().observe(viewLifecycleOwner) { + if (it.creationState == BlockchainIdentityData.CreationState.VOTING) { + binding.joinDashpayContainer.visibility = View.GONE + binding.requestedUsernameContainer.visibility = View.VISIBLE + binding.requestedUsernameTitle.text = mainActivityViewModel.getRequestedUsername() + } else { + binding.joinDashpayContainer.visibility = View.VISIBLE + binding.requestedUsernameContainer.visibility = View.GONE + } + } + +// lifecycleScope.launch { +// mainActivityViewModel.getRequestedUsername().also { username -> +// if (username.isNotEmpty()) { +// binding.joinDashpayContainer.visibility = View.GONE +// binding.requestedUsernameContainer.visibility = View.VISIBLE +// binding.requestedUsernameTitle.text = username +// } else { +// binding.joinDashpayContainer.visibility = View.VISIBLE +// binding.requestedUsernameContainer.visibility = View.GONE +// } +// } +// } + initViewModel() if (Constants.DASHPAY_DISABLED) { @@ -251,9 +277,6 @@ class MoreFragment : Fragment(R.layout.fragment_more) { binding.dashpayContainer.isVisible = it } - - - createInviteViewModel.isAbleToPerformInviteAction.observe(viewLifecycleOwner) { showInviteSection(it) } @@ -298,16 +321,7 @@ class MoreFragment : Fragment(R.layout.fragment_more) { // Developer Mode Feature binding.invite.isVisible = showInviteSection lifecycleScope.launchWhenResumed { - mainActivityViewModel.getRequestedUsername().also { username -> - if (username.isNotEmpty()) { - binding.joinDashpayContainer.visibility = View.GONE - binding.requestedUsernameContainer.visibility = View.VISIBLE - binding.requestedUsernameTitle.text = username - } else { - binding.joinDashpayContainer.visibility = View.VISIBLE - binding.requestedUsernameContainer.visibility = View.GONE - } - } + } } }