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

Commit ab14a8f5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add placeholder for lock icon in locked provider chip" into main

parents 568cfa9c a1248dc3
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.credentialmanager.ui.components

import androidx.compose.foundation.layout.Row
import androidx.compose.material3.Icon
import android.graphics.drawable.Drawable
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.RowScope
@@ -25,7 +27,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@@ -39,7 +40,6 @@ import androidx.wear.compose.material.Text
import com.android.credentialmanager.R
import com.android.credentialmanager.model.get.AuthenticationEntryInfo
import com.android.credentialmanager.ui.components.CredentialsScreenChip.TOPPADDING
import androidx.compose.material3.Icon

/* Used as credential suggestion or user action chip. */
@Composable
@@ -48,6 +48,7 @@ fun CredentialsScreenChip(
    onClick: () -> Unit,
    secondaryLabel: String? = null,
    icon: Drawable? = null,
    isAuthenticationEntryLocked: Boolean = false,
    modifier: Modifier = Modifier,
    colors: ChipColors = ChipDefaults.secondaryChipColors(),
) {
@@ -63,11 +64,24 @@ fun CredentialsScreenChip(
    val secondaryLabelParam: (@Composable RowScope.() -> Unit)? =
        secondaryLabel?.let {
            {
                Row {
                    Text(
                        text = secondaryLabel,
                        overflow = TextOverflow.Ellipsis,
                        maxLines = 1,
                    )

                    if (isAuthenticationEntryLocked)
                        // TODO(b/324465527) change this to lock icon and correct size once figma mocks are
                        // updated
                        Icon(
                            bitmap = checkNotNull(icon?.toBitmap()?.asImageBitmap()),
                            // Decorative purpose only.
                            contentDescription = null,
                            modifier = Modifier.size(20.dp),
                            tint = Color.Unspecified
                        )
                }
            }
        }

@@ -173,14 +187,11 @@ fun LockedProviderChip(
        else R.string.locked_credential_entry_label_subtext_tap_to_unlock
    )

    if (!authenticationEntryInfo.isUnlockedAndEmpty) {
        // TODO(b/324465527) need to draw a lock icon here. may need to switch over from using chip
    }

    CredentialsScreenChip(
        label = authenticationEntryInfo.title,
        icon = authenticationEntryInfo.icon,
        secondaryLabel = secondaryLabel,
        isAuthenticationEntryLocked = !authenticationEntryInfo.isUnlockedAndEmpty,
        onClick = onClick,
        modifier = Modifier.padding(top = TOPPADDING),
    )