Change M3 tokens to the framework counterparts

Also, fixed a few unnecessary safe ?. calls.

Bug: 275412580
Test: manual
Change-Id: Ic06d27d018028142225cca353d5c403e782ef62b
This commit is contained in:
Helen Qin
2023-04-06 20:29:01 +00:00
parent 4c6f578783
commit 91daf59032
8 changed files with 27 additions and 25 deletions

View File

@@ -65,8 +65,8 @@ class CredentialManagerRepo(
)
val originName: String? = when (requestInfo?.type) {
RequestInfo.TYPE_CREATE -> requestInfo?.createCredentialRequest?.origin
RequestInfo.TYPE_GET -> requestInfo?.getCredentialRequest?.origin
RequestInfo.TYPE_CREATE -> requestInfo.createCredentialRequest?.origin
RequestInfo.TYPE_GET -> requestInfo.getCredentialRequest?.origin
else -> null
}

View File

@@ -245,7 +245,7 @@ class GetFlowUtils {
userName = credentialEntry.username.toString(),
displayName = credentialEntry.displayName?.toString(),
icon = credentialEntry.icon.loadDrawable(context),
shouldTintIcon = credentialEntry.isDefaultIcon ?: false,
shouldTintIcon = credentialEntry.isDefaultIcon,
lastUsedTimeMillis = credentialEntry.lastUsedTime,
isAutoSelectable = credentialEntry.isAutoSelectAllowed &&
credentialEntry.autoSelectAllowedFromOption,

View File

@@ -316,7 +316,7 @@ fun ModalBottomSheetLayout(
rememberModalBottomSheetState(Hidden),
sheetShape: Shape = MaterialTheme.shapes.large,
sheetElevation: Dp = ModalBottomSheetDefaults.Elevation,
sheetBackgroundColor: Color = MaterialTheme.colorScheme.surface,
sheetBackgroundColor: Color,
sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
content: @Composable () -> Unit
) {

View File

@@ -32,7 +32,6 @@ import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SuggestionChip
import androidx.compose.material3.SuggestionChipDefaults
import androidx.compose.material3.TopAppBar
@@ -155,7 +154,7 @@ fun Entry(
// Decorative purpose only.
contentDescription = null,
modifier = Modifier.size(24.dp),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
)
}
}
@@ -169,7 +168,7 @@ fun Entry(
Icon(
modifier = iconSize,
bitmap = iconImageBitmap,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -193,7 +192,7 @@ fun Entry(
Icon(
modifier = iconSize,
imageVector = iconImageVector,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -205,7 +204,7 @@ fun Entry(
Icon(
modifier = iconSize,
painter = iconPainter,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -217,9 +216,8 @@ fun Entry(
border = null,
colors = SuggestionChipDefaults.suggestionChipColors(
containerColor = LocalAndroidColorScheme.current.colorSurfaceContainerHigh,
// TODO: remove?
labelColor = MaterialTheme.colorScheme.onSurfaceVariant,
iconContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
labelColor = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
iconContentColor = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
),
)
}
@@ -282,7 +280,7 @@ fun PasskeyBenefitRow(
Icon(
modifier = Modifier.size(24.dp),
painter = leadingIconPainter,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
// Decorative purpose only.
contentDescription = null,
)
@@ -341,7 +339,7 @@ fun MoreOptionTopAppBar(
R.string.accessibility_back_arrow_button
),
modifier = Modifier.size(24.dp).autoMirrored(),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
tint = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
)
}
}

View File

@@ -20,20 +20,20 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
@Composable
fun CredentialListSectionHeader(text: String) {
InternalSectionHeader(text, MaterialTheme.colorScheme.onSurfaceVariant)
InternalSectionHeader(text, LocalAndroidColorScheme.current.colorOnSurfaceVariant)
}
@Composable
fun MoreAboutPasskeySectionHeader(text: String) {
InternalSectionHeader(text, MaterialTheme.colorScheme.onSurface)
InternalSectionHeader(text, LocalAndroidColorScheme.current.colorOnSurface)
}
@Composable

View File

@@ -24,6 +24,7 @@ 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
import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
/**
* The headline for a screen. E.g. "Create a passkey for X", "Choose a saved sign-in for X".
@@ -35,7 +36,7 @@ fun HeadlineText(text: String, modifier: Modifier = Modifier) {
Text(
modifier = modifier.wrapContentSize(),
text = text,
color = MaterialTheme.colorScheme.onSurface,
color = LocalAndroidColorScheme.current.colorOnSurface,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.headlineSmall,
)
@@ -49,7 +50,7 @@ fun BodyMediumText(text: String, modifier: Modifier = Modifier) {
Text(
modifier = modifier.wrapContentSize(),
text = text,
color = MaterialTheme.colorScheme.onSurfaceVariant,
color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.bodyMedium,
)
}
@@ -62,7 +63,7 @@ fun BodySmallText(text: String, modifier: Modifier = Modifier, enforceOneLine: B
Text(
modifier = modifier.wrapContentSize(),
text = text,
color = MaterialTheme.colorScheme.onSurfaceVariant,
color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.bodySmall,
overflow = TextOverflow.Ellipsis,
maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE
@@ -77,7 +78,7 @@ fun LargeTitleText(text: String, modifier: Modifier = Modifier) {
Text(
modifier = modifier.wrapContentSize(),
text = text,
color = MaterialTheme.colorScheme.onSurface,
color = LocalAndroidColorScheme.current.colorOnSurface,
style = MaterialTheme.typography.titleLarge,
)
}
@@ -90,7 +91,7 @@ fun SmallTitleText(text: String, modifier: Modifier = Modifier, enforceOneLine:
Text(
modifier = modifier.wrapContentSize(),
text = text,
color = MaterialTheme.colorScheme.onSurface,
color = LocalAndroidColorScheme.current.colorOnSurface,
style = MaterialTheme.typography.titleSmall,
overflow = TextOverflow.Ellipsis,
maxLines = if (enforceOneLine) 1 else Int.MAX_VALUE
@@ -145,7 +146,7 @@ fun LargeLabelTextOnSurfaceVariant(text: String, modifier: Modifier = Modifier)
modifier = modifier.wrapContentSize(),
text = text,
textAlign = TextAlign.Center,
color = MaterialTheme.colorScheme.onSurfaceVariant,
color = LocalAndroidColorScheme.current.colorOnSurfaceVariant,
style = MaterialTheme.typography.labelLarge,
)
}

View File

@@ -30,7 +30,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.Divider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.NewReleases
import androidx.compose.material.icons.filled.Add
@@ -67,6 +66,7 @@ import com.android.credentialmanager.common.ui.SheetContainerCard
import com.android.credentialmanager.common.ui.PasskeyBenefitRow
import com.android.credentialmanager.common.ui.HeadlineText
import com.android.credentialmanager.logging.CreateCredentialEvent
import com.android.credentialmanager.ui.theme.LocalAndroidColorScheme
import com.android.internal.logging.UiEventLogger.UiEventEnum
@Composable
@@ -559,7 +559,7 @@ fun CreationSelectionCard(
item {
Divider(
thickness = 1.dp,
color = MaterialTheme.colorScheme.outlineVariant,
color = LocalAndroidColorScheme.current.colorOutlineVariant,
modifier = Modifier.padding(vertical = 16.dp)
)
}

View File

@@ -42,6 +42,9 @@ val LocalAndroidColorScheme =
class AndroidColorScheme internal constructor(context: Context) {
val colorSurfaceBright = getColor(context, R.attr.materialColorSurfaceBright)
val colorSurfaceContainerHigh = getColor(context, R.attr.materialColorSurfaceContainerHigh)
val colorOutlineVariant = getColor(context, R.attr.materialColorOutlineVariant)
val colorOnSurface = getColor(context, R.attr.materialColorOnSurface)
val colorOnSurfaceVariant = getColor(context, R.attr.materialColorOnSurfaceVariant)
companion object {
fun getColor(context: Context, attr: Int): Color {