Skip to content

Commit

Permalink
Merge pull request #645 from opensrp/optibp_calibration
Browse files Browse the repository at this point in the history
Enhancement of the OptiBP widget to add Calibration data


@SebaMutuku to work on the coverage improvement on the next CHT
  • Loading branch information
dubdabasoduba authored Mar 8, 2023
2 parents f9147fc + e89ccc8 commit e9eaac7
Show file tree
Hide file tree
Showing 14 changed files with 398 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
- name: Generate Javadoc with Gradle
run: ./gradlew javadoc
run: ./gradlew javadoc
1 change: 1 addition & 0 deletions android-json-form-wizard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:$androidToolsBuildGradle"
classpath 'org.apache.commons:commons-lang3:3.12.0'
classpath 'com.android.tools.lint:lint:25.3.0'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public static class OptibpConstants {
public static final int OPTIBP_REPEAT_REQUEST_CODE = 302;
public static final String OPTIBP_REPORT_RESULT = "result";
public static final String OPTIBP_REPORT_COMPONENT = "component";
public static final String OPTIBP_VALUE_STRING = "valueString";
public static final String OPTIBP_REPORT_VALUE_QUANTITY = "valueQuantity";
public static final String OPTIBP_LAUNCH_INTENT = "android.intent.action.BLOOD_MEASURE";
public static final String OPTIBP_KEY_DATA = "optibp_data";
Expand All @@ -328,6 +329,16 @@ public static class OptibpConstants {
public static final String OPTIBP_KEY_BUTTON_BG_COLOR = "optibp_button_bg_color";
public static final String OPTIBP_KEY_BUTTON_TEXT_COLOR = "optibp_button_text_color";
public static final String OPTIBP_KEY_BUTTON_TEXT = "optibp_button_text";
public static final String BP_USING_OPTIBP_BUTTON = "record_bp_using_optibp_button";
public static final String BP_USING_SECOND_OPTIBP_BUTTON = "record_bp_using_optibp_button";
public static final String CALIBRATION = "calibration";
public static final String DATE = "date";
public static final String VERSION = "version";
public static final String MODEL = "model";
public static final String HEIGHT = "height";
public static final String WEIGHT = "weight";
public static final String CURRENTWEIGHT = "current_weight";

}

public static class EDIT_TEXT_TYPE {
Expand Down Expand Up @@ -379,4 +390,5 @@ public interface FileSource {
public interface MLS {
String PROPERTIES_FILE_NAME = "properties_file_name";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
import android.graphics.Point;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.AppCompatTextView;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
Expand All @@ -34,6 +29,12 @@
import android.widget.RelativeLayout;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.rey.material.util.ViewUtil;
import com.vijay.jsonwizard.NativeFormLibrary;
import com.vijay.jsonwizard.R;
Expand Down Expand Up @@ -301,10 +302,11 @@ public static void updateEndProperties(PropertyManager propertyManager, JSONObje
}


public static JSONObject createOptiBPDataObject(String clientId, String clientOpenSRPId) throws JSONException {
public static JSONObject createOptiBPDataObject(String clientId, String clientOpenSRPId, String calibration) throws JSONException {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JsonFormConstants.OptibpConstants.OPTIBP_KEY_CLIENT_ID, clientId);
jsonObject.put(JsonFormConstants.OptibpConstants.OPTIBP_KEY_CLIENT_OPENSRP_ID, clientOpenSRPId);
jsonObject.put(JsonFormConstants.OptibpConstants.CALIBRATION, calibration);
return jsonObject;
}

Expand Down Expand Up @@ -548,8 +550,7 @@ public static JSONObject getFieldFromForm(JSONObject jsonForm, String key) throw
if (formFields != null) {
for (int i = 0; i < formFields.length(); i++) {
JSONObject widget = formFields.getJSONObject(i);
if (widget.has(JsonFormConstants.KEY) && key
.equals(widget.getString(JsonFormConstants.KEY))) {
if (widget.has(JsonFormConstants.KEY) && key.equals(widget.getString(JsonFormConstants.KEY))) {
field = widget;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,13 @@ public static void postEvent(BaseEvent event) {

public static JSONObject getJsonObjectFromJsonArray(String key, JSONArray jsonArray) {
JSONObject jsonObject = null;
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject tempJsonObject = jsonArray.optJSONObject(i);
if (tempJsonObject != null && tempJsonObject.has(key)) {
jsonObject = tempJsonObject;
break;
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject tempJsonObject = jsonArray.optJSONObject(i);
if (tempJsonObject != null && tempJsonObject.optString(KEY).equals(key)) {
jsonObject = tempJsonObject;
break;
}
}
}
return jsonObject;
Expand Down Expand Up @@ -1009,7 +1011,21 @@ public void enableExpansionPanelViews(LinearLayout linearLayout) {
okButton.setEnabled(true);
okButton.setClickable(true);
}

/***
*
* @param jsonArrayString
* @return
*/
public static boolean checkIfValidJsonArray(String jsonArrayString) {
if (StringUtils.isNotBlank(jsonArrayString)) {
try {
return new JSONArray(jsonArrayString).length() > 0;
} catch (Exception e) {
return false;
}
}
return false;
}
public static String extractValueFromJson(String value)
{
try{
Expand Down
Loading

0 comments on commit e9eaac7

Please sign in to comment.