diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingFragment.kt index f269c478ae5..267a2dbb69c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingFragment.kt @@ -53,6 +53,8 @@ class CovidCertificateOnboardingFragment : Fragment(R.layout.covid_certificate_o } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + viewModel.checkOnboardingStatus() + with(binding) { if (!args.showBottomNav) { toolbar.apply { @@ -73,6 +75,7 @@ class CovidCertificateOnboardingFragment : Fragment(R.layout.covid_certificate_o findNavController().navigate( R.id.action_covidCertificateOnboardingFragment_to_privacyFragment ) + CovidCertificateOnboardingViewModel.Event.NavigateToPersonOverview -> findNavController().navigate( R.id.action_covidCertificateOnboardingFragment_to_personOverviewFragment @@ -82,8 +85,10 @@ class CovidCertificateOnboardingFragment : Fragment(R.layout.covid_certificate_o val uri = when (event.containerId) { is VaccinationCertificateContainerId -> VaccinationDetailsFragment.uri(event.containerId.qrCodeHash) + is TestCertificateContainerId -> TestCertificateDetailsFragment.uri(event.containerId.qrCodeHash) + is RecoveryCertificateContainerId -> RecoveryCertificateDetailsFragment.uri(event.containerId.qrCodeHash) } @@ -92,8 +97,16 @@ class CovidCertificateOnboardingFragment : Fragment(R.layout.covid_certificate_o .build() findNavController().navigate(uri, navOption) } + is CovidCertificateOnboardingViewModel.Event.Error -> showCovidCertificateOnboardingErrorDialog(event.throwable) + + is CovidCertificateOnboardingViewModel.Event.SkipOnboarding -> + if (args.showBottomNav) { + findNavController().navigate( + R.id.action_covidCertificateOnboardingFragment_to_personOverviewFragment + ) + } } } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingViewModel.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingViewModel.kt index ab6cba8251d..3d57b4a6827 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingViewModel.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/ui/onboarding/CovidCertificateOnboardingViewModel.kt @@ -11,6 +11,7 @@ import de.rki.coronawarnapp.util.coroutine.DispatcherProvider import de.rki.coronawarnapp.util.ui.SingleLiveEvent import de.rki.coronawarnapp.util.viewmodel.CWAViewModel import de.rki.coronawarnapp.util.viewmodel.CWAViewModelFactory +import kotlinx.coroutines.flow.first import timber.log.Timber class CovidCertificateOnboardingViewModel @AssistedInject constructor( @@ -38,6 +39,12 @@ class CovidCertificateOnboardingViewModel @AssistedInject constructor( events.postValue(event) } + fun checkOnboardingStatus() = launch { + if (covidCertificateSettings.isOnboarded.first()) { + events.postValue(Event.SkipOnboarding) + } + } + fun onDataPrivacyClick() = events.postValue(Event.NavigateToDataPrivacy) @AssistedFactory @@ -50,6 +57,8 @@ class CovidCertificateOnboardingViewModel @AssistedInject constructor( sealed class Event { object NavigateToDataPrivacy : Event() object NavigateToPersonOverview : Event() + + object SkipOnboarding : Event() data class NavigateToDccDetailsScreen(val containerId: CertificateContainerId) : Event() data class Error(val throwable: Throwable) : Event() } diff --git a/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml b/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml index cd58d1dbc42..92da1107ded 100644 --- a/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml +++ b/Corona-Warn-App/src/main/res/navigation/covid_certificates_graph.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/covid_certificates_graph" - app:startDestination="@id/personOverviewFragment"> + app:startDestination="@id/covidCertificateOnboardingFragment">