From c2da27a5a77fcb5f0e47a13bced7923edfeafa38 Mon Sep 17 00:00:00 2001 From: Willy Tekeu Date: Mon, 1 Jul 2019 14:29:48 -0400 Subject: [PATCH] Adds processing of incoming field timeTaken from rdt app (#81) * Adds processing of incoming field timeTaken from rdt app * Makes change to positioning of mrdt timetaken and image so that webapp is backward compatible * Ensures compatiblity with < 3.6 webapp * Replace try/catcjh with if & multilines * Fixes Checkstyle error * Fix androidCheckstyle errors * Fixes console error --- .../java/org/medicmobile/webapp/mobile/MrdtSupport.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java b/src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java index aa8dc856..93c58499 100644 --- a/src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java +++ b/src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java @@ -37,7 +37,14 @@ String process(int requestCode, int resultCode, Intent i) { try { byte[] data = i.getByteArrayExtra("data"); String base64data = Base64.encodeToString(data, Base64.NO_WRAP); - return safeFormat("angular.element(document.body).injector().get('AndroidApi').v1.mrdtResponse('\"%s\"')", base64data); + long timeTaken = i.getLongExtra("timeTaken", 0); + + String javaScript = "var api = angular.element(document.body).injector().get('AndroidApi');" + + "if (api.v1.mrdtTimeTakenResponse) {" + + " api.v1.mrdtTimeTakenResponse('\"%s\"');" + + "}" + + "api.v1.mrdtResponse('\"%s\"');"; + return safeFormat(javaScript, String.valueOf(timeTaken), base64data); } catch(Exception /*| JSONException*/ ex) { warn(ex, "Problem serialising mrdt image."); return safeFormat("console.log('Problem serialising mrdt image: %s')", ex);