Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit d8347f3

Browse files
SamuraiKekmtwalli
andauthored
Fix navigation when requesting dgc for others. (#5786)
Co-authored-by: Mohamed <[email protected]>
1 parent 775c67c commit d8347f3

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/familytest/ui/consent/FamilyTestConsentFragment.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,27 @@ class FamilyTestConsentFragment : Fragment(R.layout.fragment_family_test_consent
6262
)
6363
)
6464
}
65+
6566
is FamilyTestConsentNavigationEvents.NavigateClose -> {
6667
binding.root.hideKeyboard()
6768
goBack()
6869
}
70+
6971
is FamilyTestConsentNavigationEvents.NavigateToDataPrivacy -> findNavController().navigate(
7072
FamilyTestConsentFragmentDirections.actionFamilyTestConsentFragmentToInformationPrivacyFragment()
7173
)
74+
7275
is FamilyTestConsentNavigationEvents.NavigateToCertificateRequest -> findNavController().navigate(
7376
NavGraphDirections.actionRequestCovidCertificateFragment(
7477
testRegistrationRequest = it.coronaTestQRCode,
7578
coronaTestConsent = it.consentGiven,
7679
allowTestReplacement = it.allowReplacement,
77-
personName = it.personName
80+
personName = it.personName,
81+
comesFromDispatcherFragment = navArgs.comesFromDispatcherFragment
7882
),
7983
navOptions
8084
)
85+
8186
else -> Unit
8287
}
8388
}
@@ -90,9 +95,11 @@ class FamilyTestConsentFragment : Fragment(R.layout.fragment_family_test_consent
9095
when (state) {
9196
TestRegistrationStateProcessor.State.Idle,
9297
TestRegistrationStateProcessor.State.Working -> Unit
98+
9399
is TestRegistrationStateProcessor.State.Error -> {
94100
state.showExceptionDialog(this) { popBackStack() }
95101
}
102+
96103
is TestRegistrationStateProcessor.State.TestRegistered -> findNavController().navigate(
97104
NavGraphDirections.actionSubmissionTestResultPendingFragment(
98105
testIdentifier = state.test.identifier,
@@ -115,6 +122,7 @@ class FamilyTestConsentFragment : Fragment(R.layout.fragment_family_test_consent
115122
}
116123
false
117124
}
125+
118126
else -> true
119127
}
120128
}

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/invalid/SubmissionTestResultInvalidFragment.kt

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package de.rki.coronawarnapp.ui.submission.testresult.invalid
33
import android.os.Bundle
44
import android.view.View
55
import android.view.accessibility.AccessibilityEvent
6+
import androidx.activity.OnBackPressedCallback
67
import androidx.core.view.isVisible
78
import androidx.fragment.app.Fragment
89
import androidx.navigation.fragment.findNavController
@@ -44,6 +45,11 @@ class SubmissionTestResultInvalidFragment : Fragment(R.layout.fragment_submissio
4445
}
4546
toolbar.setNavigationOnClickListener { goBack() }
4647
}
48+
val backCallback = object : OnBackPressedCallback(true) {
49+
override fun handleOnBackPressed() = goBack()
50+
}
51+
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, backCallback)
52+
4753
viewModel.testResult.observe2(this) { uiState ->
4854
when (uiState.coronaTest.type) {
4955
BaseCoronaTest.Type.PCR -> {
@@ -62,6 +68,7 @@ class SubmissionTestResultInvalidFragment : Fragment(R.layout.fragment_submissio
6268
}
6369
}
6470
}
71+
6572
BaseCoronaTest.Type.RAPID_ANTIGEN -> {
6673
binding.apply {
6774
testResultInvalidStepsPcrAdded.isVisible = false

Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/submission/testresult/positive/SubmissionTestResultKeysSharedFragment.kt

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package de.rki.coronawarnapp.ui.submission.testresult.positive
33
import android.os.Bundle
44
import android.view.View
55
import android.view.accessibility.AccessibilityEvent
6+
import androidx.activity.OnBackPressedCallback
67
import androidx.core.view.isVisible
78
import androidx.fragment.app.Fragment
89
import androidx.navigation.fragment.findNavController
@@ -47,8 +48,12 @@ class SubmissionTestResultKeysSharedFragment :
4748
viewModel.onTestOpened()
4849

4950
binding.toolbar.setNavigationOnClickListener {
50-
popBackStack()
51+
navigateBackToFlowStart()
5152
}
53+
val backCallback = object : OnBackPressedCallback(true) {
54+
override fun handleOnBackPressed() = navigateBackToFlowStart()
55+
}
56+
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, backCallback)
5257

5358
binding.deleteTest.setOnClickListener {
5459
viewModel.onShowDeleteTestDialog()
@@ -75,15 +80,19 @@ class SubmissionTestResultKeysSharedFragment :
7580
}
7681

7782
viewModel.routeToScreen.observe2(this) {
78-
if (navArgs.comesFromDispatcherFragment) {
79-
findNavController().navigate(
80-
SubmissionTestResultKeysSharedFragmentDirections
81-
.actionSubmissionTestResultKeysSharedFragmentToMainFragment()
82-
)
83-
} else popBackStack()
83+
navigateBackToFlowStart()
8484
}
8585
}
8686

87+
private fun navigateBackToFlowStart() {
88+
if (navArgs.comesFromDispatcherFragment) {
89+
findNavController().navigate(
90+
SubmissionTestResultKeysSharedFragmentDirections
91+
.actionSubmissionTestResultKeysSharedFragmentToMainFragment()
92+
)
93+
} else popBackStack()
94+
}
95+
8796
override fun onResume() {
8897
super.onResume()
8998
binding.submissionTestResultContainer.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT)

0 commit comments

Comments
 (0)