From 6b48a52f7389f0f8337607056008f53e60076770 Mon Sep 17 00:00:00 2001 From: bennsimon Date: Mon, 25 Jan 2021 17:41:03 +0300 Subject: [PATCH 1/6] add properties file --- .tx/config | 32 +++++++++- opensrp-eusm/build.gradle | 20 +++++++ .../main/assets/json.form/fix_problem.json | 17 +++--- .../main/assets/json.form/flag_problem.json | 59 ++++++++++--------- .../src/main/assets/json.form/looks_good.json | 5 +- .../src/main/assets/json.form/record_gps.json | 5 +- .../assets/json.form/service_point_check.json | 35 +++++------ .../eusm/activity/LoginActivity.java | 1 - .../eusm/activity/ProductInfoActivity.java | 1 + .../fragment/EusmTasksRegisterFragment.java | 1 + .../src/main/resources/fix_problem.properties | 7 +++ .../main/resources/flag_problem.properties | 28 +++++++++ .../src/main/resources/looks_good.properties | 1 + .../src/main/resources/record_gps.properties | 1 + .../resources/service_point_check.properties | 16 +++++ 15 files changed, 169 insertions(+), 60 deletions(-) create mode 100644 opensrp-eusm/src/main/resources/fix_problem.properties create mode 100644 opensrp-eusm/src/main/resources/flag_problem.properties create mode 100644 opensrp-eusm/src/main/resources/looks_good.properties create mode 100644 opensrp-eusm/src/main/resources/record_gps.properties create mode 100644 opensrp-eusm/src/main/resources/service_point_check.properties diff --git a/.tx/config b/.tx/config index 8d54c93..661d700 100644 --- a/.tx/config +++ b/.tx/config @@ -6,4 +6,34 @@ file_filter = opensrp-eusm/src/main/res/values-/strings.xml minimum_perc = 0 source_file = opensrp-eusm/src/main/res/values/strings.xml source_lang = en -type = ANDROID \ No newline at end of file +type = ANDROID + +[opensrp-eusm.fix_problem-properties] +file_filter = opensrp-eusm/src/main/resources/fix_problem_.properties +source_file = opensrp-eusm/src/main/resources/fix_problem.properties +source_lang = en +type = PROPERTIES + +[opensrp-eusm.flag_problem-properties] +file_filter = opensrp-eusm/src/main/resources/flag_problem_.properties +source_file = opensrp-eusm/src/main/resources/flag_problem.properties +source_lang = en +type = PROPERTIES + +[opensrp-eusm.looks_good-properties] +file_filter = opensrp-eusm/src/main/resources/looks_good_.properties +source_file = opensrp-eusm/src/main/resources/looks_good.properties +source_lang = en +type = PROPERTIES + +[opensrp-eusm.record_gps-properties] +file_filter = opensrp-eusm/src/main/resources/record_gps_.properties +source_file = opensrp-eusm/src/main/resources/record_gps.properties +source_lang = en +type = PROPERTIES + +[opensrp-eusm.service_point_check-properties] +file_filter = opensrp-eusm/src/main/resources/service_point_check_.properties +source_file = opensrp-eusm/src/main/resources/service_point_check.properties +source_lang = en +type = PROPERTIES \ No newline at end of file diff --git a/opensrp-eusm/build.gradle b/opensrp-eusm/build.gradle index a1cb1d6..6f4b7c2 100644 --- a/opensrp-eusm/build.gradle +++ b/opensrp-eusm/build.gradle @@ -122,6 +122,26 @@ android { buildTypes { + release { + resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"' + buildConfigField "int", "DATABASE_VERSION", '1' + buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250' + buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100' + buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' + buildConfigField "long", "SYNC_INTERVAL_IN_MINUTES", '15' + buildConfigField "long", "PULL_UNIQUE_IDS_MINUTES", '15' + buildConfigField "String", "ADMIN_PASSWORD_NOT_NEAR_STRUCTURES", '"AdminPass1"' + buildConfigField "float", "MY_LOCATION_BUFFER", '25' + buildConfigField "boolean", "VALIDATE_FAR_STRUCTURES", 'false' + buildConfigField "int", "RESOLVE_LOCATION_TIMEOUT_IN_SECONDS", '60' + buildConfigField "boolean", "DISPLAY_OUTSIDE_OPERATIONAL_AREA_MASK", 'false' + buildConfigField "boolean", "DISPLAY_DISTANCE_SCALE", 'true' + buildConfigField "String[]", "FACILITY_LEVELS", '{"Country", "Region", "District"}' + buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Region", "District"}' + + testCoverageEnabled true + } + debug { resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"' buildConfigField "int", "DATABASE_VERSION", '1' diff --git a/opensrp-eusm/src/main/assets/json.form/fix_problem.json b/opensrp-eusm/src/main/assets/json.form/fix_problem.json index 466637a..fde941b 100644 --- a/opensrp-eusm/src/main/assets/json.form/fix_problem.json +++ b/opensrp-eusm/src/main/assets/json.form/fix_problem.json @@ -48,7 +48,7 @@ "encounter_location": "" }, "step1": { - "title": "Fix problem", + "title": "{{fix_problem.step1.title}}", "display_back_button": true, "fields": [ { @@ -57,20 +57,20 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "Was the problem fixed?", + "label": "{{fix_problem.step1.problem_fixed.label}}", "options": [ { "key": "yes", - "text": "Yes" + "text": "{{fix_problem.step1.problem_fixed.options.yes.text}}" }, { "key": "no", - "text": "No" + "text": "{{fix_problem.step1.problem_fixed.options.no.text}}" } ], "v_required": { "value": true, - "err": "Field requred" + "err": "{{fix_problem.step1.problem_fixed.v_required.err}}" } }, { @@ -79,7 +79,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Why was the problem not able to be fixed?", + "hint": "{{fix_problem.step1.not_fixed_reason.hint}}", "relevance": { "step1:problem_fixed": { "type": "string", @@ -93,7 +93,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "What actions were taken to fix this problem?", + "hint": "{{fix_problem.step1.fix_problem_actions.hint}}", "relevance": { "step1:problem_fixed": { "type": "string", @@ -102,5 +102,6 @@ } } ] - } + }, + "properties_file_name": "fix_problem" } \ No newline at end of file diff --git a/opensrp-eusm/src/main/assets/json.form/flag_problem.json b/opensrp-eusm/src/main/assets/json.form/flag_problem.json index fef9fe9..87aa8e4 100644 --- a/opensrp-eusm/src/main/assets/json.form/flag_problem.json +++ b/opensrp-eusm/src/main/assets/json.form/flag_problem.json @@ -48,7 +48,7 @@ "encounter_location": "" }, "step1": { - "title": "Flag Problem", + "title": "{{flag_problem.step1.title}}", "next": "step2", "fields": [ { @@ -57,7 +57,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "check_box", - "label": "Flag problem(s)", + "label": "{{flag_problem.step1.flag_problem.label}}", "label_text_style": "bold", "exclusive": [ "not_there" @@ -65,21 +65,21 @@ "options": [ { "key": "not_there", - "text": "Product is not there", + "text": "{{flag_problem.step1.flag_problem.options.not_there.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "not_good", - "text": "Product is not in good condition", + "text": "{{flag_problem.step1.flag_problem.options.not_good.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "misuse", - "text": "Product is not being used appropriately", + "text": "{{flag_problem.step1.flag_problem.options.misuse.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" @@ -87,13 +87,13 @@ ], "v_required": { "value": true, - "err": "Field required" + "err": "{{flag_problem.step1.flag_problem.v_required.err}}" } } ] }, "step2": { - "title": "Reason", + "title": "{{flag_problem.step2.title}}", "fields": [ { "key": "product_picture", @@ -101,7 +101,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "choose_image", - "uploadButtonText": "Take a photo of the product", + "uploadButtonText": "{{flag_problem.step2.product_picture.uploadButtonText}}", "relevance": { "step1:flag_problem": { "ex-checkbox": [ @@ -121,33 +121,33 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "What is wrong with the product?", + "label": "{{flag_problem.step2.not_good.label}}", "label_text_style": "bold", "options": [ { "key": "worn_broken", - "text": "Worn, damaged, or broken", + "text": "{{flag_problem.step2.not_good.options.worn_broken.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "expired", - "text": "Expired", + "text": "{{flag_problem.step2.not_good.options.expired.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "parts_missing", - "text": "Parts missing", + "text": "{{flag_problem.step2.not_good.options.parts_missing.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "other", - "text": "Other (specify)", + "text": "{{flag_problem.step2.not_good.options.other.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" @@ -155,7 +155,7 @@ ], "v_required": { "value": true, - "err": "Field required" + "err": "{{flag_problem.step2.not_good.v_required.err}}" }, "relevance": { "step1:flag_problem": { @@ -175,7 +175,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Specify other:", + "hint": "{{flag_problem.step2.not_good_specify_other.hint}}", "relevance": { "step2:not_good": { "type": "string", @@ -189,40 +189,40 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "What happened to the product?", + "label": "{{flag_problem.step2.not_there.label}}", "label_text_style": "bold", "options": [ { "key": "lost_stolen", - "text": "Lost / Stolen", + "text": "{{flag_problem.step2.not_there.options.lost_stolen.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "never_received", - "text": "Never received", + "text": "{{flag_problem.step2.not_there.options.never_received.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "discarded", - "text": "Discarded (e.g. damaged on delivery, expired)", + "text": "{{flag_problem.step2.not_there.options.discarded.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "stock_out", - "text": "Stock out", + "text": "{{flag_problem.step2.not_there.options.stock_out.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "other", - "text": "Other (specify)", + "text": "{{flag_problem.step2.not_there.options.other.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" @@ -230,7 +230,7 @@ ], "v_required": { "value": true, - "err": "Field required" + "err": "{{flag_problem.step2.not_there.v_required.err}}" }, "relevance": { "step1:flag_problem": { @@ -250,7 +250,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Specify other:", + "hint": "{{flag_problem.step2.not_there_specify_other.hint}}", "relevance": { "step2:not_there": { "type": "string", @@ -264,19 +264,19 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "How is the product not being used appropriately?", + "label": "{{flag_problem.step2.misuse.label}}", "label_text_style": "bold", "options": [ { "key": "lacks_skills", - "text": "End user lacks necessary skills or knowledge", + "text": "{{flag_problem.step2.misuse.options.lacks_skills.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" }, { "key": "fraud_use", - "text": "End user is using the product for unauthorised / fraudulent purposes", + "text": "{{flag_problem.step2.misuse.options.fraud_use.text}}", "openmrs_entity_parent": "", "openmrs_entity": "", "openmrs_entity_id": "" @@ -284,7 +284,7 @@ ], "v_required": { "value": true, - "err": "Field required" + "err": "{{flag_problem.step2.misuse.v_required.err}}" }, "relevance": { "step1:flag_problem": { @@ -304,8 +304,9 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Provide some details on the specific issue, including any advice you were able to give." + "hint": "{{flag_problem.step2.issue_details.hint}}" } ] - } + }, + "properties_file_name": "flag_problem" } \ No newline at end of file diff --git a/opensrp-eusm/src/main/assets/json.form/looks_good.json b/opensrp-eusm/src/main/assets/json.form/looks_good.json index da39b62..a5d4b87 100644 --- a/opensrp-eusm/src/main/assets/json.form/looks_good.json +++ b/opensrp-eusm/src/main/assets/json.form/looks_good.json @@ -48,7 +48,7 @@ "encounter_location": "" }, "step1": { - "title": "Looks Good", + "title": "{{looks_good.step1.title}}", "display_back_button": true, "fields": [ { @@ -59,5 +59,6 @@ "openmrs_entity_id": "" } ] - } + }, + "properties_file_name": "looks_good" } \ No newline at end of file diff --git a/opensrp-eusm/src/main/assets/json.form/record_gps.json b/opensrp-eusm/src/main/assets/json.form/record_gps.json index 46c3dad..154bdb2 100644 --- a/opensrp-eusm/src/main/assets/json.form/record_gps.json +++ b/opensrp-eusm/src/main/assets/json.form/record_gps.json @@ -48,7 +48,7 @@ "encounter_location": "" }, "step1": { - "title": "Record GPS", + "title": "{{record_gps.step1.title}}", "display_back_button": true, "fields": [ { @@ -59,5 +59,6 @@ "openmrs_entity_id": "" } ] - } + }, + "properties_file_name": "record_gps" } \ No newline at end of file diff --git a/opensrp-eusm/src/main/assets/json.form/service_point_check.json b/opensrp-eusm/src/main/assets/json.form/service_point_check.json index f1a6646..b9de258 100644 --- a/opensrp-eusm/src/main/assets/json.form/service_point_check.json +++ b/opensrp-eusm/src/main/assets/json.form/service_point_check.json @@ -48,7 +48,7 @@ "encounter_location": "" }, "step1": { - "title": "Service Point Check", + "title": "{{service_point_check.step1.title}}", "display_back_button": true, "fields": [ { @@ -57,20 +57,20 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "Are there other UNICEF-supplied products at the service point which require action (ask the End User)?", + "label": "{{service_point_check.step1.other_products_action.label}}", "options": [ { "key": "yes", - "text": "Yes" + "text": "{{service_point_check.step1.other_products_action.options.yes.text}}" }, { "key": "no", - "text": "No" + "text": "{{service_point_check.step1.other_products_action.options.no.text}}" } ], "v_required": { "value": true, - "err": "Field required" + "err": "{{service_point_check.step1.other_products_action.v_required.err}}" } }, { @@ -79,7 +79,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Please describe:", + "hint": "{{service_point_check.step1.other_products_action_description.hint}}", "relevance": { "step1:other_products_action": { "type": "string", @@ -93,20 +93,20 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "Did the End User mention any products that the service point needs (ask the End User)?", + "label": "{{service_point_check.step1.other_needed_products.label}}", "options": [ { "key": "yes", - "text": "Yes" + "text": "{{service_point_check.step1.other_needed_products.options.yes.text}}" }, { "key": "no", - "text": "No" + "text": "{{service_point_check.step1.other_needed_products.options.no.text}}" } ], "v_required": { "value": true, - "err": "Field required" + "err": "{{service_point_check.step1.other_needed_products.v_required.err}}" } }, { @@ -115,7 +115,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Please describe:", + "hint": "{{service_point_check.step1.other_needed_products_description.hint}}", "relevance": { "step1:other_needed_products": { "type": "string", @@ -129,20 +129,20 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "native_radio", - "label": "Is the service point overall in good working order?", + "label": "{{service_point_check.step1.service_point_good_order.label}}", "options": [ { "key": "yes", - "text": "Yes" + "text": "{{service_point_check.step1.service_point_good_order.options.yes.text}}" }, { "key": "no", - "text": "No" + "text": "{{service_point_check.step1.service_point_good_order.options.no.text}}" } ], "v_required": { "value": true, - "err": "Field required" + "err": "{{service_point_check.step1.service_point_good_order.v_required.err}}" } }, { @@ -151,7 +151,7 @@ "openmrs_entity": "", "openmrs_entity_id": "", "type": "edit_text", - "hint": "Please describe:", + "hint": "{{service_point_check.step1.service_point_not_good_order_reason.hint}}", "relevance": { "step1:service_point_good_order": { "type": "string", @@ -160,5 +160,6 @@ } } ] - } + }, + "properties_file_name": "service_point_check" } \ No newline at end of file diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/LoginActivity.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/LoginActivity.java index 778e439..1698713 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/LoginActivity.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/LoginActivity.java @@ -58,7 +58,6 @@ public void goToHome(boolean remote) { finish(); EusmApplication.getInstance().processServerConfigs(); - } @Override diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/ProductInfoActivity.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/ProductInfoActivity.java index c369a81..fb18370 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/ProductInfoActivity.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/ProductInfoActivity.java @@ -268,6 +268,7 @@ public void startForm(JSONObject jsonForm) { Intent intent = new Intent(getActivity(), JsonWizardFormActivity.class); intent.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, jsonForm.toString()); intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form); + intent.putExtra(JsonFormConstants.PERFORM_FORM_TRANSLATION, true); startActivityForResult(intent, AppConstants.RequestCode.REQUEST_CODE_GET_JSON); } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java index 7511045..05ac007 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java @@ -218,6 +218,7 @@ public void startFormActivity(JSONObject jsonForm) { Intent intent = new Intent(getActivity(), JsonWizardFormActivity.class); intent.putExtra(JsonFormConstants.JSON_FORM_KEY.JSON, jsonForm.toString()); intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form); + intent.putExtra(JsonFormConstants.PERFORM_FORM_TRANSLATION, true); getActivity().startActivityForResult(intent, AppConstants.RequestCode.REQUEST_CODE_GET_JSON); } diff --git a/opensrp-eusm/src/main/resources/fix_problem.properties b/opensrp-eusm/src/main/resources/fix_problem.properties new file mode 100644 index 0000000..ce60272 --- /dev/null +++ b/opensrp-eusm/src/main/resources/fix_problem.properties @@ -0,0 +1,7 @@ +fix_problem.step1.problem_fixed.options.yes.text = Yes +fix_problem.step1.problem_fixed.options.no.text = No +fix_problem.step1.problem_fixed.label = Was the problem fixed? +fix_problem.step1.not_fixed_reason.hint = Why was the problem not able to be fixed? +fix_problem.step1.title = Fix problem +fix_problem.step1.fix_problem_actions.hint = What actions were taken to fix this problem? +fix_problem.step1.problem_fixed.v_required.err = Field required diff --git a/opensrp-eusm/src/main/resources/flag_problem.properties b/opensrp-eusm/src/main/resources/flag_problem.properties new file mode 100644 index 0000000..67c5f9f --- /dev/null +++ b/opensrp-eusm/src/main/resources/flag_problem.properties @@ -0,0 +1,28 @@ +flag_problem.step1.flag_problem.options.misuse.text = Product is not being used appropriately +flag_problem.step2.title = Reason +flag_problem.step2.not_there.options.lost_stolen.text = Lost / Stolen +flag_problem.step2.not_there.label = What happened to the product? +flag_problem.step2.misuse.options.fraud_use.text = End user is using the product for unauthorised / fraudulent purposes +flag_problem.step2.issue_details.hint = Provide some details on the specific issue, including any advice you were able to give. +flag_problem.step2.not_there.options.stock_out.text = Stock out +flag_problem.step2.misuse.label = How is the product not being used appropriately? +flag_problem.step2.not_there.v_required.err = Field required +flag_problem.step2.not_good.options.other.text = Other (specify) +flag_problem.step2.misuse.options.lacks_skills.text = End user lacks necessary skills or knowledge +flag_problem.step2.product_picture.uploadButtonText = Take a photo of the product +flag_problem.step2.not_good.options.expired.text = Expired +flag_problem.step1.flag_problem.label = Flag problem(s) +flag_problem.step2.not_good.options.parts_missing.text = Parts missing +flag_problem.step2.misuse.v_required.err = Field required +flag_problem.step1.flag_problem.options.not_good.text = Product is not in good condition +flag_problem.step2.not_there.options.discarded.text = Discarded (e.g. damaged on delivery, expired) +flag_problem.step2.not_good.options.worn_broken.text = Worn, damaged, or broken +flag_problem.step1.flag_problem.options.not_there.text = Product is not there +flag_problem.step1.title = Flag Problem +flag_problem.step2.not_there.options.other.text = Other (specify) +flag_problem.step2.not_good.v_required.err = Field required +flag_problem.step1.flag_problem.v_required.err = Field required +flag_problem.step2.not_there.options.never_received.text = Never received +flag_problem.step2.not_there_specify_other.hint = Specify other: +flag_problem.step2.not_good.label = What is wrong with the product? +flag_problem.step2.not_good_specify_other.hint = Specify other: diff --git a/opensrp-eusm/src/main/resources/looks_good.properties b/opensrp-eusm/src/main/resources/looks_good.properties new file mode 100644 index 0000000..4d40de2 --- /dev/null +++ b/opensrp-eusm/src/main/resources/looks_good.properties @@ -0,0 +1 @@ +looks_good.step1.title = Looks Good diff --git a/opensrp-eusm/src/main/resources/record_gps.properties b/opensrp-eusm/src/main/resources/record_gps.properties new file mode 100644 index 0000000..ae0c531 --- /dev/null +++ b/opensrp-eusm/src/main/resources/record_gps.properties @@ -0,0 +1 @@ +record_gps.step1.title = Record GPS diff --git a/opensrp-eusm/src/main/resources/service_point_check.properties b/opensrp-eusm/src/main/resources/service_point_check.properties new file mode 100644 index 0000000..765b008 --- /dev/null +++ b/opensrp-eusm/src/main/resources/service_point_check.properties @@ -0,0 +1,16 @@ +service_point_check.step1.other_needed_products.v_required.err = Field required +service_point_check.step1.other_needed_products.options.no.text = No +service_point_check.step1.service_point_good_order.v_required.err = Field required +service_point_check.step1.other_products_action.label = Are there other UNICEF-supplied products at the service point which require action (ask the End User)? +service_point_check.step1.other_products_action.options.no.text = No +service_point_check.step1.other_needed_products_description.hint = Please describe: +service_point_check.step1.service_point_good_order.options.yes.text = Yes +service_point_check.step1.other_needed_products.label = Did the End User mention any products that the service point needs (ask the End User)? +service_point_check.step1.service_point_not_good_order_reason.hint = Please describe: +service_point_check.step1.title = Service Point Check +service_point_check.step1.service_point_good_order.options.no.text = No +service_point_check.step1.other_products_action.options.yes.text = Yes +service_point_check.step1.other_needed_products.options.yes.text = Yes +service_point_check.step1.service_point_good_order.label = Is the service point overall in good working order? +service_point_check.step1.other_products_action_description.hint = Please describe: +service_point_check.step1.other_products_action.v_required.err = Field required From d86e53f3151f1b290a5f6e88a0f676c2468a6123 Mon Sep 17 00:00:00 2001 From: bennsimon Date: Mon, 25 Jan 2021 17:53:47 +0300 Subject: [PATCH 2/6] add form translations --- .../src/main/res/values-fr/strings.xml | 7 +++++ .../main/resources/fix_problem_fr.properties | 7 +++++ .../main/resources/flag_problem_fr.properties | 28 +++++++++++++++++++ .../main/resources/looks_good_fr.properties | 1 + .../main/resources/record_gps_fr.properties | 1 + .../service_point_check_fr.properties | 16 +++++++++++ 6 files changed, 60 insertions(+) create mode 100644 opensrp-eusm/src/main/res/values-fr/strings.xml create mode 100644 opensrp-eusm/src/main/resources/fix_problem_fr.properties create mode 100644 opensrp-eusm/src/main/resources/flag_problem_fr.properties create mode 100644 opensrp-eusm/src/main/resources/looks_good_fr.properties create mode 100644 opensrp-eusm/src/main/resources/record_gps_fr.properties create mode 100644 opensrp-eusm/src/main/resources/service_point_check_fr.properties diff --git a/opensrp-eusm/src/main/res/values-fr/strings.xml b/opensrp-eusm/src/main/res/values-fr/strings.xml new file mode 100644 index 0000000..b8f28e3 --- /dev/null +++ b/opensrp-eusm/src/main/res/values-fr/strings.xml @@ -0,0 +1,7 @@ + + Afficher mot de passe + + Synchro. + Page {0} de {1} + >]]> + diff --git a/opensrp-eusm/src/main/resources/fix_problem_fr.properties b/opensrp-eusm/src/main/resources/fix_problem_fr.properties new file mode 100644 index 0000000..ce60272 --- /dev/null +++ b/opensrp-eusm/src/main/resources/fix_problem_fr.properties @@ -0,0 +1,7 @@ +fix_problem.step1.problem_fixed.options.yes.text = Yes +fix_problem.step1.problem_fixed.options.no.text = No +fix_problem.step1.problem_fixed.label = Was the problem fixed? +fix_problem.step1.not_fixed_reason.hint = Why was the problem not able to be fixed? +fix_problem.step1.title = Fix problem +fix_problem.step1.fix_problem_actions.hint = What actions were taken to fix this problem? +fix_problem.step1.problem_fixed.v_required.err = Field required diff --git a/opensrp-eusm/src/main/resources/flag_problem_fr.properties b/opensrp-eusm/src/main/resources/flag_problem_fr.properties new file mode 100644 index 0000000..67c5f9f --- /dev/null +++ b/opensrp-eusm/src/main/resources/flag_problem_fr.properties @@ -0,0 +1,28 @@ +flag_problem.step1.flag_problem.options.misuse.text = Product is not being used appropriately +flag_problem.step2.title = Reason +flag_problem.step2.not_there.options.lost_stolen.text = Lost / Stolen +flag_problem.step2.not_there.label = What happened to the product? +flag_problem.step2.misuse.options.fraud_use.text = End user is using the product for unauthorised / fraudulent purposes +flag_problem.step2.issue_details.hint = Provide some details on the specific issue, including any advice you were able to give. +flag_problem.step2.not_there.options.stock_out.text = Stock out +flag_problem.step2.misuse.label = How is the product not being used appropriately? +flag_problem.step2.not_there.v_required.err = Field required +flag_problem.step2.not_good.options.other.text = Other (specify) +flag_problem.step2.misuse.options.lacks_skills.text = End user lacks necessary skills or knowledge +flag_problem.step2.product_picture.uploadButtonText = Take a photo of the product +flag_problem.step2.not_good.options.expired.text = Expired +flag_problem.step1.flag_problem.label = Flag problem(s) +flag_problem.step2.not_good.options.parts_missing.text = Parts missing +flag_problem.step2.misuse.v_required.err = Field required +flag_problem.step1.flag_problem.options.not_good.text = Product is not in good condition +flag_problem.step2.not_there.options.discarded.text = Discarded (e.g. damaged on delivery, expired) +flag_problem.step2.not_good.options.worn_broken.text = Worn, damaged, or broken +flag_problem.step1.flag_problem.options.not_there.text = Product is not there +flag_problem.step1.title = Flag Problem +flag_problem.step2.not_there.options.other.text = Other (specify) +flag_problem.step2.not_good.v_required.err = Field required +flag_problem.step1.flag_problem.v_required.err = Field required +flag_problem.step2.not_there.options.never_received.text = Never received +flag_problem.step2.not_there_specify_other.hint = Specify other: +flag_problem.step2.not_good.label = What is wrong with the product? +flag_problem.step2.not_good_specify_other.hint = Specify other: diff --git a/opensrp-eusm/src/main/resources/looks_good_fr.properties b/opensrp-eusm/src/main/resources/looks_good_fr.properties new file mode 100644 index 0000000..4d40de2 --- /dev/null +++ b/opensrp-eusm/src/main/resources/looks_good_fr.properties @@ -0,0 +1 @@ +looks_good.step1.title = Looks Good diff --git a/opensrp-eusm/src/main/resources/record_gps_fr.properties b/opensrp-eusm/src/main/resources/record_gps_fr.properties new file mode 100644 index 0000000..862ad4e --- /dev/null +++ b/opensrp-eusm/src/main/resources/record_gps_fr.properties @@ -0,0 +1 @@ +record_gps.step1.title = Some french word diff --git a/opensrp-eusm/src/main/resources/service_point_check_fr.properties b/opensrp-eusm/src/main/resources/service_point_check_fr.properties new file mode 100644 index 0000000..765b008 --- /dev/null +++ b/opensrp-eusm/src/main/resources/service_point_check_fr.properties @@ -0,0 +1,16 @@ +service_point_check.step1.other_needed_products.v_required.err = Field required +service_point_check.step1.other_needed_products.options.no.text = No +service_point_check.step1.service_point_good_order.v_required.err = Field required +service_point_check.step1.other_products_action.label = Are there other UNICEF-supplied products at the service point which require action (ask the End User)? +service_point_check.step1.other_products_action.options.no.text = No +service_point_check.step1.other_needed_products_description.hint = Please describe: +service_point_check.step1.service_point_good_order.options.yes.text = Yes +service_point_check.step1.other_needed_products.label = Did the End User mention any products that the service point needs (ask the End User)? +service_point_check.step1.service_point_not_good_order_reason.hint = Please describe: +service_point_check.step1.title = Service Point Check +service_point_check.step1.service_point_good_order.options.no.text = No +service_point_check.step1.other_products_action.options.yes.text = Yes +service_point_check.step1.other_needed_products.options.yes.text = Yes +service_point_check.step1.service_point_good_order.label = Is the service point overall in good working order? +service_point_check.step1.other_products_action_description.hint = Please describe: +service_point_check.step1.other_products_action.v_required.err = Field required From 7b1438e95d7706e9dc526750a78776b4822cc51d Mon Sep 17 00:00:00 2001 From: bennsimon Date: Tue, 26 Jan 2021 15:12:25 +0300 Subject: [PATCH 3/6] add filter plan & group when fetching tasks and structures && added tests --- .../eusm/activity/EusmTaskingMapActivity.java | 1 + .../AppTaskingLibraryConfiguration.java | 16 +-- .../eusm/domain/EusmCardDetail.java | 9 ++ .../fragment/EusmTasksRegisterFragment.java | 6 -- .../interactor/EusmTaskingMapInteractor.java | 2 +- .../TaskRegisterFragmentInteractor.java | 77 ++++++-------- .../model/StructureRegisterFragmentModel.java | 4 +- .../repository/AppStructureRepository.java | 20 ++-- .../eusm/repository/AppTaskRepository.java | 6 +- .../smartregister/eusm/util/AppConstants.java | 1 + .../org/smartregister/eusm/util/AppUtils.java | 7 ++ .../smartregister/eusm/util/GeoJsonUtils.java | 1 + .../main/resources/record_gps_fr.properties | 2 +- .../EusmStockSyncConfigurationTest.java | 39 +++++++ .../EusmTaskingMapInteractorTest.java | 2 +- .../eusm/presenter/LoginPresenterTest.java | 100 ++++++++++++++++++ ...tructureRegisterFragmentPresenterTest.java | 37 +++++++ .../AppStructureRepositoryTest.java | 4 +- .../repository/AppTaskRepositoryTest.java | 2 +- 19 files changed, 258 insertions(+), 78 deletions(-) create mode 100644 opensrp-eusm/src/test/java/org/smartregister/eusm/configuration/EusmStockSyncConfigurationTest.java create mode 100644 opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/LoginPresenterTest.java diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java index e7852ef..ef8be9b 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java @@ -149,6 +149,7 @@ public void onClick(View v) { structureDetail.setStructureType(eusmCardDetail.getStructureType()); structureDetail.setTaskStatus(eusmCardDetail.getTaskStatus()); structureDetail.setEntityName(eusmCardDetail.getStructureName()); + structureDetail.setParentId(eusmCardDetail.getCommuneId()); Intent intent = new Intent(getActivity(), EusmTaskRegisterActivity.class); intent.putExtra(AppConstants.IntentData.STRUCTURE_DETAIL, structureDetail); diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/config/AppTaskingLibraryConfiguration.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/config/AppTaskingLibraryConfiguration.java index c942068..1c64a3b 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/config/AppTaskingLibraryConfiguration.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/config/AppTaskingLibraryConfiguration.java @@ -34,6 +34,7 @@ import org.smartregister.eusm.helper.EusmTaskingMapHelper; import org.smartregister.eusm.job.LocationTaskServiceJob; import org.smartregister.eusm.util.AppConstants; +import org.smartregister.eusm.util.AppUtils; import org.smartregister.eusm.util.DefaultLocationUtils; import org.smartregister.eusm.view.NavigationDrawerView; import org.smartregister.job.ImageUploadServiceJob; @@ -445,13 +446,14 @@ public void onFeatureSelectedByClick(Feature feature, TaskingMapActivityContract public void run() { JsonObject jsonObject = feature.properties(); if (jsonObject != null) { - EusmCardDetail eusmCardDetail = new EusmCardDetail(jsonObject.get(AppConstants.CardDetailKeys.STATUS).getAsString()); - eusmCardDetail.setCommune(jsonObject.get(AppConstants.CardDetailKeys.COMMUNE).getAsString()); - eusmCardDetail.setDistanceMeta(jsonObject.get(AppConstants.CardDetailKeys.DISTANCE_META).getAsString()); - eusmCardDetail.setStructureId(jsonObject.get(AppConstants.CardDetailKeys.STRUCTURE_ID).getAsString()); - eusmCardDetail.setTaskStatus(jsonObject.get(AppConstants.CardDetailKeys.TASK_STATUS).getAsString()); - eusmCardDetail.setStructureName(jsonObject.get(AppConstants.CardDetailKeys.NAME).getAsString()); - eusmCardDetail.setStructureType(jsonObject.get(AppConstants.CardDetailKeys.TYPE).getAsString()); + EusmCardDetail eusmCardDetail = new EusmCardDetail(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.STATUS)); + eusmCardDetail.setCommune(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.COMMUNE)); + eusmCardDetail.setDistanceMeta(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.DISTANCE_META)); + eusmCardDetail.setStructureId(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.STRUCTURE_ID)); + eusmCardDetail.setTaskStatus(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.TASK_STATUS)); + eusmCardDetail.setStructureName(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.NAME)); + eusmCardDetail.setStructureType(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.TYPE)); + eusmCardDetail.setCommuneId(AppUtils.getStringFromJsonElement(jsonObject, AppConstants.CardDetailKeys.COMMUNE_ID)); getAppExecutors().mainThread().execute(new Runnable() { @Override public void run() { diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/domain/EusmCardDetail.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/domain/EusmCardDetail.java index b421523..8ea2a4a 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/domain/EusmCardDetail.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/domain/EusmCardDetail.java @@ -11,6 +11,7 @@ public class EusmCardDetail extends CardDetails { private String structureType; private String commune; private String numOfTasks; + private String communeId; public EusmCardDetail(String status) { super(status); @@ -79,4 +80,12 @@ public String getNumOfTasks() { public void setNumOfTasks(String numOfTasks) { this.numOfTasks = numOfTasks; } + + public String getCommuneId() { + return communeId; + } + + public void setCommuneId(String communeId) { + this.communeId = communeId; + } } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java index 05ac007..347ae67 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/fragment/EusmTasksRegisterFragment.java @@ -99,12 +99,6 @@ public void setAdvancedSearchFormData(HashMap hashMap) { //do nothing } - @Override - public void onResume() { - super.onResume(); - onResumption(); - } - @Override protected void renderView() { //do nothing diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractor.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractor.java index 42df102..e49f731 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractor.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractor.java @@ -40,7 +40,7 @@ public void run() { featureCollection = createFeatureCollection(); if (operationalAreaLocation != null) { List structureDetails = appStructureRepository - .fetchStructureDetails(null, operationalAreaLocation.getId(), null, true); + .fetchStructureDetails(null, operationalAreaLocation.getId(), null, true, plan); if (structureDetails != null && !structureDetails.isEmpty()) { String features = geoJsonUtils.getGeoJsonFromStructureDetail(structureDetails); diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/TaskRegisterFragmentInteractor.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/TaskRegisterFragmentInteractor.java index 525e140..a92e1e3 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/TaskRegisterFragmentInteractor.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/TaskRegisterFragmentInteractor.java @@ -21,6 +21,7 @@ import org.smartregister.eusm.util.AppConstants; import org.smartregister.eusm.util.AppJsonFormUtils; import org.smartregister.eusm.util.AppUtils; +import org.smartregister.tasking.util.PreferencesUtil; import org.smartregister.util.AppExecutors; import java.util.Comparator; @@ -44,21 +45,13 @@ public TaskRegisterFragmentInteractor() { @Override public void fetchData(@NonNull StructureDetail structureDetail, @NonNull TaskRegisterFragmentContract.InteractorCallBack callBack) { - appExecutors.diskIO().execute(new Runnable() { - @Override - public void run() { - List taskDetails = EusmApplication.getInstance().getAppTaskRepository() - .getTasksByStructureId(structureDetail.getStructureId()); - - List sortTaskDetails = sortTaskDetails(taskDetails); - - appExecutors.mainThread().execute(new Runnable() { - @Override - public void run() { - callBack.onFetchedData(sortTaskDetails); - } - }); - } + appExecutors.diskIO().execute(() -> { + List taskDetails = EusmApplication.getInstance().getAppTaskRepository() + .getTasksByStructureId(structureDetail.getStructureId(), PreferencesUtil.getInstance().getCurrentPlanId(), structureDetail.getParentId()); + + List sortTaskDetails = sortTaskDetails(taskDetails); + + appExecutors.mainThread().execute(() -> callBack.onFetchedData(sortTaskDetails)); }); } @@ -92,45 +85,37 @@ public void injectAdditionalFields(@NonNull JSONObject jsonForm, @Override public void undoTask(TaskDetail taskDetail, TaskRegisterFragmentContract.InteractorCallBack callBack) { - appExecutors.diskIO().execute(new Runnable() { - @Override - public void run() { - if (taskDetail != null && StringUtils.isNotBlank(taskDetail.getTaskId())) { - - String taskId = taskDetail.getTaskId(); - - AppRepository appRepository = EusmApplication.getInstance().getAppRepository(); - appRepository.archiveEventsForTask(taskDetail); - - AppTaskRepository taskRepository = EusmApplication.getInstance().getAppTaskRepository(); - taskRepository.updateTaskStatus(taskId, Task.TaskStatus.READY, AppConstants.BusinessStatus.NOT_VISITED); - - //fetch fix problem task if present - if (AppConstants.BusinessStatus.HAS_PROBLEM.equals(taskDetail.getBusinessStatus())) { - Set taskSet = taskRepository.getTasksByEntityAndCode(taskDetail.getPlanId(), taskDetail.getGroupId(), - taskDetail.getForEntity(), AppConstants.EncounterType.FIX_PROBLEM); - for (Task task : taskSet) { - if (task.getStatus() == Task.TaskStatus.READY) { - taskRepository.updateTaskStatus(task.getIdentifier(), Task.TaskStatus.CANCELLED, AppConstants.BusinessStatus.NOT_VISITED); - break; - } + appExecutors.diskIO().execute(() -> { + if (taskDetail != null && StringUtils.isNotBlank(taskDetail.getTaskId())) { + + String taskId = taskDetail.getTaskId(); + + AppRepository appRepository = EusmApplication.getInstance().getAppRepository(); + appRepository.archiveEventsForTask(taskDetail); + + AppTaskRepository taskRepository = EusmApplication.getInstance().getAppTaskRepository(); + taskRepository.updateTaskStatus(taskId, Task.TaskStatus.READY, AppConstants.BusinessStatus.NOT_VISITED); + + //fetch fix problem task if present + if (AppConstants.BusinessStatus.HAS_PROBLEM.equals(taskDetail.getBusinessStatus())) { + Set taskSet = taskRepository.getTasksByEntityAndCode(taskDetail.getPlanId(), taskDetail.getGroupId(), + taskDetail.getForEntity(), AppConstants.EncounterType.FIX_PROBLEM); + for (Task task : taskSet) { + if (task.getStatus() == Task.TaskStatus.READY) { + taskRepository.updateTaskStatus(task.getIdentifier(), Task.TaskStatus.CANCELLED, AppConstants.BusinessStatus.NOT_VISITED); + break; } } - returnResponse(callBack, taskDetail, true); - } else { - returnResponse(callBack, taskDetail, false); } + returnResponse(callBack, taskDetail, true); + } else { + returnResponse(callBack, taskDetail, false); } }); } private void returnResponse(TaskRegisterFragmentContract.InteractorCallBack callBack, TaskDetail taskDetail, boolean status) { - appExecutors.mainThread().execute(new Runnable() { - @Override - public void run() { - callBack.onTaskUndone(status, taskDetail); - } - }); + appExecutors.mainThread().execute(() -> callBack.onTaskUndone(status, taskDetail)); } private List sortTaskDetails(List taskDetails_) { diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/model/StructureRegisterFragmentModel.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/model/StructureRegisterFragmentModel.java index a393272..4160265 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/model/StructureRegisterFragmentModel.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/model/StructureRegisterFragmentModel.java @@ -21,7 +21,7 @@ public StructureRegisterFragmentModel() { public int countOfStructures(String nameFilter) { Location location = Utils.getOperationalAreaLocation(PreferencesUtil.getInstance().getCurrentOperationalArea()); if (location != null) { - return appStructureRepository.countOfStructures(nameFilter, location.getId()); + return appStructureRepository.countOfStructures(nameFilter, location.getId(), PreferencesUtil.getInstance().getCurrentPlanId()); } else { return 0; } @@ -30,7 +30,7 @@ public int countOfStructures(String nameFilter) { public List fetchStructures(int pageNo, String nameFilter) { Location location = Utils.getOperationalAreaLocation(PreferencesUtil.getInstance().getCurrentOperationalArea()); if (location != null) { - return appStructureRepository.fetchStructureDetails(pageNo, location.getId(), nameFilter); + return appStructureRepository.fetchStructureDetails(pageNo, location.getId(), nameFilter, PreferencesUtil.getInstance().getCurrentPlanId()); } else { return new ArrayList<>(); } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java index 098ee7d..62ccc96 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java @@ -92,20 +92,20 @@ public void addOrUpdate(org.smartregister.domain.Location location) { getWritableDatabase().replace(getLocationTableName(), null, contentValues); } - public int countOfStructures(String nameFilter, String locationParentId) { + public int countOfStructures(String nameFilter, String locationParentId, String planId) { SQLiteDatabase sqLiteDatabase = getReadableDatabase(); String query = "SELECT count(1) from " + STRUCTURE_TABLE; - String[] args = StringUtils.stripAll(locationParentId); + String[] args = StringUtils.stripAll(locationParentId, planId); query += " join task on task.for = " + StructureRepository.STRUCTURE_TABLE + "._id "; query += " join location on location._id = " + StructureRepository.STRUCTURE_TABLE + ".parent_id "; - query += " where location.parent_id = ? "; + query += " where location.parent_id = ? AND task.plan_id = ?"; if (StringUtils.isNotBlank(nameFilter)) { - args = StringUtils.stripAll(locationParentId, nameFilter); + args = StringUtils.stripAll(locationParentId, planId, nameFilter); query += " and " + STRUCTURE_TABLE + "." + NAME + " like '%?%'"; } @@ -121,12 +121,12 @@ public int countOfStructures(String nameFilter, String locationParentId) { return count; } - public List fetchStructureDetails(int pageNo, String locationParentId, String nameFilter) { - return fetchStructureDetails(pageNo, locationParentId, nameFilter, false); + public List fetchStructureDetails(int pageNo, String locationParentId, String nameFilter, String planId) { + return fetchStructureDetails(pageNo, locationParentId, nameFilter, false, planId); } public List fetchStructureDetails(Integer pageNo, String locationParentId, - String nameFilter, boolean isForMapping) { + String nameFilter, boolean isForMapping, String planId) { List structureDetails = new ArrayList<>(); SQLiteDatabase sqLiteDatabase = getReadableDatabase(); String[] columns = new String[]{ @@ -168,9 +168,10 @@ public List fetchStructureDetails(Integer pageNo, String locati String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getLatitude()), + planId, locationParentId); - query += " where locationParentId = ? "; + query += " where task.plan_id = ? AND locationParentId = ? "; if (StringUtils.isNotBlank(nameFilter)) { args = StringUtils.stripAll( @@ -178,6 +179,7 @@ public List fetchStructureDetails(Integer pageNo, String locati String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getLatitude()), + planId, locationParentId, nameFilter); query += " and structureName like '%?%'"; @@ -228,6 +230,8 @@ private StructureDetail createStructureDetail(@NonNull Cursor cursor, boolean is structureDetail.setDistance(distanceInMetres); structureDetail.setDistanceMeta(formatDistance(distanceInMetres)); structureDetail.setNearby(distanceInMetres <= AppConstants.NEARBY_DISTANCE_IN_METRES); + } else { + structureDetail.setDistanceMeta("-"); } if (isForMapping) diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppTaskRepository.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppTaskRepository.java index edadcd7..a44e3ba 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppTaskRepository.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppTaskRepository.java @@ -29,7 +29,7 @@ public AppTaskRepository(TaskNotesRepository taskNotesRepository) { super(taskNotesRepository); } - public List getTasksByStructureId(String structureId) { + public List getTasksByStructureId(String structureId, String planId, String groupId) { List taskDetails = new ArrayList<>(); SQLiteDatabase sqLiteDatabase = getReadableDatabase(); String[] columns = new String[]{ @@ -59,8 +59,8 @@ public List getTasksByStructureId(String structureId) { + " FROM " + TASK_TABLE + " LEFT JOIN " + StockRepository.STOCK_TABLE_NAME + " ON " + StockRepository.STOCK_TABLE_NAME + "." + StockRepository.STOCK_ID + " = " + TASK_TABLE + "." + AppConstants.Column.Task.FOR + " LEFT JOIN " + StockTypeRepository.STOCK_TYPE_TABLE_NAME + " ON " + StockTypeRepository.STOCK_TYPE_TABLE_NAME + "." + StockTypeRepository.UNIQUE_ID + " = " + StockRepository.STOCK_TABLE_NAME + "." + StockRepository.IDENTIFIER + - " WHERE task.structure_id = ? AND task.status NOT IN (" + StringUtils.repeat("?",",", INACTIVE_TASK_STATUS.length) + ") group by taskId"; - try (Cursor cursor = sqLiteDatabase.rawQuery(query, ArrayUtils.addAll(new String[]{structureId}, INACTIVE_TASK_STATUS))) { + " WHERE task.structure_id = ? AND task.plan_id = ? AND task.group_id = ? AND task.status NOT IN (" + StringUtils.repeat("?", ",", INACTIVE_TASK_STATUS.length) + ") group by taskId"; + try (Cursor cursor = sqLiteDatabase.rawQuery(query, ArrayUtils.addAll(new String[]{structureId, planId, groupId}, INACTIVE_TASK_STATUS))) { if (cursor != null) { while (cursor.moveToNext()) { taskDetails.add(readStructureTaskDetailCursor(cursor)); diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppConstants.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppConstants.java index 12894e4..20eb159 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppConstants.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppConstants.java @@ -139,6 +139,7 @@ interface CardDetailKeys { String STATUS = "status"; String NAME = "name"; String TYPE = "type"; + String COMMUNE_ID = "communeId"; } interface LocationLevels { diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppUtils.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppUtils.java index 3e3f35f..2a0ada0 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppUtils.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/AppUtils.java @@ -8,6 +8,8 @@ import androidx.annotation.NonNull; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.vijay.jsonwizard.constants.JsonFormConstants; import org.apache.commons.lang3.StringUtils; @@ -179,4 +181,9 @@ public static Set getDistrictsFromLocationHierarchy() { } return districtIds; } + + public static String getStringFromJsonElement(JsonObject jsonObject, String key) { + JsonElement element = jsonObject.get(key); + return (element != null) ? element.getAsString() : AppConstants.CardDetailKeys.DISTANCE_META.equals(key) ? "-" : ""; + } } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/GeoJsonUtils.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/GeoJsonUtils.java index 0589b07..ffed356 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/util/GeoJsonUtils.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/util/GeoJsonUtils.java @@ -25,6 +25,7 @@ public String getGeoJsonFromStructureDetail(List structureDetai map.put(AppConstants.CardDetailKeys.TASK_STATUS, taskStatus); map.put(STRUCTURE_NAME, structureDetail.getEntityName()); map.put(AppConstants.CardDetailKeys.COMMUNE, structureDetail.getCommune()); + map.put(AppConstants.CardDetailKeys.COMMUNE_ID, structureDetail.getParentId()); map.put(AppConstants.CardDetailKeys.DISTANCE_META, structureDetail.getDistanceMeta()); map.put(AppConstants.CardDetailKeys.STRUCTURE_ID, structureDetail.getStructureId()); locations.add(location); diff --git a/opensrp-eusm/src/main/resources/record_gps_fr.properties b/opensrp-eusm/src/main/resources/record_gps_fr.properties index 862ad4e..ae0c531 100644 --- a/opensrp-eusm/src/main/resources/record_gps_fr.properties +++ b/opensrp-eusm/src/main/resources/record_gps_fr.properties @@ -1 +1 @@ -record_gps.step1.title = Some french word +record_gps.step1.title = Record GPS diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/configuration/EusmStockSyncConfigurationTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/configuration/EusmStockSyncConfigurationTest.java new file mode 100644 index 0000000..847e9b4 --- /dev/null +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/configuration/EusmStockSyncConfigurationTest.java @@ -0,0 +1,39 @@ +package org.smartregister.eusm.configuration; + +import org.json.JSONArray; +import org.junit.Before; +import org.junit.Test; +import org.smartregister.eusm.BaseUnitTest; +import org.smartregister.stock.util.Constants; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class EusmStockSyncConfigurationTest extends BaseUnitTest { + + private EusmStockSyncConfiguration stockSyncConfiguration; + + @Before + public void setUp() { + stockSyncConfiguration = new EusmStockSyncConfiguration(); + } + + @Test + public void testStockSyncRequestBody() { + String[] locationsArr = new String[]{"2"}; + + JSONArray jsonArray = new JSONArray(); + + for (String s : locationsArr) { + jsonArray.put(s); + } + + Map syncParams = new HashMap<>(); + syncParams.put(Constants.StockResponseKey.SERVER_VERSION, 5); + syncParams.put(Constants.StockResponseKey.LOCATIONS, jsonArray); + + assertEquals("{\"serverVersion\":5,\"locations\":[\"2\"]}", stockSyncConfiguration.stockSyncRequestBody(syncParams)); + } +} \ No newline at end of file diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractorTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractorTest.java index aef7b98..40d953e 100644 --- a/opensrp-eusm/src/test/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractorTest.java +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractorTest.java @@ -101,7 +101,7 @@ public void testFetchLocationsWhenOperationalAreaAvailableShouldInvokeRequiredMe structureDetails.add(structureDetail); doReturn(structureDetails).when(appStructureRepository) - .fetchStructureDetails(isNull(), anyString(), isNull(), eq(true)); + .fetchStructureDetails(isNull(), anyString(), isNull(), eq(true), isNull()); doReturn(location).when(eusmTaskingMapInteractor).getOperationalAreaLocation(eq(operationalArea)); diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/LoginPresenterTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/LoginPresenterTest.java new file mode 100644 index 0000000..30c2bae --- /dev/null +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/LoginPresenterTest.java @@ -0,0 +1,100 @@ +package org.smartregister.eusm.presenter; + +import android.graphics.drawable.GradientDrawable; +import android.view.View; +import android.widget.CheckBox; +import android.widget.TextView; + +import com.android.volley.toolbox.ImageLoader; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.robolectric.Robolectric; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.configurableviews.helper.JsonSpecHelper; +import org.smartregister.configurableviews.model.LoginConfiguration; +import org.smartregister.configurableviews.model.ViewConfiguration; +import org.smartregister.eusm.BaseUnitTest; +import org.smartregister.eusm.R; +import org.smartregister.eusm.activity.LoginActivity; +import org.smartregister.eusm.application.EusmApplication; +import org.smartregister.eusm.util.AppConstants; +import org.smartregister.eusm.util.ImageLoaderRequest; +import org.smartregister.view.activity.DrishtiApplication; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +public class LoginPresenterTest extends BaseUnitTest { + + private LoginPresenter loginPresenter; + + private LoginActivity loginView; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + loginView = spy(Robolectric.buildActivity(LoginActivity.class).create().get()); + loginPresenter = spy(new LoginPresenter(loginView)); + } + + @Test + public void testProcessViewCustomizationsShouldUpdateBackgroundAndHideSomeViews() { + EusmApplication spyEusmApplication = spy(EusmApplication.getInstance()); + JsonSpecHelper jsonSpecHelper = mock(JsonSpecHelper.class); + ReflectionHelpers.setField(spyEusmApplication, "jsonSpecHelper", jsonSpecHelper); + ViewConfiguration mockViewConfiguration = mock(ViewConfiguration.class); + ImageLoaderRequest mockImageLoaderRequest = mock(ImageLoaderRequest.class); + ImageLoader mockImageLoader = mock(ImageLoader.class); + doReturn(mockImageLoader).when(mockImageLoaderRequest).getImageLoader(); + + doReturn(mockViewConfiguration).when(jsonSpecHelper).getConfigurableView(anyString()); + + LoginConfiguration.Background background = mock(LoginConfiguration.Background.class); + doReturn("TOP_BOTTOM").when(background).getOrientation(); + doReturn("#000000").when(background).getStartColor(); + doReturn("#000000").when(background).getEndColor(); + + LoginConfiguration loginConfiguration = new LoginConfiguration(); + loginConfiguration.setLogoUrl("http://opensrpurl/login_image"); + loginConfiguration.setBackground(background); + + ReflectionHelpers.setStaticField(ImageLoaderRequest.class, "imageLoaderRequest", mockImageLoaderRequest); + + doReturn(loginConfiguration).when(mockViewConfiguration).getMetadata(); + + ReflectionHelpers.setStaticField(DrishtiApplication.class, "mInstance", spyEusmApplication); + + doReturn("{}").when(loginPresenter).getJsonViewFromPreference(eq(AppConstants.VIEW_CONFIGURATION_PREFIX + AppConstants.CONFIGURATION.LOGIN)); + + View mockView = mock(View.class); + CheckBox mockCheckBox = mock(CheckBox.class); + TextView mockTextView = mock(TextView.class); + + doReturn(mockCheckBox).when(loginView).findViewById(R.id.login_show_password_checkbox); + + doReturn(mockTextView).when(loginView).findViewById(R.id.login_show_password_text_view); + + doReturn(mockView).when(loginView).findViewById(R.id.login_layout); + + loginPresenter.processViewCustomizations(); + + verify(mockView).setBackground(any(GradientDrawable.class)); + + verify(mockCheckBox).setVisibility(View.GONE); + + verify(mockTextView).setVisibility(View.GONE); + } + + @After + public void tearDown() { + loginView.finish(); + } +} \ No newline at end of file diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java index c1874a0..869e342 100644 --- a/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java @@ -1,8 +1,13 @@ package org.smartregister.eusm.presenter; +import android.widget.Button; + +import androidx.recyclerview.widget.RecyclerView; + import org.junit.Before; import org.junit.Test; import org.mockito.Mock; +import org.powermock.reflect.internal.WhiteboxImpl; import org.robolectric.annotation.LooperMode; import org.robolectric.util.ReflectionHelpers; import org.smartregister.eusm.BaseUnitTest; @@ -18,6 +23,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.annotation.LooperMode.Mode.PAUSED; @@ -63,4 +69,35 @@ public void testFilterByNameShouldAddNameToSearch() throws InterruptedException verify(structureRegisterFragmentPresenter).onCountOfStructuresFetched(anyInt()); verify(structureRegisterFragmentPresenter).onFetchedStructures(anyList()); } + + @Test + public void testOnNextButtonClickShouldInvokeFetch() { + Button mockNextButton = mock(Button.class); + StructureRegisterFragment mockStructureRegisterFragment = mock(StructureRegisterFragment.class); + StructureRegisterAdapter mockStructureRegisterAdapter = mock(StructureRegisterAdapter.class); + doReturn(mockStructureRegisterAdapter).when(view).getAdapter(); + doReturn(mockStructureRegisterFragment).when(structureRegisterFragmentPresenter).getFragment(); + doReturn(mockNextButton).when(mockStructureRegisterFragment).getNextButton(); + structureRegisterFragmentPresenter.onNextButtonClick(); + + verify(structureRegisterFragmentPresenter).fetchStructures(); + } + + @Test + public void testOnPreviousButtonClickShouldInvokeFetch() { + Button mockNextButton = mock(Button.class); + StructureRegisterFragment mockStructureRegisterFragment = mock(StructureRegisterFragment.class); + StructureRegisterAdapter mockStructureRegisterAdapter = mock(StructureRegisterAdapter.class); + RecyclerView mockRecyclerView = mock(RecyclerView.class); + doReturn(mockStructureRegisterAdapter).when(view).getAdapter(); + doReturn(mockStructureRegisterFragment).when(structureRegisterFragmentPresenter).getFragment(); + doReturn(mockNextButton).when(mockStructureRegisterFragment).getNextButton(); + doReturn(mockNextButton).when(mockStructureRegisterFragment).getPreviousButton(); + + WhiteboxImpl.setInternalState(mockStructureRegisterFragment, "clientsView", mockRecyclerView); + + structureRegisterFragmentPresenter.onPreviousButtonClick(); + + verify(structureRegisterFragmentPresenter).fetchStructures(); + } } \ No newline at end of file diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppStructureRepositoryTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppStructureRepositoryTest.java index 0c8cabe..7a114f0 100644 --- a/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppStructureRepositoryTest.java +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppStructureRepositoryTest.java @@ -107,7 +107,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { } }).when(cursor).moveToNext(); - int result = appStructureRepository.countOfStructures("tes", UUID.randomUUID().toString()); + int result = appStructureRepository.countOfStructures("tes", UUID.randomUUID().toString(), UUID.randomUUID().toString()); assertEquals(0, result); } @@ -169,7 +169,7 @@ public Object answer(InvocationOnMock invocation) { } }).when(cursor).moveToNext(); - List structureDetails = appStructureRepository.fetchStructureDetails(0, "23-2", "tes", false); + List structureDetails = appStructureRepository.fetchStructureDetails(0, "23-2", "tes", false, UUID.randomUUID().toString()); assertEquals(1, structureDetails.size()); } diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppTaskRepositoryTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppTaskRepositoryTest.java index f947837..b6018d0 100644 --- a/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppTaskRepositoryTest.java +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/repository/AppTaskRepositoryTest.java @@ -58,7 +58,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { } }).when(cursor).moveToNext(); - List taskDetails = appTaskRepository.getTasksByStructureId("23-3"); + List taskDetails = appTaskRepository.getTasksByStructureId("23-3", "32", "23"); assertEquals(1, taskDetails.size()); } } \ No newline at end of file From d238c4eb8a85392dd8af5490c4ab468a5229f90d Mon Sep 17 00:00:00 2001 From: bennsimon Date: Tue, 26 Jan 2021 15:18:31 +0300 Subject: [PATCH 4/6] code cleanup --- .../eusm/presenter/StructureRegisterFragmentPresenterTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java index 869e342..2797a03 100644 --- a/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java +++ b/opensrp-eusm/src/test/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenterTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import static org.robolectric.annotation.LooperMode.Mode.PAUSED; From 78de6a705de732b907527a46097e6429b0749d1c Mon Sep 17 00:00:00 2001 From: bennsimon Date: Thu, 28 Jan 2021 09:38:58 +0300 Subject: [PATCH 5/6] fix QA bugs --- opensrp-eusm/build.gradle | 22 +------ .../eusm/activity/EusmTaskingMapActivity.java | 9 ++- .../StructureRegisterFragmentPresenter.java | 1 + .../repository/AppStructureRepository.java | 42 ++++++------- .../service/AppLocationTaskIntentService.java | 13 +++- .../res/drawable/rounded_blue_outline.xml | 4 +- .../main/res/layout/activity_product_info.xml | 2 +- .../src/main/res/layout/card_view.xml | 42 ++++++------- .../src/main/res/layout/generic_empty_row.xml | 2 +- .../src/main/res/layout/generic_title_row.xml | 2 +- .../src/main/res/layout/gps_unknown_view.xml | 2 +- .../src/main/res/layout/task_register_row.xml | 7 ++- opensrp-eusm/src/main/res/values/dimens.xml | 2 +- opensrp-eusm/src/main/res/values/strings.xml | 1 + .../eusm/util/GeoJsonUtilsTest.java | 63 +++++++++++++++++++ 15 files changed, 138 insertions(+), 76 deletions(-) create mode 100644 opensrp-eusm/src/test/java/org/smartregister/eusm/util/GeoJsonUtilsTest.java diff --git a/opensrp-eusm/build.gradle b/opensrp-eusm/build.gradle index 6f4b7c2..ba7f80a 100644 --- a/opensrp-eusm/build.gradle +++ b/opensrp-eusm/build.gradle @@ -122,26 +122,6 @@ android { buildTypes { - release { - resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"' - buildConfigField "int", "DATABASE_VERSION", '1' - buildConfigField "int", "OPENMRS_UNIQUE_ID_INITIAL_BATCH_SIZE", '250' - buildConfigField "int", "OPENMRS_UNIQUE_ID_BATCH_SIZE", '100' - buildConfigField "int", "OPENMRS_UNIQUE_ID_SOURCE", '2' - buildConfigField "long", "SYNC_INTERVAL_IN_MINUTES", '15' - buildConfigField "long", "PULL_UNIQUE_IDS_MINUTES", '15' - buildConfigField "String", "ADMIN_PASSWORD_NOT_NEAR_STRUCTURES", '"AdminPass1"' - buildConfigField "float", "MY_LOCATION_BUFFER", '25' - buildConfigField "boolean", "VALIDATE_FAR_STRUCTURES", 'false' - buildConfigField "int", "RESOLVE_LOCATION_TIMEOUT_IN_SECONDS", '60' - buildConfigField "boolean", "DISPLAY_OUTSIDE_OPERATIONAL_AREA_MASK", 'false' - buildConfigField "boolean", "DISPLAY_DISTANCE_SCALE", 'true' - buildConfigField "String[]", "FACILITY_LEVELS", '{"Country", "Region", "District"}' - buildConfigField "String[]", "LOCATION_LEVELS", '{"Country", "Region", "District"}' - - testCoverageEnabled true - } - debug { resValue "string", 'opensrp_url', '"https://mg-eusm-staging.smartregister.org/opensrp/"' buildConfigField "int", "DATABASE_VERSION", '1' @@ -243,7 +223,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' } - api('org.smartregister:opensrp-client-stock:1.2.2-SNAPSHOT') { + api('org.smartregister:opensrp-client-stock:1.2.3-SNAPSHOT') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java index ef8be9b..a5478d4 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/activity/EusmTaskingMapActivity.java @@ -38,6 +38,8 @@ import org.smartregister.tasking.presenter.ValidateUserLocationPresenter; import org.smartregister.util.Utils; +import timber.log.Timber; + public class EusmTaskingMapActivity extends TaskingMapActivity { private CardView eusmCardView; @@ -181,6 +183,11 @@ public void displaySelectedFeature(Feature feature, LatLng clickedPoint, double @Override public Location getUserCurrentLocation() { - return super.getUserCurrentLocation(); + try { + return super.getUserCurrentLocation(); + } catch (NullPointerException e) { + Timber.e(e); + return null; + } } } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenter.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenter.java index 3cf95e3..466cf75 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenter.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/presenter/StructureRegisterFragmentPresenter.java @@ -92,6 +92,7 @@ public void onNextButtonClick() { if ((totalCount - ((currentPageNo) * pageSize)) > pageSize) { getFragment().clientsView.scrollToPosition(0); getFragment().getNextButton().setVisibility(View.VISIBLE); + getFragment().getPreviousButton().setVisibility(View.VISIBLE); } else { getFragment().getNextButton().setVisibility(View.INVISIBLE); } diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java index 62ccc96..d023e87 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/repository/AppStructureRepository.java @@ -9,6 +9,7 @@ import net.sqlcipher.SQLException; import net.sqlcipher.database.SQLiteDatabase; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.smartregister.domain.Geometry; import org.smartregister.eusm.application.EusmApplication; @@ -94,7 +95,7 @@ public void addOrUpdate(org.smartregister.domain.Location location) { public int countOfStructures(String nameFilter, String locationParentId, String planId) { SQLiteDatabase sqLiteDatabase = getReadableDatabase(); - String query = "SELECT count(1) from " + STRUCTURE_TABLE; + String query = "SELECT count(DISTINCT structure._id) from " + STRUCTURE_TABLE; String[] args = StringUtils.stripAll(locationParentId, planId); @@ -105,15 +106,15 @@ public int countOfStructures(String nameFilter, String locationParentId, String query += " where location.parent_id = ? AND task.plan_id = ?"; if (StringUtils.isNotBlank(nameFilter)) { - args = StringUtils.stripAll(locationParentId, planId, nameFilter); + args = StringUtils.stripAll(locationParentId, planId, "%" + nameFilter + "%"); - query += " and " + STRUCTURE_TABLE + "." + NAME + " like '%?%'"; + query += " and " + STRUCTURE_TABLE + "." + NAME + " like ? "; } int count = 0; try (Cursor cursor = sqLiteDatabase.rawQuery(query, args)) { - if (cursor != null) { - count = cursor.getCount(); + if (cursor != null && cursor.moveToNext()) { + count = cursor.getInt(0); } } catch (SQLException w) { Timber.e(w); @@ -127,6 +128,9 @@ public List fetchStructureDetails(int pageNo, String locationPa public List fetchStructureDetails(Integer pageNo, String locationParentId, String nameFilter, boolean isForMapping, String planId) { + + Location location = EusmApplication.getInstance().getUserLocation(); + List structureDetails = new ArrayList<>(); SQLiteDatabase sqLiteDatabase = getReadableDatabase(); String[] columns = new String[]{ @@ -139,7 +143,7 @@ public List fetchStructureDetails(Integer pageNo, String locati STRUCTURE_TABLE + "." + "geojson as structureGeoJson", LOCATION_TABLE + "." + "name as locationName", LOCATION_TABLE + "." + "parent_id as locationParentId", - "(((? - longitude)*(? - longitude)) + ((? - latitude)*(? - latitude))) as dist", + location == null ? "0 as dist " : "(((? - longitude)*(? - longitude)) + ((? - latitude)*(? - latitude))) as dist", "case \n" + "\twhen (sum(task.status = 'COMPLETED')*1.0/sum(task.status= 'READY')*1.0) = 0.0 \n" + "\t\tthen sum(task.status= 'READY')\n" + @@ -155,19 +159,7 @@ public List fetchStructureDetails(Integer pageNo, String locati + " join task on task.structure_id = " + StructureRepository.STRUCTURE_TABLE + "._id " + " join location on location._id = " + StructureRepository.STRUCTURE_TABLE + ".parent_id "; - - Location location = EusmApplication.getInstance().getUserLocation(); - if (location == null) { - location = new Location("temp"); - location.setLongitude(0.000); - location.setLatitude(0.000); - } - String[] args = StringUtils.stripAll( - String.valueOf(location.getLongitude()), - String.valueOf(location.getLongitude()), - String.valueOf(location.getLatitude()), - String.valueOf(location.getLatitude()), planId, locationParentId); @@ -175,14 +167,20 @@ public List fetchStructureDetails(Integer pageNo, String locati if (StringUtils.isNotBlank(nameFilter)) { args = StringUtils.stripAll( + planId, + locationParentId, + "%" + nameFilter + "%"); + query += " and structureName like ? "; + } + + if (location != null) { + String[] locationArgsArray = new String[]{ String.valueOf(location.getLongitude()), String.valueOf(location.getLongitude()), String.valueOf(location.getLatitude()), String.valueOf(location.getLatitude()), - planId, - locationParentId, - nameFilter); - query += " and structureName like '%?%'"; + }; + args = ArrayUtils.addAll(locationArgsArray, args); } query += " group by " + STRUCTURE_TABLE + "." + "_id" + " order by case when dist is null then 1 else 0 end, dist" diff --git a/opensrp-eusm/src/main/java/org/smartregister/eusm/service/AppLocationTaskIntentService.java b/opensrp-eusm/src/main/java/org/smartregister/eusm/service/AppLocationTaskIntentService.java index 8d8855f..f2d1e10 100644 --- a/opensrp-eusm/src/main/java/org/smartregister/eusm/service/AppLocationTaskIntentService.java +++ b/opensrp-eusm/src/main/java/org/smartregister/eusm/service/AppLocationTaskIntentService.java @@ -1,7 +1,10 @@ package org.smartregister.eusm.service; +import android.Manifest; import android.content.Intent; +import android.content.pm.PackageManager; +import androidx.core.app.ActivityCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.jetbrains.annotations.NotNull; @@ -19,6 +22,8 @@ import java.util.List; import java.util.Set; +import timber.log.Timber; + import static org.smartregister.tasking.util.Constants.Action.STRUCTURE_TASK_SYNCED; public class AppLocationTaskIntentService extends LocationTaskIntentService { @@ -46,7 +51,13 @@ protected List syncStructures(LocationServiceHelper locationServiceHel //initiate Stock And StockType sync after structures have been fetched SyncStockServiceJob.scheduleJobImmediately(SyncStockServiceJob.TAG); - SyncStockTypeServiceJob.scheduleJobImmediately(SyncStockTypeServiceJob.TAG); + if ((ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) + + ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) + == PackageManager.PERMISSION_GRANTED) { + SyncStockTypeServiceJob.scheduleJobImmediately(SyncStockTypeServiceJob.TAG); + } else { + Timber.e("Read and Write Permission Not Granted"); + } } return locationList; } diff --git a/opensrp-eusm/src/main/res/drawable/rounded_blue_outline.xml b/opensrp-eusm/src/main/res/drawable/rounded_blue_outline.xml index 3fcbd7d..afbc031 100644 --- a/opensrp-eusm/src/main/res/drawable/rounded_blue_outline.xml +++ b/opensrp-eusm/src/main/res/drawable/rounded_blue_outline.xml @@ -5,7 +5,7 @@ \ No newline at end of file diff --git a/opensrp-eusm/src/main/res/layout/activity_product_info.xml b/opensrp-eusm/src/main/res/layout/activity_product_info.xml index bcac0da..3971db1 100644 --- a/opensrp-eusm/src/main/res/layout/activity_product_info.xml +++ b/opensrp-eusm/src/main/res/layout/activity_product_info.xml @@ -112,7 +112,7 @@ android:paddingEnd="3dp" android:text="@string/back" android:textColor="@color/customAppThemeBlue" - android:textSize="16dp" + android:textSize="16sp" android:textStyle="bold" /> diff --git a/opensrp-eusm/src/main/res/layout/card_view.xml b/opensrp-eusm/src/main/res/layout/card_view.xml index d895a9a..904a545 100644 --- a/opensrp-eusm/src/main/res/layout/card_view.xml +++ b/opensrp-eusm/src/main/res/layout/card_view.xml @@ -48,7 +48,7 @@ android:layout_height="wrap_content" android:text="Alabsdos sdwewe" android:textColor="@color/text_black" - android:textSize="20dp" + android:textSize="20sp" android:textStyle="bold" /> - - + android:textSize="20sp" /> - + -