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

Commit

Permalink
Fix checkins consent screen nav (EXPOSUREAPP-14387, 14388) (#5749)
Browse files Browse the repository at this point in the history
* Fix consent navigation for checkins.

* Lint complaining?
  • Loading branch information
SamuraiKek authored Dec 7, 2022
1 parent ef02fb8 commit 0000786
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CheckInsFragment : Fragment(R.layout.trace_location_attendee_checkins_frag
is CheckInEvent.ShowInformation -> {
setupAxisTransition()
findNavController().navigate(
CheckInsFragmentDirections.actionCheckInsFragmentToCheckInOnboardingFragment(false)
CheckInsFragmentDirections.actionCheckInsFragmentToCheckInOnboardingFragment(showBottomNav = false)
)
}

Expand Down Expand Up @@ -194,14 +194,17 @@ class CheckInsFragment : Fragment(R.layout.trace_location_attendee_checkins_frag
}

companion object {
fun createDeepLink(rootUri: String, cleanHistory: Boolean = false): Uri {
fun createDeepLink(rootUri: String, cleanHistory: Boolean = false, isOrganizerOnboarded: Boolean = false): Uri {
val encodedUrl = try {
URLEncoder.encode(rootUri, Charsets.UTF_8.name())
} catch (e: Exception) {
Timber.d(e, "URL Encoding failed url($rootUri)")
rootUri // Pass original
}
return "cwa://check-in-onboarding/$encodedUrl/?cleanHistory=$cleanHistory&showBottomNav=false".toUri()
return (
"cwa://check-in-onboarding/$encodedUrl/?cleanHistory=$cleanHistory&showBottomNav=false" +
"&isOrganizerOnboarded=$isOrganizerOnboarded"
).toUri()
}

fun canHandle(rootUri: String): Boolean = rootUri.startsWith("https://e.coronawarn.app")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ class CheckInOnboardingFragment : Fragment(R.layout.fragment_trace_location_onbo
.setPopUpTo(R.id.checkInOnboardingFragment, true)
.build()
findNavController().navigate(ConfirmCheckInFragment.uri(locationId), navOption)
} else {
findNavController().navigate(
CheckInOnboardingFragmentDirections.actionCheckInOnboardingFragmentToCheckInsFragment(
uri = args.uri,
cleanHistory = true
)
)
}
}

CheckInOnboardingNavigation.SkipOnboardingInfo -> {
if (args.uri == null) {
if (args.showBottomNav || args.isOrganizerOnboarded) {
findNavController().navigate(
CheckInOnboardingFragmentDirections.actionCheckInOnboardingFragmentToCheckInsFragment(
args.uri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sealed class TraceLocationEvent {

data class DuplicateItem(val traceLocation: TraceLocation) : TraceLocationEvent()

data class SelfCheckIn(val traceLocation: TraceLocation) : TraceLocationEvent()
data class SelfCheckIn(val traceLocation: TraceLocation, val isOnboarded: Boolean) : TraceLocationEvent()

data class ConfirmDeleteItem(val traceLocation: TraceLocation) : TraceLocationEvent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class TraceLocationsFragment : Fragment(R.layout.trace_location_organizer_trace_

is TraceLocationEvent.SelfCheckIn -> {
findNavController().navigate(
CheckInsFragment.createDeepLink(it.traceLocation.locationUrl, true),
CheckInsFragment.createDeepLink(it.traceLocation.locationUrl, true, it.isOnboarded),
NavOptions.Builder()
.setPopUpTo(R.id.checkInsFragment, true)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import de.rki.coronawarnapp.presencetracing.TraceLocationSettings
import de.rki.coronawarnapp.presencetracing.checkins.CheckInRepository
import de.rki.coronawarnapp.presencetracing.checkins.qrcode.TraceLocation
import de.rki.coronawarnapp.presencetracing.storage.repo.TraceLocationRepository
Expand All @@ -24,6 +25,7 @@ class TraceLocationsViewModel @AssistedInject constructor(
dispatcherProvider: DispatcherProvider,
checkInsRepository: CheckInRepository,
private val traceLocationRepository: TraceLocationRepository,
private val settings: TraceLocationSettings
) : CWAViewModel(dispatcherProvider = dispatcherProvider) {

val events = SingleLiveEvent<TraceLocationEvent>()
Expand All @@ -42,10 +44,11 @@ class TraceLocationsViewModel @AssistedInject constructor(
}
.map { traceLocations ->
traceLocations.map { item ->
val isOnboarded = settings.isOnboardingDone()
TraceLocationVH.Item(
traceLocation = item.first,
canCheckIn = item.second,
onCheckIn = { events.postValue(TraceLocationEvent.SelfCheckIn(it)) },
onCheckIn = { events.postValue(TraceLocationEvent.SelfCheckIn(it, isOnboarded)) },
onDuplicate = { events.postValue(TraceLocationEvent.DuplicateItem(it)) },
onShowPrint = { events.postValue(TraceLocationEvent.StartQrCodePosterFragment(it)) },
onDeleteItem = { events.postValue(TraceLocationEvent.ConfirmDeleteItem(it)) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:name="de.rki.coronawarnapp.ui.presencetracing.attendee.onboarding.CheckInOnboardingFragment"
android:label="CheckInOnboardingFragment"
tools:layout="@layout/fragment_trace_location_onboarding">
<deepLink app:uri="cwa://check-in-onboarding/{uri}/?cleanHistory={cleanHistory}&amp;showBottomNav={showBottomNav}" />
<deepLink app:uri="cwa://check-in-onboarding/{uri}/?cleanHistory={cleanHistory}&amp;showBottomNav={showBottomNav}&amp;isOrganizerOnboarded={isOrganizerOnboarded}" />
<deepLink app:uri="cwa://check-in-onboarding/?showBottomNav={showBottomNav}&amp;locationId={locationId}" />

<action
Expand All @@ -20,6 +20,10 @@
<action
android:id="@+id/action_checkInOnboardingFragment_to_privacyFragment"
app:destination="@id/checkInPrivacyFragment" />
<argument
android:name="isOrganizerOnboarded"
android:defaultValue="false"
app:argType="boolean" />
<argument
android:name="showBottomNav"
android:defaultValue="true"
Expand Down

0 comments on commit 0000786

Please sign in to comment.