Skip to content

Commit c2da27a

Browse files
authored
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
1 parent fa1d83c commit c2da27a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ String process(int requestCode, int resultCode, Intent i) {
3737
try {
3838
byte[] data = i.getByteArrayExtra("data");
3939
String base64data = Base64.encodeToString(data, Base64.NO_WRAP);
40-
return safeFormat("angular.element(document.body).injector().get('AndroidApi').v1.mrdtResponse('\"%s\"')", base64data);
40+
long timeTaken = i.getLongExtra("timeTaken", 0);
41+
42+
String javaScript = "var api = angular.element(document.body).injector().get('AndroidApi');" +
43+
"if (api.v1.mrdtTimeTakenResponse) {" +
44+
" api.v1.mrdtTimeTakenResponse('\"%s\"');" +
45+
"}" +
46+
"api.v1.mrdtResponse('\"%s\"');";
47+
return safeFormat(javaScript, String.valueOf(timeTaken), base64data);
4148
} catch(Exception /*| JSONException*/ ex) {
4249
warn(ex, "Problem serialising mrdt image.");
4350
return safeFormat("console.log('Problem serialising mrdt image: %s')", ex);

0 commit comments

Comments
 (0)