Skip to content
Snippets Groups Projects
Unverified Commit 9a20a40c authored by Kolya Opahle's avatar Kolya Opahle Committed by GitHub
Browse files

Changed ConfirmCheckInFragment duration picker to 15 min based increments (#2781)


Added 15 min interval based rounding to default duration in ConfirmCheckInViewModel

Co-authored-by: default avatarLukas Lechner <lukas.lechner@sap.com>
Co-authored-by: default avatarMohamed <mohamed.metwalli@sap.com>
parent 5810717c
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,6 @@ class ConfirmCheckInFragment : Fragment(R.layout.fragment_confirm_check_in), Aut
) {
val durationPicker = DurationPicker.Builder()
.duration(defaultValue ?: "00:00")
.minutes()
.title(getString(R.string.duration_dialog_title))
.build()
durationPicker.show(parentFragmentManager, DURATION_PICKER_TAG)
......
......@@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.combine
import org.joda.time.Duration
import org.joda.time.Instant
import org.joda.time.format.DateTimeFormat
import kotlin.math.roundToLong
class ConfirmCheckInViewModel @AssistedInject constructor(
@Assisted private val verifiedTraceLocation: VerifiedTraceLocation,
......@@ -28,11 +29,14 @@ class ConfirmCheckInViewModel @AssistedInject constructor(
) : CWAViewModel() {
private val traceLocation = MutableStateFlow(verifiedTraceLocation.traceLocation)
private val createJournalEntry = MutableStateFlow(true)
private val checkInLength = MutableStateFlow(
Duration.standardMinutes(
verifiedTraceLocation.traceLocation.defaultCheckInLengthInMinutes?.toLong() ?: 0L
)
private val truncatedDefaultCheckInLength = roundToNearestValidDuration(
verifiedTraceLocation.traceLocation.defaultCheckInLengthInMinutes ?: 0
)
private val checkInLength = MutableStateFlow(truncatedDefaultCheckInLength)
private fun roundToNearestValidDuration(minutes: Int): Duration =
Duration.standardMinutes((minutes.toFloat() / 15).roundToLong() * 15)
val openDatePickerEvent = SingleLiveEvent<String>()
val events = SingleLiveEvent<ConfirmCheckInNavigation>()
......@@ -98,7 +102,7 @@ class ConfirmCheckInViewModel @AssistedInject constructor(
address = traceLocation.address,
traceLocationStart = traceLocation.startDate,
traceLocationEnd = traceLocation.endDate,
defaultCheckInLengthInMinutes = traceLocation.defaultCheckInLengthInMinutes,
defaultCheckInLengthInMinutes = truncatedDefaultCheckInLength.standardMinutes.toInt(),
cryptographicSeed = traceLocation.cryptographicSeed,
cnPublicKey = traceLocation.cnPublicKey,
checkInStart = checkInStart,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment