Skip to content

Commit

Permalink
fix(dashpay): fix username UI crashes and support recovery during use…
Browse files Browse the repository at this point in the history
…rname creation (#1326)

* fix: eliminate cast exception in BlockInfoActivity

* fix: remove unused fragments in Username Navigation

* fix: prevent NPE's

* chore: remove unnecessary code in UsernameRegistrationFragment

* chore: use dpp v1.5.1-SNAPSHOT

* fix: allow 128 char links for verification

* fix: simplify coinjoin system notification status updates

* fix: cancel work if databased are cleared

* fix: more screen fixes

* fix: allow credits to be used on WelcomeToDashPayFragment

* fix: use a double for mixing status

* fix: handle failed restore after failed request

* fix: CreateIdentityService fixes
  • Loading branch information
HashEngineering authored Nov 20, 2024
1 parent 384deb9 commit 261c7de
Show file tree
Hide file tree
Showing 33 changed files with 99 additions and 124 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
coroutinesVersion = '1.6.4'
ok_http_version = '4.9.1'
dashjVersion = '21.1.2'
dppVersion = "1.3.1-SNAPSHOT"
dppVersion = "1.5.1-SNAPSHOT"
hiltVersion = '2.51'
hiltCompilerVersion = '1.2.0'
hiltWorkVersion = '1.0.0'
Expand Down
2 changes: 1 addition & 1 deletion wallet/res/layout/fragment_verfiy_identity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
android:ellipsize="middle"
android:gravity="center_vertical"
android:imeOptions="actionNext"
android:maxLength="75"
android:maxLength="128"
tools:visibility="visible" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
34 changes: 2 additions & 32 deletions wallet/res/navigation/nav_username.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,9 @@
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
app:startDestination="@id/createUsernameFragment"
app:startDestination="@id/requestUsernameFragment"
android:id="@+id/nav_username">

<fragment
android:id="@+id/createUsernameFragment"
android:name="de.schildbach.wallet.ui.username.CreateUsernameFragment"
tools:layout="@layout/fragment_create_username">

<argument
android:name="createUsernameFragmentArgs"
app:argType="de.schildbach.wallet.ui.username.CreateUsernameArgs" />

<action
android:id="@+id/create_username_to_username_privacy"
app:destination="@id/createUsernamePrivacyFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/activity_stay"
app:popExitAnim="@anim/slide_out_left" />

</fragment>

<fragment
android:id="@+id/createUsernamePrivacyFragment"
android:name="de.schildbach.wallet.ui.coinjoin.CoinJoinLevelFragment"
tools:layout="@layout/fragment_coinjoin_level">
<action
android:id="@+id/username_privacy_to_createUsernameFragment"
app:popUpTo="@+id/createUsernameFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/activity_stay"
app:popExitAnim="@anim/slide_out_left" />
</fragment>

<fragment
android:id="@+id/welcomeToDashPayFragment"
android:name="de.schildbach.wallet.ui.username.voting.WelcomeToDashPayFragment"
Expand Down Expand Up @@ -143,7 +113,7 @@
<fragment
android:id="@+id/usernameRegistrationFragment"
android:name="de.schildbach.wallet.ui.username.UsernameRegistrationFragment"
tools:layout="@layout/fragment_verfiy_identity">
tools:layout="@layout/fragment_username_registration">
</fragment>


Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-de/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ Benutzernamen</b></string>
<string name="coinjoin_mixing">Mixing</string>
<string name="coinjoin_paused">Mixing pausiert</string>
<string name="coinjoin_not_started">Nicht gestartet</string>
<string name="coinjoin_progress">%s (%d%%) %s von %s</string>
<string name="coinjoin_progress_balance">%1$s von %2$s</string>
<string name="coinjoin_progress_finished">Vollständig gemixt</string>
<string name="coinjoin_change_level_confirmation">Möchtest du die Einstellung der Privatsphäre wirklich ändern\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-el/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@
<string name="coinjoin_mixing">Ανάμιξη</string>
<string name="coinjoin_paused">Ανάμειξη σε παύση</string>
<string name="coinjoin_not_started">Δεν ξεκίνησε</string>
<string name="coinjoin_progress">%s (%d%%) %s από %s</string>
<string name="coinjoin_progress_balance">%1$s από%2$s</string>
<string name="coinjoin_progress_finished">Πλήρως αναμεμειγμένα</string>
<string name="coinjoin_change_level_confirmation">Είστε σίγουροι ότι θέλετε να αλλάξετε το επίπεδο απορρήτου;</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-es/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ de Dash</b></string>
<string name="coinjoin_mixing">Mezclando</string>
<string name="coinjoin_paused">Mezcla en pausa</string>
<string name="coinjoin_not_started">No iniciado</string>
<string name="coinjoin_progress">%s (%d%%) %s of %s</string>
<string name="coinjoin_progress_balance">%1$s de %2$s</string>
<string name="coinjoin_progress_finished">Completamente mezclado</string>
<string name="coinjoin_change_level_confirmation">¿Estás seguro de que deseas cambiar el nivel de privacidad\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-fa/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@
<string name="coinjoin_mixing">در حال ترکیب</string>
<string name="coinjoin_paused">توقف موقت ترکیب</string>
<string name="coinjoin_not_started">شروع نشده</string>
<string name="coinjoin_progress">%s(%d%%) %s از %s</string>
<string name="coinjoin_progress_balance">%1$s از %2$s</string>
<string name="coinjoin_progress_finished">کاملا ترکیب شده</string>
<string name="coinjoin_change_level_confirmation">آیا مطمئن هستید که می‌خواهید سطح محرمانگی را تغییر دهید؟</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-fil/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ Username</b></string>
<string name="coinjoin_mixing">Paghahalo</string>
<string name="coinjoin_paused">Nakahinto ang Paghahalo</string>
<string name="coinjoin_not_started">Hindi Nagsimula</string>
<string name="coinjoin_progress">%s (%d%%) %s ng %s</string>
<string name="coinjoin_progress_balance">%1$s ng %2$s</string>
<string name="coinjoin_progress_finished">Ganap na Nahalo</string>
<string name="coinjoin_change_level_confirmation">Sigurado ka bang gusto mong baguhin ang antas ng privacy\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-fr/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@
<string name="coinjoin_mixing">Mélange</string>
<string name="coinjoin_paused">Mélange mis en pause</string>
<string name="coinjoin_not_started">Non démarré</string>
<string name="coinjoin_progress">%s (%d%%) %s de %s</string>
<string name="coinjoin_progress_balance">%1$s de %2$s</string>
<string name="coinjoin_progress_finished">Entièrement mélangé</string>
<string name="coinjoin_change_level_confirmation">Souhaitez-vous vraiment modifier le niveau de confidentialité \?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-id/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ Dash</b> anda</string>
<string name="coinjoin_mixing">Pencampuran</string>
<string name="coinjoin_paused">Pencampuran Dijeda</string>
<string name="coinjoin_not_started">Tidak Dimulai</string>
<string name="coinjoin_progress">%s (%d%%) %s dari %s</string>
<string name="coinjoin_progress_balance">%1$s dari %2$s</string>
<string name="coinjoin_progress_finished">Tercampur Sepenuhnya</string>
<string name="coinjoin_change_level_confirmation">Apakah Anda yakin ingin mengubah tingkat privasi\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-it/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ Username</b></string>
<string name="coinjoin_mixing">Miscelazione</string>
<string name="coinjoin_paused">Miscelazione in pausa</string>
<string name="coinjoin_not_started">Non iniziato</string>
<string name="coinjoin_progress">%s (%d %% ) %s di %s</string>
<string name="coinjoin_progress_balance">%1$s di %2$s</string>
<string name="coinjoin_progress_finished">Completamente Miscelato</string>
<string name="coinjoin_change_level_confirmation">Sei sicuro di voler modificare il livello di privacy\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-ja/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@
<string name="coinjoin_mixing">ミキシング中</string>
<string name="coinjoin_paused">ミキシングを一時停止しました</string>
<string name="coinjoin_not_started">開始していません</string>
<string name="coinjoin_progress">%sの%s (%d%%) と%s</string>
<string name="coinjoin_progress_balance">%2$sの%1$s</string>
<string name="coinjoin_progress_finished">ミキシング完了しました</string>
<string name="coinjoin_change_level_confirmation">プライバシーレベルを変更してよろしいですか。</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-ko/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@
<string name="coinjoin_mixing">믹싱</string>
<string name="coinjoin_paused">믹싱이 멈춰짐</string>
<string name="coinjoin_not_started">시작되지 않음</string>
<string name="coinjoin_progress">%s 중 %s (%d%%) %s</string>
<string name="coinjoin_progress_balance">%2$s 중 %1$s</string>
<string name="coinjoin_progress_finished">완전히 믹싱됨</string>
<string name="coinjoin_change_level_confirmation">정말 프라이버시 수준을 변경하시겠습니까\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-nl/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ gebruikersnaam</b></string>
<string name="coinjoin_mixing">Aan het mixen</string>
<string name="coinjoin_paused">mixen gepauzeerd </string>
<string name="coinjoin_not_started">Niet gestart</string>
<string name="coinjoin_progress">%s (%d%%) %s van %s</string>
<string name="coinjoin_progress_balance">%1$s van %2$s</string>
<string name="coinjoin_progress_finished">Volledig gemixt</string>
<string name="coinjoin_change_level_confirmation">Weet je zeker dat je het privacy niveau wilt wijzigen\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-pl/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@
<string name="coinjoin_mixing">Miksowanie</string>
<string name="coinjoin_paused">Miksowanie zostało zatrzywame</string>
<string name="coinjoin_not_started">Nie rozpoczęto</string>
<string name="coinjoin_progress">%s (%d%%) %s lub %s</string>
<string name="coinjoin_progress_balance">%1$s z %2$s</string>
<string name="coinjoin_progress_finished">Całkowicie wymieszane</string>
<string name="coinjoin_change_level_confirmation">Czy na pewno chcesz zmienić poziom prywatności\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-pt/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ Dash</b></string>
<string name="coinjoin_mixing">Misturando</string>
<string name="coinjoin_paused">Mistura Pausada</string>
<string name="coinjoin_not_started">Não iniciado</string>
<string name="coinjoin_progress">%s (%d%%) %s de %s</string>
<string name="coinjoin_progress_balance">%1$s de %2$s</string>
<string name="coinjoin_progress_finished">Totalmente Misturado</string>
<string name="coinjoin_change_level_confirmation">Tem certeza de que deseja mudar o nível de privacidade\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-ru/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ Dash</b></string>
<string name="coinjoin_mixing">Перемешивание</string>
<string name="coinjoin_paused">Перемешивание на паузе</string>
<string name="coinjoin_not_started">Не начато</string>
<string name="coinjoin_progress">%s (%d %%) %s из %s</string>
<string name="coinjoin_progress_balance">%1$s из %2$s</string>
<string name="coinjoin_progress_finished">Полностью перемешано</string>
<string name="coinjoin_change_level_confirmation">Уверены, что хотите изменить уровень приватности\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-sk/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ používateľské meno</b></string>
<string name="coinjoin_mixing">Miešanie</string>
<string name="coinjoin_paused">Miešanie pozastavené</string>
<string name="coinjoin_not_started">Nespustené</string>
<string name="coinjoin_progress">%s (%d%%) %s z %s</string>
<string name="coinjoin_progress_balance">%1$s z %2$s</string>
<string name="coinjoin_progress_finished">Plne zmiešané</string>
<string name="coinjoin_change_level_confirmation">Naozaj chcete zmeniť úroveň ochrany osobných údajov\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-tr/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@
<string name="coinjoin_mixing">Karıştırma</string>
<string name="coinjoin_paused">Karıştırma Duraklatıldı</string>
<string name="coinjoin_not_started">Başlamadı</string>
<string name="coinjoin_progress">%s (%d%%) %s / %s</string>
<string name="coinjoin_progress_balance">%1$s / %2$s</string>
<string name="coinjoin_progress_finished">Tamamen Karıştırılmış</string>
<string name="coinjoin_change_level_confirmation">Gizlilik düzeyini değiştirmek istediğinizden emin misiniz\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-uk/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@
<string name="coinjoin_mixing">Змішування</string>
<string name="coinjoin_paused">Змішування на паузі</string>
<string name="coinjoin_not_started">Не розпачато</string>
<string name="coinjoin_progress">%s(%d%%)%s з %s</string>
<string name="coinjoin_progress_balance">%1$s з %2$s</string>
<string name="coinjoin_progress_finished">Повністю змішано</string>
<string name="coinjoin_change_level_confirmation">Ви впевнені, що бажаєте змінити рівень конфіденційності\?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-zh-rTW/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@
<string name="coinjoin_mixing">混合</string>
<string name="coinjoin_paused">混合暫停</string>
<string name="coinjoin_not_started">尚未開始</string>
<string name="coinjoin_progress">%s (%d%%) %s of %s</string>
<string name="coinjoin_progress_balance">%1$s of %2$s</string>
<string name="coinjoin_progress_finished">充分混合</string>
<string name="coinjoin_change_level_confirmation">您確定要變更隱私等級嗎?</string>
Expand Down
1 change: 0 additions & 1 deletion wallet/res/values-zh/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@
<string name="coinjoin_mixing">混币</string>
<string name="coinjoin_paused">混币暂停</string>
<string name="coinjoin_not_started">尚未开始</string>
<string name="coinjoin_progress">%s中的 %s (%d%%) %s</string>
<string name="coinjoin_progress_balance">%2$s中的%1$s</string>
<string name="coinjoin_progress_finished">完全混币</string>
<string name="coinjoin_change_level_confirmation">您确定要改变隐私级别吗\?</string>
Expand Down
2 changes: 1 addition & 1 deletion wallet/res/values/strings-dashpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
<string name="coinjoin_mixing">Mixing</string>
<string name="coinjoin_paused">Mixing Paused</string>
<string name="coinjoin_not_started">Not Started</string>
<string name="coinjoin_progress">%s (%d%%) %s of %s</string>
<string name="coinjoin_progress" translatable="false">%s (%.1f%%) %s / %s</string>
<string name="coinjoin_progress_balance">%1$s of %2$s</string>
<string name="coinjoin_progress_finished">Fully Mixed</string>
<string name="coinjoin_change_level_confirmation">Are you sure you want to change the privacy level?</string>
Expand Down
4 changes: 3 additions & 1 deletion wallet/src/de/schildbach/wallet/WalletApplicationExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package de.schildbach.wallet

import androidx.work.WorkManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asCoroutineDispatcher
Expand All @@ -33,13 +34,14 @@ object WalletApplicationExt {
*/
fun WalletApplication.clearDatabases(isWalletWipe: Boolean) {
val scope = CoroutineScope(Dispatchers.IO)

val context = this
scope.launch {
platformSyncService.clearDatabases()
if (isWalletWipe) {
transactionMetadataProvider.clear()
}
platformRepo.clearDatabase(isWalletWipe)
WorkManager.getInstance(context).cancelAllWork()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public class BlockchainServiceImpl extends LifecycleService implements Blockchai
private final Executor executor = Executors.newSingleThreadExecutor();
private int syncPercentage = 0; // 0 to 100%
private MixingStatus mixingStatus = MixingStatus.NOT_STARTED;
private Double mixingProgress = 0.0;
private double mixingProgress = 0.0;
private ForegroundService foregroundService = ForegroundService.NONE;

// Risk Analyser for Transactions that is PeerGroup Aware
Expand Down Expand Up @@ -1088,7 +1088,7 @@ private Notification createCoinJoinNotification() {
final String message = getString(
R.string.coinjoin_progress,
getString(statusStringId),
mixingProgress.intValue(),
mixingProgress,
decimalFormat.format(MonetaryExtKt.toBigDecimal(mixedBalance)),
decimalFormat.format(MonetaryExtKt.toBigDecimal(totalBalance))
);
Expand Down
2 changes: 1 addition & 1 deletion wallet/src/de/schildbach/wallet/ui/BlockInfoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toolbar
import androidx.appcompat.widget.Toolbar
import dagger.hilt.android.AndroidEntryPoint
import de.schildbach.wallet.data.BlockInfo
import de.schildbach.wallet_test.R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ class CreateIdentityService : LifecycleService() {
if (blockchainIdentityData.creationStateErrorMessage?.contains("preorderDocument was not found with a salted domain hash") == true) {
blockchainIdentityData.creationState = CreationState.PREORDER_REGISTERING
platformRepo.updateBlockchainIdentityData(blockchainIdentityData)
} else if (blockchainIdentityData.creationStateErrorMessage?.contains("missing domain document for") == true) {
blockchainIdentityData.creationState = CreationState.PREORDER_REGISTERING
platformRepo.updateBlockchainIdentityData(blockchainIdentityData)
} else if (retryWithNewUserName) {
// lets rewind the state to allow for a new username registration or request
// it may have failed later in the process
Expand Down Expand Up @@ -776,6 +779,9 @@ class CreateIdentityService : LifecycleService() {
}
}

/**
* restores an identity using information from the wallet and platform
*/
private suspend fun restoreIdentity(identity: ByteArray) {
log.info("Restoring identity and username")
try {
Expand Down Expand Up @@ -863,7 +869,7 @@ class CreateIdentityService : LifecycleService() {
platformRepo.updateIdentityCreationState(blockchainIdentityData, CreationState.REQUESTED_NAME_CHECKING)

// check if the network has this name in the queue for voting
val contestedNames = platformRepo.platform.names.getContestedNames()
val contestedNames = platformRepo.platform.names.getAllContestedNames()

contestedNames.forEach { name ->
val voteContenders = platformRepo.getVoteContenders(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class HistoryHeaderAdapter(
if (blockchainIdentityData.creationState == BlockchainIdentityData.CreationState.USERNAME_REGISTERING &&
(blockchainIdentityData.creationStateErrorMessage.contains("Document transitions with duplicate unique properties") ||
blockchainIdentityData.creationStateErrorMessage.contains("Document Contest for vote_poll ContestedDocumentResourceVotePoll")) ||
blockchainIdentityData.creationStateErrorMessage.contains(Regex("does not have .* as a contender"))
blockchainIdentityData.creationStateErrorMessage.contains(Regex("does not have .* as a contender")) ||
blockchainIdentityData.creationStateErrorMessage.contains("missing domain document for ")
) {
binding.identityCreation.title.text = binding.root.context.getString(R.string.processing_username_unavailable_title)
binding.identityCreation.subtitle.visibility = View.VISIBLE
Expand Down
Loading

0 comments on commit 261c7de

Please sign in to comment.