From 24fb8147a6b4653926ffb434d522f94aeca662a7 Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Tue, 9 Jan 2024 08:17:26 +0100 Subject: [PATCH 1/7] fix: [ANDROAPP-5830] update mobile-ui version 0.2-20240103.112017-2 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5aeba73972..46675b1f49 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ kotlin = '1.9.21' hilt = '2.47' hiltCompiler = '1.0.0' jacoco = '0.8.10' -designSystem = "1.0-20231116.084101-124" +designSystem = "0.2-20240103.112017-2" dhis2sdk = "1.10.0-20240119.100209-6" ruleEngine = "2.1.9" appcompat = "1.6.1" From 645f70e959d31ea3831dc64cce12cb2623847fbe Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Wed, 10 Jan 2024 12:56:39 +0100 Subject: [PATCH 2/7] feat: [ANDROAPP-5830] add to do's and bare minimun for compilation --- .../dhis2/usescases/enrollment/EnrollmentActivity.kt | 1 + .../eventDetails/providers/InputFieldsProvider.kt | 9 +++++---- .../searchTrackEntity/listView/SearchTEList.kt | 1 + .../usescases/searchTrackEntity/mapView/SearchTEMap.kt | 1 + .../dashboardfragments/teidata/TEIDataFragment.kt | 2 ++ form/src/main/java/org/dhis2/form/ui/FormView.kt | 1 + .../form/ui/provider/inputfield/DropdownProvider.kt | 10 +++++----- .../form/ui/provider/inputfield/ImageInputProvider.kt | 6 +++--- .../form/ui/provider/inputfield/SignatureProvider.kt | 5 ++--- 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt b/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt index 09696b45b0..78a7e35d4b 100644 --- a/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt @@ -348,6 +348,7 @@ class EnrollmentActivity : ActivityGlobalAbstract(), EnrollmentView { } override fun displayTeiPicture(picturePath: String) { + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component ImageDetailBottomDialog( null, File(picturePath), diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt index 8b159560df..a6cfa6224c 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt @@ -36,6 +36,7 @@ import org.hisp.dhis.android.core.common.Geometry import org.hisp.dhis.android.core.common.ValueType import org.hisp.dhis.mobile.ui.designsystem.component.Coordinates import org.hisp.dhis.mobile.ui.designsystem.component.DateTimeActionIconType +import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem import org.hisp.dhis.mobile.ui.designsystem.component.InputCoordinate import org.hisp.dhis.mobile.ui.designsystem.component.InputDateTime import org.hisp.dhis.mobile.ui.designsystem.component.InputDropDown @@ -197,6 +198,7 @@ fun ProvideOrgUnit( ) } +// TODO adapt Input dropdown to new Mobile ui functionality @OptIn(ExperimentalMaterialApi::class) @Composable fun ProvideCategorySelector( @@ -228,14 +230,13 @@ fun ProvideCategorySelector( modifier = modifier, title = category.name, state = getInputState(detailsEnabled), - selectedItem = selectedItem, + selectedItem = DropdownItem(selectedItem ?: ""), onResetButtonClicked = { selectedItem = null onClearCatCombo(category) }, - onArrowDropDownButtonClicked = { - expanded = !expanded - }, + onItemSelected = {}, + dropdownItems = emptyList(), isRequiredField = required, ) diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt index c585a11183..d35acf6b5f 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt @@ -230,6 +230,7 @@ class SearchTEList : FragmentGlobalAbstract() { } } + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component private fun displayImageDetail(imagePath: String) { ImageDetailBottomDialog(null, File(imagePath)) .show(childFragmentManager, ImageDetailBottomDialog.TAG) diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt index 33b28e34d5..98c8723f34 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt @@ -260,6 +260,7 @@ class SearchTEMap : FragmentGlobalAbstract(), MapboxMap.OnMapClickListener { } .addOnProfileImageClickListener { path: String? -> if (binding.mapCarousel.carouselEnabled) { + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component ImageDetailBottomDialog( null, File(path), diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index 78d3e1941b..aeaa18fa11 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -269,6 +269,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { val card = teiDashboardCardMapper.map( dashboardModel = dashboardModel, onImageClick = { fileToShow -> + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component ImageDetailBottomDialog( null, fileToShow, @@ -537,6 +538,7 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { binding.cardFront.teiImage.setOnClickListener { val fileToShow = File(filePath) if (fileToShow.exists()) { + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component ImageDetailBottomDialog( null, fileToShow, 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 bba222013f..abfddbcd60 100644 --- a/form/src/main/java/org/dhis2/form/ui/FormView.kt +++ b/form/src/main/java/org/dhis2/form/ui/FormView.kt @@ -961,6 +961,7 @@ class FormView : Fragment() { .show() } + // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component private fun showFullPicture(event: RecyclerViewUiEvents.ShowImage) { ImageDetailBottomDialog(event.label, File(event.value)) .show(parentFragmentManager, ImageDetailBottomDialog.TAG) diff --git a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/DropdownProvider.kt b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/DropdownProvider.kt index 3cc0bfa51b..ae61cd9b5f 100644 --- a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/DropdownProvider.kt +++ b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/DropdownProvider.kt @@ -19,10 +19,12 @@ import org.dhis2.form.extensions.supportingText import org.dhis2.form.model.FieldUiModel import org.dhis2.form.model.OptionSetConfiguration import org.dhis2.form.model.UiEventType +import org.hisp.dhis.mobile.ui.designsystem.component.DropdownItem import org.hisp.dhis.mobile.ui.designsystem.component.InputDropDown import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor +// TODO adapt Input dropdown to new Mobile ui functionality @OptIn(ExperimentalMaterialApi::class) @Composable fun ProvideDropdownInput( @@ -42,15 +44,13 @@ fun ProvideDropdownInput( modifier = modifier, title = fieldUiModel.label, state = fieldUiModel.inputState(), - selectedItem = selectedItem, + selectedItem = DropdownItem(selectedItem ?: ""), supportingTextData = fieldUiModel.supportingText(), legendData = fieldUiModel.legend(), isRequiredField = fieldUiModel.mandatory, onResetButtonClicked = { fieldUiModel.onClear() }, - onArrowDropDownButtonClicked = { - fieldUiModel.onItemClick() - expanded = !expanded - }, + dropdownItems = emptyList(), + onItemSelected = {}, ) if (expanded) { when (val optionSetConfig = fieldUiModel.optionSetConfiguration) { diff --git a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt index 93bcab9de8..21c96e3ac8 100644 --- a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt +++ b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt @@ -21,6 +21,7 @@ import org.dhis2.form.ui.event.RecyclerViewUiEvents import org.dhis2.form.ui.intent.FormIntent import org.hisp.dhis.mobile.ui.designsystem.component.InputImage import org.hisp.dhis.mobile.ui.designsystem.component.UploadState +// TODO adapt Input image to new Mobile ui functionality @Composable internal fun ProvideInputImage( @@ -62,9 +63,8 @@ internal fun ProvideInputImage( uploadState = getUploadState(fieldUiModel.displayName, true) fieldUiModel.invokeUiEvent(UiEventType.ADD_PICTURE) }, - onImageClick = { - uiEventHandler.invoke(RecyclerViewUiEvents.ShowImage(fieldUiModel.label, fieldUiModel.displayName ?: "")) - }, + onShareButtonClick = {}, + ) } diff --git a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt index 0bc7dccae6..0ad9ea58f4 100644 --- a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt +++ b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt @@ -20,6 +20,7 @@ import org.dhis2.form.ui.intent.FormIntent import org.hisp.dhis.mobile.ui.designsystem.component.InputSignature import java.io.File +// TODO adapt Input signature to new Mobile ui functionality @Composable fun ProvideInputSignature( modifier: Modifier, @@ -67,8 +68,6 @@ fun ProvideInputSignature( uploadState = getUploadState(fieldUiModel.displayName, true) fieldUiModel.invokeUiEvent(UiEventType.ADD_SIGNATURE) }, - onImageClick = { - uiEventHandler.invoke(RecyclerViewUiEvents.ShowImage(fieldUiModel.label, fieldUiModel.displayName ?: "")) - }, + onShareButtonClick = {}, ) } From 2b383a27216acb6f0968e54126bfec1457ccb99e Mon Sep 17 00:00:00 2001 From: Sasikanth Miriyampalli Date: Tue, 16 Jan 2024 16:48:21 +0530 Subject: [PATCH 3/7] ANDROAPP-5829-adapt-input-image-to-new-mobile-ui-functionality (#3462) * Handle `Intent.ACTION_SEND` in form view for sharing files * Open chooser intent when share button is clicked in `ImageInput` * Open chooser intent when share button is clicked in `InputSignature`` * Move `getBitmap` extension to commons module * Move `FormFileProvider` to commons module * Add image detail activity Currently we don't have a working "save image" functionality. So, it didn't make sense to copy the implementation that is not working. So for the time being I marked it as TODO * Launch `ImageDetailActivity` instead of `ImageDetailBottomDialog` * Remove `ImageDetailBottomDialog` --- .../enrollment/EnrollmentActivity.kt | 15 ++-- .../listView/SearchTEList.kt | 12 ++- .../searchTrackEntity/mapView/SearchTEMap.kt | 20 ++--- .../teidata/TEIDataFragment.kt | 26 +++--- commons/src/main/AndroidManifest.xml | 5 +- .../dhis2/commons}/data/FormFileProvider.kt | 2 +- .../imagedetail/ImageDetailActivity.kt | 79 ++++++++++++++++++ .../imagedetail/ImageDetailBottomDialog.kt | 83 ------------------- .../commons/extensions/PictureBindings.kt | 9 ++ commons/src/main/res/values/strings.xml | 1 + .../main/java/org/dhis2/form/ui/FormView.kt | 24 +++++- .../dhis2/form/ui/binding/PictureBindings.kt | 8 +- .../form/ui/dialog/QRDetailBottomDialog.kt | 2 +- .../provider/inputfield/ImageInputProvider.kt | 14 +++- .../provider/inputfield/SignatureProvider.kt | 11 ++- 15 files changed, 177 insertions(+), 134 deletions(-) rename {form/src/main/java/org/dhis2/form => commons/src/main/java/org/dhis2/commons}/data/FormFileProvider.kt (88%) create mode 100644 commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailActivity.kt delete mode 100644 commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailBottomDialog.kt create mode 100644 commons/src/main/java/org/dhis2/commons/extensions/PictureBindings.kt diff --git a/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt b/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt index 78a7e35d4b..2f6914d8af 100644 --- a/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt +++ b/app/src/main/java/org/dhis2/usescases/enrollment/EnrollmentActivity.kt @@ -19,7 +19,7 @@ import org.dhis2.commons.Constants.ENROLLMENT_UID import org.dhis2.commons.Constants.PROGRAM_UID import org.dhis2.commons.Constants.TEI_UID import org.dhis2.commons.data.TeiAttributesInfo -import org.dhis2.commons.dialogs.imagedetail.ImageDetailBottomDialog +import org.dhis2.commons.dialogs.imagedetail.ImageDetailActivity import org.dhis2.commons.featureconfig.data.FeatureConfigRepository import org.dhis2.commons.featureconfig.model.Feature import org.dhis2.databinding.EnrollmentActivityBinding @@ -348,14 +348,13 @@ class EnrollmentActivity : ActivityGlobalAbstract(), EnrollmentView { } override fun displayTeiPicture(picturePath: String) { - // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component - ImageDetailBottomDialog( - null, - File(picturePath), - ).show( - supportFragmentManager, - ImageDetailBottomDialog.TAG, + val intent = ImageDetailActivity.intent( + context = this, + title = null, + imagePath = picturePath, ) + + startActivity(intent) } /*endregion*/ /*region ACCESS*/ diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt index d35acf6b5f..d374a11429 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt @@ -21,7 +21,7 @@ import androidx.paging.PagedList import androidx.recyclerview.widget.ConcatAdapter import androidx.recyclerview.widget.RecyclerView import org.dhis2.bindings.dp -import org.dhis2.commons.dialogs.imagedetail.ImageDetailBottomDialog +import org.dhis2.commons.dialogs.imagedetail.ImageDetailActivity import org.dhis2.commons.filters.workingLists.WorkingListViewModel import org.dhis2.commons.filters.workingLists.WorkingListViewModelFactory import org.dhis2.commons.resources.ColorUtils @@ -35,7 +35,6 @@ import org.dhis2.usescases.searchTrackEntity.ui.CreateNewButton import org.dhis2.usescases.searchTrackEntity.ui.FullSearchButtonAndWorkingList import org.dhis2.usescases.searchTrackEntity.ui.mapper.TEICardMapper import org.dhis2.utils.isLandscape -import java.io.File import javax.inject.Inject const val ARG_FROM_RELATIONSHIP = "ARG_FROM_RELATIONSHIP" @@ -232,8 +231,13 @@ class SearchTEList : FragmentGlobalAbstract() { // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component private fun displayImageDetail(imagePath: String) { - ImageDetailBottomDialog(null, File(imagePath)) - .show(childFragmentManager, ImageDetailBottomDialog.TAG) + val intent = ImageDetailActivity.intent( + context = requireContext(), + title = null, + imagePath = imagePath, + ) + + startActivity(intent) } private fun observeNewData() { diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt index 98c8723f34..475fe6fbb8 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/mapView/SearchTEMap.kt @@ -14,7 +14,7 @@ import org.dhis2.animations.CarouselViewAnimations import org.dhis2.bindings.dp import org.dhis2.commons.bindings.clipWithRoundedCorners import org.dhis2.commons.data.RelationshipOwnerType -import org.dhis2.commons.dialogs.imagedetail.ImageDetailBottomDialog +import org.dhis2.commons.dialogs.imagedetail.ImageDetailActivity import org.dhis2.commons.locationprovider.LocationSettingLauncher import org.dhis2.commons.resources.ColorType import org.dhis2.commons.resources.ColorUtils @@ -33,7 +33,6 @@ import org.dhis2.usescases.searchTrackEntity.SearchTEIViewModel import org.dhis2.usescases.searchTrackEntity.SearchTeiViewModelFactory import org.dhis2.utils.NetworkUtils import org.dhis2.utils.isPortrait -import java.io.File import javax.inject.Inject const val ARG_FROM_RELATIONSHIP = "ARG_FROM_RELATIONSHIP" @@ -260,14 +259,15 @@ class SearchTEMap : FragmentGlobalAbstract(), MapboxMap.OnMapClickListener { } .addOnProfileImageClickListener { path: String? -> if (binding.mapCarousel.carouselEnabled) { - // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component - ImageDetailBottomDialog( - null, - File(path), - ).show( - childFragmentManager, - ImageDetailBottomDialog.TAG, - ) + if (!path.isNullOrBlank()) { + val intent = ImageDetailActivity.intent( + context = requireContext(), + title = null, + imagePath = path, + ) + + startActivity(intent) + } } Unit } diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt index aeaa18fa11..22e458dbf3 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataFragment.kt @@ -31,7 +31,7 @@ import org.dhis2.commons.data.EventViewModel import org.dhis2.commons.data.StageSection import org.dhis2.commons.dialogs.CustomDialog import org.dhis2.commons.dialogs.DialogClickListener -import org.dhis2.commons.dialogs.imagedetail.ImageDetailBottomDialog +import org.dhis2.commons.dialogs.imagedetail.ImageDetailActivity import org.dhis2.commons.filters.FilterItem import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.filters.FilterManager.PeriodRequest @@ -269,11 +269,13 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { val card = teiDashboardCardMapper.map( dashboardModel = dashboardModel, onImageClick = { fileToShow -> - // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component - ImageDetailBottomDialog( - null, - fileToShow, - ).show(childFragmentManager, ImageDetailBottomDialog.TAG) + val intent = ImageDetailActivity.intent( + context = requireActivity(), + title = null, + imagePath = fileToShow.path, + ) + + startActivity(intent) }, phoneCallback = { openChooser(it, Intent.ACTION_DIAL) }, emailCallback = { openChooser(it, Intent.ACTION_SENDTO) }, @@ -538,11 +540,13 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View { binding.cardFront.teiImage.setOnClickListener { val fileToShow = File(filePath) if (fileToShow.exists()) { - // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component - ImageDetailBottomDialog( - null, - fileToShow, - ).show(childFragmentManager, ImageDetailBottomDialog.TAG) + val intent = ImageDetailActivity.intent( + context = requireActivity(), + title = null, + imagePath = fileToShow.path, + ) + + startActivity(intent) } } } diff --git a/commons/src/main/AndroidManifest.xml b/commons/src/main/AndroidManifest.xml index d1a58dce21..6c8c73cf91 100644 --- a/commons/src/main/AndroidManifest.xml +++ b/commons/src/main/AndroidManifest.xml @@ -16,6 +16,9 @@ android:name="org.dhis2.commons.featureconfig.ui.FeatureConfigView" android:exported="false"/> + + - \ No newline at end of file + diff --git a/form/src/main/java/org/dhis2/form/data/FormFileProvider.kt b/commons/src/main/java/org/dhis2/commons/data/FormFileProvider.kt similarity index 88% rename from form/src/main/java/org/dhis2/form/data/FormFileProvider.kt rename to commons/src/main/java/org/dhis2/commons/data/FormFileProvider.kt index f62191993e..e807a84461 100644 --- a/form/src/main/java/org/dhis2/form/data/FormFileProvider.kt +++ b/commons/src/main/java/org/dhis2/commons/data/FormFileProvider.kt @@ -1,4 +1,4 @@ -package org.dhis2.form.data +package org.dhis2.commons.data import android.content.Context diff --git a/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailActivity.kt b/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailActivity.kt new file mode 100644 index 0000000000..b5d12adac3 --- /dev/null +++ b/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailActivity.kt @@ -0,0 +1,79 @@ +package org.dhis2.commons.dialogs.imagedetail + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import androidx.activity.compose.setContent +import androidx.appcompat.app.AppCompatActivity +import androidx.compose.runtime.remember +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.painter.BitmapPainter +import androidx.core.content.FileProvider +import org.dhis2.commons.R +import org.dhis2.commons.data.FormFileProvider +import org.dhis2.commons.extensions.getBitmap +import org.hisp.dhis.mobile.ui.designsystem.component.FullScreenImage +import timber.log.Timber +import java.io.File +import java.io.IOException + +class ImageDetailActivity : AppCompatActivity() { + + companion object { + + private const val ARG_IMAGE_TITLE = "arg_image_title" + private const val ARG_IMAGE_PATH = "arg_image_path" + + fun intent(context: Context, title: String?, imagePath: String): Intent { + return Intent(context, ImageDetailActivity::class.java).apply { + putExtra(ARG_IMAGE_TITLE, title) + putExtra(ARG_IMAGE_PATH, imagePath) + } + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val title = intent.getStringExtra(ARG_IMAGE_TITLE) + val imagePath = intent.getStringExtra(ARG_IMAGE_PATH)!! + + setContent { + val painter = remember(imagePath) { + imagePath.getBitmap()?.let { BitmapPainter(it.asImageBitmap()) } + } + + FullScreenImage( + painter = painter!!, + title = title.orEmpty(), + onDismiss = { finish() }, + onDownloadButtonClick = { saveImage(imagePath) }, + onShareButtonClick = { shareImage(imagePath) }, + ) + } + } + + private fun saveImage(image: String) { + // TODO: Implement saving image to disk + } + + private fun shareImage(image: String) { + val intent = Intent(Intent.ACTION_SEND).apply { + val contentUri = FileProvider.getUriForFile( + this@ImageDetailActivity, + FormFileProvider.fileProviderAuthority, + File(image), + ) + setDataAndType(contentUri, contentResolver.getType(contentUri)) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + putExtra(Intent.EXTRA_STREAM, contentUri) + } + + val title = resources.getString(R.string.open_with) + val chooser = Intent.createChooser(intent, title) + try { + startActivity(chooser) + } catch (e: IOException) { + Timber.e(e) + } + } +} diff --git a/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailBottomDialog.kt b/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailBottomDialog.kt deleted file mode 100644 index 09a95bd288..0000000000 --- a/commons/src/main/java/org/dhis2/commons/dialogs/imagedetail/ImageDetailBottomDialog.kt +++ /dev/null @@ -1,83 +0,0 @@ -package org.dhis2.commons.dialogs.imagedetail - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import androidx.databinding.DataBindingUtil -import com.bumptech.glide.Glide -import com.bumptech.glide.load.engine.DiskCacheStrategy -import com.bumptech.glide.load.resource.bitmap.RoundedCorners -import com.bumptech.glide.request.RequestOptions -import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog -import com.google.android.material.bottomsheet.BottomSheetDialogFragment -import org.dhis2.commons.R -import org.dhis2.commons.bindings.dp -import org.dhis2.commons.bindings.widthAndHeight -import org.dhis2.commons.databinding.DetailImageBottomDialogBinding -import org.dhis2.commons.resources.ColorType -import org.dhis2.commons.resources.ColorUtils -import java.io.File - -class ImageDetailBottomDialog( - val label: String?, - private val fileToShow: File, -) : BottomSheetDialogFragment() { - companion object { - const val TAG: String = "IMG_DETAIL_DIALOG" - } - - private lateinit var binding: DetailImageBottomDialogBinding - - val colorUtils: ColorUtils = ColorUtils() - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle?, - ): View { - binding = - DataBindingUtil.inflate(inflater, R.layout.detail_image_bottom_dialog, container, false) - binding.title = label - binding.closeButton.setImageDrawable( - colorUtils.tintDrawableWithColor( - binding.closeButton.drawable, - colorUtils.getPrimaryColor(requireContext(), ColorType.PRIMARY), - ), - ) - binding.closeButton.setOnClickListener { dismiss() } - - return binding.root - } - - // This is necessary to show the bottomSheet dialog with full height on landscape - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - view.viewTreeObserver.addOnGlobalLayoutListener { - val dialog = dialog as BottomSheetDialog - - val bottomSheet = - dialog.findViewById( - com.google.android.material.R.id.design_bottom_sheet, - ) - val behavior = BottomSheetBehavior.from(bottomSheet!!) - behavior.state = BottomSheetBehavior.STATE_EXPANDED - behavior.setPeekHeight(0) - } - } - - override fun onResume() { - super.onResume() - val (width, height) = fileToShow.widthAndHeight(300.dp) - Glide.with(this) - .load(fileToShow) - .apply(RequestOptions.skipMemoryCacheOf(true)) - .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE)) - .apply(RequestOptions.bitmapTransform(RoundedCorners(40))) - .apply(RequestOptions().override(width, height)) - .skipMemoryCache(true) - .into(binding.fullImage) - } -} diff --git a/commons/src/main/java/org/dhis2/commons/extensions/PictureBindings.kt b/commons/src/main/java/org/dhis2/commons/extensions/PictureBindings.kt new file mode 100644 index 0000000000..88bf020036 --- /dev/null +++ b/commons/src/main/java/org/dhis2/commons/extensions/PictureBindings.kt @@ -0,0 +1,9 @@ +package org.dhis2.commons.extensions + +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import java.io.File + +fun String.getBitmap(): Bitmap? = File(this) + .takeIf { it.exists() } + ?.let { BitmapFactory.decodeFile(it.absolutePath) } diff --git a/commons/src/main/res/values/strings.xml b/commons/src/main/res/values/strings.xml index 7a4741b683..537fd500d8 100644 --- a/commons/src/main/res/values/strings.xml +++ b/commons/src/main/res/values/strings.xml @@ -239,4 +239,5 @@ %d year overdue %d years overdue + Open with 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 abfddbcd60..1ab3491afc 100644 --- a/form/src/main/java/org/dhis2/form/ui/FormView.kt +++ b/form/src/main/java/org/dhis2/form/ui/FormView.kt @@ -50,11 +50,12 @@ import org.dhis2.commons.Constants import org.dhis2.commons.bindings.getFileFrom import org.dhis2.commons.bindings.getFileFromGallery import org.dhis2.commons.bindings.rotateImage +import org.dhis2.commons.data.FormFileProvider import org.dhis2.commons.dialogs.AlertBottomDialog import org.dhis2.commons.dialogs.CustomDialog import org.dhis2.commons.dialogs.calendarpicker.CalendarPicker import org.dhis2.commons.dialogs.calendarpicker.OnDatePickerListener -import org.dhis2.commons.dialogs.imagedetail.ImageDetailBottomDialog +import org.dhis2.commons.dialogs.imagedetail.ImageDetailActivity import org.dhis2.commons.extensions.closeKeyboard import org.dhis2.commons.extensions.serializable import org.dhis2.commons.extensions.truncate @@ -64,7 +65,6 @@ import org.dhis2.commons.orgunitselector.OUTreeFragment import org.dhis2.commons.orgunitselector.OrgUnitSelectorScope import org.dhis2.form.R import org.dhis2.form.data.DataIntegrityCheckResult -import org.dhis2.form.data.FormFileProvider import org.dhis2.form.data.RulesUtilsProviderConfigurationError import org.dhis2.form.data.SuccessfulResult import org.dhis2.form.data.scan.ScanContract @@ -638,6 +638,17 @@ class FormView : Fragment() { Uri.parse(currentValue.value) } } + + Intent.ACTION_SEND -> { + val contentUri = FileProvider.getUriForFile( + requireContext(), + FormFileProvider.fileProviderAuthority, + File(currentValue.value), + ) + setDataAndType(contentUri, requireContext().contentResolver.getType(contentUri)) + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + putExtra(Intent.EXTRA_STREAM, contentUri) + } } } @@ -963,8 +974,13 @@ class FormView : Fragment() { // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component private fun showFullPicture(event: RecyclerViewUiEvents.ShowImage) { - ImageDetailBottomDialog(event.label, File(event.value)) - .show(parentFragmentManager, ImageDetailBottomDialog.TAG) + val intent = ImageDetailActivity.intent( + title = event.label, + imagePath = event.value, + context = requireActivity(), + ) + + startActivity(intent) } private fun openFileSelector(event: RecyclerViewUiEvents.OpenFileSelector) { diff --git a/form/src/main/java/org/dhis2/form/ui/binding/PictureBindings.kt b/form/src/main/java/org/dhis2/form/ui/binding/PictureBindings.kt index 727c4ff47a..d8384b0d93 100644 --- a/form/src/main/java/org/dhis2/form/ui/binding/PictureBindings.kt +++ b/form/src/main/java/org/dhis2/form/ui/binding/PictureBindings.kt @@ -1,12 +1,11 @@ package org.dhis2.form.ui.binding -import android.graphics.Bitmap -import android.graphics.BitmapFactory import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.databinding.BindingAdapter +import org.dhis2.commons.extensions.getBitmap import org.dhis2.form.R import org.dhis2.form.model.FieldUiModel import org.dhis2.form.model.UiEventType @@ -18,7 +17,6 @@ import org.dhis2.ui.theme.Dhis2Theme import org.dhis2.ui.theme.errorColor import org.dhis2.ui.theme.textSecondary import org.dhis2.ui.theme.warningColor -import java.io.File @BindingAdapter("picture") fun ComposeView.setPicture(fieldUiModel: FieldUiModel) { @@ -63,7 +61,3 @@ fun ComposeView.setPicture(fieldUiModel: FieldUiModel) { } } } - -fun String.getBitmap(): Bitmap? = File(this) - .takeIf { it.exists() } - ?.let { BitmapFactory.decodeFile(it.absolutePath) } diff --git a/form/src/main/java/org/dhis2/form/ui/dialog/QRDetailBottomDialog.kt b/form/src/main/java/org/dhis2/form/ui/dialog/QRDetailBottomDialog.kt index 63e6210b54..ba11ce614c 100644 --- a/form/src/main/java/org/dhis2/form/ui/dialog/QRDetailBottomDialog.kt +++ b/form/src/main/java/org/dhis2/form/ui/dialog/QRDetailBottomDialog.kt @@ -27,10 +27,10 @@ import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.core.content.FileProvider import androidx.fragment.app.viewModels import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import org.dhis2.commons.data.FormFileProvider import org.dhis2.commons.resources.ColorType import org.dhis2.commons.resources.ColorUtils import org.dhis2.form.R -import org.dhis2.form.data.FormFileProvider import org.dhis2.form.model.UiRenderType import org.hisp.dhis.android.core.arch.helpers.FileResourceDirectoryHelper import org.hisp.dhis.lib.expression.math.GS1Elements diff --git a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt index 21c96e3ac8..554cad08f0 100644 --- a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt +++ b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/ImageInputProvider.kt @@ -1,5 +1,6 @@ package org.dhis2.form.ui.provider.inputfield +import android.content.Intent import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -9,6 +10,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.painter.BitmapPainter +import org.dhis2.commons.extensions.getBitmap import org.dhis2.commons.resources.ResourceManager import org.dhis2.form.R import org.dhis2.form.extensions.inputState @@ -16,7 +18,6 @@ import org.dhis2.form.extensions.legend import org.dhis2.form.extensions.supportingText import org.dhis2.form.model.FieldUiModel import org.dhis2.form.model.UiEventType -import org.dhis2.form.ui.binding.getBitmap import org.dhis2.form.ui.event.RecyclerViewUiEvents import org.dhis2.form.ui.intent.FormIntent import org.hisp.dhis.mobile.ui.designsystem.component.InputImage @@ -50,6 +51,15 @@ internal fun ProvideInputImage( onDownloadButtonClick = { uiEventHandler.invoke(RecyclerViewUiEvents.OpenFile(fieldUiModel)) }, + onShareButtonClick = { + uiEventHandler.invoke( + RecyclerViewUiEvents.OpenChooserIntent( + Intent.ACTION_SEND, + fieldUiModel.displayName, + fieldUiModel.uid, + ), + ) + }, onResetButtonClicked = { fieldUiModel.onClear() uploadState = getUploadState(fieldUiModel.displayName, false) @@ -63,8 +73,6 @@ internal fun ProvideInputImage( uploadState = getUploadState(fieldUiModel.displayName, true) fieldUiModel.invokeUiEvent(UiEventType.ADD_PICTURE) }, - onShareButtonClick = {}, - ) } diff --git a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt index 0ad9ea58f4..3d49a4fa2d 100644 --- a/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt +++ b/form/src/main/java/org/dhis2/form/ui/provider/inputfield/SignatureProvider.kt @@ -1,5 +1,6 @@ package org.dhis2.form.ui.provider.inputfield +import android.content.Intent import android.graphics.BitmapFactory import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -68,6 +69,14 @@ fun ProvideInputSignature( uploadState = getUploadState(fieldUiModel.displayName, true) fieldUiModel.invokeUiEvent(UiEventType.ADD_SIGNATURE) }, - onShareButtonClick = {}, + onShareButtonClick = { + uiEventHandler.invoke( + RecyclerViewUiEvents.OpenChooserIntent( + Intent.ACTION_SEND, + fieldUiModel.displayName, + fieldUiModel.uid, + ), + ) + }, ) } From 441efed034a8c3e27fce67cd052e8247e256e8ec Mon Sep 17 00:00:00 2001 From: Xavier Molloy <44061143+xavimolloy@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:51:23 +0100 Subject: [PATCH 4/7] feat: [ANDROAPP-5848] Adapt Input dropdown to new functionality (#3465) * feat: [ANDROAPP-5848] remove old option set dialog, recycler event and deprecated code. refactor OptionSetConfiguration to default adapt input dropdown to new functionality * feat: [ANDROAPP-5848] remove deprecated code * fix: [ANDROAPP-5848] remove deprecated code * fix: [ANDROAPP-5848] ktlint fix * fix: [ANDROAPP-5848] dismiss keyboard on dismiss popup * fix: [ANDROAPP-5848] add old pop in again to maintain old form logic --- app/src/main/AndroidManifest.xml | 10 +- .../providers/InputFieldsProvider.kt | 103 ++++-------------- .../eventDetails/ui/EventDetailsFragment.kt | 3 - .../EventInitialRepositoryImpl.java | 1 - .../listView/SearchTEList.kt | 1 - .../workingLists/WorkingListChipGroup.kt | 4 +- form/src/main/AndroidManifest.xml | 1 + .../dhis2/form/data/EnrollmentRepository.kt | 4 +- .../org/dhis2/form/data/EventRepository.kt | 4 +- .../form/model/OptionSetConfiguration.kt | 4 +- .../main/java/org/dhis2/form/ui/FormView.kt | 3 +- .../provider/inputfield/DropdownProvider.kt | 97 ++++------------- 12 files changed, 62 insertions(+), 173 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d3e5e952e1..0a64207c11 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -89,7 +89,9 @@ + android:configChanges="keyboardHidden|screenSize" + android:windowSoftInputMode="stateAlwaysHidden" + /> @@ -98,7 +100,7 @@ + android:windowSoftInputMode="stateAlwaysHidden" /> @@ -125,7 +127,7 @@ + android:windowSoftInputMode="adjustResize|stateAlwaysHidden" /> + android:windowSoftInputMode="adjustResize|stateAlwaysHidden" /> Unit, onClearCatCombo: (EventCategory) -> Unit, onOptionSelected: (CategoryOption?) -> Unit, required: Boolean = false, @@ -220,73 +207,31 @@ fun ProvideCategorySelector( ) } - var expanded by remember { mutableStateOf(false) } - - ExposedDropdownMenuBox( - expanded = expanded, - onExpandedChange = {}, - ) { - InputDropDown( - modifier = modifier, - title = category.name, - state = getInputState(detailsEnabled), - selectedItem = DropdownItem(selectedItem ?: ""), - onResetButtonClicked = { - selectedItem = null - onClearCatCombo(category) - }, - onItemSelected = {}, - dropdownItems = emptyList(), - isRequiredField = required, - ) - - if (expanded) { - if (category.optionsSize > DEFAULT_COUNT_LIMIT) { - onShowCategoryDialog(category) - expanded = false - } else { - DropdownMenu( - modifier = modifier.exposedDropdownSize(), - expanded = expanded, - onDismissRequest = { expanded = false }, - ) { - val selectableOptions = category.options - .filter { option -> - option.access().data().write() - }.filter { option -> - option.inDateRange(currentDate) - }.filter { option -> - option.inOrgUnit(selectedOrgUnit) - } - selectableOptions.forEach { option -> - val isSelected = option.displayName() == selectedItem - DropdownMenuItem( - modifier = Modifier.background( - when { - isSelected -> SurfaceColor.PrimaryContainer - else -> Color.Transparent - }, - ), - content = { - Text( - text = option.displayName() ?: option.code() ?: "", - color = when { - isSelected -> TextColor.OnPrimaryContainer - else -> TextColor.OnSurface - }, - ) - }, - onClick = { - expanded = false - selectedItem = option.displayName() - onOptionSelected(option) - }, - ) - } - } - } + val selectableOptions = category.options + .filter { option -> + option.access().data().write() + }.filter { option -> + option.inDateRange(currentDate) + }.filter { option -> + option.inOrgUnit(selectedOrgUnit) } - } + val dropdownItems = selectableOptions.map { DropdownItem(it.displayName() ?: it.code() ?: "") } + InputDropDown( + modifier = modifier, + title = category.name, + state = getInputState(detailsEnabled), + selectedItem = DropdownItem(selectedItem ?: ""), + onResetButtonClicked = { + selectedItem = null + onClearCatCombo(category) + }, + onItemSelected = { newSelectedDropdownItem -> + selectedItem = newSelectedDropdownItem.label + onOptionSelected(selectableOptions.firstOrNull { it.displayName() == newSelectedDropdownItem.label }) + }, + dropdownItems = dropdownItems, + isRequiredField = required, + ) } private fun getInputState(enabled: Boolean) = if (enabled) { diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/ui/EventDetailsFragment.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/ui/EventDetailsFragment.kt index 74561abba0..b55ac76a97 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/ui/EventDetailsFragment.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/ui/EventDetailsFragment.kt @@ -179,9 +179,6 @@ class EventDetailsFragment : FragmentGlobalAbstract() { detailsEnabled = details.enabled, currentDate = date.currentDate, selectedOrgUnit = details.selectedOrgUnit, - onShowCategoryDialog = { - showCategoryDialog(it) - }, onClearCatCombo = { viewModel.onClearCatCombo() }, diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialRepositoryImpl.java b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialRepositoryImpl.java index 7b3d36fbf0..f9c53b58f1 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialRepositoryImpl.java +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventInitial/EventInitialRepositoryImpl.java @@ -40,7 +40,6 @@ import java.util.Date; import java.util.List; -import io.reactivex.Completable; import io.reactivex.Flowable; import io.reactivex.Observable; import timber.log.Timber; diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt index d374a11429..58d186a0e6 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/listView/SearchTEList.kt @@ -229,7 +229,6 @@ class SearchTEList : FragmentGlobalAbstract() { } } - // TODO replace ImageDetailBottomDialog with new mobile ui Image detail component private fun displayImageDetail(imagePath: String) { val intent = ImageDetailActivity.intent( context = requireContext(), diff --git a/commons/src/main/java/org/dhis2/commons/filters/workingLists/WorkingListChipGroup.kt b/commons/src/main/java/org/dhis2/commons/filters/workingLists/WorkingListChipGroup.kt index 176adc638f..125ea08aed 100644 --- a/commons/src/main/java/org/dhis2/commons/filters/workingLists/WorkingListChipGroup.kt +++ b/commons/src/main/java/org/dhis2/commons/filters/workingLists/WorkingListChipGroup.kt @@ -21,7 +21,7 @@ import org.dhis2.commons.databinding.ItemFilterWorkingListChipBinding import org.dhis2.commons.filters.FilterManager import org.dhis2.commons.filters.WorkingListFilter import org.dhis2.commons.filters.data.EmptyWorkingList -import org.hisp.dhis.mobile.ui.designsystem.component.Chip +import org.hisp.dhis.mobile.ui.designsystem.component.FilterChip import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing class WorkingListChipGroup @JvmOverloads constructor( @@ -88,7 +88,7 @@ fun WorkingListChipGroup( workingListFilterState.value?.let { workingListFilter -> LazyRow(modifier) { itemsIndexed(workingListFilter.workingLists) { index, workingList -> - Chip( + FilterChip( modifier = Modifier.padding( start = if (index == 0) Spacing.Spacing16 else Spacing.Spacing0, end = if (index == workingListFilter.workingLists.size - 1) { diff --git a/form/src/main/AndroidManifest.xml b/form/src/main/AndroidManifest.xml index d63ef3cb31..7a7f0d1e0a 100644 --- a/form/src/main/AndroidManifest.xml +++ b/form/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ diff --git a/form/src/main/java/org/dhis2/form/data/EnrollmentRepository.kt b/form/src/main/java/org/dhis2/form/data/EnrollmentRepository.kt index 7fc03cc015..03e3dd0b91 100644 --- a/form/src/main/java/org/dhis2/form/data/EnrollmentRepository.kt +++ b/form/src/main/java/org/dhis2/form/data/EnrollmentRepository.kt @@ -175,9 +175,7 @@ class EnrollmentRepository( if (!optionSet.isNullOrEmpty()) { val optionCount = d2.optionModule().options().byOptionSetUid().eq(optionSet).blockingCount() - optionSetConfig = OptionSetConfiguration.config( - optionCount, - ) { + optionSetConfig = OptionSetConfiguration.config(optionCount) { d2.optionModule().options().byOptionSetUid().eq(optionSet) .orderBySortOrder(RepositoryScope.OrderByDirection.ASC) .blockingGet() diff --git a/form/src/main/java/org/dhis2/form/data/EventRepository.kt b/form/src/main/java/org/dhis2/form/data/EventRepository.kt index 09414a55c3..d452cf7d0b 100644 --- a/form/src/main/java/org/dhis2/form/data/EventRepository.kt +++ b/form/src/main/java/org/dhis2/form/data/EventRepository.kt @@ -146,9 +146,7 @@ class EventRepository( val optionCount = d2.optionModule().options().byOptionSetUid().eq(optionSet) .blockingCount() - optionSetConfig = OptionSetConfiguration.config( - optionCount, - ) { + optionSetConfig = OptionSetConfiguration.config(optionCount) { d2.optionModule().options().byOptionSetUid().eq(optionSet) .orderBySortOrder(RepositoryScope.OrderByDirection.ASC).blockingGet() } diff --git a/form/src/main/java/org/dhis2/form/model/OptionSetConfiguration.kt b/form/src/main/java/org/dhis2/form/model/OptionSetConfiguration.kt index 77607a14e7..2b80108554 100644 --- a/form/src/main/java/org/dhis2/form/model/OptionSetConfiguration.kt +++ b/form/src/main/java/org/dhis2/form/model/OptionSetConfiguration.kt @@ -18,9 +18,11 @@ sealed class OptionSetConfiguration( ) data class BigOptionSet( + override val options: List