Merge "[CredManUi] Display provider info for single entry sign-in." into udc-dev
This commit is contained in:
@@ -59,6 +59,8 @@ import com.android.credentialmanager.common.ui.SheetContainerCard
|
|||||||
import com.android.credentialmanager.common.ui.SnackbarActionText
|
import com.android.credentialmanager.common.ui.SnackbarActionText
|
||||||
import com.android.credentialmanager.common.ui.HeadlineText
|
import com.android.credentialmanager.common.ui.HeadlineText
|
||||||
import com.android.credentialmanager.common.ui.CredentialListSectionHeader
|
import com.android.credentialmanager.common.ui.CredentialListSectionHeader
|
||||||
|
import com.android.credentialmanager.common.ui.HeadlineIcon
|
||||||
|
import com.android.credentialmanager.common.ui.LargeLabelTextOnSurfaceVariant
|
||||||
import com.android.credentialmanager.common.ui.Snackbar
|
import com.android.credentialmanager.common.ui.Snackbar
|
||||||
import com.android.credentialmanager.common.ui.setTransparentSystemBarsColor
|
import com.android.credentialmanager.common.ui.setTransparentSystemBarsColor
|
||||||
import com.android.credentialmanager.common.ui.setBottomSheetSystemBarsColor
|
import com.android.credentialmanager.common.ui.setBottomSheetSystemBarsColor
|
||||||
@@ -167,22 +169,42 @@ fun PrimarySelectionCard(
|
|||||||
providerDisplayInfo.sortedUserNameToCredentialEntryList
|
providerDisplayInfo.sortedUserNameToCredentialEntryList
|
||||||
val authenticationEntryList = providerDisplayInfo.authenticationEntryList
|
val authenticationEntryList = providerDisplayInfo.authenticationEntryList
|
||||||
SheetContainerCard {
|
SheetContainerCard {
|
||||||
|
// When only one provider (not counting the remote-only provider) exists, display that
|
||||||
|
// provider's icon + name up top.
|
||||||
|
if (providerInfoList.size <= 2) { // It's only possible to be the single provider case
|
||||||
|
// if we are started with no more than 2 providers.
|
||||||
|
val nonRemoteProviderList = providerInfoList.filter(
|
||||||
|
{ it.credentialEntryList.isNotEmpty() || it.authenticationEntryList.isNotEmpty() }
|
||||||
|
)
|
||||||
|
if (nonRemoteProviderList.size == 1) {
|
||||||
|
val providerInfo = nonRemoteProviderList.firstOrNull() // First should always work
|
||||||
|
// but just to be safe.
|
||||||
|
if (providerInfo != null) {
|
||||||
|
item {
|
||||||
|
HeadlineIcon(
|
||||||
|
bitmap = providerInfo.icon.toBitmap().asImageBitmap(),
|
||||||
|
tint = Color.Unspecified,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
item { Divider(thickness = 4.dp, color = Color.Transparent) }
|
||||||
|
item { LargeLabelTextOnSurfaceVariant(text = providerInfo.displayName) }
|
||||||
|
item { Divider(thickness = 16.dp, color = Color.Transparent) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val hasSingleEntry = (sortedUserNameToCredentialEntryList.size == 1 &&
|
||||||
|
authenticationEntryList.isEmpty()) || (sortedUserNameToCredentialEntryList.isEmpty() &&
|
||||||
|
authenticationEntryList.size == 1)
|
||||||
item {
|
item {
|
||||||
HeadlineText(
|
HeadlineText(
|
||||||
text = stringResource(
|
text = stringResource(
|
||||||
if (sortedUserNameToCredentialEntryList
|
if (hasSingleEntry) {
|
||||||
.size == 1 && authenticationEntryList.isEmpty()
|
if (sortedUserNameToCredentialEntryList.firstOrNull()
|
||||||
) {
|
?.sortedCredentialEntryList?.first()?.credentialType
|
||||||
if (sortedUserNameToCredentialEntryList.first()
|
|
||||||
.sortedCredentialEntryList.first().credentialType
|
|
||||||
== CredentialType.PASSKEY
|
== CredentialType.PASSKEY
|
||||||
) R.string.get_dialog_title_use_passkey_for
|
) R.string.get_dialog_title_use_passkey_for
|
||||||
else R.string.get_dialog_title_use_sign_in_for
|
else R.string.get_dialog_title_use_sign_in_for
|
||||||
} else if (
|
|
||||||
sortedUserNameToCredentialEntryList
|
|
||||||
.isEmpty() && authenticationEntryList.size == 1
|
|
||||||
) {
|
|
||||||
R.string.get_dialog_title_use_sign_in_for
|
|
||||||
} else R.string.get_dialog_title_choose_sign_in_for,
|
} else R.string.get_dialog_title_choose_sign_in_for,
|
||||||
requestDisplayInfo.appName
|
requestDisplayInfo.appName
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user