Skip to content

Commit

Permalink
#183 added the new request features
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony4m committed Jan 21, 2025
1 parent b70b500 commit c27b2a9
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.content.Context;

import de.symeda.sormas.api.ebs.ResponseStatus;
import de.symeda.sormas.api.ebs.RiskAssesment;
import de.symeda.sormas.app.R;

public class EbsAlertStatusElaborator implements StatusElaborator {
Expand All @@ -41,12 +40,10 @@ public String getFriendlyName(Context context) {
@Override
public int getColorIndicatorResource() {
switch (responseStatus) {
case NOT_STARTED:
return R.color.indicatorConfirmedContact;
case ON_GOING:
return R.color.indicatorSignal;
case COMPLETED:
return R.color.indicatorNoContact;
case ON_GOING:
return R.color.indicatorSignal;
case COMPLETED:
return R.color.indicatorNoContact;
}

return R.color.noColor;
Expand All @@ -60,13 +57,11 @@ public Enum getValue() {
@Override
public int getIconResourceId() {
switch (responseStatus) {
case NOT_STARTED:
return R.drawable.ic_lp_possible_alerts_192dp;
case ON_GOING:
case COMPLETED:
return R.drawable.ic_lp_confirmed_alerts_192dp;
default:
throw new IllegalArgumentException("Unknown response Status: " + responseStatus);
case ON_GOING:
case COMPLETED:
return R.drawable.ic_lp_confirmed_alerts_192dp;
default:
throw new IllegalArgumentException("Unknown response Status: " + responseStatus);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

package de.symeda.sormas.app.ebs.edit;

import android.content.res.Resources;

import java.util.List;

import android.content.res.Resources;
import android.view.View;

import de.symeda.sormas.api.ebs.ResponseStatus;
import de.symeda.sormas.api.utils.YesNo;
Expand All @@ -31,7 +31,6 @@
import de.symeda.sormas.app.databinding.FragmentEbsAlertEditLayoutBinding;
import de.symeda.sormas.app.util.DataUtils;


public class EbsAlertEditFragment extends BaseEditFragment<FragmentEbsAlertEditLayoutBinding, EbsAlert, EbsAlert> {

public static final String TAG = EbsAlertEditFragment.class.getSimpleName();
Expand All @@ -48,6 +47,7 @@ public static EbsAlertEditFragment newInstance(Ebs activityRootData) {
null,
UiFieldAccessCheckers.forSensitiveData(activityRootData.isPseudonymized()));
}

public static EbsAlertEditFragment newInstance(EbsAlert activityRootData) {
return newInstanceWithFieldCheckers(
EbsAlertEditFragment.class,
Expand All @@ -73,7 +73,7 @@ public EbsAlert getPrimaryData() {
@Override
protected void prepareFragmentData() {
record = getActivityRootData();
statuses = DataUtils.getEnumItems(ResponseStatus.class,true);
statuses = DataUtils.getEnumItems(ResponseStatus.class, true);
}

@Override
Expand All @@ -88,6 +88,23 @@ protected void onAfterLayoutBinding(FragmentEbsAlertEditLayoutBinding contentBin
// Initialize ControlDateFields
contentBinding.ebsAlertAlertDate.initializeDateField(getFragmentManager());
contentBinding.ebsAlertResponseDate.initializeDateField(getFragmentManager());
contentBinding.ebsAlertActionInitiated.addValueChangedListener(e -> {
updateAlertUI(contentBinding, e.getValue() == YesNo.YES);
});

updateAlertUI(contentBinding, record.getActionInitiated() == YesNo.YES);

}

private void updateAlertUI(FragmentEbsAlertEditLayoutBinding contentBinding, boolean isYes) {
int visibility = isYes ? View.VISIBLE : View.GONE;
contentBinding.ebsAlertResponseStatus.setVisibility(visibility);
contentBinding.ebsAlertDetailsResponseActivities.setVisibility(visibility);

if (!isYes) {
contentBinding.ebsAlertDetailsResponseActivities.setValue(null);
contentBinding.ebsAlertResponseStatus.setValue(null);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class EbsAlertListActivity extends PagedBaseListActivity {

public static ResponseStatus[] responseStatuses = new ResponseStatus[] {
null,
ResponseStatus.NOT_STARTED,
ResponseStatus.ON_GOING,
ResponseStatus.COMPLETED };
private EbsAlertListViewModel model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@

public class EbsAlertListAdapter extends BindingPagedListAdapter<EbsAlert, RowEbsAlertListItemLayoutBinding> {

public EbsAlertListAdapter() {super(R.layout.row_ebs_alert_list_item_layout);}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position){
super.onBindViewHolder(holder,position);

if(getItemViewType(position) == TYPE_ITEM){
BindingViewHolder<EbsAlert, RowEbsAlertListItemLayoutBinding> pagedHolder = (BindingViewHolder) holder;
EbsAlert item = getItem(position);

pagedHolder.setOnListItemClickListener(this.mOnListItemClickListener);

indicateResponseStatus(pagedHolder.binding.imgEbsStatusIcon,item);

if (item.isModifiedOrChildModified()){
pagedHolder.binding.imgSyncIcon.setVisibility(View.VISIBLE);
pagedHolder.binding.imgSyncIcon.setImageResource(R.drawable.ic_sync_blue_24dp);
}else {
pagedHolder.binding.imgSyncIcon.setVisibility(View.GONE);
}
}
}

public void indicateResponseStatus(ImageView imgStatusPriorityIcon, EbsAlert ebsAlert) {
Resources resources = imgStatusPriorityIcon.getContext().getResources();
Drawable drw = (Drawable) ContextCompat.getDrawable(imgStatusPriorityIcon.getContext(), R.drawable.indicator_status_circle);
//TODO: MAKE IT CONFORM TO RESPONSE STATUS
if (ebsAlert.getResponseStatus() == ResponseStatus.COMPLETED) {
drw.setColorFilter(resources.getColor(R.color.indicatorTaskPriorityLow), PorterDuff.Mode.SRC_OVER);
} else if (ebsAlert.getResponseStatus() == ResponseStatus.ON_GOING) {
drw.setColorFilter(resources.getColor(R.color.indicatorTaskPriorityNormal), PorterDuff.Mode.SRC_OVER);
} else if (ebsAlert.getResponseStatus() == ResponseStatus.NOT_STARTED) {
drw.setColorFilter(resources.getColor(R.color.indicatorTaskPriorityHigh), PorterDuff.Mode.SRC_OVER);
}
imgStatusPriorityIcon.setBackground(drw);
}
}
public EbsAlertListAdapter() {
super(R.layout.row_ebs_alert_list_item_layout);
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
super.onBindViewHolder(holder, position);

if (getItemViewType(position) == TYPE_ITEM) {
BindingViewHolder<EbsAlert, RowEbsAlertListItemLayoutBinding> pagedHolder = (BindingViewHolder) holder;
EbsAlert item = getItem(position);

pagedHolder.setOnListItemClickListener(this.mOnListItemClickListener);

indicateResponseStatus(pagedHolder.binding.imgEbsStatusIcon, item);

if (item.isModifiedOrChildModified()) {
pagedHolder.binding.imgSyncIcon.setVisibility(View.VISIBLE);
pagedHolder.binding.imgSyncIcon.setImageResource(R.drawable.ic_sync_blue_24dp);
} else {
pagedHolder.binding.imgSyncIcon.setVisibility(View.GONE);
}
}
}

public void indicateResponseStatus(ImageView imgStatusPriorityIcon, EbsAlert ebsAlert) {
Resources resources = imgStatusPriorityIcon.getContext().getResources();
Drawable drw = (Drawable) ContextCompat.getDrawable(imgStatusPriorityIcon.getContext(), R.drawable.indicator_status_circle);
//TODO: MAKE IT CONFORM TO RESPONSE STATUS
if (ebsAlert.getResponseStatus() == ResponseStatus.COMPLETED) {
drw.setColorFilter(resources.getColor(R.color.indicatorTaskPriorityLow), PorterDuff.Mode.SRC_OVER);
} else if (ebsAlert.getResponseStatus() == ResponseStatus.ON_GOING) {
drw.setColorFilter(resources.getColor(R.color.indicatorTaskPriorityNormal), PorterDuff.Mode.SRC_OVER);
}
imgStatusPriorityIcon.setBackground(drw);
}
}
137 changes: 79 additions & 58 deletions sormas-app/app/src/main/res/layout/fragment_ebs_alert_edit_layout.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ SORMAS® - Surveillance Outbreak Response Management & Analysis System
~ Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
~
Expand All @@ -20,18 +19,30 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="contentDescription"
android:id="@+id/base_layout"
android:descendantFocusability="beforeDescendants"
android:id="@+id/base_layout">
tools:ignore="contentDescription">


<data>

<import type="android.view.View" />
<import type="de.symeda.sormas.api.ebs.ResponseStatus"/>
<import type="de.symeda.sormas.api.utils.YesNo"/>
<variable name="data" type="de.symeda.sormas.app.backend.ebs.ebsAlert.EbsAlert"/>
<variable name="yesNoClass" type="Class" />
<variable name="responseStatusClass" type="Class" />

<import type="de.symeda.sormas.api.ebs.ResponseStatus" />

<import type="de.symeda.sormas.api.utils.YesNo" />

<variable
name="data"
type="de.symeda.sormas.app.backend.ebs.ebsAlert.EbsAlert" />

<variable
name="yesNoClass"
type="Class" />

<variable
name="responseStatusClass"
type="Class" />

</data>

Expand All @@ -57,91 +68,101 @@
app:shortUuidValue="@{data.uuid}" />
</LinearLayout>

<ImageView style="@style/FullHorizontalDividerStyle"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/ebsAlert_alertIssued"
style="@style/ControlFirstOfTwoColumnsStyle"
app:required="true"
app:enumClass="@{yesNoClass}"
app:value="@={data.alertIssued}"/>

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/ebsAlert_alertDate"
style="@style/ControlSecondOfTwoColumnsStyle"
app:dependencyParentField="@{ebsAlertAlertIssued}"
app:dependencyParentValue="@{YesNo.YES}"
app:allowedDaysInFuture="0"
app:value="@={data.alertDate}" />
</LinearLayout>
<ImageView style="@style/FullHorizontalDividerStyle" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/ebsAlert_detailsAlertUsed"
app:inputType="textMultiLine"
app:textAlignment="gravity"
app:gravity="top|start"
app:dependencyParentField="@{ebsAlertAlertIssued}"
app:dependencyParentValue="@{YesNo.YES}"
app:textArea="true"
app:singleLine="false"
app:maxLines="5"
app:value="@={data.detailsAlertUsed}"
style="@style/ControlFirstOfTwoColumnsStyle" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/ebsAlert_alertIssued"
style="@style/ControlFirstOfTwoColumnsStyle"
app:enumClass="@{yesNoClass}"
app:required="true"
app:value="@={data.alertIssued}" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/ebsAlert_alertDate"
style="@style/ControlSecondOfTwoColumnsStyle"
app:allowedDaysInFuture="0"
app:dependencyParentField="@{ebsAlertAlertIssued}"
app:dependencyParentValue="@{YesNo.YES}"
app:value="@={data.alertDate}" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/ebsAlert_detailsAlertUsed"
style="@style/ControlFirstOfTwoColumnsStyle"
app:dependencyParentField="@{ebsAlertAlertIssued}"
app:dependencyParentValue="@{YesNo.YES}"
app:dependencyParentValue2="@{YesNo.NO}"
app:gravity="top|start"
app:inputType="textMultiLine"
app:maxLines="5"
app:singleLine="false"
app:textAlignment="gravity"
app:textArea="true"
app:value="@={data.detailsAlertUsed}" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/ebsAlert_actionInitiated"
style="@style/ControlFirstOfTwoColumnsStyle"
app:required="true"
app:dependencyParentField="@{ebsAlertAlertIssued}"
app:dependencyParentValue="@{YesNo.YES}"
app:enumClass="@{yesNoClass}"
app:value="@={data.actionInitiated}"/>
app:required="true"
app:value="@={data.actionInitiated}" />
</LinearLayout>
<LinearLayout

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlSwitchField
android:id="@+id/ebsAlert_responseStatus"
style="@style/ControlFirstOfTwoColumnsStyle"
app:required="true"
app:enumClass="@{responseStatusClass}"
app:value="@={data.responseStatus}"/>
app:required="true"
app:value="@={data.responseStatus}" />

<de.symeda.sormas.app.component.controls.ControlDateField
android:id="@+id/ebsAlert_responseDate"
style="@style/ControlSecondOfTwoColumnsStyle"
app:allowedDaysInFuture="0"
app:dependencyParentField="@{ebsAlertResponseStatus}"
app:dependencyParentValue="@{ResponseStatus.COMPLETED}"
app:allowedDaysInFuture="0"
app:value="@={data.responseDate}" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<de.symeda.sormas.app.component.controls.ControlTextEditField
android:id="@+id/ebsAlert_detailsResponseActivities"
app:inputType="textMultiLine"
app:textAlignment="gravity"
style="@style/ControlFirstOfTwoColumnsStyle"
app:gravity="top|start"
app:inputType="textMultiLine"
app:maxLines="5"
app:required="true"
app:textArea="true"
app:singleLine="false"
app:maxLines="5"
app:value="@={data.detailsResponseActivities}"
style="@style/ControlFirstOfTwoColumnsStyle" />
app:textAlignment="gravity"
app:textArea="true"
app:value="@={data.detailsResponseActivities}" />
</LinearLayout>
</LinearLayout>

Expand Down
Loading

0 comments on commit c27b2a9

Please sign in to comment.