diff --git a/gradle.properties b/gradle.properties index a2da63d62..75a72bf12 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.10.5-SNAPSHOT +VERSION_NAME=0.10.6-ALPHA1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Child Library diff --git a/opensrp-child/src/main/java/org/smartregister/child/activity/BaseChildImmunizationActivity.java b/opensrp-child/src/main/java/org/smartregister/child/activity/BaseChildImmunizationActivity.java index 58182b3b2..ba5e95f4a 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/activity/BaseChildImmunizationActivity.java +++ b/opensrp-child/src/main/java/org/smartregister/child/activity/BaseChildImmunizationActivity.java @@ -403,7 +403,7 @@ protected int[] updateGenderViews(Gender gender) { identifier = getString(R.string.male_sex_id); } - if (Locale.getDefault().toString().equalsIgnoreCase("ar") || Locale.getDefault().toString().equalsIgnoreCase("fr")) { + if (Locale.getDefault().toString().startsWith("ar") || Locale.getDefault().toString().equalsIgnoreCase("fr")) { identifier = ""; } toolbar.updateSeparatorView(toolbarResource); @@ -1903,6 +1903,21 @@ protected void onPostExecute(Map> map) { updateVaccinationViews(vaccineList, alertList); performRegisterActions(); + // PRint Vaccine Schedule For logging + StringBuilder vaccineGiven = new StringBuilder(); + for (Vaccine vaccine : vaccineList) { + vaccineGiven.append(vaccine.getName()).append("|").append(vaccine.getDate()).append("\n"); + } + vaccineGiven.append("Current Device Time: " + DateTime.now().toString("yyyy-MM-dd'T'HH:mm:ssZ") + "\n"); + Timber.e("Vaccines given for " + childDetails.name() + " with id " + childDetails.entityId() + " is: \n" + vaccineGiven); + + String vaccineAlerts = ""; + for (Alert vaccine : alertList) { + vaccineAlerts += vaccine.scheduleName() + "|" + vaccine.status() + "|" + vaccine.startDate() + "|" + vaccine.expiryDate() + "\n"; + } + vaccineAlerts += "Current Device Time: " + DateTime.now().toString("yyyy-MM-dd'T'HH:mm:ssZ") + "\n"; + Timber.e("Vaccine Schedule for " + childDetails.name() + " with id " + childDetails.entityId() + " is: \n" + vaccineAlerts); + hideProgressDialog(); } } diff --git a/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseAdvancedSearchFragment.java b/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseAdvancedSearchFragment.java index adb3eb307..783ab566e 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseAdvancedSearchFragment.java +++ b/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseAdvancedSearchFragment.java @@ -103,7 +103,7 @@ public abstract class BaseAdvancedSearchFragment extends BaseChildRegisterFragme private AdvanceSearchDatePickerDialog startDateDatePicker; private AdvanceSearchDatePickerDialog endDateDatePicker; private final SimpleDateFormat dateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, - Locale.getDefault().toString().startsWith("ar") ? Locale.ENGLISH : Locale.getDefault()); + Utils.getDefaultLocale()); @SuppressLint("StaticFieldLeak") private final Listener moveToMyCatchmentListener = moveToCatchmentEvent -> { if (moveToCatchmentEvent != null) { diff --git a/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseChildRegistrationDataFragment.java b/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseChildRegistrationDataFragment.java index 0d5a47341..321cef502 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseChildRegistrationDataFragment.java +++ b/opensrp-child/src/main/java/org/smartregister/child/fragment/BaseChildRegistrationDataFragment.java @@ -279,8 +279,10 @@ public String cleanValue(Field field, String raw) { case JsonFormConstants.DATE_PICKER: Date date = ChildJsonFormUtils.formatDate(raw.contains("T") ? raw.substring(0, raw.indexOf('T')) : raw, false); if (date != null) { - result = new SimpleDateFormat(com.vijay.jsonwizard.utils.FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, - Locale.getDefault().toString().startsWith("ar") ? Locale.ENGLISH : Locale.getDefault()).format(date); + result = new SimpleDateFormat( + com.vijay.jsonwizard.utils.FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, + Utils.getDefaultLocale() + ).format(date); } break; case JsonFormConstants.SPINNER: diff --git a/opensrp-child/src/main/java/org/smartregister/child/fragment/ChildFormFragment.java b/opensrp-child/src/main/java/org/smartregister/child/fragment/ChildFormFragment.java index 1452ad956..927e58b3b 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/fragment/ChildFormFragment.java +++ b/opensrp-child/src/main/java/org/smartregister/child/fragment/ChildFormFragment.java @@ -407,8 +407,7 @@ private String getCurrentFieldValue(Map columnMaps, String field String value = getValue(columnMaps, fieldName, !getNonHumanizedFields().contains(fieldName)); if (getActivity() != null) { Locale locale = getActivity().getResources().getConfiguration().locale; - SimpleDateFormat mlsLookupDateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, - locale.getLanguage().equals("ar") ? Locale.ENGLISH : locale); + SimpleDateFormat mlsLookupDateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, Utils.getDefaultLocale()); if (fieldName.equalsIgnoreCase(Constants.KEY.DOB)) { String dobString = getValue(columnMaps, Constants.KEY.DOB, false); Date motherDob = Utils.dobStringToDate(dobString); diff --git a/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildAdvancedSearchModel.java b/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildAdvancedSearchModel.java index 29b9d4025..a77e56f14 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildAdvancedSearchModel.java +++ b/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildAdvancedSearchModel.java @@ -181,9 +181,9 @@ public String getMainConditionString(Map editMap) { private void convertDateToDesiredFormat(Map editMap) { try { - if(editMap.containsKey(START_DATE) && editMap.containsKey(END_DATE)) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()); - SimpleDateFormat desiredDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); + if (editMap.containsKey(START_DATE) && editMap.containsKey(END_DATE)) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Utils.getDefaultLocale()); + SimpleDateFormat desiredDateFormat = new SimpleDateFormat("yyyy-MM-dd", Utils.getDefaultLocale()); Date parsedStartDate = simpleDateFormat.parse(editMap.get(START_DATE)); Date parsedEndDate = simpleDateFormat.parse(editMap.get(END_DATE)); editMap.put(START_DATE, desiredDateFormat.format(parsedStartDate)); diff --git a/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildRegisterModel.java b/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildRegisterModel.java index 8d23db5c4..5fff42902 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildRegisterModel.java +++ b/opensrp-child/src/main/java/org/smartregister/child/model/BaseChildRegisterModel.java @@ -152,8 +152,7 @@ private void updateMotherDetails(ChildEventClient childHeadEventClient, Client c String dob = null; try { - dob = Utils.reverseHyphenatedString(Utils.convertDateFormat(childHeadEventClient.getClient().getBirthdate(), new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()))); - + dob = Utils.reverseHyphenatedString(Utils.convertDateFormat(childHeadEventClient.getClient().getBirthdate(), new SimpleDateFormat("dd-MM-yyyy", org.smartregister.util.Utils.getDefaultLocale()))); } catch (Exception e) { Timber.e(e); } diff --git a/opensrp-child/src/main/java/org/smartregister/child/util/Utils.java b/opensrp-child/src/main/java/org/smartregister/child/util/Utils.java index ac0d417c8..8978f624c 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/util/Utils.java +++ b/opensrp-child/src/main/java/org/smartregister/child/util/Utils.java @@ -95,7 +95,7 @@ * Created by ndegwamartin on 25/02/2019. */ public class Utils extends org.smartregister.util.Utils { - public static final SimpleDateFormat DB_DF = new SimpleDateFormat(Constants.SQLITE_DATE_TIME_FORMAT); + public static final SimpleDateFormat DB_DF = new SimpleDateFormat(Constants.SQLITE_DATE_TIME_FORMAT, Utils.getDefaultLocale()); public static int getProfileImageResourceIDentifier() { return R.mipmap.ic_child; @@ -799,15 +799,15 @@ public static boolean isChildTemporaryOOC(@NotNull Map childDeta public static String getLocationIdFromChildTempOOCEvent(String baseEntityId) { EventClientRepository eventClientRepository = ChildLibrary.getInstance().eventClientRepository(); - String query = "SELECT "+ EventClientRepository.event_column.json.name() +" FROM " + String query = "SELECT " + EventClientRepository.event_column.json.name() + " FROM " + EventClientRepository.Table.event.name() + " WHERE " - + "eventType = '"+ MOVE_TO_CATCHMENT_SYNC_EVENT +"' " - + "AND baseEntityId = '"+ baseEntityId +"' " - + "ORDER BY "+EventClientRepository.event_column.dateCreated.name()+" DESC LIMIT 1"; + + "eventType = '" + MOVE_TO_CATCHMENT_SYNC_EVENT + "' " + + "AND baseEntityId = '" + baseEntityId + "' " + + "ORDER BY " + EventClientRepository.event_column.dateCreated.name() + " DESC LIMIT 1"; List moveToCatchmentSyncEventClient = eventClientRepository.fetchEventClientsCore(query, null); org.smartregister.domain.Event moveToCatchmentSyncEvent = moveToCatchmentSyncEventClient.get(0).getEvent(); - String locationId = ""; + String locationId = ""; for (int i = moveToCatchmentSyncEvent.getObs().size() - 1; i > -1; i--) { org.smartregister.domain.Obs obs = moveToCatchmentSyncEvent.getObs().get(i); diff --git a/opensrp-child/src/test/java/org/smartregister/child/presenter/ChildUnderFiveFragmentPresenterTest.java b/opensrp-child/src/test/java/org/smartregister/child/presenter/ChildUnderFiveFragmentPresenterTest.java index a39c3b422..86afa9915 100644 --- a/opensrp-child/src/test/java/org/smartregister/child/presenter/ChildUnderFiveFragmentPresenterTest.java +++ b/opensrp-child/src/test/java/org/smartregister/child/presenter/ChildUnderFiveFragmentPresenterTest.java @@ -664,4 +664,4 @@ public void testGetProfilePhotoByClientObjectReturnsCorrectPhotoInstance() { Assert.assertEquals(TEST_PHOTO_LINE_PATH, photo.getFilePath()); } -} \ No newline at end of file +} diff --git a/opensrp-child/src/test/java/org/smartregister/child/util/UtilsTest.java b/opensrp-child/src/test/java/org/smartregister/child/util/UtilsTest.java index 8e4b73dfb..38c39805a 100644 --- a/opensrp-child/src/test/java/org/smartregister/child/util/UtilsTest.java +++ b/opensrp-child/src/test/java/org/smartregister/child/util/UtilsTest.java @@ -529,4 +529,4 @@ public void testIsChildHasNFCCardShouldReturnTrueIfCardIsBlacklisted() { boolean isChildHasNFCCard = Utils.isChildHasNFCCard(childDetails); Assert.assertFalse(isChildHasNFCCard); } -} \ No newline at end of file +}