Skip to content

Commit 4ee8d91

Browse files
feat: support for forgot keyphrase instructions (#1047)
1 parent 5be19d1 commit 4ee8d91

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.yogeshpaliyal.keypass.ui.home.components
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.Spacer
5+
import androidx.compose.foundation.layout.fillMaxWidth
6+
import androidx.compose.foundation.layout.size
7+
import androidx.compose.material3.AlertDialog
8+
import androidx.compose.material3.Text
9+
import androidx.compose.material3.TextButton
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.res.stringResource
13+
import androidx.compose.ui.unit.dp
14+
import com.yogeshpaliyal.keypass.R
15+
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
16+
import com.yogeshpaliyal.keypass.ui.redux.actions.UpdateDialogState
17+
import com.yogeshpaliyal.keypass.ui.redux.states.ValidateKeyPhrase
18+
import org.reduxkotlin.compose.rememberTypedDispatcher
19+
20+
@Composable
21+
fun ForgotKeyPhraseDialog() {
22+
val dispatchAction = rememberTypedDispatcher<Action>()
23+
24+
val hideDialog: () -> Unit = {
25+
dispatchAction(UpdateDialogState(ValidateKeyPhrase))
26+
}
27+
28+
AlertDialog(
29+
onDismissRequest = {
30+
hideDialog()
31+
},
32+
title = {
33+
Text(text = stringResource(id = R.string.forgot_keyphrase))
34+
},
35+
confirmButton = {
36+
TextButton(onClick = {
37+
hideDialog()
38+
}) {
39+
Text(text = stringResource(id = R.string.got_it))
40+
}
41+
},
42+
text = {
43+
Column(modifier = Modifier.fillMaxWidth(1f)) {
44+
Spacer(modifier = Modifier.size(8.dp))
45+
Text(text = stringResource(id = R.string.forgot_keyphrase_info))
46+
Spacer(modifier = Modifier.size(8.dp))
47+
}
48+
}
49+
)
50+
}

app/src/main/java/com/yogeshpaliyal/keypass/ui/home/components/ValidateKeyPhraseDialog.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.yogeshpaliyal.keypass.ui.nav.LocalUserSettings
2222
import com.yogeshpaliyal.keypass.ui.redux.actions.Action
2323
import com.yogeshpaliyal.keypass.ui.redux.actions.ToastAction
2424
import com.yogeshpaliyal.keypass.ui.redux.actions.UpdateDialogState
25+
import com.yogeshpaliyal.keypass.ui.redux.states.ForgotKeyPhraseState
2526
import kotlinx.coroutines.launch
2627
import org.reduxkotlin.compose.rememberTypedDispatcher
2728

@@ -87,6 +88,16 @@ fun ValidateKeyPhraseDialog() {
8788
Text(text = stringResource(id = R.string.enter_keyphrase))
8889
}
8990
)
91+
92+
Spacer(modifier = Modifier.size(8.dp))
93+
94+
TextButton(onClick = {
95+
dispatchAction(UpdateDialogState(ForgotKeyPhraseState))
96+
}) {
97+
Text(text = stringResource(id = R.string.forgot_keyphrase_question))
98+
}
99+
100+
Spacer(modifier = Modifier.size(8.dp))
90101
}
91102
}
92103
)

app/src/main/java/com/yogeshpaliyal/keypass/ui/nav/DashboardComposeActivity.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.yogeshpaliyal.keypass.ui.changePassword.ChangePassword
3333
import com.yogeshpaliyal.keypass.ui.detail.AccountDetailPage
3434
import com.yogeshpaliyal.keypass.ui.generate.ui.GeneratePasswordScreen
3535
import com.yogeshpaliyal.keypass.ui.home.Homepage
36+
import com.yogeshpaliyal.keypass.ui.home.components.ForgotKeyPhraseDialog
3637
import com.yogeshpaliyal.keypass.ui.home.components.ValidateKeyPhraseDialog
3738
import com.yogeshpaliyal.keypass.ui.nav.components.DashboardBottomSheet
3839
import com.yogeshpaliyal.keypass.ui.nav.components.KeyPassBottomBar
@@ -48,6 +49,7 @@ import com.yogeshpaliyal.keypass.ui.redux.states.BackupScreenState
4849
import com.yogeshpaliyal.keypass.ui.redux.states.ChangeAppHintState
4950
import com.yogeshpaliyal.keypass.ui.redux.states.ChangeAppPasswordState
5051
import com.yogeshpaliyal.keypass.ui.redux.states.ChangeDefaultPasswordLengthState
52+
import com.yogeshpaliyal.keypass.ui.redux.states.ForgotKeyPhraseState
5153
import com.yogeshpaliyal.keypass.ui.redux.states.HomeState
5254
import com.yogeshpaliyal.keypass.ui.redux.states.KeyPassState
5355
import com.yogeshpaliyal.keypass.ui.redux.states.PasswordGeneratorState
@@ -189,9 +191,8 @@ fun CurrentPage() {
189191

190192
currentScreen.dialog?.let {
191193
when (it) {
192-
is ValidateKeyPhrase -> {
193-
ValidateKeyPhraseDialog()
194-
}
194+
is ValidateKeyPhrase -> ValidateKeyPhraseDialog()
195+
ForgotKeyPhraseState -> ForgotKeyPhraseDialog()
195196
}
196197
}
197198
}

app/src/main/java/com/yogeshpaliyal/keypass/ui/redux/states/DialogState.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ package com.yogeshpaliyal.keypass.ui.redux.states
33
sealed class DialogState()
44

55
object ValidateKeyPhrase : DialogState()
6+
object ForgotKeyPhraseState : DialogState()

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@
125125
<string name="file_not_found">File not found (please try again)</string>
126126
<string name="enter_password_hint">Enter password hint</string>
127127
<string name="validate_keyphrase">Keyphrase Check</string>
128+
<string name="forgot_keyphrase">Forgot Keyphrase</string>
129+
<string name="forgot_keyphrase_question">Forgot Keyphrase?</string>
130+
<string name="forgot_keyphrase_info">If you can\'t remember your keyphrase, the only way to regain access is to turn off backups and then turn them back on. This will generate a new backup file and a new keyphrase. \nNote: Your old backup will be inaccessible.</string>
128131
<string name="valid_keyphrase">Valid Keyphrase</string>
129132
<string name="mismatch_keyphrase">Entered Keyphrase does not match with backup keyphrase</string>
130133
<string name="validate">Check</string>
134+
<string name="got_it">Got it</string>
131135
<string name="biometric_disabled_due_to_timeout">Please login via password because you haven\'t used password in last 24 hours</string>
132136

133137
</resources>

0 commit comments

Comments
 (0)