Add fallback screen logic to CredentialSelectorActivity
Bug: 274129098 Test: local-deployment Change-Id: Icaff370e11d2755e135d313bbe71f48333c763d4
This commit is contained in:
@@ -38,7 +38,9 @@ import com.android.credentialmanager.common.StartBalIntentSenderForResultContrac
|
||||
import com.android.credentialmanager.createflow.CreateCredentialScreen
|
||||
import com.android.credentialmanager.createflow.hasContentToDisplay
|
||||
import com.android.credentialmanager.getflow.GetCredentialScreen
|
||||
import com.android.credentialmanager.getflow.GetGenericCredentialScreen
|
||||
import com.android.credentialmanager.getflow.hasContentToDisplay
|
||||
import com.android.credentialmanager.getflow.isFallbackScreen
|
||||
import com.android.credentialmanager.ui.theme.PlatformTheme
|
||||
|
||||
@ExperimentalMaterialApi
|
||||
@@ -118,11 +120,19 @@ class CredentialSelectorActivity : ComponentActivity() {
|
||||
providerActivityLauncher = launcher
|
||||
)
|
||||
} else if (getCredentialUiState != null && hasContentToDisplay(getCredentialUiState)) {
|
||||
GetCredentialScreen(
|
||||
viewModel = viewModel,
|
||||
getCredentialUiState = getCredentialUiState,
|
||||
providerActivityLauncher = launcher
|
||||
)
|
||||
if (isFallbackScreen(getCredentialUiState)) {
|
||||
GetGenericCredentialScreen(
|
||||
viewModel = viewModel,
|
||||
getCredentialUiState = getCredentialUiState,
|
||||
providerActivityLauncher = launcher
|
||||
)
|
||||
} else {
|
||||
GetCredentialScreen(
|
||||
viewModel = viewModel,
|
||||
getCredentialUiState = getCredentialUiState,
|
||||
providerActivityLauncher = launcher
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Log.d(Constants.LOG_TAG, "UI wasn't able to render neither get nor create flow")
|
||||
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)
|
||||
}
|
||||
|
||||
internal fun isFallbackScreen(state: GetCredentialUiState): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
internal fun findAutoSelectEntry(providerDisplayInfo: ProviderDisplayInfo): CredentialEntryInfo? {
|
||||
if (providerDisplayInfo.authenticationEntryList.isNotEmpty()) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user