diff --git a/form/src/main/java/org/dhis2/form/model/UiEventType.kt b/form/src/main/java/org/dhis2/form/model/UiEventType.kt index c07a86484a..5e7a85142e 100644 --- a/form/src/main/java/org/dhis2/form/model/UiEventType.kt +++ b/form/src/main/java/org/dhis2/form/model/UiEventType.kt @@ -3,7 +3,6 @@ package org.dhis2.form.model enum class UiEventType { DATE_TIME, AGE_CALENDAR, - AGE_YEAR_MONTH_DAY, ORG_UNIT, REQUEST_CURRENT_LOCATION, REQUEST_LOCATION_BY_MAP, diff --git a/form/src/main/java/org/dhis2/form/ui/FormView.kt b/form/src/main/java/org/dhis2/form/ui/FormView.kt index 0c491fff3a..93748e0c28 100644 --- a/form/src/main/java/org/dhis2/form/ui/FormView.kt +++ b/form/src/main/java/org/dhis2/form/ui/FormView.kt @@ -493,8 +493,6 @@ class FormView : Fragment() { private fun uiEventHandler(uiEvent: RecyclerViewUiEvents) { when (uiEvent) { is RecyclerViewUiEvents.OpenCustomCalendar -> showCustomCalendar(uiEvent) - is RecyclerViewUiEvents.OpenYearMonthDayAgeCalendar -> {} - is RecyclerViewUiEvents.OpenTimePicker -> showTimePicker(uiEvent) is RecyclerViewUiEvents.ShowDescriptionLabelDialog -> showDescriptionLabelDialog( uiEvent, diff --git a/form/src/main/java/org/dhis2/form/ui/event/RecyclerViewUiEvents.kt b/form/src/main/java/org/dhis2/form/ui/event/RecyclerViewUiEvents.kt index f4ba63b212..017b751638 100644 --- a/form/src/main/java/org/dhis2/form/ui/event/RecyclerViewUiEvents.kt +++ b/form/src/main/java/org/dhis2/form/ui/event/RecyclerViewUiEvents.kt @@ -9,13 +9,6 @@ import java.util.Date sealed class RecyclerViewUiEvents { - data class OpenYearMonthDayAgeCalendar( - val uid: String, - val year: Int, - val month: Int, - val day: Int, - ) : RecyclerViewUiEvents() - data class OpenCustomCalendar( val uid: String, val label: String, diff --git a/form/src/main/java/org/dhis2/form/ui/event/UiEventFactoryImpl.kt b/form/src/main/java/org/dhis2/form/ui/event/UiEventFactoryImpl.kt index 20b51a84fb..ee52d3439f 100644 --- a/form/src/main/java/org/dhis2/form/ui/event/UiEventFactoryImpl.kt +++ b/form/src/main/java/org/dhis2/form/ui/event/UiEventFactoryImpl.kt @@ -9,7 +9,6 @@ import org.dhis2.form.model.UiEventType.ADD_FILE import org.dhis2.form.model.UiEventType.ADD_PICTURE import org.dhis2.form.model.UiEventType.ADD_SIGNATURE import org.dhis2.form.model.UiEventType.AGE_CALENDAR -import org.dhis2.form.model.UiEventType.AGE_YEAR_MONTH_DAY import org.dhis2.form.model.UiEventType.COPY_TO_CLIPBOARD import org.dhis2.form.model.UiEventType.DATE_TIME import org.dhis2.form.model.UiEventType.EMAIL @@ -27,7 +26,6 @@ import org.dhis2.form.model.UiRenderType import org.hisp.dhis.android.core.common.FeatureType import org.hisp.dhis.android.core.common.ValueType import timber.log.Timber -import java.util.Calendar class UiEventFactoryImpl( val uid: String, @@ -54,6 +52,7 @@ class UiEventFactoryImpl( value?.let { DateUtils.oldUiDateFormat().parse(it) }, allowFutureDates ?: true, ) + ValueType.DATETIME -> RecyclerViewUiEvents.OpenCustomCalendar( uid, label, @@ -61,55 +60,56 @@ class UiEventFactoryImpl( allowFutureDates ?: true, isDateTime = true, ) + ValueType.TIME -> RecyclerViewUiEvents.OpenTimePicker( uid, label, value?.let { DateUtils.timeFormat().parse(it) }, ) + else -> null } } + AGE_CALENDAR -> RecyclerViewUiEvents.OpenCustomCalendar( uid = uid, label = label, date = value?.toDate(), allowFutureDates = allowFutureDates ?: false, ) - AGE_YEAR_MONTH_DAY -> { - val yearMonthDay = valueToYearMonthDay(value) - RecyclerViewUiEvents.OpenYearMonthDayAgeCalendar( - uid = uid, - year = yearMonthDay[0], - month = yearMonthDay[1], - day = yearMonthDay[2], - ) - } + ORG_UNIT -> RecyclerViewUiEvents.OpenOrgUnitDialog( uid, label, value, fieldUiModel.orgUnitSelectorScope, ) + REQUEST_CURRENT_LOCATION -> RecyclerViewUiEvents.RequestCurrentLocation( uid = uid, ) + REQUEST_LOCATION_BY_MAP -> RecyclerViewUiEvents.RequestLocationByMap( uid = uid, featureType = getFeatureType(renderingType), value = value, ) + SHOW_DESCRIPTION -> RecyclerViewUiEvents.ShowDescriptionLabelDialog( title = label, message = description, ) + ADD_PICTURE -> RecyclerViewUiEvents.AddImage(uid) SHOW_PICTURE -> RecyclerViewUiEvents.ShowImage( label, value ?: "", ) + COPY_TO_CLIPBOARD -> RecyclerViewUiEvents.CopyToClipboard( value = value, ) + QR_CODE -> { if (value.isNullOrEmpty() && fieldUiModel.editable) { RecyclerViewUiEvents.ScanQRCode( @@ -130,6 +130,7 @@ class UiEventFactoryImpl( null } } + OPTION_SET -> RecyclerViewUiEvents.OpenOptionSetDialog(fieldUiModel) ADD_SIGNATURE -> RecyclerViewUiEvents.AddSignature(uid, label) ADD_FILE -> RecyclerViewUiEvents.OpenFileSelector(fieldUiModel) @@ -140,11 +141,13 @@ class UiEventFactoryImpl( value, uid, ) + SHARE_IMAGE -> RecyclerViewUiEvents.OpenChooserIntent( Intent.ACTION_SEND, fieldUiModel.displayName, uid, ) + else -> null } } catch (e: Exception) { @@ -163,9 +166,4 @@ class UiEventFactoryImpl( else -> FeatureType.NONE } } - - private fun valueToYearMonthDay(value: String?) = value?.toDate()?.let { - Calendar.getInstance().time = it - DateUtils.getDifference(it, Calendar.getInstance().time) - } ?: intArrayOf(0, 0, 0) }