Skip to content

Commit

Permalink
Adds processing of incoming field timeTaken from rdt app (#81)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tookam authored Jul 1, 2019
1 parent fa1d83c commit c2da27a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/org/medicmobile/webapp/mobile/MrdtSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c2da27a

Please sign in to comment.