diff options
| author | 2023-11-08 00:55:34 +0000 | |
|---|---|---|
| committer | 2023-11-08 00:58:16 +0000 | |
| commit | 1fce31b530ad4cf0952b98a7a561dc9d73bf4b2c (patch) | |
| tree | 00ce3bedbf51b6dcb0b53b0ec642d45d587d9031 | |
| parent | 1672bdbbd33644cdf3c2553868320cc852464140 (diff) | |
Remove workaround since compose navigation issue was fixed.
Test: Manual
Change-Id: I6931a4fd5f8626e58c7779d71592a1a0bf733ce3
3 files changed, 9 insertions, 50 deletions
diff --git a/packages/CredentialManager/wear/Android.bp b/packages/CredentialManager/wear/Android.bp index c883b1f26160..2a89a9940936 100644 --- a/packages/CredentialManager/wear/Android.bp +++ b/packages/CredentialManager/wear/Android.bp @@ -35,6 +35,7 @@ android_app { "androidx.compose.ui_ui", "androidx.compose.ui_ui-tooling", "androidx.core_core-ktx", + "androidx.hilt_hilt-navigation-compose", "androidx.lifecycle_lifecycle-extensions", "androidx.lifecycle_lifecycle-livedata", "androidx.lifecycle_lifecycle-runtime-ktx", diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt index 0a63cb74a25a..f2df64aee22e 100644 --- a/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt +++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/CredentialSelectorActivity.kt @@ -21,16 +21,10 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.viewModels -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.lifecycleScope -import androidx.lifecycle.repeatOnLifecycle import androidx.wear.compose.material.MaterialTheme import com.android.credentialmanager.ui.WearApp -import com.android.credentialmanager.ui.screens.single.password.SinglePasswordScreen import com.google.android.horologist.annotations.ExperimentalHorologistApi -import com.google.android.horologist.compose.layout.belowTimeTextPreview import dagger.hilt.android.AndroidEntryPoint -import kotlinx.coroutines.launch @AndroidEntryPoint(ComponentActivity::class) class CredentialSelectorActivity : Hilt_CredentialSelectorActivity() { @@ -42,50 +36,14 @@ class CredentialSelectorActivity : Hilt_CredentialSelectorActivity() { super.onCreate(savedInstanceState) setTheme(android.R.style.Theme_DeviceDefault) - - // TODO: b/301027810 due to this issue with compose in Main platform, we are implementing a - // workaround. Once the issue is fixed, remove the "else" bracket and leave only the - // contents of the "if" bracket. - if (false) { - setContent { - MaterialTheme { - WearApp( - viewModel = viewModel, - onCloseApp = ::finish, - ) - } - } - } else { - // TODO: b/301027810 Remove the content of this "else" bracket fully once issue is fixed - lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - viewModel.uiState.collect { uiState -> - when (uiState) { - CredentialSelectorUiState.Idle -> { - // Don't display anything, assuming that there should be minimal latency - // to parse the Credential Manager intent and define the state of the - // app. If latency is big, then a "loading" screen should be displayed - // to the user. - } - - is CredentialSelectorUiState.Get -> { - setContent { - MaterialTheme { - SinglePasswordScreen( - columnState = belowTimeTextPreview(), - onCloseApp = ::finish, - ) - } - } - } - - else -> finish() - } - } - } + setContent { + MaterialTheme { + WearApp( + viewModel = viewModel, + onCloseApp = ::finish, + ) } } - viewModel.onNewIntent(intent) } diff --git a/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/single/password/SinglePasswordScreen.kt b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/single/password/SinglePasswordScreen.kt index 81a067289d89..c28df3e8895a 100644 --- a/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/single/password/SinglePasswordScreen.kt +++ b/packages/CredentialManager/wear/src/com/android/credentialmanager/ui/screens/single/password/SinglePasswordScreen.kt @@ -27,8 +27,8 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import com.android.credentialmanager.R import com.android.credentialmanager.TAG import com.android.credentialmanager.activity.StartBalIntentSenderForResultContract @@ -47,7 +47,7 @@ fun SinglePasswordScreen( columnState: ScalingLazyColumnState, onCloseApp: () -> Unit, modifier: Modifier = Modifier, - viewModel: SinglePasswordScreenViewModel = viewModel(), + viewModel: SinglePasswordScreenViewModel = hiltViewModel(), ) { viewModel.initialize() |