Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 164b7875 authored by Helen Qin's avatar Helen Qin Committed by Automerger Merge Worker
Browse files

Merge "[CredManUi] Truncate credential entry texts on the first page." into udc-dev am: 82348e00

parents a5882f39 82348e00
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -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
@@ -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(),
@@ -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 = {
@@ -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.
+7 −2
Original line number Diff line number Diff line
@@ -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".
@@ -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
    )
}

@@ -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
    )
}

+1 −0
Original line number Diff line number Diff line
@@ -637,6 +637,7 @@ fun PrimaryCreateOptionRow(
        // This subtitle would never be null for create password
            requestDisplayInfo.subtitle ?: ""
        else null,
        enforceOneLine = true,
    )
}

+9 −0
Original line number Diff line number Diff line
@@ -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) {
@@ -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 {
@@ -208,6 +212,7 @@ fun PrimarySelectionCard(
                            CredentialEntryRow(
                                credentialEntryInfo = it.sortedCredentialEntryList.first(),
                                onEntrySelected = onEntrySelected,
                                enforceOneLine = true,
                            )
                        }
                    }
@@ -402,6 +407,7 @@ fun PerUserNameCredentials(
fun CredentialEntryRow(
    credentialEntryInfo: CredentialEntryInfo,
    onEntrySelected: (BaseEntry) -> Unit,
    enforceOneLine: Boolean = false,
) {
    Entry(
        onClick = { onEntrySelected(credentialEntryInfo) },
@@ -426,6 +432,7 @@ fun CredentialEntryRow(
                separator = stringResource(R.string.get_dialog_sign_in_type_username_separator)
            )
        },
        enforceOneLine = enforceOneLine,
    )
}

@@ -433,6 +440,7 @@ fun CredentialEntryRow(
fun AuthenticationEntryRow(
    authenticationEntryInfo: AuthenticationEntryInfo,
    onEntrySelected: (BaseEntry) -> Unit,
    enforceOneLine: Boolean = false,
) {
    Entry(
        onClick = { onEntrySelected(authenticationEntryInfo) },
@@ -444,6 +452,7 @@ fun AuthenticationEntryRow(
            else R.string.locked_credential_entry_label_subtext_tap_to_unlock
        ),
        isLockedAuthEntry = !authenticationEntryInfo.isUnlockedAndEmpty,
        enforceOneLine = enforceOneLine,
    )
}