Loading packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt +10 −6 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ fun Entry( passwordValue: String? = null, /** If true, draws a trailing lock icon. */ isLockedAuthEntry: Boolean = false, enforceOneLine: Boolean = false, ) { val iconPadding = Modifier.wrapContentSize().padding( // Horizontal padding should be 16dp, but the suggestion chip itself Loading @@ -93,10 +94,12 @@ fun Entry( // has 8dp horizontal elements padding horizontal = 8.dp, vertical = 16.dp, ), // Make sure the trailing icon and text column are centered vertically. verticalAlignment = Alignment.CenterVertically, ) { Column(modifier = Modifier.wrapContentSize()) { SmallTitleText(entryHeadlineText) // Apply weight so that the trailing icon can always show. Column(modifier = Modifier.wrapContentHeight().fillMaxWidth().weight(1f)) { SmallTitleText(text = entryHeadlineText, enforceOneLine = enforceOneLine) if (passwordValue != null) { Row( modifier = Modifier.fillMaxWidth(), Loading @@ -113,7 +116,8 @@ fun Entry( ).text.text ) } BodySmallText(displayedPassword.value) BodySmallText( text = displayedPassword.value, enforceOneLine = enforceOneLine) ToggleVisibilityButton( modifier = Modifier.padding(start = 12.dp, top = 5.dp).size(24.dp), onToggle = { Loading @@ -128,14 +132,14 @@ fun Entry( ) } } else if (entrySecondLineText != null) { BodySmallText(entrySecondLineText) BodySmallText(text = entrySecondLineText, enforceOneLine = enforceOneLine) } if (entryThirdLineText != null) { BodySmallText(entryThirdLineText) BodySmallText(text = entryThirdLineText, enforceOneLine = enforceOneLine) } } if (isLockedAuthEntry) { Box(modifier = Modifier.wrapContentSize()) { Box(modifier = Modifier.wrapContentSize().padding(start = 16.dp)) { Icon( imageVector = Icons.Outlined.Lock, // Decorative purpose only. Loading packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt +7 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow /** * The headline for a screen. E.g. "Create a passkey for X", "Choose a saved sign-in for X". Loading Loading @@ -57,12 +58,14 @@ fun BodyMediumText(text: String, modifier: Modifier = Modifier) { * Body-small typography; on-surface-variant color. */ @Composable fun BodySmallText(text: String, modifier: Modifier = Modifier) { fun BodySmallText(text: String, modifier: Modifier = Modifier, enforceOneLine: Boolean = false) { Text( modifier = modifier.wrapContentSize(), text = text, color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodySmall, overflow = TextOverflow.Ellipsis, maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE ) } Loading @@ -83,12 +86,14 @@ fun LargeTitleText(text: String, modifier: Modifier = Modifier) { * Title-small typography; on-surface color. */ @Composable fun SmallTitleText(text: String, modifier: Modifier = Modifier) { fun SmallTitleText(text: String, modifier: Modifier = Modifier, enforceOneLine: Boolean = false) { Text( modifier = modifier.wrapContentSize(), text = text, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.titleSmall, overflow = TextOverflow.Ellipsis, maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE ) } Loading packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt +1 −0 Original line number Diff line number Diff line Loading @@ -637,6 +637,7 @@ fun PrimaryCreateOptionRow( // This subtitle would never be null for create password requestDisplayInfo.subtitle ?: "" else null, enforceOneLine = true, ) } Loading packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt +9 −0 Original line number Diff line number Diff line Loading @@ -182,12 +182,14 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } authenticationEntryList.forEach { AuthenticationEntryRow( authenticationEntryInfo = it, onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } else if (usernameForCredentialSize < 4) { Loading @@ -195,12 +197,14 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } authenticationEntryList.take(4 - usernameForCredentialSize).forEach { AuthenticationEntryRow( authenticationEntryInfo = it, onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } else { Loading @@ -208,6 +212,7 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } Loading Loading @@ -402,6 +407,7 @@ fun PerUserNameCredentials( fun CredentialEntryRow( credentialEntryInfo: CredentialEntryInfo, onEntrySelected: (BaseEntry) -> Unit, enforceOneLine: Boolean = false, ) { Entry( onClick = { onEntrySelected(credentialEntryInfo) }, Loading @@ -426,6 +432,7 @@ fun CredentialEntryRow( separator = stringResource(R.string.get_dialog_sign_in_type_username_separator) ) }, enforceOneLine = enforceOneLine, ) } Loading @@ -433,6 +440,7 @@ fun CredentialEntryRow( fun AuthenticationEntryRow( authenticationEntryInfo: AuthenticationEntryInfo, onEntrySelected: (BaseEntry) -> Unit, enforceOneLine: Boolean = false, ) { Entry( onClick = { onEntrySelected(authenticationEntryInfo) }, Loading @@ -444,6 +452,7 @@ fun AuthenticationEntryRow( else R.string.locked_credential_entry_label_subtext_tap_to_unlock ), isLockedAuthEntry = !authenticationEntryInfo.isUnlockedAndEmpty, enforceOneLine = enforceOneLine, ) } Loading Loading
packages/CredentialManager/src/com/android/credentialmanager/common/ui/Entry.kt +10 −6 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ fun Entry( passwordValue: String? = null, /** If true, draws a trailing lock icon. */ isLockedAuthEntry: Boolean = false, enforceOneLine: Boolean = false, ) { val iconPadding = Modifier.wrapContentSize().padding( // Horizontal padding should be 16dp, but the suggestion chip itself Loading @@ -93,10 +94,12 @@ fun Entry( // has 8dp horizontal elements padding horizontal = 8.dp, vertical = 16.dp, ), // Make sure the trailing icon and text column are centered vertically. verticalAlignment = Alignment.CenterVertically, ) { Column(modifier = Modifier.wrapContentSize()) { SmallTitleText(entryHeadlineText) // Apply weight so that the trailing icon can always show. Column(modifier = Modifier.wrapContentHeight().fillMaxWidth().weight(1f)) { SmallTitleText(text = entryHeadlineText, enforceOneLine = enforceOneLine) if (passwordValue != null) { Row( modifier = Modifier.fillMaxWidth(), Loading @@ -113,7 +116,8 @@ fun Entry( ).text.text ) } BodySmallText(displayedPassword.value) BodySmallText( text = displayedPassword.value, enforceOneLine = enforceOneLine) ToggleVisibilityButton( modifier = Modifier.padding(start = 12.dp, top = 5.dp).size(24.dp), onToggle = { Loading @@ -128,14 +132,14 @@ fun Entry( ) } } else if (entrySecondLineText != null) { BodySmallText(entrySecondLineText) BodySmallText(text = entrySecondLineText, enforceOneLine = enforceOneLine) } if (entryThirdLineText != null) { BodySmallText(entryThirdLineText) BodySmallText(text = entryThirdLineText, enforceOneLine = enforceOneLine) } } if (isLockedAuthEntry) { Box(modifier = Modifier.wrapContentSize()) { Box(modifier = Modifier.wrapContentSize().padding(start = 16.dp)) { Icon( imageVector = Icons.Outlined.Lock, // Decorative purpose only. Loading
packages/CredentialManager/src/com/android/credentialmanager/common/ui/Texts.kt +7 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow /** * The headline for a screen. E.g. "Create a passkey for X", "Choose a saved sign-in for X". Loading Loading @@ -57,12 +58,14 @@ fun BodyMediumText(text: String, modifier: Modifier = Modifier) { * Body-small typography; on-surface-variant color. */ @Composable fun BodySmallText(text: String, modifier: Modifier = Modifier) { fun BodySmallText(text: String, modifier: Modifier = Modifier, enforceOneLine: Boolean = false) { Text( modifier = modifier.wrapContentSize(), text = text, color = MaterialTheme.colorScheme.onSurfaceVariant, style = MaterialTheme.typography.bodySmall, overflow = TextOverflow.Ellipsis, maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE ) } Loading @@ -83,12 +86,14 @@ fun LargeTitleText(text: String, modifier: Modifier = Modifier) { * Title-small typography; on-surface color. */ @Composable fun SmallTitleText(text: String, modifier: Modifier = Modifier) { fun SmallTitleText(text: String, modifier: Modifier = Modifier, enforceOneLine: Boolean = false) { Text( modifier = modifier.wrapContentSize(), text = text, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.titleSmall, overflow = TextOverflow.Ellipsis, maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE ) } Loading
packages/CredentialManager/src/com/android/credentialmanager/createflow/CreateCredentialComponents.kt +1 −0 Original line number Diff line number Diff line Loading @@ -637,6 +637,7 @@ fun PrimaryCreateOptionRow( // This subtitle would never be null for create password requestDisplayInfo.subtitle ?: "" else null, enforceOneLine = true, ) } Loading
packages/CredentialManager/src/com/android/credentialmanager/getflow/GetCredentialComponents.kt +9 −0 Original line number Diff line number Diff line Loading @@ -182,12 +182,14 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } authenticationEntryList.forEach { AuthenticationEntryRow( authenticationEntryInfo = it, onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } else if (usernameForCredentialSize < 4) { Loading @@ -195,12 +197,14 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } authenticationEntryList.take(4 - usernameForCredentialSize).forEach { AuthenticationEntryRow( authenticationEntryInfo = it, onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } else { Loading @@ -208,6 +212,7 @@ fun PrimarySelectionCard( CredentialEntryRow( credentialEntryInfo = it.sortedCredentialEntryList.first(), onEntrySelected = onEntrySelected, enforceOneLine = true, ) } } Loading Loading @@ -402,6 +407,7 @@ fun PerUserNameCredentials( fun CredentialEntryRow( credentialEntryInfo: CredentialEntryInfo, onEntrySelected: (BaseEntry) -> Unit, enforceOneLine: Boolean = false, ) { Entry( onClick = { onEntrySelected(credentialEntryInfo) }, Loading @@ -426,6 +432,7 @@ fun CredentialEntryRow( separator = stringResource(R.string.get_dialog_sign_in_type_username_separator) ) }, enforceOneLine = enforceOneLine, ) } Loading @@ -433,6 +440,7 @@ fun CredentialEntryRow( fun AuthenticationEntryRow( authenticationEntryInfo: AuthenticationEntryInfo, onEntrySelected: (BaseEntry) -> Unit, enforceOneLine: Boolean = false, ) { Entry( onClick = { onEntrySelected(authenticationEntryInfo) }, Loading @@ -444,6 +452,7 @@ fun AuthenticationEntryRow( else R.string.locked_credential_entry_label_subtext_tap_to_unlock ), isLockedAuthEntry = !authenticationEntryInfo.isUnlockedAndEmpty, enforceOneLine = enforceOneLine, ) } Loading