[CredManUi] Add account name to the default provider dialog.

Bug: 271340033
Test: manual (see bug for screenshot)
Change-Id: I53848977115d925e1f3af04d7f08953a7130763d
This commit is contained in:
Helen Qin
2023-03-03 20:13:01 +00:00
parent c2634f8d68
commit 65b28fd053
4 changed files with 36 additions and 15 deletions

View File

@@ -67,9 +67,8 @@
<string name="create_passkey_in_other_device_title">Create passkey in another device?</string>
<!-- This appears as the title of the modal bottom sheet for users to confirm whether they should use the selected provider as default or not. [CHAR LIMIT=200] -->
<string name="use_provider_for_all_title">Use <xliff:g id="providerInfoDisplayName" example="Google Password Manager">%1$s</xliff:g> for all your sign-ins?</string>
<!-- TODO: Check the wording here. -->
<!-- This appears as the description body of the modal bottom sheet for users to confirm whether they should use the selected provider as default or not. [CHAR LIMIT=200] -->
<string name="use_provider_for_all_description">This password manager will store your passwords and passkeys to help you easily sign in</string>
<!-- This appears as the description body of the modal bottom sheet for users to confirm whether they should use the selected provider as default or not. [CHAR LIMIT=300] -->
<string name="use_provider_for_all_description">This password manager for <xliff:g id="username" example="becket@gmail.com">%1$s</xliff:g> will store your passwords and passkeys to help you easily sign in</string>
<!-- This is a label for a button that sets this password manager as the default. [CHAR LIMIT=20] -->
<string name="set_as_default">Set as default</string>
<!-- This is a label for a button that makes this password manager be used just in this specific case. [CHAR LIMIT=20] -->

View File

@@ -130,6 +130,11 @@ class CredentialSelectorViewModel(
onInternalError()
}
fun onIllegalUiState(errorMessage: String) {
Log.w(Constants.LOG_TAG, errorMessage)
onInternalError()
}
private fun onInternalError() {
Log.w(Constants.LOG_TAG, "UI closed due to illegal internal state")
credManRepo.onParsingFailureCancel()

View File

@@ -120,11 +120,20 @@ fun CreateCredentialScreen(
viewModel::createFlowOnDisabledProvidersSelected,
onRemoteEntrySelected = viewModel::createFlowOnEntrySelected,
)
CreateScreenState.MORE_OPTIONS_ROW_INTRO -> MoreOptionsRowIntroCard(
providerInfo = createCredentialUiState.activeEntry?.activeProvider!!,
onChangeDefaultSelected = viewModel::createFlowOnChangeDefaultSelected,
onUseOnceSelected = viewModel::createFlowOnUseOnceSelected,
)
CreateScreenState.MORE_OPTIONS_ROW_INTRO -> {
if (createCredentialUiState.activeEntry == null) {
viewModel.onIllegalUiState("Expect active entry to be non-null" +
" upon default provider dialog.")
} else {
MoreOptionsRowIntroCard(
selectedEntry = createCredentialUiState.activeEntry,
onIllegalScreenState = viewModel::onIllegalUiState,
onChangeDefaultSelected =
viewModel::createFlowOnChangeDefaultSelected,
onUseOnceSelected = viewModel::createFlowOnUseOnceSelected,
)
}
}
CreateScreenState.EXTERNAL_ONLY_SELECTION -> ExternalOnlySelectionCard(
requestDisplayInfo = createCredentialUiState.requestDisplayInfo,
activeRemoteEntry =
@@ -331,7 +340,7 @@ fun MoreOptionsSelectionCard(
)
}) {
item { Divider(thickness = 8.dp, color = Color.Transparent) } // Top app bar has a 8dp
// bottom padding already
// bottom padding already
item {
CredentialContainerCard {
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
@@ -376,23 +385,31 @@ fun MoreOptionsSelectionCard(
@Composable
fun MoreOptionsRowIntroCard(
providerInfo: EnabledProviderInfo,
selectedEntry: ActiveEntry,
onIllegalScreenState: (String) -> Unit,
onChangeDefaultSelected: () -> Unit,
onUseOnceSelected: () -> Unit,
) {
val entryInfo = selectedEntry.activeEntryInfo
if (entryInfo !is CreateOptionInfo) {
onIllegalScreenState("Encountered unexpected type of entry during the default provider" +
" dialog: ${entryInfo::class}")
return
}
SheetContainerCard {
item { HeadlineIcon(imageVector = Icons.Outlined.NewReleases) }
item { Divider(thickness = 24.dp, color = Color.Transparent) }
item {
HeadlineText(
text = stringResource(
R.string.use_provider_for_all_title,
providerInfo.displayName
)
R.string.use_provider_for_all_title, selectedEntry.activeProvider.displayName)
)
}
item { Divider(thickness = 24.dp, color = Color.Transparent) }
item { BodyMediumText(text = stringResource(R.string.use_provider_for_all_description)) }
item {
BodyMediumText(text = stringResource(
R.string.use_provider_for_all_description, entryInfo.userProviderDisplayName))
}
item {
CtaButtonRow(
leftButton = {

View File

@@ -69,7 +69,7 @@ class CreateOptionInfo(
entrySubkey: String,
pendingIntent: PendingIntent?,
fillInIntent: Intent?,
val userProviderDisplayName: String?,
val userProviderDisplayName: String,
val profileIcon: Drawable?,
val passwordCount: Int?,
val passkeyCount: Int?,