diff --git a/gradle.properties b/gradle.properties index c1446212c..6aa092b2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.1.2-SNAPSHOT +VERSION_NAME=2.1.2.1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Core Application diff --git a/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java b/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java index 41dc7be64..139d359c1 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java +++ b/opensrp-app/src/main/java/org/smartregister/view/activity/BaseRegisterActivity.java @@ -29,6 +29,7 @@ import org.smartregister.util.PermissionUtils; import org.smartregister.util.Utils; import org.smartregister.view.contract.BaseRegisterContract; +import org.smartregister.view.contract.ConfigurableRegisterActivityContract; import org.smartregister.view.fragment.BaseRegisterFragment; import org.smartregister.view.viewpager.OpenSRPViewPager; @@ -41,7 +42,7 @@ * Created by keyman on 26/06/2018. */ -public abstract class BaseRegisterActivity extends SecuredNativeSmartRegisterActivity implements BaseRegisterContract.View { +public abstract class BaseRegisterActivity extends SecuredNativeSmartRegisterActivity implements BaseRegisterContract.View, ConfigurableRegisterActivityContract.View { protected OpenSRPViewPager mPager; @@ -354,4 +355,10 @@ public void setSelectedBottomBarMenuItem(int itemId) { public void setSearchTerm(String searchTerm) { mBaseFragment.setSearchTerm(searchTerm); } + + @Override + public ConfigurableRegisterActivityContract.Presenter presenter() { + initializePresenter(); + return presenter; + } } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java index 16a235981..a217b37f1 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterContract.java @@ -11,7 +11,8 @@ * Created by keyamn on 27/06/2018. */ public interface BaseRegisterContract { - interface Presenter { + + interface Presenter extends ConfigurableRegisterActivityContract.Presenter { void registerViewConfigurations(List viewIdentifiers); @@ -22,7 +23,7 @@ interface Presenter { void updateInitials(); } - interface View { + interface View extends ConfigurableRegisterActivityContract.View { Context getContext(); @@ -44,4 +45,8 @@ interface View { void updateInitialsText(String initials); } + + interface Model extends ConfigurableRegisterActivityContract.Model { + + } } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java index a42a50372..ea1609098 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/BaseRegisterFragmentContract.java @@ -4,7 +4,7 @@ public interface BaseRegisterFragmentContract { - interface View { + interface View extends ConfigurableRegisterFragmentContract.View { void initializeQueryParams(String tableName, String countSelect, String mainSelect); @@ -29,7 +29,7 @@ interface View { void setTotalPatients(); } - interface Presenter { + interface Presenter extends ConfigurableRegisterFragmentContract.Presenter { void processViewConfigurations(); @@ -41,5 +41,9 @@ interface Presenter { } + interface Model extends ConfigurableRegisterFragmentContract.Model { + + } + } diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java new file mode 100644 index 000000000..15c393226 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterActivityContract.java @@ -0,0 +1,75 @@ +package org.smartregister.view.contract; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import org.apache.commons.lang3.tuple.Triple; +import org.json.JSONException; +import org.json.JSONObject; +import org.smartregister.domain.db.EventClient; +import org.smartregister.domain.tag.FormTag; + +import java.util.List; + +public interface ConfigurableRegisterActivityContract { + + interface View { + Presenter presenter(); + } + + interface Presenter { + + default void saveLanguage(String language) { + + } + + default void startForm(String formName, String entityId, String metadata, String currentLocationId) { + + } + + default void saveForm(String jsonString, @NonNull RegisterParams registerParams) { + + } + + default Interactor createInteractor() { + return null; + } + } + + interface Model { + + JSONObject getFormAsJson(String formName, String entityId, + String currentLocationId) throws JSONException; + + void registerViewConfigurations(List viewIdentifiers); + + void unregisterViewConfiguration(List viewIdentifiers); + + void saveLanguage(String language); + + List processRegistration(String jsonString, FormTag formTag); + + String getLocationId(String locationName); + + String getInitials(); + } + + interface Interactor { + + void onDestroy(boolean isChangingConfiguration); + + void getNextUniqueId(Triple triple, ConfigurableRegisterActivityContract.InteractorCallBack callBack); + + void saveRegistration(@Nullable final List clientList, final String jsonString, @NonNull RegisterParams registerParams, final ConfigurableRegisterActivityContract.InteractorCallBack callBack); + + } + + interface InteractorCallBack { + + void onUniqueIdFetched(Triple triple, String entityId); + + void onNoUniqueId(); + + void onRegistrationSaved(@NonNull RegisterParams registerParams, @Nullable List clientList); + } +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java new file mode 100644 index 000000000..101377c5d --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/ConfigurableRegisterFragmentContract.java @@ -0,0 +1,47 @@ +package org.smartregister.view.contract; + +import org.json.JSONArray; +import org.smartregister.domain.Response; + +import java.util.List; +import java.util.Set; + +public interface ConfigurableRegisterFragmentContract { + + interface View { + + void initializeAdapter(Set visibleColumns); + + Presenter presenter(); + + } + + interface Presenter { + + default void updateSortAndFilter(List filterList, IField sortField) {} + + default String getMainCondition() { return null; } + + default String getDefaultSortQuery() { return null; } + + default String getQueryTable() {return null; } + } + + interface Model { + + IViewConfiguration getViewConfiguration(String viewConfigurationIdentifier); + + Set getRegisterActiveColumns(String viewConfigurationIdentifier); + + String countSelect(String tableName, String mainCondition); + + String mainSelect(String tableName, String mainCondition); + + String getFilterText(List filterList, String filter); + + String getSortText(IField sortField); + + JSONArray getJsonArray(Response response); + + } +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java new file mode 100644 index 000000000..0c6088174 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IBaseConfiguration.java @@ -0,0 +1,19 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IBaseConfiguration { + + String getLanguage(); + + void setLanguage(String language); + + String getApplicationName(); + + void setApplicationName(String applicationName); + + boolean isEnableJsonViews(); + + void setEnableJsonViews(boolean enableJsonViews); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java new file mode 100644 index 000000000..0239ef48f --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IField.java @@ -0,0 +1,16 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IField { + + + String getDisplayName(); + + void setDisplayName(String displayName); + + String getDbAlias(); + + void setDbAlias(String dbAlias); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java new file mode 100644 index 000000000..0cf859bdf --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IResidence.java @@ -0,0 +1,19 @@ +package org.smartregister.view.contract; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IResidence { + + String getParent(); + + void setParent(String parent); + + int getPosition(); + + void setPosition(int position); + + String getLayoutWeight(); + + void setLayoutWeight(String layoutWeight); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java new file mode 100644 index 000000000..1e33da386 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IView.java @@ -0,0 +1,40 @@ +package org.smartregister.view.contract; + +import java.util.Map; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IView { + + + void setParent(String parent); + + String getIdentifier(); + + void setIdentifier(String identifier); + + String getType(); + + void setType(String type); + + String getOrientation(); + + void setOrientation(String orientation); + + boolean isVisible(); + + void setVisible(boolean visible); + + String getLabel(); + + void setLabel(String label); + + IResidence getResidence(); + + void setResidence(IResidence residence); + + Map getMetadata(); + + void setMetadata(Map metadata); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java b/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java new file mode 100644 index 000000000..c0cf9e926 --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/IViewConfiguration.java @@ -0,0 +1,31 @@ +package org.smartregister.view.contract; + +import java.util.List; +import java.util.Map; + +/** + * Created by Ephraim Kigamba - nek.eam@gmail.com on 17-09-2020. + */ +public interface IViewConfiguration { + + + String getIdentifier(); + + void setIdentifier(String identifier); + + IBaseConfiguration getMetadata(); + + void setMetadata(IBaseConfiguration metadata); + + List getViews(); + + void setViews(List views); + + Map getLabels(); + + void setLabels(Map labels); + + Map getJsonView(); + + void setJsonView(Map jsonView); +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java b/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java new file mode 100644 index 000000000..26b7de75a --- /dev/null +++ b/opensrp-app/src/main/java/org/smartregister/view/contract/RegisterParams.java @@ -0,0 +1,47 @@ +package org.smartregister.view.contract; + +import org.smartregister.domain.tag.FormTag; +import org.smartregister.repository.BaseRepository; + +public class RegisterParams { + + private String status = BaseRepository.TYPE_Unsynced; + + private boolean editMode; + + private boolean saved; + + private FormTag formTag; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public boolean isEditMode() { + return editMode; + } + + public void setEditMode(boolean editMode) { + this.editMode = editMode; + } + + public boolean isSaved() { + return saved; + } + + public void setSaved(boolean saved) { + this.saved = saved; + } + + public FormTag getFormTag() { + return formTag; + } + + public void setFormTag(FormTag formTag) { + this.formTag = formTag; + } +} diff --git a/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java b/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java index 82f4fbafd..443891796 100644 --- a/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java +++ b/opensrp-app/src/main/java/org/smartregister/view/fragment/BaseRegisterFragment.java @@ -35,9 +35,12 @@ import org.smartregister.view.activity.BaseRegisterActivity; import org.smartregister.view.activity.SecuredNativeSmartRegisterActivity; import org.smartregister.view.contract.BaseRegisterFragmentContract; +import org.smartregister.view.contract.ConfigurableRegisterFragmentContract; +import org.smartregister.view.contract.IView; import org.smartregister.view.dialog.DialogOption; import java.util.HashMap; +import java.util.Set; import timber.log.Timber; @@ -476,6 +479,16 @@ protected void refreshSyncProgressSpinner() { } } + @Override + public void initializeAdapter(Set visibleColumns) { + // Do nothing + } + + @Override + public ConfigurableRegisterFragmentContract.Presenter presenter() { + initializePresenter(); + return presenter; + } //////////////////////////////////////////////////////////////// // Inner classes