Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit b7a8bf2

Browse files
author
seldon1000
committed
last cleanup
1 parent 4fcf9a9 commit b7a8bf2

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

app/src/main/java/eu/seldon1000/nextpass/MainViewModel.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
6969
private var unlocked = false
7070
private var pendingUnlockAction: (() -> Unit)? = null
7171
private var promptInfo: BiometricPrompt.PromptInfo
72-
private lateinit var biometricPrompt: BiometricPrompt
7372
private lateinit var autofillIntent: Intent
7473

7574
private val disablePinAction = {
@@ -242,7 +241,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
242241
if (pinProtected.value) {
243242
unlocked = false
244243
refreshing.value = false
245-
if (biometricProtected.value) biometricDismissed.value = false
244+
biometricDismissed.value = false
246245
dismissDialog()
247246

248247
navigate(route = Routes.AccessPin.getRoute(arg = shouldRaiseBiometric))
@@ -284,11 +283,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
284283
fun changePin() {
285284
pendingUnlockAction = { navigate(route = Routes.Pin.route) }
286285

287-
if (pinProtected.value) lock()
288-
else {
289-
pendingUnlockAction!!()
290-
pendingUnlockAction = null
291-
}
286+
lock()
292287
}
293288

294289
fun setPin(pin: String) {
@@ -321,7 +316,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
321316
}
322317

323318
fun showBiometricPrompt(toEnable: Boolean = false) {
324-
biometricPrompt = BiometricPrompt(
319+
BiometricPrompt(
325320
(navController.value.context as MainActivity),
326321
object : BiometricPrompt.AuthenticationCallback() {
327322
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
@@ -331,21 +326,22 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
331326
override fun onAuthenticationSucceeded(
332327
result: BiometricPrompt.AuthenticationResult
333328
) {
329+
biometricDismissed.value = true
330+
334331
if (toEnable) {
335332
sharedPreferences.edit().putBoolean("biometric", true).apply()
336333
biometricProtected.value = true
337334
} else {
338335
unlocked = true
339-
unlock()
336+
unlock(shouldRememberScreen = true)
340337
}
341338
}
342339

343340
override fun onAuthenticationFailed() {
344341
biometricDismissed.value = true
345342
}
346343
}
347-
)
348-
biometricPrompt.authenticate(promptInfo)
344+
).authenticate(promptInfo)
349345
}
350346

351347
fun setLockTimeout(timeout: Long) {

app/src/main/java/eu/seldon1000/nextpass/ui/layout/MySnackbar.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.Modifier
2727
import androidx.compose.ui.graphics.Color
2828
import androidx.compose.ui.text.font.FontWeight
2929
import androidx.compose.ui.unit.dp
30+
import androidx.compose.ui.unit.sp
3031

3132
@Composable
3233
fun MySnackbar(snackbarHostState: SnackbarHostState) {
@@ -37,6 +38,13 @@ fun MySnackbar(snackbarHostState: SnackbarHostState) {
3738
backgroundColor = Color.DarkGray,
3839
shape = RoundedCornerShape(size = 8.dp),
3940
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 96.dp)
40-
) { Text(text = data.message, fontWeight = FontWeight.SemiBold, color = Color.White) }
41+
) {
42+
Text(
43+
text = data.message,
44+
fontSize = 15.sp,
45+
fontWeight = FontWeight.SemiBold,
46+
color = Color.White
47+
)
48+
}
4149
})
4250
}

app/src/main/java/eu/seldon1000/nextpass/ui/screens/Settings.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,7 @@ fun Settings(viewModel: MainViewModel) {
214214
modifier = Modifier.padding(end = 16.dp)
215215
)
216216
}
217-
) {
218-
if (protected) viewModel.changePin()
219-
else
220-
viewModel.showDialog(
221-
title = context.getString(R.string.pin_not_enabled),
222-
body = {
223-
Text(
224-
text = context.getString(R.string.pin_not_enabled_body),
225-
fontSize = 14.sp
226-
)
227-
},
228-
confirm = true
229-
) { viewModel.navigate(route = Routes.Pin.route) }
230-
}
217+
) { viewModel.changePin() }
231218
}
232219
item {
233220
GenericColumnItem(

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
<string name="security">Security</string>
6161
<string name="pin_authentication">PIN authentication</string>
6262
<string name="pin_authentication_tip">Protect the app using a PIN code, at least 4-digit long. Click here to modify the current pin.</string>
63-
<string name="pin_not_enabled">PIN authentication is not enabled</string>
64-
<string name="pin_not_enabled_body">Do you want to enable it now?</string>
6563
<string name="biometric_authentication">Biometric authentication</string>
6664
<string name="biometric_authentication_tip">Protect the app using biometric authentication (if supported by the device). PIN authentication must be enabled as fallback.</string>
6765
<string name="url">URL</string>

0 commit comments

Comments
 (0)