summaryrefslogtreecommitdiff
path: root/packages/CredentialManager/src
diff options
context:
space:
mode:
author Reema Bajwa <reemabajwa@google.com> 2024-04-17 02:47:49 +0000
committer Reema Bajwa <reemabajwa@google.com> 2024-04-17 16:57:38 +0000
commit77d3276dd1f68cd7f8ac13311ffab4dce36540a6 (patch)
tree8dbfea890475d9e46578769c30106479049089d5 /packages/CredentialManager/src
parenta55d0834db1b61d4f91ecbf01d8ebaf942f442e2 (diff)
Change back button to cross for create flow
Bug: 328086145 Test: Cts Change-Id: Ie4cac17df2302c7efa8a09d54dc719c200f24c4b
Diffstat (limited to 'packages/CredentialManager/src')
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt8
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt39
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt76
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt1
-rw-r--r--packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt9
5 files changed, 78 insertions, 55 deletions
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
index 429bdbf5959b..7bc32419e070 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/CredentialSelectorViewModel.kt
@@ -317,6 +317,14 @@ class CredentialSelectorViewModel(
)
}
+ fun createFlowOnMoreOptionsOnlySelectedOnCreationSelection() {
+ uiState = uiState.copy(
+ createCredentialUiState = uiState.createCredentialUiState?.copy(
+ currentScreenState = CreateScreenState.MORE_OPTIONS_SELECTION_ONLY,
+ )
+ )
+ }
+
fun createFlowOnBackCreationSelectionButtonSelected() {
uiState = uiState.copy(
createCredentialUiState = uiState.createCredentialUiState?.copy(
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
index 149c14a24085..2c3c63bea95f 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt
@@ -28,7 +28,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -47,7 +46,6 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalLayoutDirection
-import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.input.PasswordVisualTransformation
@@ -55,7 +53,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import com.android.compose.theme.LocalAndroidColorScheme
-import com.android.credentialmanager.R
import com.android.credentialmanager.ui.theme.EntryShape
import com.android.credentialmanager.ui.theme.Shapes
@@ -321,6 +318,8 @@ fun CtaButtonRow(
fun MoreOptionTopAppBar(
text: String,
onNavigationIconClicked: () -> Unit,
+ navigationIcon: ImageVector,
+ navigationIconContentDescription: String,
bottomPadding: Dp,
) {
Row(
@@ -336,40 +335,6 @@ fun MoreOptionTopAppBar(
contentAlignment = Alignment.Center,
) {
Icon(
- imageVector = Icons.Filled.ArrowBack,
- contentDescription = stringResource(
- R.string.accessibility_back_arrow_button
- ),
- modifier = Modifier.size(24.dp).autoMirrored(),
- tint = LocalAndroidColorScheme.current.onSurfaceVariant,
- )
- }
- }
- LargeTitleText(text = text, modifier = Modifier.padding(horizontal = 4.dp))
- }
-}
-
-@Composable
-fun MoreOptionTopAppBarWithCustomNavigation(
- text: String,
- onNavigationIconClicked: () -> Unit,
- navigationIcon: ImageVector,
- navigationIconContentDescription: String,
- bottomPadding: Dp,
-) {
- Row(
- modifier = Modifier.padding(top = 12.dp, bottom = bottomPadding),
- verticalAlignment = Alignment.CenterVertically,
- ) {
- IconButton(
- modifier = Modifier.padding(top = 8.dp, bottom = 8.dp, start = 4.dp).size(48.dp),
- onClick = onNavigationIconClicked
- ) {
- Box(
- modifier = Modifier.size(48.dp),
- contentAlignment = Alignment.Center,
- ) {
- Icon(
imageVector = navigationIcon,
contentDescription = navigationIconContentDescription,
modifier = Modifier.size(24.dp).autoMirrored(),
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
index a0915d22b613..282a1b5736ac 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt
@@ -32,6 +32,8 @@ import androidx.compose.material3.Divider
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.NewReleases
import androidx.compose.material.icons.filled.Add
+import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.outlined.QrCodeScanner
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -107,7 +109,7 @@ fun CreateCredentialScreen(
onCancelFlowAndFinish = viewModel::onUserCancel,
onIllegalScreenStateAndFinish = viewModel::onIllegalUiState,
onMoreOptionSelected =
- viewModel::createFlowOnMoreOptionsSelectedOnCreationSelection,
+ viewModel::createFlowOnMoreOptionsOnlySelectedOnCreationSelection,
requestDisplayInfo = createCredentialUiState.requestDisplayInfo,
enabledProviderInfo = createCredentialUiState
.activeEntry?.activeProvider!!,
@@ -120,6 +122,41 @@ fun CreateCredentialScreen(
onBiometricPromptStateChange =
viewModel::onBiometricPromptStateChange
)
+ CreateScreenState.MORE_OPTIONS_SELECTION_ONLY -> MoreOptionsSelectionCard(
+ requestDisplayInfo = createCredentialUiState.requestDisplayInfo,
+ enabledProviderList = createCredentialUiState.enabledProviders,
+ disabledProviderList = createCredentialUiState.disabledProviders,
+ sortedCreateOptionsPairs =
+ createCredentialUiState.sortedCreateOptionsPairs,
+ onBackCreationSelectionButtonSelected =
+ viewModel::createFlowOnBackCreationSelectionButtonSelected,
+ onOptionSelected =
+ viewModel::createFlowOnEntrySelectedFromMoreOptionScreen,
+ onDisabledProvidersSelected =
+ viewModel::createFlowOnLaunchSettings,
+ onRemoteEntrySelected = viewModel::createFlowOnEntrySelected,
+ onLog = { viewModel.logUiEvent(it) },
+ customTopAppBar = { MoreOptionTopAppBar(
+ text = stringResource(
+ R.string.save_credential_to_title,
+ when (createCredentialUiState.requestDisplayInfo
+ .type) {
+ CredentialType.PASSKEY ->
+ stringResource(R.string.passkey)
+ CredentialType.PASSWORD ->
+ stringResource(R.string.password)
+ CredentialType.UNKNOWN -> stringResource(
+ R.string.sign_in_info)
+ }
+ ),
+ onNavigationIconClicked = viewModel::onUserCancel,
+ bottomPadding = 16.dp,
+ navigationIcon = Icons.Filled.Close,
+ navigationIconContentDescription = stringResource(
+ R.string.accessibility_close_button
+ )
+ )}
+ )
CreateScreenState.MORE_OPTIONS_SELECTION -> MoreOptionsSelectionCard(
requestDisplayInfo = createCredentialUiState.requestDisplayInfo,
enabledProviderList = createCredentialUiState.enabledProviders,
@@ -207,22 +244,31 @@ fun MoreOptionsSelectionCard(
onDisabledProvidersSelected: () -> Unit,
onRemoteEntrySelected: (EntryInfo) -> Unit,
onLog: @Composable (UiEventEnum) -> Unit,
+ customTopAppBar: (@Composable() () -> Unit)? = null
) {
SheetContainerCard(topAppBar = {
- MoreOptionTopAppBar(
- text = stringResource(
- R.string.save_credential_to_title,
- when (requestDisplayInfo.type) {
- CredentialType.PASSKEY ->
- stringResource(R.string.passkey)
- CredentialType.PASSWORD ->
- stringResource(R.string.password)
- CredentialType.UNKNOWN -> stringResource(R.string.sign_in_info)
- }
- ),
- onNavigationIconClicked = onBackCreationSelectionButtonSelected,
- bottomPadding = 16.dp,
- )
+ if (customTopAppBar != null) {
+ customTopAppBar()
+ } else {
+ MoreOptionTopAppBar(
+ text = stringResource(
+ R.string.save_credential_to_title,
+ when (requestDisplayInfo.type) {
+ CredentialType.PASSKEY ->
+ stringResource(R.string.passkey)
+ CredentialType.PASSWORD ->
+ stringResource(R.string.password)
+ CredentialType.UNKNOWN -> stringResource(R.string.sign_in_info)
+ }
+ ),
+ onNavigationIconClicked = onBackCreationSelectionButtonSelected,
+ bottomPadding = 16.dp,
+ navigationIcon = Icons.Filled.ArrowBack,
+ navigationIconContentDescription = stringResource(
+ R.string.accessibility_back_arrow_button
+ )
+ )
+ }
}) {
// bottom padding already
item {
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
index ddd4139b65b6..130937c70895 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateModel.kt
@@ -181,4 +181,5 @@ enum class CreateScreenState {
MORE_OPTIONS_SELECTION,
DEFAULT_PROVIDER_CONFIRMATION,
EXTERNAL_ONLY_SELECTION,
+ MORE_OPTIONS_SELECTION_ONLY,
}
diff --git a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
index ce4f402700d3..c98bb5ed17c1 100644
--- a/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
+++ b/packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt
@@ -32,6 +32,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.outlined.QrCodeScanner
import androidx.compose.material3.Divider
@@ -71,7 +72,6 @@ import com.android.credentialmanager.common.ui.HeadlineText
import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant
import com.android.credentialmanager.common.ui.ModalBottomSheet
import com.android.credentialmanager.common.ui.MoreOptionTopAppBar
-import com.android.credentialmanager.common.ui.MoreOptionTopAppBarWithCustomNavigation
import com.android.credentialmanager.common.ui.SheetContainerCard
import com.android.credentialmanager.common.ui.Snackbar
import com.android.credentialmanager.common.ui.SnackbarActionText
@@ -175,7 +175,7 @@ fun GetCredentialScreen(
onBackButtonClicked = viewModel::onUserCancel,
onCancel = viewModel::onUserCancel,
onLog = { viewModel.logUiEvent(it) },
- customTopBar = { MoreOptionTopAppBarWithCustomNavigation(
+ customTopBar = { MoreOptionTopAppBar(
text = stringResource(
R.string.get_dialog_title_sign_in_options),
onNavigationIconClicked = viewModel::onUserCancel,
@@ -683,7 +683,10 @@ fun AllSignInOptionCard(
text = stringResource(R.string.get_dialog_title_sign_in_options),
onNavigationIconClicked = onBackButtonClicked,
bottomPadding = 0.dp,
- )
+ navigationIcon = Icons.Filled.ArrowBack,
+ navigationIconContentDescription = stringResource(
+ R.string.accessibility_back_arrow_button
+ ))
}
}) {
var isFirstSection = true