From 95a654459fd3ca13415e80a056e4f779a923db66 Mon Sep 17 00:00:00 2001 From: LZRS Date: Thu, 8 Jul 2021 15:59:00 +0300 Subject: [PATCH 1/4] allow getting forms from db without appending locale allow configurability of different strategies of form identity naming --- .../FormConfigurationJsonFormActivity.java | 7 ++++- .../activities/JsonWizardFormActivity.java | 2 +- .../NoLocaleJsonWizardFormActivity.java | 11 ++++++++ .../com/vijay/jsonwizard/utils/FormUtils.java | 26 +++++++------------ .../jsonwizard/utils/FormUtilsFactory.java | 18 +++++++++++++ gradle.properties | 2 +- 6 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java index 9d86a4650..3fb279588 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java @@ -15,6 +15,7 @@ import com.vijay.jsonwizard.interfaces.OnFormFetchedCallback; import com.vijay.jsonwizard.utils.AppExecutors; import com.vijay.jsonwizard.utils.FormUtils; +import com.vijay.jsonwizard.utils.FormUtilsFactory; import com.vijay.jsonwizard.utils.NativeFormLangUtils; import org.json.JSONException; @@ -38,11 +39,15 @@ public class FormConfigurationJsonFormActivity extends JsonFormActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - formUtils = new FormUtils(); + formUtils = getFormUtils(); JSONObject jsonObject = getmJSONObject(); checkIfFormUpdate(jsonObject); } + protected FormUtils getFormUtils(){ + return FormUtilsFactory.newInstance(); + } + private void checkIfFormUpdate(@NonNull JSONObject formJsonObject) { if (FormUtils.isFormNew(formJsonObject)) { showFormVersionUpdateDialog(formJsonObject, getString(R.string.form_update_title), getString(R.string.form_update_message)); diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java index c85d2762b..d64af4f3b 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java @@ -8,7 +8,7 @@ /** * Created by keyman on 04/12/2018. */ -public class JsonWizardFormActivity extends JsonFormActivity { +public class JsonWizardFormActivity extends FormConfigurationJsonFormActivity { @Override public void initializeFormFragment() { diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java new file mode 100644 index 000000000..372b962a7 --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java @@ -0,0 +1,11 @@ +package com.vijay.jsonwizard.activities; + +import com.vijay.jsonwizard.utils.FormUtils; +import com.vijay.jsonwizard.utils.FormUtilsFactory; + +public class NoLocaleJsonWizardFormActivity extends JsonWizardFormActivity { + @Override + protected FormUtils getFormUtils() { + return FormUtilsFactory.noLocaleInstance(); + } +} 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 16f868580..9c0c3cf2e 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 @@ -1979,13 +1979,17 @@ public JSONObject getFormJson(@NonNull Context context, @NonNull String formIden } } - private ClientFormContract.Model getClientFormFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormRepository, String formIdentity) { - //Check the current locale of the app to load the correct version of the form in the desired language + protected String getLocaleFormIdentity(final Context context, final String formIdentity){ String locale = context.getResources().getConfiguration().locale.getLanguage(); - String localeFormIdentity = formIdentity; if (!Locale.ENGLISH.getLanguage().equals(locale)) { - localeFormIdentity = localeFormIdentity + "-" + locale; + return formIdentity + "-" + locale; } + return formIdentity; + } + + private ClientFormContract.Model getClientFormFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormRepository, String formIdentity) { + //Check the current locale of the app to load the correct version of the form in the desired language + String localeFormIdentity = getLocaleFormIdentity(context, formIdentity); ClientFormContract.Model clientForm = clientFormRepository.getActiveClientFormByIdentifier(localeFormIdentity); @@ -2061,13 +2065,8 @@ public void onCancelClicked() { @Nullable public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, String formIdentity, String subFormsLocation, boolean translateSubForm) throws JSONException { - String locale = context.getResources().getConfiguration().locale.getLanguage(); - //Check the current locale of the app to load the correct version of the form in the desired language - String localeFormIdentity = formIdentity; - if (!Locale.ENGLISH.getLanguage().equals(locale)) { - localeFormIdentity = localeFormIdentity + "-" + locale; - } + String localeFormIdentity = getLocaleFormIdentity(context, formIdentity); String dbFormName = StringUtils.isBlank(subFormsLocation) ? localeFormIdentity : subFormsLocation + "/" + localeFormIdentity; ClientFormContract.Model clientForm = clientFormDao.getActiveClientFormByIdentifier(dbFormName); @@ -2098,13 +2097,8 @@ public JSONObject getSubFormJsonFromRepository(@NonNull Context context, @NonNul @Nullable public BufferedReader getRulesFromRepository(@NonNull Context context, @NonNull ClientFormContract.Dao clientFormDao, @NonNull String fileName) { - String locale = context.getResources().getConfiguration().locale.getLanguage(); - //Check the current locale of the app to load the correct version of the form in the desired language - String localeFormIdentity = fileName; - if (!Locale.ENGLISH.getLanguage().equals(locale)) { - localeFormIdentity = localeFormIdentity + "-" + locale; - } + String localeFormIdentity = getLocaleFormIdentity(context, fileName); ClientFormContract.Model clientForm = clientFormDao.getActiveClientFormByIdentifier(localeFormIdentity); if (clientForm == null && StringUtils.isNotBlank(fileName) && fileName.contains("/") && !fileName.endsWith("/")) { diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java new file mode 100644 index 000000000..853d9988b --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java @@ -0,0 +1,18 @@ +package com.vijay.jsonwizard.utils; + +import android.content.Context; + +public class FormUtilsFactory { + public static FormUtils newInstance(){ + return new FormUtils(); + } + + public static FormUtils noLocaleInstance(){ + return new FormUtils(){ + @Override + protected String getLocaleFormIdentity(Context context, String formIdentity) { + return formIdentity; + } + }; + } +} diff --git a/gradle.properties b/gradle.properties index 0de4d45a2..b5cb94a61 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.1.0-SNAPSHOT +VERSION_NAME=2.1.1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard From f7a4606207702c3eafeffcbb8b2c03ca6eda8c72 Mon Sep 17 00:00:00 2001 From: LZRS Date: Fri, 9 Jul 2021 10:21:41 +0300 Subject: [PATCH 2/4] move formutils factory methods into formutils fix codacy util class naming --- .../FormConfigurationJsonFormActivity.java | 3 +-- .../NoLocaleJsonWizardFormActivity.java | 3 +-- .../com/vijay/jsonwizard/utils/FormUtils.java | 13 +++++++++++++ .../jsonwizard/utils/FormUtilsFactory.java | 18 ------------------ 4 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java index 3fb279588..cee6cbd57 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java @@ -15,7 +15,6 @@ import com.vijay.jsonwizard.interfaces.OnFormFetchedCallback; import com.vijay.jsonwizard.utils.AppExecutors; import com.vijay.jsonwizard.utils.FormUtils; -import com.vijay.jsonwizard.utils.FormUtilsFactory; import com.vijay.jsonwizard.utils.NativeFormLangUtils; import org.json.JSONException; @@ -45,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { } protected FormUtils getFormUtils(){ - return FormUtilsFactory.newInstance(); + return FormUtils.newInstance(); } private void checkIfFormUpdate(@NonNull JSONObject formJsonObject) { diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java index 372b962a7..6c8ad940f 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java @@ -1,11 +1,10 @@ package com.vijay.jsonwizard.activities; import com.vijay.jsonwizard.utils.FormUtils; -import com.vijay.jsonwizard.utils.FormUtilsFactory; public class NoLocaleJsonWizardFormActivity extends JsonWizardFormActivity { @Override protected FormUtils getFormUtils() { - return FormUtilsFactory.noLocaleInstance(); + return FormUtils.newInstanceWithNoLocale(); } } 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..a7be0dff5 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 @@ -104,6 +104,19 @@ public class FormUtils { private Utils utils = new Utils(); private GenericDialogInterface genericDialogInterface; + public static FormUtils newInstance(){ + return new FormUtils(); + } + + public static FormUtils newInstanceWithNoLocale(){ + return new FormUtils(){ + @Override + protected String getLocaleFormIdentity(Context context, String formIdentity) { + return formIdentity; + } + }; + } + public static Point getViewLocationOnScreen(View view) { int[] location = new int[2]; view.getLocationOnScreen(location); diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java deleted file mode 100644 index 853d9988b..000000000 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/FormUtilsFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vijay.jsonwizard.utils; - -import android.content.Context; - -public class FormUtilsFactory { - public static FormUtils newInstance(){ - return new FormUtils(); - } - - public static FormUtils noLocaleInstance(){ - return new FormUtils(){ - @Override - protected String getLocaleFormIdentity(Context context, String formIdentity) { - return formIdentity; - } - }; - } -} From 2b05466537c0eaaca8fec7dab879669032c6b397 Mon Sep 17 00:00:00 2001 From: LZRS Date: Fri, 9 Jul 2021 15:12:12 +0300 Subject: [PATCH 3/4] add new activity to capture both form config and jsonwizard --- .../FormConfigurationJsonFormActivity.java | 12 +++++- ...rmConfigurationJsonWizardFormActivity.java | 37 +++++++++++++++++++ .../activities/JsonWizardFormActivity.java | 12 +++--- ...rmConfigurationJsonWizardFormActivity.java | 8 ++++ .../NoLocaleJsonWizardFormActivity.java | 10 ----- .../delegates/JsonWizardFormDelegate.java | 18 +++++++++ .../com/vijay/jsonwizard/utils/FormUtils.java | 13 ------- .../jsonwizard/utils/NoLocaleFormUtils.java | 10 +++++ 8 files changed, 89 insertions(+), 31 deletions(-) create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java delete mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/delegates/JsonWizardFormDelegate.java create mode 100644 android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/NoLocaleFormUtils.java diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java index cee6cbd57..aac2110cc 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java @@ -16,6 +16,7 @@ import com.vijay.jsonwizard.utils.AppExecutors; import com.vijay.jsonwizard.utils.FormUtils; import com.vijay.jsonwizard.utils.NativeFormLangUtils; +import com.vijay.jsonwizard.utils.NoLocaleFormUtils; import org.json.JSONException; import org.json.JSONObject; @@ -43,8 +44,15 @@ protected void onCreate(Bundle savedInstanceState) { checkIfFormUpdate(jsonObject); } - protected FormUtils getFormUtils(){ - return FormUtils.newInstance(); + private FormUtils getFormUtils(){ + if (!this.isUsingLocaleForms()){ + return new NoLocaleFormUtils(); + } + return new FormUtils(); + } + + protected boolean isUsingLocaleForms(){ + return true; } private void checkIfFormUpdate(@NonNull JSONObject formJsonObject) { diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java new file mode 100644 index 000000000..c1337714c --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java @@ -0,0 +1,37 @@ +package com.vijay.jsonwizard.activities; + +import com.vijay.jsonwizard.delegates.JsonWizardFormDelegate; + +import org.json.JSONException; + +public class FormConfigurationJsonWizardFormActivity extends FormConfigurationJsonFormActivity{ + + private final JsonWizardFormDelegate delegate = new JsonWizardFormDelegate(); + + @Override + public void initializeFormFragment() { + initializeFormFragmentCore(); + } + + @Override + public void writeValue(String stepName, String key, String value, String openMrsEntityParent, String openMrsEntity, String openMrsEntityId) throws JSONException { + callSuperWriteValue(stepName, key, value, openMrsEntityParent, openMrsEntity, openMrsEntityId); + } + + @Override + public void onFormFinish() { + callSuperFinish(); + } + + protected void callSuperFinish(){ + super.onFormFinish(); + } + + protected void callSuperWriteValue(String stepName, String key, String value, String openMrsEntityParent, String openMrsEntity, String openMrsEntityId) throws JSONException { + super.writeValue(stepName, key, value, openMrsEntityParent, openMrsEntity, openMrsEntityId); + } + + protected void initializeFormFragmentCore(){ + delegate.initializeFormFragmentCore(this.getSupportFragmentManager()); + } +} diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java index d64af4f3b..dce1e0525 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/JsonWizardFormActivity.java @@ -1,17 +1,18 @@ package com.vijay.jsonwizard.activities; -import com.vijay.jsonwizard.constants.JsonFormConstants; -import com.vijay.jsonwizard.fragments.JsonWizardFormFragment; +import com.vijay.jsonwizard.delegates.JsonWizardFormDelegate; import org.json.JSONException; /** * Created by keyman on 04/12/2018. */ -public class JsonWizardFormActivity extends FormConfigurationJsonFormActivity { +public class JsonWizardFormActivity extends JsonFormActivity { + + private final JsonWizardFormDelegate delegate = new JsonWizardFormDelegate(); @Override - public void initializeFormFragment() { + public synchronized void initializeFormFragment() { initializeFormFragmentCore(); } @@ -34,8 +35,7 @@ protected void callSuperWriteValue(String stepName, String key, String value, St } protected void initializeFormFragmentCore() { - JsonWizardFormFragment jsonWizardFormFragment = JsonWizardFormFragment.getFormFragment(JsonFormConstants.FIRST_STEP_NAME); - getSupportFragmentManager().beginTransaction().add(com.vijay.jsonwizard.R.id.container, jsonWizardFormFragment).commit(); + delegate.initializeFormFragmentCore(this.getSupportFragmentManager()); } } diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java new file mode 100644 index 000000000..1ecbbdc27 --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java @@ -0,0 +1,8 @@ +package com.vijay.jsonwizard.activities; + +public class NoLocaleFormConfigurationJsonWizardFormActivity extends FormConfigurationJsonWizardFormActivity { + @Override + protected boolean isUsingLocaleForms() { + return false; + } +} diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java deleted file mode 100644 index 6c8ad940f..000000000 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleJsonWizardFormActivity.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.vijay.jsonwizard.activities; - -import com.vijay.jsonwizard.utils.FormUtils; - -public class NoLocaleJsonWizardFormActivity extends JsonWizardFormActivity { - @Override - protected FormUtils getFormUtils() { - return FormUtils.newInstanceWithNoLocale(); - } -} diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/delegates/JsonWizardFormDelegate.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/delegates/JsonWizardFormDelegate.java new file mode 100644 index 000000000..1cb137682 --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/delegates/JsonWizardFormDelegate.java @@ -0,0 +1,18 @@ +package com.vijay.jsonwizard.delegates; + +import android.support.annotation.NonNull; +import android.support.v4.app.FragmentManager; + +import com.vijay.jsonwizard.constants.JsonFormConstants; +import com.vijay.jsonwizard.fragments.JsonWizardFormFragment; + +public class JsonWizardFormDelegate { + + public void initializeFormFragmentCore(@NonNull FragmentManager supportFragmentManager){ + JsonWizardFormFragment jsonWizardFormFragment = JsonWizardFormFragment.getFormFragment(JsonFormConstants.FIRST_STEP_NAME); + supportFragmentManager.beginTransaction() + .add(com.vijay.jsonwizard.R.id.container, jsonWizardFormFragment) + .commit(); + } + +} 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 a7be0dff5..9c0c3cf2e 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 @@ -104,19 +104,6 @@ public class FormUtils { private Utils utils = new Utils(); private GenericDialogInterface genericDialogInterface; - public static FormUtils newInstance(){ - return new FormUtils(); - } - - public static FormUtils newInstanceWithNoLocale(){ - return new FormUtils(){ - @Override - protected String getLocaleFormIdentity(Context context, String formIdentity) { - return formIdentity; - } - }; - } - public static Point getViewLocationOnScreen(View view) { int[] location = new int[2]; view.getLocationOnScreen(location); diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/NoLocaleFormUtils.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/NoLocaleFormUtils.java new file mode 100644 index 000000000..bc40efbed --- /dev/null +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/utils/NoLocaleFormUtils.java @@ -0,0 +1,10 @@ +package com.vijay.jsonwizard.utils; + +import android.content.Context; + +public class NoLocaleFormUtils extends FormUtils{ + @Override + protected String getLocaleFormIdentity(Context context, String formIdentity) { + return formIdentity; + } +} From a787630deed303eae20b45920c2da1470b09fc9f Mon Sep 17 00:00:00 2001 From: LZRS Date: Fri, 9 Jul 2021 16:02:41 +0300 Subject: [PATCH 4/4] refactor name isUsingLocaleForms to supportsLocaleBasedForms and other formatting improvements --- .../activities/FormConfigurationJsonFormActivity.java | 6 +++--- .../FormConfigurationJsonWizardFormActivity.java | 8 ++++---- .../NoLocaleFormConfigurationJsonWizardFormActivity.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java index aac2110cc..0ee860ee0 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonFormActivity.java @@ -44,14 +44,14 @@ protected void onCreate(Bundle savedInstanceState) { checkIfFormUpdate(jsonObject); } - private FormUtils getFormUtils(){ - if (!this.isUsingLocaleForms()){ + private FormUtils getFormUtils() { + if (!this.supportsLocaleBasedForms()) { return new NoLocaleFormUtils(); } return new FormUtils(); } - protected boolean isUsingLocaleForms(){ + protected boolean supportsLocaleBasedForms() { return true; } diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java index c1337714c..f310c916a 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/FormConfigurationJsonWizardFormActivity.java @@ -4,12 +4,12 @@ import org.json.JSONException; -public class FormConfigurationJsonWizardFormActivity extends FormConfigurationJsonFormActivity{ +public class FormConfigurationJsonWizardFormActivity extends FormConfigurationJsonFormActivity { private final JsonWizardFormDelegate delegate = new JsonWizardFormDelegate(); @Override - public void initializeFormFragment() { + public synchronized void initializeFormFragment() { initializeFormFragmentCore(); } @@ -23,7 +23,7 @@ public void onFormFinish() { callSuperFinish(); } - protected void callSuperFinish(){ + protected void callSuperFinish() { super.onFormFinish(); } @@ -31,7 +31,7 @@ protected void callSuperWriteValue(String stepName, String key, String value, St super.writeValue(stepName, key, value, openMrsEntityParent, openMrsEntity, openMrsEntityId); } - protected void initializeFormFragmentCore(){ + protected void initializeFormFragmentCore() { delegate.initializeFormFragmentCore(this.getSupportFragmentManager()); } } diff --git a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java index 1ecbbdc27..19b83665f 100644 --- a/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java +++ b/android-json-form-wizard/src/main/java/com/vijay/jsonwizard/activities/NoLocaleFormConfigurationJsonWizardFormActivity.java @@ -2,7 +2,7 @@ public class NoLocaleFormConfigurationJsonWizardFormActivity extends FormConfigurationJsonWizardFormActivity { @Override - protected boolean isUsingLocaleForms() { + protected boolean supportsLocaleBasedForms() { return false; } }