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

Event Creation - Self check-in flow (EXPOSUREAPP-6299) #2812

Merged
merged 9 commits into from
Apr 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ sealed class CheckInEvent {

data class ConfirmCheckIn(val verifiedTraceLocation: VerifiedTraceLocation) : CheckInEvent()

data class ConfirmCheckInWithoutHistory(val verifiedTraceLocation: VerifiedTraceLocation) : CheckInEvent()

data class EditCheckIn(val checkInId: Long, val position: Int) : CheckInEvent()

data class ConfirmSwipeItem(val checkIn: CheckIn, val position: Int) : CheckInEvent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class CheckInsFragment : Fragment(R.layout.trace_location_attendee_checkins_frag
factory as CheckInsViewModel.Factory
factory.create(
savedState = savedState,
deepLink = navArgs.uri
deepLink = navArgs.uri,
cleanHistory = navArgs.cleanHistory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better if you call it clearHistory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have nothing against using clear vs clean it could be refactored later

)
}
)
Expand Down Expand Up @@ -97,6 +98,12 @@ class CheckInsFragment : Fragment(R.layout.trace_location_attendee_checkins_frag
)
}

is CheckInEvent.ConfirmCheckInWithoutHistory -> doNavigate(
CheckInsFragmentDirections.actionCheckInsFragmentToConfirmCheckInFragmentCleanHistory(
verifiedTraceLocation = event.verifiedTraceLocation
)
)

is CheckInEvent.ConfirmSwipeItem -> showRemovalConfirmation(event.checkIn, event.position)

is CheckInEvent.ConfirmRemoveItem -> showRemovalConfirmation(event.checkIn, null)
Expand Down Expand Up @@ -232,14 +239,14 @@ class CheckInsFragment : Fragment(R.layout.trace_location_attendee_checkins_frag
}

companion object {
fun createCheckInUri(rootUri: String): Uri {
fun createCheckInUri(rootUri: String, cleanHistory: 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 "coronawarnapp://check-ins/$encodedUrl".toUri()
return "coronawarnapp://check-ins/$encodedUrl/?cleanHistory=$cleanHistory".toUri()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import timber.log.Timber
class CheckInsViewModel @AssistedInject constructor(
@Assisted private val savedState: SavedStateHandle,
@Assisted private val deepLink: String?,
@Assisted private val cleanHistory: Boolean,
dispatcherProvider: DispatcherProvider,
@AppScope private val appScope: CoroutineScope,
private val qrCodeUriParser: QRCodeUriParser,
Expand Down Expand Up @@ -143,7 +144,12 @@ class CheckInsViewModel @AssistedInject constructor(
Timber.i("uri: $uri")
val qrCodePayload = qrCodeUriParser.getQrCodePayload(uri)
val verifiedTraceLocation = VerifiedTraceLocation(qrCodePayload)
events.postValue(CheckInEvent.ConfirmCheckIn(verifiedTraceLocation))
events.postValue(
if (cleanHistory)
CheckInEvent.ConfirmCheckInWithoutHistory(verifiedTraceLocation)
else
CheckInEvent.ConfirmCheckIn(verifiedTraceLocation)
)
} catch (e: Exception) {
Timber.d(e, "TraceLocation verification failed")
e.report(ExceptionCategory.INTERNAL)
Expand All @@ -162,7 +168,8 @@ class CheckInsViewModel @AssistedInject constructor(
interface Factory : CWAViewModelFactory<CheckInsViewModel> {
fun create(
savedState: SavedStateHandle,
deepLink: String?
deepLink: String?,
cleanHistory: Boolean
): CheckInsViewModel
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ class CheckInOnboardingFragment : Fragment(R.layout.fragment_trace_location_onbo
super.onViewCreated(view, savedInstanceState)

if (viewModel.isOnboardingComplete && args.uri != null) {
doNavigate(CheckInOnboardingFragmentDirections.actionCheckInOnboardingFragmentToCheckInsFragment(args.uri))
doNavigate(
CheckInOnboardingFragmentDirections.actionCheckInOnboardingFragmentToCheckInsFragment(
args.uri,
args.cleanHistory
)
)
}

with(binding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class TraceLocationsFragment : Fragment(R.layout.trace_location_organizer_trace_

is TraceLocationEvent.SelfCheckIn -> {
findNavController().navigate(
CheckInsFragment.createCheckInUri(it.traceLocation.locationUrl),
CheckInsFragment.createCheckInUri(it.traceLocation.locationUrl, true),
NavOptions.Builder()
.setPopUpTo(R.id.checkInsFragment, true)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:name="de.rki.coronawarnapp.ui.eventregistration.attendee.onboarding.CheckInOnboardingFragment"
android:label="CheckInOnboardingFragment"
tools:layout="@layout/fragment_trace_location_onboarding">
<deepLink app:uri="coronawarnapp://check-ins/{uri}" />
<deepLink app:uri="coronawarnapp://check-ins/{uri}/?cleanHistory={cleanHistory}" />
<action
android:id="@+id/action_checkInOnboardingFragment_to_checkInsFragment"
app:destination="@id/checkInsFragment"
Expand All @@ -22,6 +22,10 @@
android:name="showBottomNav"
android:defaultValue="true"
app:argType="boolean" />
<argument
android:name="cleanHistory"
android:defaultValue="false"
app:argType="boolean" />
<argument
android:name="uri"
android:defaultValue="@null"
Expand Down Expand Up @@ -68,11 +72,20 @@
<action
android:id="@+id/action_checkInsFragment_to_confirmCheckInFragment"
app:destination="@id/confirmCheckInFragment" />
<action
android:id="@+id/action_checkInsFragment_to_confirmCheckInFragment_cleanHistory"
app:popUpTo="@id/checkInsFragment"
app:popUpToInclusive="true"
app:destination="@id/confirmCheckInFragment" />
<argument
android:name="uri"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
android:name="cleanHistory"
android:defaultValue="false"
app:argType="boolean" />
<action
android:id="@+id/action_checkInsFragment_to_editCheckInFragment"
app:destination="@id/editCheckInFragment" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class CheckInsViewModelTest : BaseTest() {
qrCodeUriParser = qrCodeUriParser,
checkInsRepository = checkInsRepository,
checkOutHandler = checkOutHandler,
cameraPermissionProvider = cameraPermissionProvider
cameraPermissionProvider = cameraPermissionProvider,
cleanHistory = false
)

companion object {
Expand Down