Merge "Enhance fallback UI for single entry" into udc-dev

This commit is contained in:
Harsh Lal
2023-03-29 16:20:38 +00:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 2 deletions

View File

@@ -105,6 +105,8 @@
<string name="get_dialog_title_choose_sign_in_for">Choose a saved sign-in for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g></string> <string name="get_dialog_title_choose_sign_in_for">Choose a saved sign-in for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g></string>
<!-- This appears as the title of the dialog asking for user to make a choice from various previously saved credentials to sign in to the app. [CHAR LIMIT=200] --> <!-- This appears as the title of the dialog asking for user to make a choice from various previously saved credentials to sign in to the app. [CHAR LIMIT=200] -->
<string name="get_dialog_title_choose_option_for">Choose an option for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g>?</string> <string name="get_dialog_title_choose_option_for">Choose an option for <xliff:g id="app_name" example="YouTube">%1$s</xliff:g>?</string>
<!-- This appears as the title of the dialog asking user to use a previously saved credentials to sign in to the app. [CHAR LIMIT=200] -->
<string name="get_dialog_title_use_info_on">Use this info on <xliff:g id="app_name" example="YouTube">%1$s</xliff:g>?</string>
<!-- This is a label for a button that links the user to different sign-in methods . [CHAR LIMIT=80] --> <!-- This is a label for a button that links the user to different sign-in methods . [CHAR LIMIT=80] -->
<string name="get_dialog_use_saved_passkey_for">Sign in another way</string> <string name="get_dialog_use_saved_passkey_for">Sign in another way</string>
<!-- This is a label for a button that links the user to different sign-in methods. [CHAR LIMIT=80] --> <!-- This is a label for a button that links the user to different sign-in methods. [CHAR LIMIT=80] -->

View File

@@ -34,7 +34,9 @@ import com.android.credentialmanager.CredentialSelectorViewModel
import com.android.credentialmanager.R import com.android.credentialmanager.R
import com.android.credentialmanager.common.BaseEntry import com.android.credentialmanager.common.BaseEntry
import com.android.credentialmanager.common.ProviderActivityState import com.android.credentialmanager.common.ProviderActivityState
import com.android.credentialmanager.common.ui.ConfirmButton
import com.android.credentialmanager.common.ui.CredentialContainerCard import com.android.credentialmanager.common.ui.CredentialContainerCard
import com.android.credentialmanager.common.ui.CtaButtonRow
import com.android.credentialmanager.common.ui.HeadlineIcon import com.android.credentialmanager.common.ui.HeadlineIcon
import com.android.credentialmanager.common.ui.HeadlineText import com.android.credentialmanager.common.ui.HeadlineText
import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant
@@ -62,6 +64,7 @@ fun GetGenericCredentialScreen(
providerDisplayInfo = getCredentialUiState.providerDisplayInfo, providerDisplayInfo = getCredentialUiState.providerDisplayInfo,
providerInfoList = getCredentialUiState.providerInfoList, providerInfoList = getCredentialUiState.providerInfoList,
onEntrySelected = viewModel::getFlowOnEntrySelected, onEntrySelected = viewModel::getFlowOnEntrySelected,
onConfirm = viewModel::getFlowOnConfirmEntrySelected,
onLog = { viewModel.logUiEvent(it) }, onLog = { viewModel.logUiEvent(it) },
) )
viewModel.uiMetrics.log(GetCredentialEvent viewModel.uiMetrics.log(GetCredentialEvent
@@ -93,10 +96,13 @@ fun PrimarySelectionCardGeneric(
providerDisplayInfo: ProviderDisplayInfo, providerDisplayInfo: ProviderDisplayInfo,
providerInfoList: List<ProviderInfo>, providerInfoList: List<ProviderInfo>,
onEntrySelected: (BaseEntry) -> Unit, onEntrySelected: (BaseEntry) -> Unit,
onConfirm: () -> Unit,
onLog: @Composable (UiEventLogger.UiEventEnum) -> Unit, onLog: @Composable (UiEventLogger.UiEventEnum) -> Unit,
) { ) {
val sortedUserNameToCredentialEntryList = val sortedUserNameToCredentialEntryList =
providerDisplayInfo.sortedUserNameToCredentialEntryList providerDisplayInfo.sortedUserNameToCredentialEntryList
val totalEntriesCount = sortedUserNameToCredentialEntryList
.flatMap { it.sortedCredentialEntryList }.size
SheetContainerCard { SheetContainerCard {
// When only one provider (not counting the remote-only provider) exists, display that // When only one provider (not counting the remote-only provider) exists, display that
// provider's icon + name up top. // provider's icon + name up top.
@@ -125,7 +131,11 @@ fun PrimarySelectionCardGeneric(
item { item {
HeadlineText( HeadlineText(
text = stringResource( text = stringResource(
R.string.get_dialog_title_choose_option_for, if (totalEntriesCount == 1) {
R.string.get_dialog_title_use_info_on
} else {
R.string.get_dialog_title_choose_option_for
},
requestDisplayInfo.appName requestDisplayInfo.appName
), ),
) )
@@ -134,7 +144,6 @@ fun PrimarySelectionCardGeneric(
item { item {
CredentialContainerCard { CredentialContainerCard {
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) { Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
// Show max 4 entries in this primary page
sortedUserNameToCredentialEntryList.forEach { sortedUserNameToCredentialEntryList.forEach {
// TODO(b/275375861): fallback UI merges entries by account names. // TODO(b/275375861): fallback UI merges entries by account names.
// Need a strategy to be able to show all entries. // Need a strategy to be able to show all entries.
@@ -147,6 +156,19 @@ fun PrimarySelectionCardGeneric(
} }
} }
} }
item { Divider(thickness = 24.dp, color = Color.Transparent) }
item {
if (totalEntriesCount == 1) {
CtaButtonRow(
rightButton = {
ConfirmButton(
stringResource(R.string.get_dialog_button_label_continue),
onClick = onConfirm
)
}
)
}
}
} }
onLog(GetCredentialEvent.CREDMAN_GET_CRED_PRIMARY_SELECTION_CARD) onLog(GetCredentialEvent.CREDMAN_GET_CRED_PRIMARY_SELECTION_CARD)
} }