Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [ANDROAPP-5830] update mobile UI version to 0.2-20240103.112017-2 #3461

Merged
merged 7 commits into from
Jan 24, 2024
Merged
10 changes: 6 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
<activity android:name=".usescases.programEventDetail.ProgramEventDetailActivity" />
<activity
android:name=".usescases.searchTrackEntity.SearchTEActivity"
android:configChanges="keyboardHidden|screenSize" />
android:configChanges="keyboardHidden|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
/>
<activity android:name=".usescases.teiDashboard.TeiDashboardMobileActivity" />
<activity android:name=".usescases.qrScanner.ScanActivity" />
<activity android:name=".usescases.teiDashboard.teiProgramList.TeiProgramListActivity" />
Expand All @@ -98,7 +100,7 @@
<activity android:name=".utils.WebViewActivity" />
<activity
android:name=".usescases.eventsWithoutRegistration.eventInitial.EventInitialActivity"
android:windowSoftInputMode="stateHidden" />
android:windowSoftInputMode="stateAlwaysHidden" />
<activity android:name=".usescases.qrCodes.QrActivity" />
<activity android:name=".usescases.qrCodes.eventsworegistration.QrEventsWORegistrationActivity" />

Expand All @@ -125,7 +127,7 @@
<activity
android:name=".usescases.eventsWithoutRegistration.eventCapture.EventCaptureActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize|stateHidden" />
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity android:name=".usescases.sync.SyncActivity" />

<service
Expand All @@ -137,7 +139,7 @@
<activity
android:name=".usescases.enrollment.EnrollmentActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize|stateHidden" />
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity android:name=".usescases.events.ScheduledEventActivity" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -348,13 +348,13 @@ class EnrollmentActivity : ActivityGlobalAbstract(), EnrollmentView {
}

override fun displayTeiPicture(picturePath: String) {
ImageDetailBottomDialog(
null,
File(picturePath),
).show(
supportFragmentManager,
ImageDetailBottomDialog.TAG,
val intent = ImageDetailActivity.intent(
context = this,
title = null,
imagePath = picturePath,
)

startActivity(intent)
}
/*endregion*/
/*region ACCESS*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers

import androidx.compose.foundation.background
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ExposedDropdownMenuBox
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import org.dhis2.R
import org.dhis2.commons.resources.ResourceManager
Expand All @@ -27,7 +20,6 @@ import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventDa
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventOrgUnit
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventTemp
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventTempStatus
import org.dhis2.utils.category.CategoryDialog.Companion.DEFAULT_COUNT_LIMIT
import org.hisp.dhis.android.core.arch.helpers.GeometryHelper
import org.hisp.dhis.android.core.arch.helpers.Result
import org.hisp.dhis.android.core.category.CategoryOption
Expand All @@ -36,6 +28,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
Expand All @@ -46,8 +39,6 @@ import org.hisp.dhis.mobile.ui.designsystem.component.InputShellState
import org.hisp.dhis.mobile.ui.designsystem.component.Orientation
import org.hisp.dhis.mobile.ui.designsystem.component.RadioButtonData
import org.hisp.dhis.mobile.ui.designsystem.component.internal.DateTransformation
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
Expand Down Expand Up @@ -197,7 +188,6 @@ fun ProvideOrgUnit(
)
}

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun ProvideCategorySelector(
modifier: Modifier = Modifier,
Expand All @@ -206,7 +196,6 @@ fun ProvideCategorySelector(
detailsEnabled: Boolean,
currentDate: Date?,
selectedOrgUnit: String?,
onShowCategoryDialog: (EventCategory) -> Unit,
onClearCatCombo: (EventCategory) -> Unit,
onOptionSelected: (CategoryOption?) -> Unit,
required: Boolean = false,
Expand All @@ -218,74 +207,31 @@ fun ProvideCategorySelector(
)
}

var expanded by remember { mutableStateOf(false) }

ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = {},
) {
InputDropDown(
modifier = modifier,
title = category.name,
state = getInputState(detailsEnabled),
selectedItem = selectedItem,
onResetButtonClicked = {
selectedItem = null
onClearCatCombo(category)
},
onArrowDropDownButtonClicked = {
expanded = !expanded
},
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ import org.dhis2.databinding.EventDetailsFragmentBinding
import org.dhis2.maps.views.MapSelectorActivity
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.injection.EventDetailsComponentProvider
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.injection.EventDetailsModule
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventCategory
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.models.EventDetails
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.ProvideCategorySelector
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.ProvideCoordinates
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.ProvideInputDate
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.ProvideOrgUnit
import org.dhis2.usescases.eventsWithoutRegistration.eventDetails.providers.ProvideRadioButtons
import org.dhis2.usescases.general.FragmentGlobalAbstract
import org.dhis2.utils.category.CategoryDialog
import org.dhis2.utils.category.CategoryDialog.Companion.TAG
import org.dhis2.utils.customviews.PeriodDialog
import org.hisp.dhis.android.core.common.FeatureType
import org.hisp.dhis.android.core.enrollment.EnrollmentStatus
Expand Down Expand Up @@ -179,9 +176,6 @@ class EventDetailsFragment : FragmentGlobalAbstract() {
detailsEnabled = details.enabled,
currentDate = date.currentDate,
selectedOrgUnit = details.selectedOrgUnit,
onShowCategoryDialog = {
showCategoryDialog(it)
},
onClearCatCombo = {
viewModel.onClearCatCombo()
},
Expand Down Expand Up @@ -346,18 +340,6 @@ class EventDetailsFragment : FragmentGlobalAbstract() {
showInfoDialog(getString(R.string.error), getString(R.string.no_org_units))
}

private fun showCategoryDialog(category: EventCategory) {
CategoryDialog(
CategoryDialog.Type.CATEGORY_OPTIONS,
category.uid,
true,
viewModel.eventDate.value.currentDate,
) { categoryOption ->
val selectedOption = Pair(category.uid, categoryOption)
viewModel.setUpCategoryCombo(selectedOption)
}.show(requireActivity().supportFragmentManager, TAG)
}

private fun getEventCreationType(typeString: String?): EventCreationType {
return typeString?.let {
EventCreationType.valueOf(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -231,8 +230,13 @@ class SearchTEList : FragmentGlobalAbstract() {
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -259,14 +258,14 @@ class SearchTEMap : FragmentGlobalAbstract(), MapboxMap.OnMapClickListener {
true
}
.addOnProfileImageClickListener { path: String? ->
if (binding.mapCarousel.carouselEnabled) {
ImageDetailBottomDialog(
null,
File(path),
).show(
childFragmentManager,
ImageDetailBottomDialog.TAG,
if (binding.mapCarousel.carouselEnabled && !path.isNullOrBlank()) {
val intent = ImageDetailActivity.intent(
context = requireContext(),
title = null,
imagePath = path,
)

startActivity(intent)
}
Unit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -269,10 +269,13 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {
val card = teiDashboardCardMapper.map(
dashboardModel = dashboardModel,
onImageClick = { fileToShow ->
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) },
Expand Down Expand Up @@ -537,10 +540,13 @@ class TEIDataFragment : FragmentGlobalAbstract(), TEIDataContracts.View {
binding.cardFront.teiImage.setOnClickListener {
val fileToShow = File(filePath)
if (fileToShow.exists()) {
ImageDetailBottomDialog(
null,
fileToShow,
).show(childFragmentManager, ImageDetailBottomDialog.TAG)
val intent = ImageDetailActivity.intent(
context = requireActivity(),
title = null,
imagePath = fileToShow.path,
)

startActivity(intent)
}
}
}
Expand Down
Loading
Loading