Merge "Add fallback screen logic to CredentialSelectorActivity" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6eaa2302b5
@@ -38,7 +38,9 @@ import com.android.credentialmanager.common.StartBalIntentSenderForResultContrac
|
|||||||
import com.android.credentialmanager.createflow.CreateCredentialScreen
|
import com.android.credentialmanager.createflow.CreateCredentialScreen
|
||||||
import com.android.credentialmanager.createflow.hasContentToDisplay
|
import com.android.credentialmanager.createflow.hasContentToDisplay
|
||||||
import com.android.credentialmanager.getflow.GetCredentialScreen
|
import com.android.credentialmanager.getflow.GetCredentialScreen
|
||||||
|
import com.android.credentialmanager.getflow.GetGenericCredentialScreen
|
||||||
import com.android.credentialmanager.getflow.hasContentToDisplay
|
import com.android.credentialmanager.getflow.hasContentToDisplay
|
||||||
|
import com.android.credentialmanager.getflow.isFallbackScreen
|
||||||
import com.android.credentialmanager.ui.theme.PlatformTheme
|
import com.android.credentialmanager.ui.theme.PlatformTheme
|
||||||
|
|
||||||
@ExperimentalMaterialApi
|
@ExperimentalMaterialApi
|
||||||
@@ -118,11 +120,19 @@ class CredentialSelectorActivity : ComponentActivity() {
|
|||||||
providerActivityLauncher = launcher
|
providerActivityLauncher = launcher
|
||||||
)
|
)
|
||||||
} else if (getCredentialUiState != null && hasContentToDisplay(getCredentialUiState)) {
|
} else if (getCredentialUiState != null && hasContentToDisplay(getCredentialUiState)) {
|
||||||
|
if (isFallbackScreen(getCredentialUiState)) {
|
||||||
|
GetGenericCredentialScreen(
|
||||||
|
viewModel = viewModel,
|
||||||
|
getCredentialUiState = getCredentialUiState,
|
||||||
|
providerActivityLauncher = launcher
|
||||||
|
)
|
||||||
|
} else {
|
||||||
GetCredentialScreen(
|
GetCredentialScreen(
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
getCredentialUiState = getCredentialUiState,
|
getCredentialUiState = getCredentialUiState,
|
||||||
providerActivityLauncher = launcher
|
providerActivityLauncher = launcher
|
||||||
)
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d(Constants.LOG_TAG, "UI wasn't able to render neither get nor create flow")
|
Log.d(Constants.LOG_TAG, "UI wasn't able to render neither get nor create flow")
|
||||||
reportInstantiationErrorAndFinishActivity(credManRepo)
|
reportInstantiationErrorAndFinishActivity(credManRepo)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.credentialmanager.getflow
|
||||||
|
|
||||||
|
import androidx.activity.compose.ManagedActivityResultLauncher
|
||||||
|
import androidx.activity.result.ActivityResult
|
||||||
|
import androidx.activity.result.IntentSenderRequest
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import com.android.credentialmanager.CredentialSelectorViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun GetGenericCredentialScreen(
|
||||||
|
viewModel: CredentialSelectorViewModel,
|
||||||
|
getCredentialUiState: GetCredentialUiState,
|
||||||
|
providerActivityLauncher: ManagedActivityResultLauncher<IntentSenderRequest, ActivityResult>
|
||||||
|
) {
|
||||||
|
// TODO(b/274129098): Implement Screen for mDocs
|
||||||
|
}
|
||||||
@@ -41,6 +41,10 @@ internal fun hasContentToDisplay(state: GetCredentialUiState): Boolean {
|
|||||||
!state.requestDisplayInfo.preferImmediatelyAvailableCredentials)
|
!state.requestDisplayInfo.preferImmediatelyAvailableCredentials)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun isFallbackScreen(state: GetCredentialUiState): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
internal fun findAutoSelectEntry(providerDisplayInfo: ProviderDisplayInfo): CredentialEntryInfo? {
|
internal fun findAutoSelectEntry(providerDisplayInfo: ProviderDisplayInfo): CredentialEntryInfo? {
|
||||||
if (providerDisplayInfo.authenticationEntryList.isNotEmpty()) {
|
if (providerDisplayInfo.authenticationEntryList.isNotEmpty()) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
Reference in New Issue
Block a user