From 4f49fbe60a30b8163df6db5e7a4bfc4ccad0de4d Mon Sep 17 00:00:00 2001
From: LZRS <12814349+LZRS@users.noreply.github.com>
Date: Tue, 5 Oct 2021 18:36:15 +0300
Subject: [PATCH 01/12] add performance monitoring
---
android-json-form-wizard/build.gradle | 4 ++++
.../src/main/AndroidManifest.xml | 4 ++++
.../interactors/JsonFormInteractor.java | 3 +++
.../presenters/JsonFormFragmentPresenter.java | 11 ++++++++++
.../com/vijay/jsonwizard/utils/FormUtils.java | 22 +++++++++++++++----
.../com/vijay/jsonwizard/utils/Utils.java | 5 ++++-
6 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle
index cc3de8ea4..02966d348 100644
--- a/android-json-form-wizard/build.gradle
+++ b/android-json-form-wizard/build.gradle
@@ -140,6 +140,10 @@ dependencies {
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
+ implementation platform('com.google.firebase:firebase-bom:28.4.1')
+
+ implementation 'com.google.firebase:firebase-perf'
+
// PowerMock
def powerMockVersion = '2.0.4'
testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
diff --git a/android-json-form-wizard/src/main/AndroidManifest.xml b/android-json-form-wizard/src/main/AndroidManifest.xml
index 20272e491..483c7e028 100644
--- a/android-json-form-wizard/src/main/AndroidManifest.xml
+++ b/android-json-form-wizard/src/main/AndroidManifest.xml
@@ -35,5 +35,9 @@
+
+
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
index 6280427f5..f43017572 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
@@ -6,6 +6,7 @@
import android.support.annotation.Nullable;
import android.view.View;
+import com.google.firebase.perf.metrics.AddTrace;
import com.vijay.jsonwizard.R;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.fragments.JsonFormFragment;
@@ -152,6 +153,7 @@ protected void registerWidgets() {
}
+ @AddTrace(name = "JsonFormInteractor#fetchFormElements")
public List fetchFormElements(String stepName, JsonFormFragment formFragment,
JSONObject parentJson, CommonListener listener, Boolean popup) {
List viewsFromJson = new ArrayList<>(5);
@@ -201,6 +203,7 @@ private void fetchSections(List viewsFromJson, String stepName, JsonFormFr
}
}
+ @AddTrace(name = "JsonFormInteractor#fetchFields")
public void fetchFields(List viewsFromJson, String stepName, JsonFormFragment formFragment,
JSONArray fields, CommonListener listener, Boolean popup) {
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
index 71031b494..1f9cbbf65 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
@@ -38,6 +38,7 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
+import com.google.firebase.perf.metrics.AddTrace;
import com.rengwuxian.materialedittext.MaterialEditText;
import com.rey.material.widget.Button;
import com.vijay.jsonwizard.R;
@@ -129,6 +130,7 @@ public JsonFormFragmentPresenter(JsonFormFragment formFragment) {
incorrectlyFormattedFields = new Stack<>();
}
+ @AddTrace(name = "JsonFormFragmentPresenter$validate")
public static ValidationStatus validate(JsonFormFragmentView formFragmentView, View childAt,
boolean requestFocus) {
if (childAt instanceof RadioGroup) {
@@ -251,6 +253,7 @@ public JsonFormInteractor getmJsonFormInteractor() {
return mJsonFormInteractor;
}
+ @AddTrace(name = "JsonFormFragmentPresenter#addFormElements")
public void addFormElements() {
final ProgressDialog dialog = new ProgressDialog(formFragment.getContext());
dialog.setCancelable(false);
@@ -372,6 +375,7 @@ public boolean onNextClick(LinearLayout mainView) {
return false;
}
+ @AddTrace(name = "JsonFormFragmentPresenter#validateAndWriteValues")
public void validateAndWriteValues() {
for (View childView : formFragment.getJsonApi().getFormDataViews()) {
ValidationStatus validationStatus = validateView(childView);
@@ -470,6 +474,7 @@ public void validateAndWriteValues() {
/**
* Check if alarm is ringing and stop it if so
*/
+ @AddTrace(name = "JsonFormFragmentPresenter#checkAndStopCountdownAlarm")
public void checkAndStopCountdownAlarm() {
try {
JSONObject formJSONObject = new JSONObject(formFragment.getCurrentJsonState());
@@ -490,6 +495,7 @@ public boolean validateOnSubmit() {
return entireJsonForm.optBoolean(JsonFormConstants.VALIDATE_ON_SUBMIT, false);
}
+ @AddTrace(name = "JsonFormFragmentPresenter#executeRefreshLogicForNextStep")
public boolean executeRefreshLogicForNextStep() {
boolean isSkipped = false;
final String nextStep = getFormFragment().getJsonApi().nextStep();
@@ -565,6 +571,7 @@ public Map getInvalidFields() {
return invalidFields;
}
+ @AddTrace(name = "JsonFormFragmentPresenter#onSaveClick")
public void onSaveClick(LinearLayout mainView) {
validateAndWriteValues();
checkAndStopCountdownAlarm();
@@ -973,6 +980,7 @@ public void onClickCameraIcon(String key, String type) {
dispatchTakePictureIntent(key, type);
}
+ @AddTrace(name = "JsonFormFragmentPresenter#onCheckedChanged")
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (compoundButton instanceof CheckBox) {
String parentKey = (String) compoundButton.getTag(R.id.key);
@@ -1039,6 +1047,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
}
}
+ @AddTrace(name = "JsonFormFragmentPresenter#onItemSelected")
public void onItemSelected(AdapterView> parent, View view, int position, long id) {
String parentKey = (String) parent.getTag(R.id.key);
String openMrsEntityParent = (String) parent.getTag(R.id.openmrs_entity_parent);
@@ -1160,6 +1169,7 @@ public void run() {
}
+ @AddTrace(name = "JsonFormFragmentPresenter#preLoadRules")
private void preLoadRules(String stepName, JSONObject formJSONObject) {
Set ruleFiles = new HashSet<>();
JSONObject step = formJSONObject.optJSONObject(stepName);
@@ -1190,6 +1200,7 @@ public void run() {
}
}
+ @AddTrace(name = "JsonFormFragmentPresenter#addRules")
private void addRules(JSONObject jsonObject, Set ruleFiles) {
if (jsonObject != null) {
JSONObject ruleEngine = jsonObject.optJSONObject(RuleConstant.RULES_ENGINE);
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
index 9c0c3cf2e..09d2295c9 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
@@ -30,6 +30,7 @@
import android.widget.RelativeLayout;
import android.widget.Toast;
+import com.google.firebase.perf.metrics.AddTrace;
import com.rey.material.util.ViewUtil;
import com.vijay.jsonwizard.BuildConfig;
import com.vijay.jsonwizard.NativeFormLibrary;
@@ -169,6 +170,7 @@ public static CustomTextView getTextViewWith(Context context, int textSizeInSp,
return textView;
}
+ @AddTrace(name = "FormUtils$updateStartProperties")
public static void updateStartProperties(PropertyManager propertyManager, JSONObject form)
throws Exception {
if (form.has(METADATA_PROPERTY)) {
@@ -229,6 +231,7 @@ public static void updateStartProperties(PropertyManager propertyManager, JSONOb
}
}
+ @AddTrace(name = "FormUtils$updateEndProperties")
public static void updateEndProperties(PropertyManager propertyManager, JSONObject form)
throws Exception {
if (form.has(METADATA_PROPERTY)) {
@@ -669,6 +672,7 @@ public static String getSubFormLocation(String subFormsLocation) {
return TextUtils.isEmpty(subFormsLocation) ? JsonFormConstants.DEFAULT_SUB_FORM_LOCATION : subFormsLocation;
}
+ @AddTrace(name = "FormUtils$loadSubForm")
public static String loadSubForm(String formIdentity, String defaultSubFormLocation,
Context context, boolean translateSubForm) throws IOException {
@@ -676,12 +680,14 @@ public static String loadSubForm(String formIdentity, String defaultSubFormLocat
return translateSubForm ? NativeFormLangUtils.getTranslatedString(subForm, context) : subForm;
}
+ @AddTrace(name = "FormUtils$loadSubForm")
public static String loadSubForm(String formIdentity, String defaultSubFormLocation,
Context context) throws IOException {
return convertStreamToString(context.getAssets().open(defaultSubFormLocation + "/" + formIdentity + ".json"));
}
+ @AddTrace(name = "FormUtils$getFieldFromForm")
public static JSONObject getFieldFromForm(JSONObject jsonForm, String key) throws JSONException {
JSONObject field = new JSONObject();
if (jsonForm != null) {
@@ -700,6 +706,7 @@ public static JSONObject getFieldFromForm(JSONObject jsonForm, String key) throw
return field;
}
+ @AddTrace(name = "FormUtils$getMultiStepFormFields")
public static JSONArray getMultiStepFormFields(JSONObject jsonForm) {
JSONArray fields = new JSONArray();
try {
@@ -723,6 +730,7 @@ public static JSONArray getMultiStepFormFields(JSONObject jsonForm) {
return fields;
}
+ @AddTrace(name = "FormUtils$fields")
public static JSONArray fields(JSONObject jsonForm, String step) {
try {
JSONObject stepJSONObject = jsonForm.has(step) ? jsonForm.getJSONObject(step) : null;
@@ -1117,6 +1125,7 @@ public JSONArray getSecondaryValues(JSONObject jsonObject, String type) {
* @return formFields {JSONArray}
* @author dubdabasoduba
*/
+ @AddTrace(name = "FormUtils$getFormFields")
public JSONArray getFormFields(String stepName, Context context) {
Activity activity = (Activity) context;
JsonApi jsonApi = (JsonApi) activity;
@@ -1262,6 +1271,7 @@ public void changeIcon(ImageView imageView, String type, Context context) {
}
}
+ @AddTrace(name = "FormUtils$getCheckBoxResults")
public Facts getCheckBoxResults(JSONObject jsonObject) throws JSONException {
Facts result = new Facts();
JSONArray options = jsonObject.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
@@ -1312,6 +1322,7 @@ public Facts getCheckBoxResults(JSONObject jsonObject) throws JSONException {
* @return result {@link Facts}
* @throws JSONException
*/
+ @AddTrace(name = "FormUtils$getRadioButtonResults")
public Facts getRadioButtonResults(Boolean multiRelevance, JSONObject object) throws JSONException {
Facts result = new Facts();
if (multiRelevance) {
@@ -1846,13 +1857,12 @@ public String setValues(JSONArray jsonArray, String type) {
return value.replaceAll(", $", "");
}
- @Nullable
+ @Nullable @AddTrace(name = "FormUtils#getFormJsonFromRepositoryOrAssets")
public JSONObject getFormJsonFromRepositoryOrAssets(@NonNull Context context, @NonNull String formIdentity) throws JSONException {
ClientFormContract.Dao clientFormRepository = NativeFormLibrary.getInstance().getClientFormDao();
return getFormJsonFromRepositoryOrAssetsWithOptionalCallback(context, clientFormRepository, formIdentity, null);
}
- @Nullable
public JSONObject getFormJsonFromRepositoryOrAssets(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormRepository, @NonNull String formIdentity) throws JSONException {
return getFormJsonFromRepositoryOrAssetsWithOptionalCallback(context, clientFormRepository, formIdentity, null);
}
@@ -1897,6 +1907,7 @@ public void getFormJsonFromRepositoryOrAssets(@NonNull Context context, @NonNull
* @return
* @throws JSONException
*/
+ @AddTrace(name = "FormUtils#getFormJsonFromRepositoryOrAssetsWithOptionalCallback")
private JSONObject getFormJsonFromRepositoryOrAssetsWithOptionalCallback(@NonNull Context context, @Nullable ClientFormContract.Dao clientFormRepository, String formIdentity, @Nullable final OnFormFetchedCallback onFormFetchedCallback) throws JSONException {
if (clientFormRepository != null) {
ClientFormContract.Model clientForm = getClientFormFromRepository(context, clientFormRepository, formIdentity);
@@ -1948,6 +1959,7 @@ public void onFormFetched(@Nullable String form) {
}
}
+ @AddTrace(name = "FormUtils#getFormJson")
public JSONObject getFormJson(@NonNull Context context, @NonNull String formIdentity) {
try {
String locale = context.getResources().getConfiguration().locale.getLanguage();
@@ -2013,6 +2025,7 @@ public void handleJsonFormOrRulesError(@NonNull Context context, @NonNull Client
handleJsonFormOrRulesError(context, clientFormRepository, false, formIdentity, onFormFetchedCallback);
}
+ @AddTrace(name = "FormUtils#handleJsonFormOrRulesError")
public void handleJsonFormOrRulesError(@NonNull final Context context, @NonNull final ClientFormContract.Dao clientFormRepository, final boolean isRulesFile, @NonNull final String formIdentity, @NonNull final OnFormFetchedCallback onFormFetchedCallback) {
final ClientFormContract.Model clientForm = getClientFormFromRepository(context, clientFormRepository, formIdentity);
List clientForms = clientFormRepository.getClientFormByIdentifier(clientForm.getIdentifier());
@@ -2063,7 +2076,7 @@ public void onCancelClicked() {
}
}
- @Nullable
+ @Nullable @AddTrace(name = "FormUtils#getSubFormJsonFromRepository")
public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, String formIdentity, String subFormsLocation, boolean translateSubForm) throws JSONException {
//Check the current locale of the app to load the correct version of the form in the desired language
String localeFormIdentity = getLocaleFormIdentity(context, formIdentity);
@@ -2095,7 +2108,7 @@ public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNul
return null;
}
- @Nullable
+ @Nullable @AddTrace(name = "FormUtils#getRulesFromRepository")
public BufferedReader getRulesFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, @NonNull String fileName) {
//Check the current locale of the app to load the correct version of the form in the desired language
String localeFormIdentity = getLocaleFormIdentity(context, fileName);
@@ -2118,6 +2131,7 @@ public BufferedReader getRulesFromRepository(@NonNull Context context, @NonNull
return null;
}
+ @AddTrace(name = "FormUtils#getPropertiesFileContentsFromDB")
public String getPropertiesFileContentsFromDB(String identifier) {
ClientFormContract.Dao clientFormRepository = NativeFormLibrary.getInstance().getClientFormDao();
if (clientFormRepository != null) {
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
index 8980dc9f5..8aa537336 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
@@ -23,6 +23,7 @@
import android.widget.RelativeLayout;
import android.widget.Toast;
+import com.google.firebase.perf.metrics.AddTrace;
import com.vijay.jsonwizard.R;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.customviews.CompoundButton;
@@ -328,6 +329,7 @@ private static String cleanConditionString(String conditionStringRaw) {
return conditionString.replaceAll(" ", " ");
}
+ @AddTrace(name = "Utils$buildRulesWithUniqueId")
public static void buildRulesWithUniqueId(JSONObject element, String uniqueId, String ruleType,
Context context, Map>> rulesFileMap, String stepName) throws JSONException {
JSONObject rules = element.optJSONObject(ruleType);
@@ -839,6 +841,7 @@ public static void checkIfStepHasNoSkipLogic(JsonFormFragment formFragment) {
/***
* removes the generated dynamic rules by repeating group
*/
+ @AddTrace(name = "Utils$removeGeneratedDynamicRules")
public static void removeGeneratedDynamicRules(JsonFormFragment formFragment) {
JSONObject form = formFragment.getJsonApi().getmJSONObject();
JSONArray jsonArray = FormUtils.getMultiStepFormFields(form);
@@ -928,7 +931,7 @@ public static boolean isEmptyJsonObject(JSONObject jsonObject) {
* @return
* @throws JSONException
*/
- @Nullable
+ @Nullable @AddTrace(name = "Utils$getRepeatingGroupCountObj")
public static JSONObject getRepeatingGroupCountObj(@NotNull WidgetArgs widgetArgs) throws JSONException {
String repeatingGroupCountObjKey = widgetArgs.getJsonObject().get(KEY) + "_count";
JSONObject stepJsonObject = widgetArgs.getFormFragment().getStep(widgetArgs.getStepName());
From 12abc1f7ed0c7b93161aeb4ebdf8977aa6f6853f Mon Sep 17 00:00:00 2001
From: LZRS <12814349+LZRS@users.noreply.github.com>
Date: Mon, 28 Feb 2022 16:55:44 +0300
Subject: [PATCH 02/12] Add sentry sdk to check performance using Sentry
---
android-json-form-wizard/build.gradle | 11 ++++++++---
android-json-form-wizard/src/main/AndroidManifest.xml | 9 +++++++--
android-json-form-wizard/src/multidex-config.pro | 2 ++
3 files changed, 17 insertions(+), 5 deletions(-)
create mode 100644 android-json-form-wizard/src/multidex-config.pro
diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle
index 45914a751..d03abfafa 100644
--- a/android-json-form-wizard/build.gradle
+++ b/android-json-form-wizard/build.gradle
@@ -37,6 +37,8 @@ android {
includeCompileClasspath = true
}
}
+
+ multiDexKeepProguard file('multidex-config.pro')
}
buildTypes {
@@ -65,6 +67,11 @@ android {
configurations.all {
resolutionStrategy.force 'com.android.support:design:28.0.0'
}
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
}
@@ -140,9 +147,7 @@ dependencies {
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
- implementation platform('com.google.firebase:firebase-bom:28.4.1')
-
- implementation 'com.google.firebase:firebase-perf'
+ implementation 'io.sentry:sentry-android:5.0.1'
// PowerMock
def powerMockVersion = '2.0.4'
diff --git a/android-json-form-wizard/src/main/AndroidManifest.xml b/android-json-form-wizard/src/main/AndroidManifest.xml
index 483c7e028..648ec648a 100644
--- a/android-json-form-wizard/src/main/AndroidManifest.xml
+++ b/android-json-form-wizard/src/main/AndroidManifest.xml
@@ -37,7 +37,12 @@
android:value="@integer/google_play_services_version" />
+ android:name="io.sentry.dsn"
+ android:value="https://d4003cd0df6548b9aac50a9b709cbab3@sentry.k8s.onalabs.org/57" />
+
+
+
diff --git a/android-json-form-wizard/src/multidex-config.pro b/android-json-form-wizard/src/multidex-config.pro
new file mode 100644
index 000000000..94584adff
--- /dev/null
+++ b/android-json-form-wizard/src/multidex-config.pro
@@ -0,0 +1,2 @@
+-keep class io.sentry.android.core.SentryAndroidOptions
+-keep class io.sentry.android.ndk.SentryNdk
\ No newline at end of file
From e4f79f77988b9c4b080f3a3ddcf2549f5f3d3c5b Mon Sep 17 00:00:00 2001
From: Richard Kareko
Date: Tue, 12 Jul 2022 17:44:37 +0300
Subject: [PATCH 03/12] Remove firebase performance monitoring traces
---
.../interactors/JsonFormInteractor.java | 3 ---
.../presenters/JsonFormFragmentPresenter.java | 11 -----------
.../com/vijay/jsonwizard/utils/FormUtils.java | 18 ------------------
.../java/com/vijay/jsonwizard/utils/Utils.java | 4 ----
4 files changed, 36 deletions(-)
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
index f43017572..6280427f5 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/interactors/JsonFormInteractor.java
@@ -6,7 +6,6 @@
import android.support.annotation.Nullable;
import android.view.View;
-import com.google.firebase.perf.metrics.AddTrace;
import com.vijay.jsonwizard.R;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.fragments.JsonFormFragment;
@@ -153,7 +152,6 @@ protected void registerWidgets() {
}
- @AddTrace(name = "JsonFormInteractor#fetchFormElements")
public List fetchFormElements(String stepName, JsonFormFragment formFragment,
JSONObject parentJson, CommonListener listener, Boolean popup) {
List viewsFromJson = new ArrayList<>(5);
@@ -203,7 +201,6 @@ private void fetchSections(List viewsFromJson, String stepName, JsonFormFr
}
}
- @AddTrace(name = "JsonFormInteractor#fetchFields")
public void fetchFields(List viewsFromJson, String stepName, JsonFormFragment formFragment,
JSONArray fields, CommonListener listener, Boolean popup) {
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
index d9810daf5..1864e1c76 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
@@ -38,7 +38,6 @@
import android.widget.RelativeLayout;
import android.widget.TextView;
-import com.google.firebase.perf.metrics.AddTrace;
import com.rengwuxian.materialedittext.MaterialEditText;
import com.rengwuxian.materialedittext.validation.METValidator;
import com.rey.material.widget.Button;
@@ -131,7 +130,6 @@ public JsonFormFragmentPresenter(JsonFormFragment formFragment) {
incorrectlyFormattedFields = new Stack<>();
}
- @AddTrace(name = "JsonFormFragmentPresenter$validate")
public static ValidationStatus validate(JsonFormFragmentView formFragmentView, View childAt,
boolean requestFocus) {
if (childAt instanceof RadioGroup) {
@@ -254,7 +252,6 @@ public JsonFormInteractor getmJsonFormInteractor() {
return mJsonFormInteractor;
}
- @AddTrace(name = "JsonFormFragmentPresenter#addFormElements")
public void addFormElements() {
final ProgressDialog dialog = new ProgressDialog(formFragment.getContext());
dialog.setCancelable(false);
@@ -376,7 +373,6 @@ public boolean onNextClick(LinearLayout mainView) {
return false;
}
- @AddTrace(name = "JsonFormFragmentPresenter#validateAndWriteValues")
public boolean areFormViewsFilled() {
boolean filled = true;
for (View childView : formFragment.getJsonApi().getFormDataViews()) {
@@ -539,7 +535,6 @@ public void validateAndWriteValues() {
/**
* Check if alarm is ringing and stop it if so
*/
- @AddTrace(name = "JsonFormFragmentPresenter#checkAndStopCountdownAlarm")
public void checkAndStopCountdownAlarm() {
try {
JSONObject formJSONObject = new JSONObject(formFragment.getCurrentJsonState());
@@ -560,7 +555,6 @@ public boolean validateOnSubmit() {
return entireJsonForm.optBoolean(JsonFormConstants.VALIDATE_ON_SUBMIT, false);
}
- @AddTrace(name = "JsonFormFragmentPresenter#executeRefreshLogicForNextStep")
public boolean executeRefreshLogicForNextStep() {
boolean isSkipped = false;
final String nextStep = getFormFragment().getJsonApi().nextStep();
@@ -636,7 +630,6 @@ public Map getInvalidFields() {
return invalidFields;
}
- @AddTrace(name = "JsonFormFragmentPresenter#onSaveClick")
public void onSaveClick(LinearLayout mainView) {
validateAndWriteValues();
checkAndStopCountdownAlarm();
@@ -1045,7 +1038,6 @@ public void onClickCameraIcon(String key, String type) {
dispatchTakePictureIntent(key, type);
}
- @AddTrace(name = "JsonFormFragmentPresenter#onCheckedChanged")
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
if (compoundButton instanceof CheckBox) {
String parentKey = (String) compoundButton.getTag(R.id.key);
@@ -1112,7 +1104,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
}
}
- @AddTrace(name = "JsonFormFragmentPresenter#onItemSelected")
public void onItemSelected(AdapterView> parent, View view, int position, long id) {
String parentKey = (String) parent.getTag(R.id.key);
String openMrsEntityParent = (String) parent.getTag(R.id.openmrs_entity_parent);
@@ -1234,7 +1225,6 @@ public void run() {
}
- @AddTrace(name = "JsonFormFragmentPresenter#preLoadRules")
private void preLoadRules(String stepName, JSONObject formJSONObject) {
Set ruleFiles = new HashSet<>();
JSONObject step = formJSONObject.optJSONObject(stepName);
@@ -1265,7 +1255,6 @@ public void run() {
}
}
- @AddTrace(name = "JsonFormFragmentPresenter#addRules")
private void addRules(JSONObject jsonObject, Set ruleFiles) {
if (jsonObject != null) {
JSONObject ruleEngine = jsonObject.optJSONObject(RuleConstant.RULES_ENGINE);
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
index 92fe780fe..8447b739c 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
@@ -30,7 +30,6 @@
import android.widget.RelativeLayout;
import android.widget.Toast;
-import com.google.firebase.perf.metrics.AddTrace;
import com.rey.material.util.ViewUtil;
import com.vijay.jsonwizard.NativeFormLibrary;
import com.vijay.jsonwizard.R;
@@ -170,7 +169,6 @@ public static CustomTextView getTextViewWith(Context context, int textSizeInSp,
return textView;
}
- @AddTrace(name = "FormUtils$updateStartProperties")
public static void updateStartProperties(PropertyManager propertyManager, JSONObject form)
throws Exception {
if (form.has(METADATA_PROPERTY)) {
@@ -231,7 +229,6 @@ public static void updateStartProperties(PropertyManager propertyManager, JSONOb
}
}
- @AddTrace(name = "FormUtils$updateEndProperties")
public static void updateEndProperties(PropertyManager propertyManager, JSONObject form)
throws Exception {
if (form.has(METADATA_PROPERTY)) {
@@ -672,7 +669,6 @@ public static String getSubFormLocation(String subFormsLocation) {
return TextUtils.isEmpty(subFormsLocation) ? JsonFormConstants.DEFAULT_SUB_FORM_LOCATION : subFormsLocation;
}
- @AddTrace(name = "FormUtils$loadSubForm")
public static String loadSubForm(String formIdentity, String defaultSubFormLocation,
Context context, boolean translateSubForm) throws IOException {
@@ -680,14 +676,12 @@ public static String loadSubForm(String formIdentity, String defaultSubFormLocat
return translateSubForm ? NativeFormLangUtils.getTranslatedString(subForm, context) : subForm;
}
- @AddTrace(name = "FormUtils$loadSubForm")
public static String loadSubForm(String formIdentity, String defaultSubFormLocation,
Context context) throws IOException {
return convertStreamToString(context.getAssets().open(defaultSubFormLocation + "/" + formIdentity + ".json"));
}
- @AddTrace(name = "FormUtils$getFieldFromForm")
public static JSONObject getFieldFromForm(JSONObject jsonForm, String key) throws JSONException {
JSONObject field = new JSONObject();
if (jsonForm != null) {
@@ -706,7 +700,6 @@ public static JSONObject getFieldFromForm(JSONObject jsonForm, String key) throw
return field;
}
- @AddTrace(name = "FormUtils$getMultiStepFormFields")
public static JSONArray getMultiStepFormFields(JSONObject jsonForm) {
JSONArray fields = new JSONArray();
try {
@@ -730,7 +723,6 @@ public static JSONArray getMultiStepFormFields(JSONObject jsonForm) {
return fields;
}
- @AddTrace(name = "FormUtils$fields")
public static JSONArray fields(JSONObject jsonForm, String step) {
try {
JSONObject stepJSONObject = jsonForm.has(step) ? jsonForm.getJSONObject(step) : null;
@@ -1125,7 +1117,6 @@ public JSONArray getSecondaryValues(JSONObject jsonObject, String type) {
* @return formFields {JSONArray}
* @author dubdabasoduba
*/
- @AddTrace(name = "FormUtils$getFormFields")
public JSONArray getFormFields(String stepName, Context context) {
Activity activity = (Activity) context;
JsonApi jsonApi = (JsonApi) activity;
@@ -1271,7 +1262,6 @@ public void changeIcon(ImageView imageView, String type, Context context) {
}
}
- @AddTrace(name = "FormUtils$getCheckBoxResults")
public Facts getCheckBoxResults(JSONObject jsonObject) throws JSONException {
Facts result = new Facts();
JSONArray options = jsonObject.getJSONArray(JsonFormConstants.OPTIONS_FIELD_NAME);
@@ -1322,7 +1312,6 @@ public Facts getCheckBoxResults(JSONObject jsonObject) throws JSONException {
* @return result {@link Facts}
* @throws JSONException
*/
- @AddTrace(name = "FormUtils$getRadioButtonResults")
public Facts getRadioButtonResults(Boolean multiRelevance, JSONObject object) throws JSONException {
Facts result = new Facts();
if (multiRelevance) {
@@ -1857,7 +1846,6 @@ public String setValues(JSONArray jsonArray, String type) {
return value.replaceAll(", $", "");
}
- @Nullable @AddTrace(name = "FormUtils#getFormJsonFromRepositoryOrAssets")
public JSONObject getFormJsonFromRepositoryOrAssets(@NonNull Context context, @NonNull String formIdentity) throws JSONException {
ClientFormContract.Dao clientFormRepository = NativeFormLibrary.getInstance().getClientFormDao();
return getFormJsonFromRepositoryOrAssetsWithOptionalCallback(context, clientFormRepository, formIdentity, null);
@@ -1907,7 +1895,6 @@ public void getFormJsonFromRepositoryOrAssets(@NonNull Context context, @NonNull
* @return
* @throws JSONException
*/
- @AddTrace(name = "FormUtils#getFormJsonFromRepositoryOrAssetsWithOptionalCallback")
private JSONObject getFormJsonFromRepositoryOrAssetsWithOptionalCallback(@NonNull Context context, @Nullable ClientFormContract.Dao clientFormRepository, String formIdentity, @Nullable final OnFormFetchedCallback onFormFetchedCallback) throws JSONException {
if (clientFormRepository != null) {
ClientFormContract.Model clientForm = getClientFormFromRepository(context, clientFormRepository, formIdentity);
@@ -1959,7 +1946,6 @@ public void onFormFetched(@Nullable String form) {
}
}
- @AddTrace(name = "FormUtils#getFormJson")
public JSONObject getFormJson(@NonNull Context context, @NonNull String formIdentity) {
try {
String locale = context.getResources().getConfiguration().locale.getLanguage();
@@ -2025,7 +2011,6 @@ public void handleJsonFormOrRulesError(@NonNull Context context, @NonNull Client
handleJsonFormOrRulesError(context, clientFormRepository, false, formIdentity, onFormFetchedCallback);
}
- @AddTrace(name = "FormUtils#handleJsonFormOrRulesError")
public void handleJsonFormOrRulesError(@NonNull final Context context, @NonNull final ClientFormContract.Dao clientFormRepository, final boolean isRulesFile, @NonNull final String formIdentity, @NonNull final OnFormFetchedCallback onFormFetchedCallback) {
final ClientFormContract.Model clientForm = getClientFormFromRepository(context, clientFormRepository, formIdentity);
List clientForms = clientFormRepository.getClientFormByIdentifier(clientForm.getIdentifier());
@@ -2076,7 +2061,6 @@ public void onCancelClicked() {
}
}
- @Nullable @AddTrace(name = "FormUtils#getSubFormJsonFromRepository")
public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, String formIdentity, String subFormsLocation, boolean translateSubForm) throws JSONException {
//Check the current locale of the app to load the correct version of the form in the desired language
String localeFormIdentity = getLocaleFormIdentity(context, formIdentity);
@@ -2108,7 +2092,6 @@ public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNul
return null;
}
- @Nullable @AddTrace(name = "FormUtils#getRulesFromRepository")
public BufferedReader getRulesFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, @NonNull String fileName) {
//Check the current locale of the app to load the correct version of the form in the desired language
String localeFormIdentity = getLocaleFormIdentity(context, fileName);
@@ -2131,7 +2114,6 @@ public BufferedReader getRulesFromRepository(@NonNull Context context, @NonNull
return null;
}
- @AddTrace(name = "FormUtils#getPropertiesFileContentsFromDB")
public String getPropertiesFileContentsFromDB(String identifier) {
ClientFormContract.Dao clientFormRepository = NativeFormLibrary.getInstance().getClientFormDao();
if (clientFormRepository != null) {
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
index 8aa537336..1c5225caf 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
@@ -23,7 +23,6 @@
import android.widget.RelativeLayout;
import android.widget.Toast;
-import com.google.firebase.perf.metrics.AddTrace;
import com.vijay.jsonwizard.R;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.customviews.CompoundButton;
@@ -329,7 +328,6 @@ private static String cleanConditionString(String conditionStringRaw) {
return conditionString.replaceAll(" ", " ");
}
- @AddTrace(name = "Utils$buildRulesWithUniqueId")
public static void buildRulesWithUniqueId(JSONObject element, String uniqueId, String ruleType,
Context context, Map>> rulesFileMap, String stepName) throws JSONException {
JSONObject rules = element.optJSONObject(ruleType);
@@ -841,7 +839,6 @@ public static void checkIfStepHasNoSkipLogic(JsonFormFragment formFragment) {
/***
* removes the generated dynamic rules by repeating group
*/
- @AddTrace(name = "Utils$removeGeneratedDynamicRules")
public static void removeGeneratedDynamicRules(JsonFormFragment formFragment) {
JSONObject form = formFragment.getJsonApi().getmJSONObject();
JSONArray jsonArray = FormUtils.getMultiStepFormFields(form);
@@ -931,7 +928,6 @@ public static boolean isEmptyJsonObject(JSONObject jsonObject) {
* @return
* @throws JSONException
*/
- @Nullable @AddTrace(name = "Utils$getRepeatingGroupCountObj")
public static JSONObject getRepeatingGroupCountObj(@NotNull WidgetArgs widgetArgs) throws JSONException {
String repeatingGroupCountObjKey = widgetArgs.getJsonObject().get(KEY) + "_count";
JSONObject stepJsonObject = widgetArgs.getFormFragment().getStep(widgetArgs.getStepName());
From 8709e79160c4844059795e6354457546b76f01a0 Mon Sep 17 00:00:00 2001
From: Richard Kareko
Date: Fri, 19 Aug 2022 16:55:06 +0300
Subject: [PATCH 04/12] Add sentry transaction blocks
---
.../vijay/jsonwizard/activities/JsonFormBaseActivity.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
index 9c7e70a84..6536d6903 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
@@ -43,6 +43,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import io.sentry.ITransaction;
+import io.sentry.Sentry;
import timber.log.Timber;
import static com.vijay.jsonwizard.utils.NativeFormLangUtils.getTranslatedString;
@@ -82,6 +84,7 @@ public abstract class JsonFormBaseActivity extends MultiLanguageActivity impleme
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.native_form_activity_json_form);
+ ITransaction transaction = Sentry.startTransaction("revealFormOpening", "insideJsonFormBase oncreate");
findViewById(R.id.native_form_activity).setFilterTouchesWhenObscured(true);
mToolbar = findViewById(R.id.tb_top);
setSupportActionBar(mToolbar);
@@ -109,6 +112,8 @@ protected void onCreate(Bundle savedInstanceState) {
for (LifeCycleListener lifeCycleListener : lifeCycleListeners) {
lifeCycleListener.onCreate(savedInstanceState);
}
+
+ transaction.finish();
}
private String readDataSource() {
From 1c3191423b6c2a31191337ce99b0cb78fc5335a8 Mon Sep 17 00:00:00 2001
From: hilpitome
Date: Fri, 16 Sep 2022 17:54:47 +0300
Subject: [PATCH 05/12] disable sentry autoinit in manifest
---
android-json-form-wizard/build.gradle | 17 +++++++++++++++++
.../src/main/AndroidManifest.xml | 9 +--------
.../com/vijay/jsonwizard/NativeFormLibrary.java | 1 -
gradle.properties | 2 +-
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle
index aef04fcce..0d226fcc8 100644
--- a/android-json-form-wizard/build.gradle
+++ b/android-json-form-wizard/build.gradle
@@ -18,6 +18,19 @@ jacoco {
reportsDir = file("$buildDir/reports/jacoco")
}
+Properties properties = new Properties()
+if (project.rootProject.file("local.properties").exists()) {
+ properties.load(project.rootProject.file("local.properties").newDataInputStream())
+}
+ext.getLocalProperty = { key ->
+ if (properties != null && properties.containsKey(key)) {
+ println(key + ": " + properties[key])
+ return properties[key]
+ } else {
+ return "\"123\""
+ }
+}
+
android {
compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
@@ -39,6 +52,7 @@ android {
}
multiDexKeepProguard file('multidex-config.pro')
+ manifestPlaceholders += [ sentryDsnId:getLocalProperty("sentry.dsn")]
}
buildTypes {
@@ -225,3 +239,6 @@ task javadoc(type: Javadoc) {
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
+
+
+
diff --git a/android-json-form-wizard/src/main/AndroidManifest.xml b/android-json-form-wizard/src/main/AndroidManifest.xml
index 4b9a023e1..abfe7dcb7 100644
--- a/android-json-form-wizard/src/main/AndroidManifest.xml
+++ b/android-json-form-wizard/src/main/AndroidManifest.xml
@@ -24,6 +24,7 @@
android:theme="@style/NativeFormsAppTheme"
tools:replace="android:theme">
+
-
-
-
-
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
index 46a5efd46..7c148887a 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
@@ -19,7 +19,6 @@ public static NativeFormLibrary getInstance() {
if (instance == null) {
instance = new NativeFormLibrary();
}
-
return instance;
}
diff --git a/gradle.properties b/gradle.properties
index 3cf87a024..1997d71f9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-VERSION_NAME=3.0.0-SNAPSHOT
+VERSION_NAME=3.0.1-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
From 5acef6929180741e2e66a345094ea2fcf11e2917 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com>
Date: Tue, 20 Sep 2022 10:49:19 +0300
Subject: [PATCH 06/12] Remove unnecessary loading sentry dsn from
local.properties
---
android-json-form-wizard/build.gradle | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle
index 0d226fcc8..1fa5c2320 100644
--- a/android-json-form-wizard/build.gradle
+++ b/android-json-form-wizard/build.gradle
@@ -18,19 +18,6 @@ jacoco {
reportsDir = file("$buildDir/reports/jacoco")
}
-Properties properties = new Properties()
-if (project.rootProject.file("local.properties").exists()) {
- properties.load(project.rootProject.file("local.properties").newDataInputStream())
-}
-ext.getLocalProperty = { key ->
- if (properties != null && properties.containsKey(key)) {
- println(key + ": " + properties[key])
- return properties[key]
- } else {
- return "\"123\""
- }
-}
-
android {
compileSdkVersion androidCompileSdkVersion
buildToolsVersion androidBuildToolsVersion
@@ -52,7 +39,6 @@ android {
}
multiDexKeepProguard file('multidex-config.pro')
- manifestPlaceholders += [ sentryDsnId:getLocalProperty("sentry.dsn")]
}
buildTypes {
From 6ab7ed68af16b785cc1c36613fb3658e1158d587 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com>
Date: Tue, 1 Nov 2022 11:32:00 +0300
Subject: [PATCH 07/12] 472: set up sample app to showcase sentry integration
---
android-json-form-wizard/build.gradle | 2 +-
.../vijay/jsonwizard/NativeFormLibrary.java | 1 +
.../activities/JsonFormBaseActivity.java | 5 -----
.../presenters/JsonFormFragmentPresenter.java | 1 -
.../com/vijay/jsonwizard/utils/Utils.java | 1 +
sample/build.gradle | 13 +++++++++++
sample/src/main/AndroidManifest.xml | 1 +
.../nativeform/MainActivity.java | 7 +++++-
.../nativeform/MainApplication.java | 22 +++++++++++++++++++
9 files changed, 45 insertions(+), 8 deletions(-)
create mode 100644 sample/src/main/java/org/smartregister/nativeform/MainApplication.java
diff --git a/android-json-form-wizard/build.gradle b/android-json-form-wizard/build.gradle
index 709beae15..eac01747b 100644
--- a/android-json-form-wizard/build.gradle
+++ b/android-json-form-wizard/build.gradle
@@ -151,7 +151,7 @@ dependencies {
implementation "org.greenrobot:eventbus:3.2.0"
implementation 'androidx.multidex:multidex:2.0.1'
- implementation 'io.sentry:sentry-android:5.0.1'
+ api 'io.sentry:sentry-android:5.0.1'
// PowerMock
def powerMockVersion = '2.0.9'
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
index 7c148887a..46a5efd46 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/NativeFormLibrary.java
@@ -19,6 +19,7 @@ public static NativeFormLibrary getInstance() {
if (instance == null) {
instance = new NativeFormLibrary();
}
+
return instance;
}
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
index 48c79d7ae..c1f9aaa5f 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonFormBaseActivity.java
@@ -43,8 +43,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import io.sentry.ITransaction;
-import io.sentry.Sentry;
import timber.log.Timber;
import static com.vijay.jsonwizard.utils.NativeFormLangUtils.getTranslatedString;
@@ -84,7 +82,6 @@ public abstract class JsonFormBaseActivity extends MultiLanguageActivity impleme
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.native_form_activity_json_form);
- ITransaction transaction = Sentry.startTransaction("revealFormOpening", "insideJsonFormBase oncreate");
findViewById(R.id.native_form_activity).setFilterTouchesWhenObscured(true);
mToolbar = findViewById(R.id.tb_top);
setSupportActionBar(mToolbar);
@@ -112,8 +109,6 @@ protected void onCreate(Bundle savedInstanceState) {
for (LifeCycleListener lifeCycleListener : lifeCycleListeners) {
lifeCycleListener.onCreate(savedInstanceState);
}
-
- transaction.finish();
}
private String readDataSource() {
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
index ce809d1c0..2d2d569e0 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/presenters/JsonFormFragmentPresenter.java
@@ -436,7 +436,6 @@ public boolean areFormViewsFilled() {
return filled;
}
-
public void validateAndWriteValues() {
for (View childView : formFragment.getJsonApi().getFormDataViews()) {
ValidationStatus validationStatus = validateView(childView);
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
index 4a011ba03..7ba534d22 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/Utils.java
@@ -795,6 +795,7 @@ public static boolean isEmptyJsonObject(JSONObject jsonObject) {
* @return
* @throws JSONException
*/
+ @Nullable
public static JSONObject getRepeatingGroupCountObj(@NotNull WidgetArgs widgetArgs) throws JSONException {
String repeatingGroupCountObjKey = widgetArgs.getJsonObject().get(KEY) + "_count";
JSONObject stepJsonObject = widgetArgs.getFormFragment().getStep(widgetArgs.getStepName());
diff --git a/sample/build.gradle b/sample/build.gradle
index 81bfb98d6..5f5e2113b 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -29,6 +29,8 @@ android {
versionCode 1
versionName "1.0"
multiDexEnabled true
+
+ buildConfigField("String", "SENTRY_DSN", "\"" + getProps("sentry.dsn") + "\"")
}
buildTypes {
@@ -60,3 +62,14 @@ dependencies {
implementation 'org.smartregister:opensrp-client-utils:0.0.6-SNAPSHOT'
}
+
+// get property from local.properties
+def getProps(String propName) {
+ def propsFile = rootProject.file('local.properties')
+ if (propsFile.exists()) {
+ def props = new Properties()
+ props.load(new FileInputStream(propsFile))
+ return props[propName]
+ }
+ return "";
+}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 75c11a6ab..1eae6330d 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -11,6 +11,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
+ android:name=".MainApplication"
android:theme="@style/NativeFormsAppTheme">
{
+ options.setEnvironment("opensrp-native-form-sample");
+ options.setDsn(BuildConfig.SENTRY_DSN.trim());
+ });
+ }
+
+ }
+}
From ec4b0556c3167ea280f20d3dfb04e73e60b2026e Mon Sep 17 00:00:00 2001
From: Hilary Baraka Egesa
Date: Fri, 27 Jan 2023 11:24:46 +0300
Subject: [PATCH 08/12] Update README.md
Instructions on how to setup Sentry
---
README.md | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/README.md b/README.md
index 68055707b..00aca336a 100644
--- a/README.md
+++ b/README.md
@@ -2224,3 +2224,26 @@ Alternatively, a different folder can be specified by setting the `MLS_ASSETS_FO
For a form named `example_form` the generated assets will follow the following naming convention : `example_form.json` and `example_form.properties`.
The properties file can then be copied over to the `resources` folder of your Android project under `src/main`. The placeholder-injected JsonForm will typically be copied over to the `assets` folder of your Android project (although not mandatory).
+
+# How to use Sentry for OpenSRP Client Performance Monitoring
+This section explains how to setup performance monitoring with Sentry on opensrp clients if you have added opensrp-native-forms library as a dependency. Instructions are given in this article on how to initialize Sentry in the opensrp client apps and how to check for the performance data or transactions on the Sentry dashboard.
+##### Note
+* You need to have already setup a [project](https://docs.sentry.io/product/sentry-basics/integrate-frontend/create-new-project/) and dashboard with the necessary access permissions, and
+* are able to obtain the dsn of this project through [Project] > Settings > Client Keys (DSN). This will be required later for configuration and logging.
+
+
+### Instructions
+1. Add and update opensrp-native-forms library to version above v3.0.4-SNAPSHOT
+2. Sync and rebuild project to ensure new dependencies are loaded. Sentry would come as dependency to opensrp-native-forms and would load up automatically. Run your application, and confirm no logs are sent to the sentry dashboard
+3. There are a couple of configurations that would need to be setup first for logs to. show up to the dashboard. These are:
+ * DSN (Data Source Name); you can find your DSN in your Sentry project settings by navigating to [Project] > Settings > Client Keys (DSN) in sentry.io.
+
+ * and Environment; unique name that would be used to tag logs In your app’s Application class, add the following code snippet in onCreate with the placeholder values replaced . Run your application once more
+ In your app’s Application class, add the following code snippet in onCreate with the placeholder values replaced . Run your application once more
+ ```Java
+ SentryAndroid.init(this, options -> {
+ options.setEnvironment("YOUR_ENVIRONMENT_NAME");
+ options.setDsn("YOUR_DSN_NAME_LINK");
+ })
+ ```
+4. Logs in performance monitoring should show up in the Sentry dashboard. Use the Environment tag set from the previous step to filter environment.
From 98d93056d5d91836b350ba4d1dd42eb06d7681af Mon Sep 17 00:00:00 2001
From: Hilary Baraka Egesa
Date: Fri, 27 Jan 2023 11:27:07 +0300
Subject: [PATCH 09/12] Update gradle.properties
Bump up to version 3.2.0-SNAPSHOT
---
gradle.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle.properties b/gradle.properties
index be834e97e..906886943 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-VERSION_NAME=3.1.2-SNAPSHOT
+VERSION_NAME=3.2.0-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
From 3f72b036f9148aa7661835db9fe9907e28e6caa0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com>
Date: Thu, 2 Mar 2023 11:47:20 +0300
Subject: [PATCH 10/12] Fix failing testOnClickShouldDisplayDatePickerDialog
Use normal Activity instead of AndroidX Activity
---
.../widgets/NativeRadioButtonFactory.java | 2 +-
...izardFormFragmentPresenterRoboelectricTest.java | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/NativeRadioButtonFactory.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/NativeRadioButtonFactory.java
index ad4d459b0..638fc2535 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/NativeRadioButtonFactory.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/widgets/NativeRadioButtonFactory.java
@@ -64,7 +64,7 @@
*/
public class NativeRadioButtonFactory implements FormWidgetFactory {
- private static final String TAG = NativeRadioButtonFactory.class.getCanonicalName();
+ public static final String TAG = NativeRadioButtonFactory.class.getCanonicalName();
private final FormUtils formUtils = new FormUtils();
private final CustomTextViewClickListener customTextViewClickListener = new CustomTextViewClickListener();
private RadioButton radioButton;
diff --git a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
index 2c0bb07ee..e31a18ad1 100644
--- a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
+++ b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
@@ -1,12 +1,12 @@
package com.vijay.jsonwizard.presenters;
import android.app.Activity;
+import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.MediaStore;
-import androidx.appcompat.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
@@ -159,10 +159,10 @@ public void testOnClickShouldSOpenPictureTakingActivity() {
}
@Test
- public void testOnClickShouldDisplayDatePickerDialog() {
+ public void testOnClickShouldDisplayDatePickerDialog() throws InterruptedException {
LinearLayout view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.native_form_compound_button_parent, null);
CustomTextView customTextView = new CustomTextView(context);
- Activity activity = Robolectric.buildActivity(AppCompatActivity.class).create().get();
+ Activity activity = Robolectric.buildActivity(Activity.class).create().get();
RadioButton radioButton = new RadioButton(context);
view.setTag(R.id.specify_textview, customTextView);
view.setTag(R.id.native_radio_button, radioButton);
@@ -175,8 +175,12 @@ public void testOnClickShouldDisplayDatePickerDialog() {
view.setTag(R.id.specify_widget, JsonFormConstants.DATE_PICKER);
view.setTag(R.id.option_json_object, new JSONObject());
formFragmentPresenter.onClick(view);
- DatePickerDialog dialogFragment = (DatePickerDialog) activity.getFragmentManager()
- .findFragmentByTag(NativeRadioButtonFactory.class.getCanonicalName());
+ Thread.sleep(3000);
+ DatePickerDialog dialogFragment = null;
+ FragmentManager fragmentManager = activity.getFragmentManager();
+ if (fragmentManager != null){
+ dialogFragment = (DatePickerDialog) fragmentManager.findFragmentByTag(NativeRadioButtonFactory.TAG);
+ }
assertNotNull(dialogFragment);
}
From 0b69e87f7c96ffb12c923da81065ef23f093e9ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com>
Date: Thu, 2 Mar 2023 13:41:24 +0300
Subject: [PATCH 11/12] Test DatePickerDialog 'okbutton' click
---
.../customviews/DatePickerDialog.java | 19 ++++++++--
.../com/vijay/jsonwizard/utils/FormUtils.java | 38 ++++++++++---------
...FormFragmentPresenterRoboelectricTest.java | 5 +++
3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/customviews/DatePickerDialog.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/customviews/DatePickerDialog.java
index b7b14f1d5..e00d2afdd 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/customviews/DatePickerDialog.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/customviews/DatePickerDialog.java
@@ -6,6 +6,8 @@
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -27,6 +29,10 @@
public class DatePickerDialog extends DialogFragment {
private DatePicker datePicker;
+
+ private Button okButton;
+
+ private Button cancelButton;
private android.app.DatePickerDialog.OnDateSetListener onDateSetListener;
private DialogInterface.OnShowListener onShowListener;
private Date date;
@@ -67,9 +73,6 @@ public void setOnShowListener(DialogInterface.OnShowListener onShowListener_) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup dialogView = (ViewGroup) inflater.inflate(R.layout.native_form_dialog_date_picker, container, false);
- Button cancelButton;
- Button okButton;
-
setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
@@ -179,4 +182,14 @@ public DatePicker getDatePicker() {
public void setNumericDatePicker(boolean numericDatePicker) {
isNumericDatePicker = numericDatePicker;
}
+
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
+ public Button getOkButton(){
+ return okButton;
+ }
+
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
+ public Button getCancelButton(){
+ return cancelButton;
+ }
}
diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
index fc07e7472..5ceba0e25 100644
--- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
+++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtils.java
@@ -1138,28 +1138,30 @@ public JSONArray getSecondaryValues(JSONObject jsonObject, String type) {
*/
public JSONArray getFormFields(String stepName, Context context) {
Activity activity = (Activity) context;
- JsonApi jsonApi = (JsonApi) activity;
JSONArray fields = new JSONArray();
- JSONObject mJSONObject = jsonApi.getmJSONObject();
- if (mJSONObject != null) {
- JSONObject parentJson = jsonApi.getStep(stepName);
- try {
- if (parentJson.has(JsonFormConstants.SECTIONS) && parentJson
- .get(JsonFormConstants.SECTIONS) instanceof JSONArray) {
- JSONArray sections = parentJson.getJSONArray(JsonFormConstants.SECTIONS);
- for (int i = 0; i < sections.length(); i++) {
- JSONObject sectionJson = sections.getJSONObject(i);
- if (sectionJson.has(JsonFormConstants.FIELDS)) {
- fields = concatArray(fields, sectionJson.getJSONArray(JsonFormConstants.FIELDS));
+ if (activity instanceof JsonApi) {
+ JsonApi jsonApi = (JsonApi) activity;
+ JSONObject mJSONObject = jsonApi.getmJSONObject();
+ if (mJSONObject != null) {
+ JSONObject parentJson = jsonApi.getStep(stepName);
+ try {
+ if (parentJson.has(JsonFormConstants.SECTIONS) && parentJson
+ .get(JsonFormConstants.SECTIONS) instanceof JSONArray) {
+ JSONArray sections = parentJson.getJSONArray(JsonFormConstants.SECTIONS);
+ for (int i = 0; i < sections.length(); i++) {
+ JSONObject sectionJson = sections.getJSONObject(i);
+ if (sectionJson.has(JsonFormConstants.FIELDS)) {
+ fields = concatArray(fields, sectionJson.getJSONArray(JsonFormConstants.FIELDS));
+ }
}
- }
- } else if (parentJson.has(JsonFormConstants.FIELDS) && parentJson
- .get(JsonFormConstants.FIELDS) instanceof JSONArray) {
- fields = parentJson.getJSONArray(JsonFormConstants.FIELDS);
+ } else if (parentJson.has(JsonFormConstants.FIELDS) && parentJson
+ .get(JsonFormConstants.FIELDS) instanceof JSONArray) {
+ fields = parentJson.getJSONArray(JsonFormConstants.FIELDS);
+ }
+ } catch (JSONException e) {
+ Timber.e(e);
}
- } catch (JSONException e) {
- Timber.e(e);
}
}
return fields;
diff --git a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
index e31a18ad1..6913ebdbd 100644
--- a/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
+++ b/android-json-form-wizard/src/test/java/com/vijay/jsonwizard/presenters/JsonWizardFormFragmentPresenterRoboelectricTest.java
@@ -48,6 +48,7 @@
import static com.vijay.jsonwizard.presenters.JsonFormFragmentPresenter.RESULT_LOAD_IMG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -182,6 +183,10 @@ public void testOnClickShouldDisplayDatePickerDialog() throws InterruptedExcepti
dialogFragment = (DatePickerDialog) fragmentManager.findFragmentByTag(NativeRadioButtonFactory.TAG);
}
assertNotNull(dialogFragment);
+
+ View okButton = dialogFragment.getOkButton();
+ okButton.performClick();
+ assertTrue(radioButton.getText().length() > 0);
}
}
From f0c62db57a7be8d0ffa713ed4247369e27fc7783 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=E2=89=A1ZRS?= <12814349+LZRS@users.noreply.github.com>
Date: Fri, 3 Mar 2023 11:51:31 +0300
Subject: [PATCH 12/12] Fix README.md codacy lint issues
---
README.md | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index 00aca336a..b6bb24b34 100644
--- a/README.md
+++ b/README.md
@@ -2225,25 +2225,33 @@ For a form named `example_form` the generated assets will follow the following n
The properties file can then be copied over to the `resources` folder of your Android project under `src/main`. The placeholder-injected JsonForm will typically be copied over to the `assets` folder of your Android project (although not mandatory).
-# How to use Sentry for OpenSRP Client Performance Monitoring
+## How to use Sentry for OpenSRP Client Performance Monitoring
+
This section explains how to setup performance monitoring with Sentry on opensrp clients if you have added opensrp-native-forms library as a dependency. Instructions are given in this article on how to initialize Sentry in the opensrp client apps and how to check for the performance data or transactions on the Sentry dashboard.
-##### Note
-* You need to have already setup a [project](https://docs.sentry.io/product/sentry-basics/integrate-frontend/create-new-project/) and dashboard with the necessary access permissions, and
-* are able to obtain the dsn of this project through [Project] > Settings > Client Keys (DSN). This will be required later for configuration and logging.
+> ### Note
+>
+> * You need to have already setup a [project](https://docs.sentry.io/product/sentry-basics/integrate-frontend/create-new-project/) and dashboard with the necessary access permissions, and
+> * are able to obtain the dsn of this project through `[Project] > Settings > Client Keys (DSN)`. This will be required later for configuration and logging.
### Instructions
-1. Add and update opensrp-native-forms library to version above v3.0.4-SNAPSHOT
-2. Sync and rebuild project to ensure new dependencies are loaded. Sentry would come as dependency to opensrp-native-forms and would load up automatically. Run your application, and confirm no logs are sent to the sentry dashboard
-3. There are a couple of configurations that would need to be setup first for logs to. show up to the dashboard. These are:
- * DSN (Data Source Name); you can find your DSN in your Sentry project settings by navigating to [Project] > Settings > Client Keys (DSN) in sentry.io.
- * and Environment; unique name that would be used to tag logs In your app’s Application class, add the following code snippet in onCreate with the placeholder values replaced . Run your application once more
+1. Add and update opensrp-native-forms library to version above v3.0.4-SNAPSHOT
+
+2. Sync and rebuild project to ensure new dependencies are loaded. Sentry would come as dependency to opensrp-native-forms and would load up automatically. Run your application, and confirm no logs are sent to the sentry dashboard
+
+3. There are a couple of configurations that would need to be setup first for logs to. show up to the dashboard. These are:
+ * DSN (Data Source Name); you can find your DSN in your Sentry project settings by navigating to `[Project] > Settings > Client Keys (DSN)` in sentry.io.
+
+ * Environment; unique name that would be used to tag logs
+
In your app’s Application class, add the following code snippet in onCreate with the placeholder values replaced . Run your application once more
- ```Java
+
+ ```Java
SentryAndroid.init(this, options -> {
- options.setEnvironment("YOUR_ENVIRONMENT_NAME");
- options.setDsn("YOUR_DSN_NAME_LINK");
+ options.setEnvironment("YOUR_ENVIRONMENT_NAME");
+ options.setDsn("YOUR_DSN_NAME_LINK");
})
- ```
-4. Logs in performance monitoring should show up in the Sentry dashboard. Use the Environment tag set from the previous step to filter environment.
+ ```
+
+4. Logs in performance monitoring should show up in the Sentry dashboard. Use the Environment tag set from the previous step to filter environment.