From 860634f140e6de7f71cca98c93885f81a51b66a8 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Fri, 27 Nov 2020 17:45:30 +0500 Subject: [PATCH 1/4] Translation fixes for gender and family planning type --- .../fp/activity/BaseFpProfileActivity.java | 2 +- .../fp/provider/BaseFpRegisterProvider.java | 4 +-- .../org/smartregister/chw/fp/util/FpUtil.java | 33 ++++++++++++------- .../src/main/res/values/strings.xml | 2 ++ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/activity/BaseFpProfileActivity.java b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/activity/BaseFpProfileActivity.java index 8c8b99b..90fe626 100644 --- a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/activity/BaseFpProfileActivity.java +++ b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/activity/BaseFpProfileActivity.java @@ -276,7 +276,7 @@ public void setProfileViewDetails(FpMemberObject fpMemberObject) { int age = new Period(new DateTime(fpMemberObject.getAge()), new DateTime()).getYears(); tvName.setText(String.format(Locale.getDefault(), "%s %s %s, %d", fpMemberObject.getFirstName(), fpMemberObject.getMiddleName(), fpMemberObject.getLastName(), age)); - tvGender.setText(fpMemberObject.getGender()); + tvGender.setText(FpUtil.getGenderTranslated(this, fpMemberObject.getGender())); tvLocation.setText(fpMemberObject.getAddress()); tvUniqueID.setText(fpMemberObject.getUniqueId()); imageRenderHelper.refreshProfileImage(fpMemberObject.getBaseEntityId(), profileImageView, FpUtil.getMemberProfileImageResourceIDentifier()); diff --git a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/provider/BaseFpRegisterProvider.java b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/provider/BaseFpRegisterProvider.java index 5f1028a..6f032dd 100644 --- a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/provider/BaseFpRegisterProvider.java +++ b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/provider/BaseFpRegisterProvider.java @@ -66,9 +66,9 @@ private void populatePatientColumn(CommonPersonObjectClient pc, final RegisterVi int age = new Period(new DateTime(dobString), new DateTime()).getYears(); String patientName = getName(firstName, Utils.getValue(pc.getColumnmaps(), FamilyPlanningConstants.DBConstants.LAST_NAME, true)); - String methodAccepted = FpUtil.getTranslatedMethodValue(FamilyPlanningConstants.DBConstants.FP_METHOD_ACCEPTED, context); + String methodAccepted = Utils.getValue(pc.getColumnmaps(), FamilyPlanningConstants.DBConstants.FP_METHOD_ACCEPTED, true); viewHolder.patientName.setText(patientName + ", " + age); - viewHolder.textViewFpMethod.setText(Utils.getValue(pc.getColumnmaps(), methodAccepted, true)); + viewHolder.textViewFpMethod.setText(FpUtil.getTranslatedMethodValue(methodAccepted, context)); viewHolder.textViewVillage.setText(Utils.getValue(pc.getColumnmaps(), FamilyPlanningConstants.DBConstants.VILLAGE_TOWN, true)); viewHolder.patientColumn.setOnClickListener(onClickListener); viewHolder.patientColumn.setTag(pc); diff --git a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/util/FpUtil.java b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/util/FpUtil.java index 199856e..c2810c8 100644 --- a/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/util/FpUtil.java +++ b/opensrp-chw-family-planning/src/main/java/org/smartregister/chw/fp/util/FpUtil.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Nullable; import org.json.JSONObject; +import org.opensrp.api.constants.Gender; import org.smartregister.chw.fp.FpLibrary; import org.smartregister.chw.fp.contract.BaseFpCallDialogContract; import org.smartregister.chw.fp.dao.FpDao; @@ -153,28 +154,29 @@ public static void processChangeFpMethod(String baseEntityId) { public static String getTranslatedMethodValue(@Nullable String fpMethod, Context context){ if(fpMethod != null){ + fpMethod = fpMethod.toLowerCase(); switch (fpMethod){ - case "COC": + case "cdc": return context.getString(R.string.coc); - case "POP": + case "pop": return context.getString(R.string.pop); - case "Female sterilization": + case "female sterilization": return context.getString(R.string.female_sterilization); - case "Injectable": + case "injectable": return context.getString(R.string.injectable); - case "Male condom": + case "male condom": return context.getString(R.string.male_condom); - case "Female condom": + case "female condom": return context.getString(R.string.female_condom); - case "IUCD": + case "iucd": return context.getString(R.string.iucd); - case "Implanon - NXT": + case "implanon - nxt": return context.getString(R.string.implanon); - case "Male sterilization": + case "male sterilization": return context.getString(R.string.male_sterilization); - case "Jadelle": + case "jadelle": return context.getString(R.string.jadelle); - case "Standard day method": + case "standard day method": return context.getString(R.string.standard_day_method); default: return fpMethod; @@ -182,4 +184,13 @@ public static String getTranslatedMethodValue(@Nullable String fpMethod, Context } return fpMethod; } + + public static String getGenderTranslated(Context context, String gender) { + if (gender.equalsIgnoreCase(Gender.MALE.toString())) { + return context.getResources().getString(R.string.male); + } else if (gender.equalsIgnoreCase(Gender.FEMALE.toString())) { + return context.getResources().getString(R.string.female); + } + return ""; + } } diff --git a/opensrp-chw-family-planning/src/main/res/values/strings.xml b/opensrp-chw-family-planning/src/main/res/values/strings.xml index 04a4e43..0ae0469 100644 --- a/opensrp-chw-family-planning/src/main/res/values/strings.xml +++ b/opensrp-chw-family-planning/src/main/res/values/strings.xml @@ -99,4 +99,6 @@ {0} follow-up 1 {0} follow-up 2 {0} follow-up 3 + Male + Female From 1270442adc90505101e5536da239c0d8a73a0d68 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Mon, 30 Nov 2020 15:18:32 +0500 Subject: [PATCH 2/4] Updated library version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 747b3ec..562062d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.0.26-SNAPSHOT +VERSION_NAME=1.0.27-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client CHW Family Planning Library From 66431f51d30f47988b5362bb16e357480fe962a9 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Thu, 10 Dec 2020 10:21:52 +0500 Subject: [PATCH 3/4] Updated translations --- .../src/main/res/values-sw/strings.xml | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/opensrp-chw-family-planning/src/main/res/values-sw/strings.xml b/opensrp-chw-family-planning/src/main/res/values-sw/strings.xml index cbb7bdf..8712771 100644 --- a/opensrp-chw-family-planning/src/main/res/values-sw/strings.xml +++ b/opensrp-chw-family-planning/src/main/res/values-sw/strings.xml @@ -1,33 +1,33 @@ - Uzazi wa mpango + Uzazi wa Mpango Scan QR Nyumbani - Ongeza Mwanafamilia - Viendea kazi - Hitilafu wakati wa kuanza form - Rudi kwa wateja wote wa uzazi wa mpango + Sajili Kaya + Vitendea kazi + Hitilafu wakati wa kuanza fomu + Rudi kwenye wateja wote wa uzazi wa mpango MKUU WA KAYA Mlezi Rekodi tembeleo la ufuatiliaji wa uzazi wa mpango - Tembeleo la ufuatiliaji wa uzazi wa mpango limefanyika + Tembeleo la ufuatiliaji wa uzazi wa mpango limekamilka Tembeleo halifanyiki mwezi huu Tembeleo la mwisho Tembeleo la mwisho %1$s iliyopita chini ya masaa 24 - Siku + siku Hariri Angalia usajili wa Uzazi wa Mpango - Angalia historia ya matitbabu - Huduma zinazofuata + Angalia historia ya huduma + Angalia huduma zinazokaribia Hakuna huduma iliyofika muda wake kwenye kaya Huduma zimefikia muda wake kwenye kaya inayofuata (%2$s)]]> iliyopitiliza muda (%2$s)]]> imefika (%2$s) ]]> huduma zilizopitiliza muda wake]]> - Elekea kwenye taarifa binafsi za kaya + Elekea kwenye taarifa za kaya Hitilafu wakati wa kuhifadhi fomu - Tembeleo la\nufuatiliaji + Tembeleo la\nUfuatiliaji Panga Uzazi wa mpango Inahifadhi @@ -42,22 +42,22 @@ Inayofuata kufika mda %s %s Siku zimefika mda wake - Imefika leo - %s siku zimepita - Imepita leo + UMEFIKA LEO + %s SIKU ZIMEPITA + UMEPITA LEO Tembeleo la ufuatiliaji wa uzazi wa mpango Madhara Ushauri Sambaza upya %s - Hudhurio linalofuatala la kituoni + Hudhurio linalofuata Idadi ya kondomu Namba ya mzunguko wa vidonge: Tarehe inayofuata ya sindano: Madhara: - Shughuli: + Hatua: - Ndiyo - Hapana + ndiyo + hapana Matokeo ya aleji Kuvuja damu nyingi @@ -70,11 +70,11 @@ Hedhi nzito na mkakamao mkali wa misuli wakati wa hedhi Kutoa kitanzi Kutoka damu kwenye upasuaji - Pus/Kutoka kwa majimaji kwenye upasuaji + Kutoka kwa majimaji kwenye upasuaji Kuvimba kwenye upasuaji - Imesimamiwa - Rufaa imetolewa + Amepata huduma + Amepewa rufaa Kondomu ya kiume @@ -89,13 +89,15 @@ Kitanzi Njia ya kalenda Vidonge nya dharura - Sio husika + haiusiki Vipandikizi Imeanza Imewashwa {0} jaza tena - {0} ufuatiliaji 1 - {0} ufuatiliaji 2 - {0} ufuatiliaji 3 + {0} ufuatiliaji wa 1 + {0} ufuatiliaji wa 2 + {0} ufuatiliaji wa 3 + Me + Ke From d207f406850d8ce48a2a40cfa3e8e07a203d10c4 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Thu, 10 Dec 2020 10:57:48 +0500 Subject: [PATCH 4/4] Increase test coverage --- .../smartregister/chw/fp/util/FpUtilTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 opensrp-chw-family-planning/src/test/java/org/smartregister/chw/fp/util/FpUtilTest.java diff --git a/opensrp-chw-family-planning/src/test/java/org/smartregister/chw/fp/util/FpUtilTest.java b/opensrp-chw-family-planning/src/test/java/org/smartregister/chw/fp/util/FpUtilTest.java new file mode 100644 index 0000000..4e3be4e --- /dev/null +++ b/opensrp-chw-family-planning/src/test/java/org/smartregister/chw/fp/util/FpUtilTest.java @@ -0,0 +1,27 @@ +package org.smartregister.chw.fp.util; + +import android.content.Context; +import android.content.res.Resources; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.smartregister.fp.R; + +public class FpUtilTest { + + + @Test + public void testGetGender() { + Context context = Mockito.mock(Context.class); + Resources resources = Mockito.mock(Resources.class); +// + Mockito.doReturn(resources).when(context).getResources(); + Mockito.doReturn("Male").when(resources).getString(R.string.male); + Mockito.doReturn("Female").when(resources).getString(R.string.female); + + Assert.assertEquals("Male", FpUtil.getGenderTranslated(context, "male")); + Assert.assertEquals("Female", FpUtil.getGenderTranslated(context, "female")); + } + +}