-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract SecureArea-specific UI into an interface
- Loading branch information
1 parent
60fcadc
commit 600f62d
Showing
49 changed files
with
1,514 additions
and
1,386 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
128 changes: 128 additions & 0 deletions
128
appholder/src/main/java/com/android/identity/wallet/composables/AndroidSetupContainer.kt
This file contains 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,128 @@ | ||
package com.android.identity.wallet.composables | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Checkbox | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Switch | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.android.identity.wallet.R | ||
import com.android.identity.wallet.composables.state.AuthTypeState | ||
import com.android.identity.wallet.selfsigned.OutlinedContainerVertical | ||
|
||
@Composable | ||
fun AndroidSetupContainer( | ||
modifier: Modifier = Modifier, | ||
isOn: Boolean, | ||
timeoutSeconds: Int, | ||
lskfAuthTypeState: AuthTypeState, | ||
biometricAuthTypeState: AuthTypeState, | ||
useStrongBox: AuthTypeState, | ||
onUserAuthenticationChanged: (isOn: Boolean) -> Unit, | ||
onAuthTimeoutChanged: (authTimeout: Int) -> Unit, | ||
onLskfAuthChanged: (isOn: Boolean) -> Unit, | ||
onBiometricAuthChanged: (isOn: Boolean) -> Unit, | ||
onStrongBoxChanged: (isOn: Boolean) -> Unit | ||
) { | ||
Column(modifier = modifier) { | ||
OutlinedContainerVertical(modifier = Modifier.fillMaxWidth()) { | ||
val labelOn = stringResource(id = R.string.user_authentication_on) | ||
val labelOff = stringResource(id = R.string.user_authentication_off) | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
ValueLabel( | ||
modifier = Modifier.weight(1f), | ||
label = if (isOn) labelOn else labelOff, | ||
) | ||
Switch( | ||
modifier = Modifier.padding(start = 8.dp), | ||
checked = isOn, | ||
onCheckedChange = onUserAuthenticationChanged | ||
) | ||
} | ||
AnimatedVisibility( | ||
modifier = Modifier.fillMaxWidth(), | ||
visible = isOn | ||
) { | ||
Column(modifier = Modifier.fillMaxWidth()) { | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
ValueLabel( | ||
modifier = Modifier.weight(1f), | ||
label = stringResource(id = R.string.keystore_android_user_auth_timeout) | ||
) | ||
NumberChanger( | ||
number = timeoutSeconds, | ||
onNumberChanged = onAuthTimeoutChanged, | ||
counterTextStyle = MaterialTheme.typography.titleLarge | ||
) | ||
} | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
val alpha = if (lskfAuthTypeState.canBeModified) 1f else .5f | ||
ValueLabel( | ||
modifier = Modifier | ||
.weight(1f) | ||
.alpha(alpha), | ||
label = stringResource(id = R.string.user_auth_type_allow_lskf) | ||
) | ||
Checkbox( | ||
checked = lskfAuthTypeState.isEnabled, | ||
onCheckedChange = onLskfAuthChanged, | ||
enabled = lskfAuthTypeState.canBeModified | ||
) | ||
} | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
val alpha = if (biometricAuthTypeState.canBeModified) 1f else .5f | ||
ValueLabel( | ||
modifier = Modifier | ||
.weight(1f) | ||
.alpha(alpha), | ||
label = stringResource(id = R.string.user_auth_type_allow_biometric) | ||
) | ||
Checkbox( | ||
checked = biometricAuthTypeState.isEnabled, | ||
onCheckedChange = onBiometricAuthChanged, | ||
enabled = biometricAuthTypeState.canBeModified | ||
) | ||
} | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
val alpha = if (useStrongBox.canBeModified) 1f else .5f | ||
ValueLabel( | ||
modifier = Modifier | ||
.weight(1f) | ||
.alpha(alpha), | ||
label = stringResource(id = R.string.user_auth_use_strong_box) | ||
) | ||
Checkbox( | ||
checked = useStrongBox.isEnabled, | ||
onCheckedChange = onStrongBoxChanged, | ||
enabled = useStrongBox.canBeModified | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.