Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 265960c

Browse files
BarnaBarthabarnabartha
andauthored
SORMAS-Foundation#3458 - set clear to unknown button for symptoms on mobile app (SORMAS-Foundation#3847)
* SORMAS-Foundation#3458 - set clear to unknown button for symptoms on mobile app * SORMAS-Foundation#3458 - fix clear buttons layout on symptoms edit fragment Co-authored-by: barnabartha <[email protected]>
1 parent 4f40058 commit 265960c

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

sormas-app/app/src/main/java/de/symeda/sormas/app/symptoms/SymptomsEditFragment.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515

1616
package de.symeda.sormas.app.symptoms;
1717

18-
import static android.view.View.GONE;
19-
import static android.view.View.VISIBLE;
18+
import android.content.res.Resources;
19+
import android.view.View;
2020

2121
import java.util.ArrayList;
2222
import java.util.List;
2323

24-
import android.content.res.Resources;
25-
import android.view.View;
26-
2724
import de.symeda.sormas.api.Disease;
2825
import de.symeda.sormas.api.person.ApproximateAgeType;
2926
import de.symeda.sormas.api.symptoms.CongenitalHeartDiseaseType;
@@ -59,6 +56,9 @@
5956
import de.symeda.sormas.app.util.Bundler;
6057
import de.symeda.sormas.app.util.DataUtils;
6158

59+
import static android.view.View.GONE;
60+
import static android.view.View.VISIBLE;
61+
6262
public class SymptomsEditFragment extends BaseEditFragment<FragmentSymptomsEditLayoutBinding, Symptoms, AbstractDomainObject> {
6363

6464
private Symptoms record;
@@ -73,6 +73,7 @@ public class SymptomsEditFragment extends BaseEditFragment<FragmentSymptomsEditL
7373

7474
private IEntryItemOnClickListener clearAllCallback;
7575
private IEntryItemOnClickListener setClearedToNoCallback;
76+
private IEntryItemOnClickListener setClearedToUnknownCallback;
7677

7778
private List<ControlSwitchField> symptomFields;
7879

@@ -156,6 +157,7 @@ public void onLayoutBinding(final FragmentSymptomsEditLayoutBinding contentBindi
156157
contentBinding.setSymptomStateClass(SymptomState.class);
157158
contentBinding.setClearAllCallback(clearAllCallback);
158159
contentBinding.setSetClearedToNoCallback(setClearedToNoCallback);
160+
contentBinding.setSetClearedToUnknownCallback(setClearedToUnknownCallback);
159161

160162
SymptomsValidator.initializeSymptomsValidation(contentBinding, ado);
161163
}
@@ -319,6 +321,18 @@ public void onClick(View v, Object item) {
319321
}
320322
}
321323
};
324+
325+
setClearedToUnknownCallback = new IEntryItemOnClickListener() {
326+
327+
@Override
328+
public void onClick(View v, Object item) {
329+
for (ControlSwitchField symptomField : symptomFields) {
330+
if (symptomField.getVisibility() == VISIBLE && symptomField.getValue() == null) {
331+
symptomField.setValue(SymptomState.UNKNOWN);
332+
}
333+
}
334+
}
335+
};
322336
}
323337

324338
private List<Item> getTemperatures(boolean withNull) {

sormas-app/app/src/main/res/layout/fragment_symptoms_edit_layout.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<variable name="symptomStateClass" type="Class"/>
3535
<variable name="clearAllCallback" type="de.symeda.sormas.app.core.IEntryItemOnClickListener"/>
3636
<variable name="setClearedToNoCallback" type="de.symeda.sormas.app.core.IEntryItemOnClickListener"/>
37+
<variable name="setClearedToUnknownCallback" type="de.symeda.sormas.app.core.IEntryItemOnClickListener"/>
3738
<variable name="symptomsContext" type="de.symeda.sormas.api.symptoms.SymptomsContext" />
3839
</data>
3940

@@ -87,6 +88,7 @@
8788
android:layout_width="match_parent"
8889
android:layout_height="wrap_content"
8990
android:layout_marginBottom="@dimen/activity_vertical_margin"
91+
android:weightSum="2"
9092
android:orientation="horizontal">
9193

9294
<de.symeda.sormas.app.component.controls.ControlButton
@@ -103,11 +105,29 @@
103105
android:id="@+id/btn_cleared_to_no"
104106
android:layout_width="0dp"
105107
android:layout_height="wrap_content"
106-
android:layout_marginStart="@dimen/control_spacing"
107108
android:layout_weight="1"
109+
android:layout_marginLeft="@dimen/control_spacing"
108110
android:onClick="@{(view) -> setClearedToNoCallback.onClick(view, data)}"
109111
android:text="@string/action_set_cleared_to_no"
110112
app:buttonType="@{ControlButtonType.LINE_SECONDARY}"
113+
app:slim="true" />
114+
115+
</LinearLayout>
116+
117+
<LinearLayout
118+
android:layout_width="match_parent"
119+
android:layout_height="wrap_content"
120+
android:layout_marginBottom="@dimen/activity_vertical_margin"
121+
android:orientation="horizontal">
122+
123+
<de.symeda.sormas.app.component.controls.ControlButton
124+
android:id="@+id/btn_cleared_to_unknown"
125+
android:layout_width="0dp"
126+
android:layout_height="wrap_content"
127+
android:layout_weight="1"
128+
android:onClick="@{(view) -> setClearedToUnknownCallback.onClick(view, data)}"
129+
android:text="@string/action_set_cleared_to_unknown"
130+
app:buttonType="@{ControlButtonType.LINE_SECONDARY}"
111131
app:slim="true"/>
112132

113133
</LinearLayout>

sormas-app/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<string name="action_select">Select</string>
106106
<string name="action_send">Send</string>
107107
<string name="action_set_cleared_to_no">Set Cleared to No</string>
108+
<string name="action_set_cleared_to_unknown">Set Cleared to Unknown</string>
108109
<string name="action_show_classification_rules">View classification rules</string>
109110
<string name="action_submit_report">Submit Weekly Report</string>
110111
<string name="action_sync">Sync</string>

0 commit comments

Comments
 (0)