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

Commit 9e5f947f authored by Qinmei Du's avatar Qinmei Du Committed by Android (Google) Code Review
Browse files

Merge "Update the creation selection screen's strings and styles"

parents 2b830b1e d4b9ad63
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -10,10 +10,15 @@
  <string name="passkey_creation_intro_body">Use your fingerprint, face or screen lock to sign in with a unique passkey that can’t be forgotten or stolen. Learn more</string>
  <string name="choose_provider_title">Choose your default provider</string>
  <string name="choose_provider_body">This provider will store passkeys and passwords for you and help you easily autofill and sign in. Learn more</string>
  <string name="choose_create_option_title">Create a passkey at</string>
  <string name="choose_create_option_passkey_title">Create a passkey in <xliff:g id="providerInfoDisplayName">%1$s</xliff:g>?</string>
  <string name="choose_create_option_password_title">Save your password to <xliff:g id="providerInfoDisplayName">%1$s</xliff:g>?</string>
  <string name="choose_create_option_sign_in_title">Save your sign-in info to <xliff:g id="providerInfoDisplayName">%1$s</xliff:g>?</string>
  <string name="choose_sign_in_title">Use saved sign in</string>
  <string name="create_passkey_at">Create passkey at</string>
  <string name="use_provider_for_all_title">Use <xliff:g id="providerInfoName">%1$s</xliff:g> for all your sign-ins?</string>
  <string name="use_provider_for_all_title">Use <xliff:g id="providerInfoDisplayName">%1$s</xliff:g> for all your sign-ins?</string>
  <string name="set_as_default">Set as default</string>
  <string name="use_once">Use once</string>
  <string name="choose_create_option_description">You can use saved <xliff:g id="type">%1$s</xliff:g> on any device. It will be saved to <xliff:g id="providerInfoDisplayName">%2$s</xliff:g> for <xliff:g id="createInfoDisplayName">%3$s</xliff:g></string>
  <string name="more_options_title_multiple_options"><xliff:g id="providerInfoDisplayName">%1$s</xliff:g> for <xliff:g id="createInfoTitle">%2$s</xliff:g></string>
  <string name="more_options_title_one_option"><xliff:g id="providerInfoDisplayName">%1$s</xliff:g></string>
</resources>
 No newline at end of file
+14 −2
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.credentialmanager.createflow.CreateScreenState
import com.android.credentialmanager.createflow.RequestDisplayInfo
import com.android.credentialmanager.getflow.GetCredentialUiState
import com.android.credentialmanager.getflow.GetScreenState
import com.android.credentialmanager.jetpack.CredentialEntryUi.Companion.TYPE_PUBLIC_KEY_CREDENTIAL

// Consider repo per screen, similar to view model?
class CredentialManagerRepo(
@@ -83,17 +84,28 @@ class CredentialManagerRepo(

  fun getCredentialInitialUiState(): GetCredentialUiState {
    val providerList = GetFlowUtils.toProviderList(providerList, context)
    // TODO: covert from real requestInfo
    val requestDisplayInfo = com.android.credentialmanager.getflow.RequestDisplayInfo(
      "Elisa Beckett",
      "beckett-bakert@gmail.com",
      TYPE_PUBLIC_KEY_CREDENTIAL,
      "tribank")
    return GetCredentialUiState(
      providerList,
      GetScreenState.CREDENTIAL_SELECTION,
      requestDisplayInfo,
      providerList.first()
    )
  }

  fun createPasskeyInitialUiState(): CreatePasskeyUiState {
    val providerList = CreateFlowUtils.toProviderList(providerList, context)
    // TODO: covert from real requestInfo
    val requestDisplayInfo = RequestDisplayInfo(
      "Elisa Beckett", "beckett-bakert@gmail.com", "TYPE_CREATE")
      "Elisa Beckett",
      "beckett-bakert@gmail.com",
      TYPE_PUBLIC_KEY_CREDENTIAL,
      "tribank")
    return CreatePasskeyUiState(
      providers = providerList,
      currentScreenState = CreateScreenState.PASSKEY_INTRO,
@@ -182,7 +194,7 @@ class CredentialManagerRepo(
      Binder(),
      CreateCredentialRequest(
        // TODO: use the jetpack type and utils once defined.
        "androidx.credentials.TYPE_PUBLIC_KEY_CREDENTIAL",
        TYPE_PUBLIC_KEY_CREDENTIAL,
        data
      ),
      /*isFirstUsage=*/false,
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ class GetFlowUtils {
          // TODO: replace to extract from the service data structure when available
          icon = context.getDrawable(R.drawable.ic_passkey)!!,
          name = it.providerId,
          appDomainName = "tribank.us",
          displayName = it.providerDisplayName,
          credentialTypeIcon = context.getDrawable(R.drawable.ic_passkey)!!,
          credentialOptions = toCredentialOptionInfoList(it.credentialEntries, context)
        )
@@ -79,7 +79,7 @@ class CreateFlowUtils {
          // TODO: replace to extract from the service data structure when available
          icon = context.getDrawable(R.drawable.ic_passkey)!!,
          name = it.providerId,
          appDomainName = "tribank.us",
          displayName = it.providerDisplayName,
          credentialTypeIcon = context.getDrawable(R.drawable.ic_passkey)!!,
          createOptions = toCreationOptionInfoList(it.credentialEntries, context),
        )
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.graphics.drawable.Drawable
data class ProviderInfo(
  val icon: Drawable,
  val name: String,
  val appDomainName: String,
  val displayName: String,
  val credentialTypeIcon: Drawable,
  val createOptions: List<CreateOptionInfo>,
)
@@ -38,6 +38,7 @@ data class RequestDisplayInfo(
  val userName: String,
  val displayName: String,
  val type: String,
  val appDomainName: String,
)

/**
+39 −13
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import com.android.credentialmanager.R
import com.android.credentialmanager.jetpack.CredentialEntryUi.Companion.TYPE_PASSWORD_CREDENTIAL
import com.android.credentialmanager.jetpack.CredentialEntryUi.Companion.TYPE_PUBLIC_KEY_CREDENTIAL
import com.android.credentialmanager.ui.theme.Grey100
import com.android.credentialmanager.ui.theme.Shapes
import com.android.credentialmanager.ui.theme.Typography
@@ -72,6 +74,7 @@ fun CreatePasskeyScreen(
        CreateScreenState.CREATION_OPTION_SELECTION -> CreationSelectionCard(
          requestDisplayInfo = uiState.requestDisplayInfo,
          providerInfo = uiState.activeEntry?.activeProvider!!,
          createOptionInfo = uiState.activeEntry.activeCreateOptionInfo,
          onOptionSelected = {viewModel.onPrimaryCreateOptionInfoSelected()},
          onCancel = {viewModel.onCancel()},
          multiProvider = uiState.providers.size > 1,
@@ -294,7 +297,7 @@ fun MoreOptionsRowIntroCard(
  ) {
    Column() {
      Text(
        text = stringResource(R.string.use_provider_for_all_title, providerInfo.name),
        text = stringResource(R.string.use_provider_for_all_title, providerInfo.displayName),
        style = Typography.subtitle1,
        modifier = Modifier.padding(all = 24.dp).align(alignment = Alignment.CenterHorizontally)
      )
@@ -340,7 +343,7 @@ fun ProviderRow(providerInfo: ProviderInfo, onProviderSelected: (String) -> Unit
    shape = Shapes.large
  ) {
    Text(
      text = providerInfo.name,
      text = providerInfo.displayName,
      style = Typography.button,
      modifier = Modifier.padding(vertical = 18.dp)
    )
@@ -392,6 +395,7 @@ fun NavigationButton(
fun CreationSelectionCard(
  requestDisplayInfo: RequestDisplayInfo,
  providerInfo: ProviderInfo,
  createOptionInfo: CreateOptionInfo,
  onOptionSelected: () -> Unit,
  onCancel: () -> Unit,
  multiProvider: Boolean,
@@ -405,21 +409,39 @@ fun CreationSelectionCard(
        bitmap = providerInfo.credentialTypeIcon.toBitmap().asImageBitmap(),
        contentDescription = null,
        tint = Color.Unspecified,
        modifier = Modifier.align(alignment = Alignment.CenterHorizontally).padding(top = 24.dp)
        modifier = Modifier.align(alignment = Alignment.CenterHorizontally).padding(all = 24.dp)
      )
      Text(
        text = "${stringResource(R.string.choose_create_option_title)} ${providerInfo.name}",
        text = when (requestDisplayInfo.type) {
          TYPE_PUBLIC_KEY_CREDENTIAL -> stringResource(R.string.choose_create_option_passkey_title,
            providerInfo.displayName)
          TYPE_PASSWORD_CREDENTIAL -> stringResource(R.string.choose_create_option_password_title,
            providerInfo.displayName)
          else -> stringResource(R.string.choose_create_option_sign_in_title,
            providerInfo.displayName)
        },
        style = Typography.subtitle1,
        modifier = Modifier.padding(all = 24.dp).align(alignment = Alignment.CenterHorizontally)
        modifier = Modifier.padding(horizontal = 24.dp)
          .align(alignment = Alignment.CenterHorizontally),
        textAlign = TextAlign.Center,
      )
      Text(
        text = providerInfo.appDomainName,
        text = requestDisplayInfo.appDomainName,
        style = Typography.body2,
        modifier = Modifier.padding(horizontal = 28.dp)
        modifier = Modifier.align(alignment = Alignment.CenterHorizontally)
      )
      Divider(
        thickness = 24.dp,
        color = Color.Transparent
      Text(
        text = stringResource(
          R.string.choose_create_option_description,
          when (requestDisplayInfo.type) {
            TYPE_PUBLIC_KEY_CREDENTIAL -> "passkeys"
            TYPE_PASSWORD_CREDENTIAL -> "passwords"
            else -> "sign-ins"
          },
          providerInfo.displayName,
          createOptionInfo.title),
        style = Typography.body1,
        modifier = Modifier.padding(all = 24.dp).align(alignment = Alignment.CenterHorizontally)
      )
      Card(
        shape = Shapes.medium,
@@ -502,7 +524,7 @@ fun PrimaryCreateOptionRow(
) {
  Chip(
    modifier = Modifier.fillMaxWidth(),
    onClick = {onOptionSelected()},
    onClick = onOptionSelected,
    // TODO: Add an icon generated by provider according to requestDisplayInfo type
    colors = ChipDefaults.chipColors(
      backgroundColor = Grey100,
@@ -550,8 +572,12 @@ fun MoreOptionsInfoRow(
    ) {
        Column() {
            Text(
                text = if (providerInfo.createOptions.size > 1)
                {providerInfo.name + " for " + createOptionInfo.title} else { providerInfo.name},
                text =
                if (providerInfo.createOptions.size > 1)
                {stringResource(R.string.more_options_title_multiple_options,
                  providerInfo.displayName, createOptionInfo.title)} else {
                  stringResource(R.string.more_options_title_one_option,
                    providerInfo.displayName)},
                style = Typography.h6,
                modifier = Modifier.padding(top = 16.dp)
            )
Loading