-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: biometric prompt is not shown #10031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wmontwe
merged 2 commits into
thunderbird:main
from
wmontwe:fix/10013/password-prompt-not-shown
Nov 4, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...pp/k9mail/feature/account/server/settings/ui/common/ProtectedTextFieldOutlinedPassword.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package app.k9mail.feature.account.server.settings.ui.common | ||
|
|
||
| import android.app.Activity | ||
| import android.view.WindowManager | ||
| import androidx.activity.compose.LocalActivity | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.DisposableEffect | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.rememberCoroutineScope | ||
| import androidx.compose.runtime.saveable.rememberSaveable | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Modifier | ||
| import app.k9mail.core.ui.compose.designsystem.atom.textfield.TextFieldOutlinedPassword | ||
| import kotlinx.coroutines.launch | ||
| import net.thunderbird.core.outcome.Outcome | ||
| import net.thunderbird.feature.account.server.settings.ui.common.AuthenticationError | ||
| import net.thunderbird.feature.account.server.settings.ui.common.Authenticator | ||
|
|
||
| /** | ||
| * Variant of [TextFieldOutlinedPassword] that only allows the | ||
| * password to be unmasked after the user has authenticated using [Authenticator]. | ||
| */ | ||
| @Suppress("LongParameterList") | ||
| @Composable | ||
| fun ProtectedTextFieldOutlinedPassword( | ||
| value: String, | ||
| onValueChange: (String) -> Unit, | ||
| onWarningChange: (AuthenticationError?) -> Unit, | ||
| authenticator: Authenticator, | ||
| modifier: Modifier = Modifier, | ||
| label: String? = null, | ||
| isEnabled: Boolean = true, | ||
| isReadOnly: Boolean = false, | ||
| isRequired: Boolean = false, | ||
| hasError: Boolean = false, | ||
| ) { | ||
| var isPasswordVisible by rememberSaveable { mutableStateOf(false) } | ||
| var isAuthenticated by rememberSaveable { mutableStateOf(false) } | ||
|
|
||
| val activity = LocalActivity.current as Activity | ||
| val scope = rememberCoroutineScope() | ||
|
|
||
| TextFieldOutlinedPassword( | ||
| value = value, | ||
| onValueChange = onValueChange, | ||
| modifier = modifier, | ||
| label = label, | ||
| isEnabled = isEnabled, | ||
| isReadOnly = isReadOnly, | ||
| isRequired = isRequired, | ||
| hasError = hasError, | ||
| isPasswordVisible = isPasswordVisible, | ||
| onPasswordVisibilityToggleClicked = { | ||
| if (isAuthenticated) { | ||
| isPasswordVisible = !isPasswordVisible | ||
| activity.setSecure(isPasswordVisible) | ||
| } else { | ||
| scope.launch { | ||
| when (val outcome = authenticator.authenticate()) { | ||
| is Outcome.Success -> { | ||
| isAuthenticated = true | ||
| isPasswordVisible = true | ||
| onWarningChange(null) | ||
| activity.setSecure(true) | ||
| } | ||
| is Outcome.Failure -> { | ||
| onWarningChange(outcome.error) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
| DisposableEffect(key1 = "secureWindow") { | ||
| activity.setSecure(isPasswordVisible) | ||
|
|
||
| onDispose { | ||
| activity.setSecure(false) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun Activity.setSecure(secure: Boolean) { | ||
| window.setFlags(if (secure) WindowManager.LayoutParams.FLAG_SECURE else 0, WindowManager.LayoutParams.FLAG_SECURE) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 0 additions & 131 deletions
131
...pp/k9mail/feature/account/server/settings/ui/common/TextFieldOutlinedPasswordBiometric.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...rc/main/kotlin/net/thunderbird/feature/account/server/settings/ui/common/Authenticator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package net.thunderbird.feature.account.server.settings.ui.common | ||
|
|
||
| import net.thunderbird.core.outcome.Outcome | ||
|
|
||
| /** | ||
| * A functional interface for authenticating a user. | ||
| */ | ||
| fun interface Authenticator { | ||
|
|
||
| /** | ||
| * Authenticates the user. | ||
| * | ||
| * @return An [Outcome] representing the result of the authentication process. | ||
| */ | ||
| suspend fun authenticate(): Outcome<Unit, AuthenticationError> | ||
| } | ||
|
|
||
| /** | ||
| * Authentication errors that can occur during the authentication process. | ||
| */ | ||
| sealed interface AuthenticationError { | ||
| /** | ||
| * The user has not set up any authentication methods (e.g. screen lock, biometrics). | ||
| */ | ||
| data object NotAvailable : AuthenticationError | ||
|
|
||
| /** | ||
| * The authentication failed. | ||
| */ | ||
| data object Failed : AuthenticationError | ||
|
|
||
| /** | ||
| * An unknown error occurred, and authentication could not be started. | ||
| */ | ||
| data object UnableToStart : AuthenticationError | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Although this is nice to have, I don't think that this input should be responsible for setting the Activity in the secure mode.
Instead, I would have a
onPasswordVisibleChangecallback, and the screen that consumes this component would change the Activity flag.Additionally, removing the
FLAG_SECUREflag when disposing of this component opens the possibility of retrieving the password via a screenshot.See video below:
Screen.Recording.2025-11-03.at.3.15.13.PM.mov