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

Commit a2d9a439 authored by harinirajan's avatar harinirajan
Browse files

Make multi credentials fold screen title dynamic based on credential type of available credentials.

Test: Manual. See go/credential-selector-ui
Bug: 324291832
Change-Id: I005282a42183cd4699d0a725b78ab190e248c9e7
parent 83b185c4
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@
  <string name="dialog_sign_in_options_button">Sign-in Options</string>
  <!-- Title for multiple credentials folded screen. [CHAR LIMIT=NONE] -->
  <string name="sign_in_options_title">Sign-in Options</string>
  <!-- Title for multiple credentials flattened screen. [CHAR LIMIT=NONE] -->
  <!-- Title for multiple credentials screen. [CHAR LIMIT=NONE] -->
  <string name="choose_sign_in_title">Choose a sign in</string>
  <!-- Title for multiple credentials screen with only passkeys. [CHAR LIMIT=NONE] -->
  <string name="choose_passkey_title">Choose passkey</string>
  <!-- Title for multiple credentials screen with only passwords. [CHAR LIMIT=NONE] -->
  <string name="choose_password_title">Choose password</string>
</resources>
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ class CredentialSelectorViewModel @Inject constructor(

sealed class CredentialSelectorUiState {
    data object Idle : CredentialSelectorUiState()
    sealed class Get() : CredentialSelectorUiState() {
    sealed class Get : CredentialSelectorUiState() {
        data class SingleEntry(val entry: CredentialEntryInfo) : Get()
        data class SingleEntryPerAccount(val sortedEntries: List<CredentialEntryInfo>) : Get()
        data class MultipleEntry(
+12 −4
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.credentialmanager.ui.components.SignInOptionsChip
import com.google.android.horologist.annotations.ExperimentalHorologistApi
import com.google.android.horologist.compose.layout.ScalingLazyColumn
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
import com.android.credentialmanager.model.CredentialType

/**
 * Screen that shows multiple credentials to select from.
@@ -113,17 +114,25 @@ fun MultiCredentialsFoldScreen(
        columnState = columnState,
        modifier = modifier.fillMaxSize(),
    ) {
        // flatten all credentials into one
        val credentials = state.accounts.flatMap { it.sortedCredentialEntryList }
        item {
            var title = stringResource(R.string.choose_sign_in_title)
            if (credentials.all{ it.credentialType == CredentialType.PASSKEY }) {
                title = stringResource(R.string.choose_passkey_title)
            } else if (credentials.all { it.credentialType == CredentialType.PASSWORD }) {
                title = stringResource(R.string.choose_password_title)
            }

            SignInHeader(
                icon = screenIcon,
                title = stringResource(R.string.choose_sign_in_title),
                title = title,
                modifier = Modifier
                    .padding(top = 6.dp),
            )
        }

        state.accounts.forEach {
            it.sortedCredentialEntryList.forEach { credential: CredentialEntryInfo ->
        credentials.forEach { credential: CredentialEntryInfo ->
                item {
                    CredentialsScreenChip(
                        label = credential.userName,
@@ -133,7 +142,6 @@ fun MultiCredentialsFoldScreen(
                    )
                }
            }
        }
        item { SignInOptionsChip(onSignInOptionsClicked) }
        item { DismissChip(onCancelClicked) }
    }