diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java index 2d2d569e0..d96f88492 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java @@ -13,6 +13,7 @@ import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; + import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.fragment.app.FragmentManager; @@ -22,6 +23,7 @@ import androidx.appcompat.widget.AppCompatRadioButton; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; + import android.text.TextUtils; import android.util.Log; import android.view.MenuItem; @@ -385,7 +387,7 @@ public boolean areFormViewsFilled() { } else if (childView instanceof MaterialEditText) { MaterialEditText editView = (MaterialEditText) childView; - boolean noValidation = (!childView.isEnabled() || !editView.hasValidators()); + boolean noValidation = (!childView.isEnabled() || !editView.hasValidators()); boolean valid = true; if (!noValidation && editView.getValidators() != null) { for (METValidator validator : editView.getValidators()) { @@ -520,7 +522,9 @@ public void validateAndWriteValues() { } //remove invalid fields not belonging to current step since formdata view are cleared when view is created - if (invalidFields != null && !invalidFields.isEmpty()) { + final String nextStep = getFormFragment().getJsonApi().nextStep(); + // Check if this is the last step, then skip removing invalid fields from other steps, so that the final step has all invalid fields + if (StringUtils.isNotBlank(nextStep) && invalidFields != null && !invalidFields.isEmpty()) { for (Map.Entry entry : invalidFields.entrySet()) { String key = entry.getKey(); if (StringUtils.isNotBlank(key) && !key.startsWith(mStepName)) { @@ -535,7 +539,7 @@ public void validateAndWriteValues() { * Check if alarm is ringing and stop it if so */ public void checkAndStopCountdownAlarm() { - formFragment.getJsonApi().getAppExecutors().diskIO().execute(()->{ + formFragment.getJsonApi().getAppExecutors().diskIO().execute(() -> { try { JSONObject formJSONObject = new JSONObject(formFragment.getCurrentJsonState()); JSONArray fields = FormUtils.fields(formJSONObject, mStepName); @@ -1083,7 +1087,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { String.valueOf(compoundButton.isChecked()), openMrsEntityParent, openMrsEntity, openMrsEntityId, popup); } else if ((compoundButton instanceof AppCompatRadioButton || compoundButton instanceof RadioButton) - && isChecked) { + && isChecked) { String parentKey = (String) compoundButton.getTag(R.id.key); String openMrsEntityParent = (String) compoundButton.getTag(R.id.openmrs_entity_parent); String openMrsEntity = (String) compoundButton.getTag(R.id.openmrs_entity); @@ -1269,6 +1273,7 @@ private void addRules(JSONObject jsonObject, Set ruleFiles) { } } + public void cleanUp() { cleanupAndExit = true; mJsonFormInteractor.cleanUp(); diff --git a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/views/CustomTextViewTest.java b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/views/CustomTextViewTest.java index ae09ce534..5b5dc47e3 100644 --- a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/views/CustomTextViewTest.java +++ b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/views/CustomTextViewTest.java @@ -47,4 +47,10 @@ public void testSetTextColor() { customTextView.setTextColor(expectedTextColor); Assert.assertEquals(expectedTextColor, customTextView.getTextColors().getDefaultColor()); } + + @Test + public void testIsHintOnText() { + boolean isHintOnText = customTextView.isHintOnText(); + Assert.assertTrue(isHintOnText); + } }