Loading packages/CredentialManager/wear/src/com/android/credentialmanager/ui/components/CredentialsScreenChip.kt +48 −50 Original line number Diff line number Diff line Loading @@ -48,44 +48,13 @@ import com.android.credentialmanager.model.get.AuthenticationEntryInfo /* Used as credential suggestion or user action chip. */ @Composable fun CredentialsScreenChip( label: String, primaryText: @Composable () -> Unit, secondaryText: (@Composable () -> Unit)? = null, onClick: () -> Unit, secondaryLabel: String? = null, icon: Drawable? = null, isAuthenticationEntryLocked: Boolean? = null, textAlign: TextAlign = TextAlign.Center, modifier: Modifier = Modifier, colors: ChipColors = ChipDefaults.secondaryChipColors() ) { return CredentialsScreenChip( onClick, text = { WearButtonText( text = label, textAlign = textAlign, maxLines = 2 ) }, secondaryLabel, icon, isAuthenticationEntryLocked, modifier, colors ) } /* Used as credential suggestion or user action chip. */ @Composable fun CredentialsScreenChip( onClick: () -> Unit, text: @Composable () -> Unit, secondaryLabel: String? = null, icon: Drawable? = null, isAuthenticationEntryLocked: Boolean? = null, modifier: Modifier = Modifier, colors: ChipColors = ChipDefaults.primaryChipColors(), ) { val labelParam: (@Composable RowScope.() -> Unit) = { Loading @@ -94,19 +63,15 @@ fun CredentialsScreenChip( horizontalArrangement = Arrangement.Center } Row(horizontalArrangement = horizontalArrangement, modifier = modifier.fillMaxWidth()) { text() primaryText() } } val secondaryLabelParam: (@Composable RowScope.() -> Unit)? = secondaryLabel?.let { secondaryText?.let { { Row { WearSecondaryLabel( text = secondaryLabel, color = WearMaterialTheme.colors.onSurfaceVariant ) secondaryText() if (isAuthenticationEntryLocked != null) { if (isAuthenticationEntryLocked) { Icon( Loading Loading @@ -156,9 +121,19 @@ fun CredentialsScreenChip( @Composable fun CredentialsScreenChipPreview() { CredentialsScreenChip( label = "Elisa Beckett", primaryText = { WearButtonText( text = "Elisa Beckett", textAlign = TextAlign.Start, ) }, onClick = { }, secondaryLabel = "beckett_bakery@gmail.com", secondaryText = { WearSecondaryLabel( text = "beckett_bakery@gmail.com", color = WearMaterialTheme.colors.onSurfaceVariant ) }, icon = null, ) } Loading @@ -166,8 +141,13 @@ fun CredentialsScreenChipPreview() { @Composable fun SignInOptionsChip(onClick: () -> Unit) { CredentialsScreenChip( label = stringResource(R.string.dialog_sign_in_options_button), textAlign = TextAlign.Start, primaryText = { WearButtonText( text = stringResource(R.string.dialog_sign_in_options_button), textAlign = TextAlign.Center, maxLines = 2 ) }, onClick = onClick, ) } Loading @@ -182,7 +162,7 @@ fun SignInOptionsChipPreview() { fun ContinueChip(onClick: () -> Unit) { CredentialsScreenChip( onClick = onClick, text = { primaryText = { WearButtonText( text = stringResource(R.string.dialog_continue_button), textAlign = TextAlign.Center, Loading @@ -202,14 +182,21 @@ fun ContinueChipPreview() { @Composable fun DismissChip(onClick: () -> Unit) { CredentialsScreenChip( label = stringResource(R.string.dialog_dismiss_button), primaryText = { WearButtonText( text = stringResource(R.string.dialog_dismiss_button), textAlign = TextAlign.Center, maxLines = 2 ) }, onClick = onClick, ) } @Composable fun LockedProviderChip( authenticationEntryInfo: AuthenticationEntryInfo, onClick: () -> Unit secondaryMaxLines: Int = 1, onClick: () -> Unit, ) { val secondaryLabel = stringResource( if (authenticationEntryInfo.isUnlockedAndEmpty) Loading @@ -218,10 +205,21 @@ fun LockedProviderChip( ) CredentialsScreenChip( label = authenticationEntryInfo.title, icon = authenticationEntryInfo.icon, secondaryLabel = secondaryLabel, primaryText = { WearButtonText( text = authenticationEntryInfo.title, textAlign = TextAlign.Start, maxLines = 2, ) }, icon = authenticationEntryInfo.icon, secondaryText = { WearSecondaryLabel( text = secondaryLabel, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = secondaryMaxLines ) }, isAuthenticationEntryLocked = !authenticationEntryInfo.isUnlockedAndEmpty, onClick = onClick, ) Loading packages/CredentialManager/wear/src/com/android/credentialmanager/ui/components/Texts.kt +4 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.credentialmanager.common.ui.components import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.Text Loading Loading @@ -93,15 +92,16 @@ fun WearButtonText( fun WearSecondaryLabel( text: String, color: Color = WearMaterialTheme.colors.onSurface, modifier: Modifier = Modifier modifier: Modifier = Modifier, maxLines: Int = 1, ) { Text( modifier = modifier.fillMaxSize(), modifier = modifier.wrapContentSize(), text = text, color = color, style = WearMaterialTheme.typography.caption1, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Start, maxLines = 1, maxLines = maxLines, ) } packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/multiple/MultiCredentialsFlattenScreen.kt +39 −9 Original line number Diff line number Diff line Loading @@ -24,13 +24,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.Alignment import com.android.credentialmanager.CredentialSelectorUiState.Get.MultipleEntry import com.android.credentialmanager.FlowEngine import com.android.credentialmanager.R import com.android.credentialmanager.common.ui.components.WearButtonText import com.android.credentialmanager.ui.components.LockedProviderChip import com.android.credentialmanager.common.ui.components.WearSecondaryLabel import com.android.credentialmanager.model.get.CredentialEntryInfo import com.android.credentialmanager.ui.components.CredentialsScreenChipSpacer Loading @@ -38,6 +38,8 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.rememberColumnState import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults import androidx.compose.ui.text.style.TextAlign import androidx.wear.compose.material.MaterialTheme as WearMaterialTheme /** * Screen that shows multiple credentials to select from, grouped by accounts Loading Loading @@ -69,6 +71,7 @@ fun MultiCredentialsFlattenScreen( text = stringResource(R.string.sign_in_options_title), textAlign = TextAlign.Center, modifier = Modifier.weight(0.854f).fillMaxSize(), maxLines = 2, ) Spacer(Modifier.weight(0.073f)) // 7.3% side margin } Loading @@ -94,19 +97,39 @@ fun MultiCredentialsFlattenScreen( userNameEntries.sortedCredentialEntryList.forEach { credential: CredentialEntryInfo -> item { CredentialsScreenChip( label = credential.userName, primaryText = { WearButtonText( text = credential.userName, textAlign = TextAlign.Start, maxLines = 2, ) }, onClick = { selectEntry(credential, false) }, secondaryLabel = credential.credentialTypeDisplayName.ifEmpty { secondaryText = { WearSecondaryLabel( text = credential.credentialTypeDisplayName.ifEmpty { credential.providerDisplayName }, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = 2 ) }, icon = credential.icon, textAlign = TextAlign.Start ) CredentialsScreenChipSpacer() } } credentialSelectorUiState.authenticationEntryList.forEach { authenticationEntryInfo -> item { LockedProviderChip(authenticationEntryInfo, secondaryMaxLines = 2) { selectEntry(authenticationEntryInfo, false) } CredentialsScreenChipSpacer() } } } if (credentialSelectorUiState.actionEntryList.isNotEmpty()) { Loading @@ -120,7 +143,8 @@ fun MultiCredentialsFlattenScreen( bottom = 4.dp, start = 0.dp, end = 0.dp ).fillMaxWidth(0.87f) ).fillMaxWidth(0.87f), maxLines = 2 ) Spacer(Modifier.weight(0.0624f)) // 6.24% side margin } Loading @@ -128,9 +152,15 @@ fun MultiCredentialsFlattenScreen( credentialSelectorUiState.actionEntryList.forEach { actionEntry -> item { CredentialsScreenChip( label = actionEntry.title, primaryText = { WearButtonText( text = actionEntry.title, textAlign = TextAlign.Start, maxLines = 2 ) }, onClick = { selectEntry(actionEntry, false) }, secondaryLabel = null, secondaryText = null, icon = actionEntry.icon, ) CredentialsScreenChipSpacer() Loading packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/multiple/MultiCredentialsFoldScreen.kt +20 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.credentialmanager.ui.screens.multiple import androidx.compose.foundation.layout.Row import androidx.compose.ui.text.style.TextAlign import androidx.compose.foundation.layout.fillMaxSize import com.android.credentialmanager.R import androidx.compose.ui.res.stringResource Loading @@ -40,6 +39,10 @@ import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.android.credentialmanager.model.CredentialType import com.android.credentialmanager.ui.components.BottomSpacer import com.android.credentialmanager.ui.components.CredentialsScreenChipSpacer import com.android.credentialmanager.common.ui.components.WearButtonText import com.android.credentialmanager.common.ui.components.WearSecondaryLabel import androidx.compose.ui.text.style.TextAlign import androidx.wear.compose.material.MaterialTheme as WearMaterialTheme /** * Screen that shows multiple credentials to select from. Loading Loading @@ -82,14 +85,25 @@ fun MultiCredentialsFoldScreen( credentials.forEach { credential: CredentialEntryInfo -> item { CredentialsScreenChip( label = credential.userName, primaryText = { WearButtonText( text = credential.userName, textAlign = TextAlign.Start, maxLines = 2 ) }, onClick = { selectEntry(credential, false) }, secondaryLabel = credential.credentialTypeDisplayName.ifEmpty { secondaryText = { WearSecondaryLabel( text = credential.credentialTypeDisplayName.ifEmpty { credential.providerDisplayName }, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = 1 // See b/359649621 for context ) }, icon = credential.icon, textAlign = TextAlign.Start ) CredentialsScreenChipSpacer() } Loading Loading
packages/CredentialManager/wear/src/com/android/credentialmanager/ui/components/CredentialsScreenChip.kt +48 −50 Original line number Diff line number Diff line Loading @@ -48,44 +48,13 @@ import com.android.credentialmanager.model.get.AuthenticationEntryInfo /* Used as credential suggestion or user action chip. */ @Composable fun CredentialsScreenChip( label: String, primaryText: @Composable () -> Unit, secondaryText: (@Composable () -> Unit)? = null, onClick: () -> Unit, secondaryLabel: String? = null, icon: Drawable? = null, isAuthenticationEntryLocked: Boolean? = null, textAlign: TextAlign = TextAlign.Center, modifier: Modifier = Modifier, colors: ChipColors = ChipDefaults.secondaryChipColors() ) { return CredentialsScreenChip( onClick, text = { WearButtonText( text = label, textAlign = textAlign, maxLines = 2 ) }, secondaryLabel, icon, isAuthenticationEntryLocked, modifier, colors ) } /* Used as credential suggestion or user action chip. */ @Composable fun CredentialsScreenChip( onClick: () -> Unit, text: @Composable () -> Unit, secondaryLabel: String? = null, icon: Drawable? = null, isAuthenticationEntryLocked: Boolean? = null, modifier: Modifier = Modifier, colors: ChipColors = ChipDefaults.primaryChipColors(), ) { val labelParam: (@Composable RowScope.() -> Unit) = { Loading @@ -94,19 +63,15 @@ fun CredentialsScreenChip( horizontalArrangement = Arrangement.Center } Row(horizontalArrangement = horizontalArrangement, modifier = modifier.fillMaxWidth()) { text() primaryText() } } val secondaryLabelParam: (@Composable RowScope.() -> Unit)? = secondaryLabel?.let { secondaryText?.let { { Row { WearSecondaryLabel( text = secondaryLabel, color = WearMaterialTheme.colors.onSurfaceVariant ) secondaryText() if (isAuthenticationEntryLocked != null) { if (isAuthenticationEntryLocked) { Icon( Loading Loading @@ -156,9 +121,19 @@ fun CredentialsScreenChip( @Composable fun CredentialsScreenChipPreview() { CredentialsScreenChip( label = "Elisa Beckett", primaryText = { WearButtonText( text = "Elisa Beckett", textAlign = TextAlign.Start, ) }, onClick = { }, secondaryLabel = "beckett_bakery@gmail.com", secondaryText = { WearSecondaryLabel( text = "beckett_bakery@gmail.com", color = WearMaterialTheme.colors.onSurfaceVariant ) }, icon = null, ) } Loading @@ -166,8 +141,13 @@ fun CredentialsScreenChipPreview() { @Composable fun SignInOptionsChip(onClick: () -> Unit) { CredentialsScreenChip( label = stringResource(R.string.dialog_sign_in_options_button), textAlign = TextAlign.Start, primaryText = { WearButtonText( text = stringResource(R.string.dialog_sign_in_options_button), textAlign = TextAlign.Center, maxLines = 2 ) }, onClick = onClick, ) } Loading @@ -182,7 +162,7 @@ fun SignInOptionsChipPreview() { fun ContinueChip(onClick: () -> Unit) { CredentialsScreenChip( onClick = onClick, text = { primaryText = { WearButtonText( text = stringResource(R.string.dialog_continue_button), textAlign = TextAlign.Center, Loading @@ -202,14 +182,21 @@ fun ContinueChipPreview() { @Composable fun DismissChip(onClick: () -> Unit) { CredentialsScreenChip( label = stringResource(R.string.dialog_dismiss_button), primaryText = { WearButtonText( text = stringResource(R.string.dialog_dismiss_button), textAlign = TextAlign.Center, maxLines = 2 ) }, onClick = onClick, ) } @Composable fun LockedProviderChip( authenticationEntryInfo: AuthenticationEntryInfo, onClick: () -> Unit secondaryMaxLines: Int = 1, onClick: () -> Unit, ) { val secondaryLabel = stringResource( if (authenticationEntryInfo.isUnlockedAndEmpty) Loading @@ -218,10 +205,21 @@ fun LockedProviderChip( ) CredentialsScreenChip( label = authenticationEntryInfo.title, icon = authenticationEntryInfo.icon, secondaryLabel = secondaryLabel, primaryText = { WearButtonText( text = authenticationEntryInfo.title, textAlign = TextAlign.Start, maxLines = 2, ) }, icon = authenticationEntryInfo.icon, secondaryText = { WearSecondaryLabel( text = secondaryLabel, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = secondaryMaxLines ) }, isAuthenticationEntryLocked = !authenticationEntryInfo.isUnlockedAndEmpty, onClick = onClick, ) Loading
packages/CredentialManager/wear/src/com/android/credentialmanager/ui/components/Texts.kt +4 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.credentialmanager.common.ui.components import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.Text Loading Loading @@ -93,15 +92,16 @@ fun WearButtonText( fun WearSecondaryLabel( text: String, color: Color = WearMaterialTheme.colors.onSurface, modifier: Modifier = Modifier modifier: Modifier = Modifier, maxLines: Int = 1, ) { Text( modifier = modifier.fillMaxSize(), modifier = modifier.wrapContentSize(), text = text, color = color, style = WearMaterialTheme.typography.caption1, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Start, maxLines = 1, maxLines = maxLines, ) }
packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/multiple/MultiCredentialsFlattenScreen.kt +39 −9 Original line number Diff line number Diff line Loading @@ -24,13 +24,13 @@ import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.Alignment import com.android.credentialmanager.CredentialSelectorUiState.Get.MultipleEntry import com.android.credentialmanager.FlowEngine import com.android.credentialmanager.R import com.android.credentialmanager.common.ui.components.WearButtonText import com.android.credentialmanager.ui.components.LockedProviderChip import com.android.credentialmanager.common.ui.components.WearSecondaryLabel import com.android.credentialmanager.model.get.CredentialEntryInfo import com.android.credentialmanager.ui.components.CredentialsScreenChipSpacer Loading @@ -38,6 +38,8 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.rememberColumnState import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults import androidx.compose.ui.text.style.TextAlign import androidx.wear.compose.material.MaterialTheme as WearMaterialTheme /** * Screen that shows multiple credentials to select from, grouped by accounts Loading Loading @@ -69,6 +71,7 @@ fun MultiCredentialsFlattenScreen( text = stringResource(R.string.sign_in_options_title), textAlign = TextAlign.Center, modifier = Modifier.weight(0.854f).fillMaxSize(), maxLines = 2, ) Spacer(Modifier.weight(0.073f)) // 7.3% side margin } Loading @@ -94,19 +97,39 @@ fun MultiCredentialsFlattenScreen( userNameEntries.sortedCredentialEntryList.forEach { credential: CredentialEntryInfo -> item { CredentialsScreenChip( label = credential.userName, primaryText = { WearButtonText( text = credential.userName, textAlign = TextAlign.Start, maxLines = 2, ) }, onClick = { selectEntry(credential, false) }, secondaryLabel = credential.credentialTypeDisplayName.ifEmpty { secondaryText = { WearSecondaryLabel( text = credential.credentialTypeDisplayName.ifEmpty { credential.providerDisplayName }, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = 2 ) }, icon = credential.icon, textAlign = TextAlign.Start ) CredentialsScreenChipSpacer() } } credentialSelectorUiState.authenticationEntryList.forEach { authenticationEntryInfo -> item { LockedProviderChip(authenticationEntryInfo, secondaryMaxLines = 2) { selectEntry(authenticationEntryInfo, false) } CredentialsScreenChipSpacer() } } } if (credentialSelectorUiState.actionEntryList.isNotEmpty()) { Loading @@ -120,7 +143,8 @@ fun MultiCredentialsFlattenScreen( bottom = 4.dp, start = 0.dp, end = 0.dp ).fillMaxWidth(0.87f) ).fillMaxWidth(0.87f), maxLines = 2 ) Spacer(Modifier.weight(0.0624f)) // 6.24% side margin } Loading @@ -128,9 +152,15 @@ fun MultiCredentialsFlattenScreen( credentialSelectorUiState.actionEntryList.forEach { actionEntry -> item { CredentialsScreenChip( label = actionEntry.title, primaryText = { WearButtonText( text = actionEntry.title, textAlign = TextAlign.Start, maxLines = 2 ) }, onClick = { selectEntry(actionEntry, false) }, secondaryLabel = null, secondaryText = null, icon = actionEntry.icon, ) CredentialsScreenChipSpacer() Loading
packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/multiple/MultiCredentialsFoldScreen.kt +20 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.credentialmanager.ui.screens.multiple import androidx.compose.foundation.layout.Row import androidx.compose.ui.text.style.TextAlign import androidx.compose.foundation.layout.fillMaxSize import com.android.credentialmanager.R import androidx.compose.ui.res.stringResource Loading @@ -40,6 +39,10 @@ import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.android.credentialmanager.model.CredentialType import com.android.credentialmanager.ui.components.BottomSpacer import com.android.credentialmanager.ui.components.CredentialsScreenChipSpacer import com.android.credentialmanager.common.ui.components.WearButtonText import com.android.credentialmanager.common.ui.components.WearSecondaryLabel import androidx.compose.ui.text.style.TextAlign import androidx.wear.compose.material.MaterialTheme as WearMaterialTheme /** * Screen that shows multiple credentials to select from. Loading Loading @@ -82,14 +85,25 @@ fun MultiCredentialsFoldScreen( credentials.forEach { credential: CredentialEntryInfo -> item { CredentialsScreenChip( label = credential.userName, primaryText = { WearButtonText( text = credential.userName, textAlign = TextAlign.Start, maxLines = 2 ) }, onClick = { selectEntry(credential, false) }, secondaryLabel = credential.credentialTypeDisplayName.ifEmpty { secondaryText = { WearSecondaryLabel( text = credential.credentialTypeDisplayName.ifEmpty { credential.providerDisplayName }, color = WearMaterialTheme.colors.onSurfaceVariant, maxLines = 1 // See b/359649621 for context ) }, icon = credential.icon, textAlign = TextAlign.Start ) CredentialsScreenChipSpacer() } Loading