Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Family Planning register implementation #90

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ configure(allprojects) { project ->
jcenter()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases'}
mavenLocal()
}
}
Expand All @@ -33,8 +34,8 @@ subprojects {

group = 'org.smartregister'

ext.androidToolsBuildGradle = '3.1.4'
ext.androidBuildToolsVersion = '28.0.3'
ext.androidToolsBuildGradle = '4.0.2'
ext.androidBuildToolsVersion = '29.0.3'
ext.androidMinSdkVersion = 18
ext.androidCompileSdkVersion = 28
ext.androidTargetSdkVersion = 28
Expand All @@ -52,6 +53,7 @@ subprojects {
maven { url "https://cloudant.github.io/cloudant-sync-eap/repository" }
maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
maven{ url "https://plugins.gradle.org/m2/" }
maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases'}
mavenLocal()
}

Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.0.27-SNAPSHOT
VERSION_NAME=1.1.1-GS-PREVIEW-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client CHW Family Planning Library
Expand All @@ -15,3 +15,5 @@ POM_SETTING_NAME=OpenSRP Client Chw Family Plannin
POM_SETTING_ARTIFACT_ID=opensrp-chw-family-planning
POM_SETTING_PACKAGING=aar
org.gradle.jvmargs=-Xmx2048M -XX\:MaxHeapSize\=32g
android.useAndroidX=true
android.enableJetifier=true
20 changes: 12 additions & 8 deletions opensrp-chw-family-planning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ android {
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true

buildTypes {
release {
minifyEnabled false
Expand Down Expand Up @@ -64,6 +67,8 @@ android {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/NOTICE.md'
}

testOptions {
Expand All @@ -85,22 +90,22 @@ allprojects {
}

dependencies {
implementation('org.smartregister:opensrp-client-core:1.11.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-core:4.2.4.1-GS-PREVIEW-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'org.apache.httpcomponents', module: 'httpmime'
}

implementation('org.smartregister:opensrp-client-native-form:1.9.1-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-native-form:1.14.7.0-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'recyclerview-v7'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
}

implementation('org.smartregister:opensrp-client-configurable-views:1.1.5-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-configurable-views:1.2.0-GS-PREVIEW-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand All @@ -114,7 +119,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api('org.smartregister:opensrp-client-chw-anc:0.1.59-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-chw-anc:2.0.2.1-GS-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'com.android.support', module: 'appcompat-v7'
Expand All @@ -136,9 +141,9 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.7.22'
androidTestImplementation 'org.mockito:mockito-android:2.7.22'

testImplementation 'org.robolectric:robolectric:3.8'
testImplementation 'org.robolectric:shadows-multidex:3.8'
testImplementation 'org.robolectric:shadows-support-v4:3.4-rc2'
testImplementation 'org.mockito:mockito-inline:2.25.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'org.robolectric:shadows-multidex:4.3.1'


testImplementation 'junit:junit:4.12'
Expand All @@ -154,7 +159,6 @@ dependencies {
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {

reports {
xml.enabled = true
html.enabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class FpLibrary {
private ECSyncHelper syncHelper;

private ClientProcessorForJava clientProcessorForJava;
private Compressor compressor;

private FpLibrary(Context contextArg, Repository repositoryArg, int applicationVersion, int databaseVersion) {
this.context = contextArg;
Expand Down Expand Up @@ -99,11 +98,4 @@ public ClientProcessorForJava getClientProcessorForJava() {
public void setClientProcessorForJava(ClientProcessorForJava clientProcessorForJava) {
this.clientProcessorForJava = clientProcessorForJava;
}

public Compressor getCompressor() {
if (compressor == null) {
compressor = Compressor.getDefault(context().applicationContext());
}
return compressor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
Expand All @@ -17,6 +14,10 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.Days;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.MenuRes;
import android.support.design.bottomnavigation.LabelVisibilityMode;
import android.support.v4.app.Fragment;

import androidx.annotation.MenuRes;
import androidx.fragment.app.Fragment;

import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;

Expand All @@ -27,6 +28,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import timber.log.Timber;

Expand Down Expand Up @@ -58,7 +60,7 @@ protected void onStartActivityWithAction() {

@Override
public void startRegistration() {
startFormActivity(FORM_NAME, null, null);
startFormActivity(FORM_NAME, null, (String) null);
}

@Override
Expand Down Expand Up @@ -157,13 +159,19 @@ protected Fragment[] getOtherFragments() {
return new Fragment[0];
}

@Override
public void startFormActivity(String formName, String entityId, Map<String, String> metaData) {
// Implement abstract method
}

@Override
public BaseFpRegisterContract.Presenter presenter() {
return (BaseFpRegisterContract.Presenter) presenter;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == FamilyPlanningConstants.REQUEST_CODE_GET_JSON) {
try {
String jsonString = data.getStringExtra(FamilyPlanningConstants.JsonFromExtra.JSON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public interface BaseFpRegisterFragmentContract {

interface View extends BaseRegisterFragmentContract.View {

void initializeAdapter(Set<org.smartregister.configurableviews.model.View> visibleColumns);

Presenter presenter();

}
Expand All @@ -36,20 +34,14 @@ interface Presenter extends BaseRegisterFragmentContract.Presenter {

}

interface Model {
interface Model extends BaseRegisterFragmentContract.Model {

RegisterConfiguration defaultRegisterConfiguration();

ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier);

Set<org.smartregister.configurableviews.model.View> getRegisterActiveColumns(String viewConfigurationIdentifier);

String countSelect(String tableName, String mainCondition);

String mainSelect(String tableName, String mainCondition);

String getFilterText(List<Field> filterList, String filter);

String getSortText(Field sortField);

JSONArray getJsonArray(Response<String> response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import android.app.Activity;
import android.content.Context;
import android.support.design.widget.FloatingActionButton;
import android.view.View;
import android.widget.LinearLayout;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

import org.smartregister.chw.fp.domain.FpMemberObject;
import org.smartregister.chw.fp.fragment.BaseFpCallDialogFragment;
import org.smartregister.fp.R;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.smartregister.chw.fp.presenter.BaseFpRegisterFragmentPresenter;
import org.smartregister.chw.fp.provider.BaseFpRegisterProvider;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.configurableviews.model.View;
import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter;
import org.smartregister.fp.R;
import org.smartregister.view.contract.IView;
import org.smartregister.view.customcontrols.CustomFontTextView;
import org.smartregister.view.customcontrols.FontVariant;
import org.smartregister.view.fragment.BaseRegisterFragment;
Expand All @@ -24,7 +24,7 @@ public class BaseFpRegisterFragment extends BaseRegisterFragment implements Base
public static final String FOLLOW_UP_VISIT = "follow_up_visit";

@Override
public void initializeAdapter(Set<View> visibleColumns) {
public void initializeAdapter(Set<IView> visibleColumns) {
BaseFpRegisterProvider fpRegisterProvider = new BaseFpRegisterProvider(getActivity(), paginationViewHandler, registerActionHandler, visibleColumns);
clientAdapter = new RecyclerViewPaginatedAdapter(null, fpRegisterProvider, context().commonrepository(this.tablename));
clientAdapter.setCurrentlimit(20);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.smartregister.chw.fp.interactor;

import android.support.annotation.VisibleForTesting;

import androidx.annotation.VisibleForTesting;

import org.smartregister.chw.fp.contract.BaseFpProfileContract;
import org.smartregister.chw.fp.domain.FpMemberObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.smartregister.chw.fp.interactor;

import android.support.annotation.VisibleForTesting;
import androidx.annotation.VisibleForTesting;

import org.smartregister.chw.fp.contract.BaseFpRegisterContract;
import org.smartregister.chw.fp.util.AppExecutors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.smartregister.chw.fp.listener;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.MenuItem;

import androidx.annotation.NonNull;

import org.smartregister.fp.R;
import org.smartregister.listener.BottomNavigationListener;
import org.smartregister.view.activity.BaseRegisterActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.smartregister.chw.fp.model;

import android.support.annotation.NonNull;

import androidx.annotation.NonNull;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
Expand All @@ -11,11 +12,12 @@
import org.smartregister.configurableviews.ConfigurableViewsLibrary;
import org.smartregister.configurableviews.model.Field;
import org.smartregister.configurableviews.model.RegisterConfiguration;
import org.smartregister.configurableviews.model.View;
import org.smartregister.configurableviews.model.ViewConfiguration;
import org.smartregister.cursoradapter.SmartRegisterQueryBuilder;
import org.smartregister.domain.Response;
import org.smartregister.domain.ResponseStatus;
import org.smartregister.view.contract.IField;
import org.smartregister.view.contract.IView;
import org.smartregister.view.contract.IViewConfiguration;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -44,13 +46,15 @@ public RegisterConfiguration defaultRegisterConfiguration() {
}

@Override
public ViewConfiguration getViewConfiguration(String viewConfigurationIdentifier) {
public IViewConfiguration getViewConfiguration(String viewConfigurationIdentifier) {
return ConfigurableViewsLibrary.getInstance().getConfigurableViewsHelper().getViewConfiguration(viewConfigurationIdentifier);
}

@Override
public Set<View> getRegisterActiveColumns(String viewConfigurationIdentifier) {
return ConfigurableViewsLibrary.getInstance().getConfigurableViewsHelper().getRegisterActiveColumns(viewConfigurationIdentifier);
public Set<IView> getRegisterActiveColumns(String viewConfigurationIdentifier) {
HashSet<IView> iviews = new HashSet();
iviews.addAll(ConfigurableViewsLibrary.getInstance().getConfigurableViewsHelper().getRegisterActiveColumns(viewConfigurationIdentifier));
return iviews;
}

@Override
Expand Down Expand Up @@ -80,8 +84,8 @@ protected String[] mainColumns(String tableName) {
}

@Override
public String getFilterText(List<Field> list, String filterTitle) {
List<Field> filterList = list;
public String getFilterText(List<IField> list, String filterTitle) {
List<IField> filterList = list;
if (filterList == null) {
filterList = new ArrayList<>();
}
Expand All @@ -93,6 +97,11 @@ public String getFilterText(List<Field> list, String filterTitle) {
return "<font color=#727272>" + filter + "</font> <font color=#f0ab41>(" + filterList.size() + ")</font>";
}

@Override
public String getSortText(IField sortField) {
return null;
}

@Override
public String getSortText(Field sortField) {
String sortText = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.smartregister.configurableviews.model.RegisterConfiguration;
import org.smartregister.configurableviews.model.View;
import org.smartregister.configurableviews.model.ViewConfiguration;
import org.smartregister.view.contract.IView;
import org.smartregister.view.contract.IViewConfiguration;

import java.lang.ref.WeakReference;
import java.util.List;
Expand All @@ -20,7 +22,7 @@ public class BaseFpRegisterFragmentPresenter implements BaseFpRegisterFragmentCo

protected RegisterConfiguration config;

protected Set<View> visibleColumns = new TreeSet<>();
protected Set<IView> visibleColumns = new TreeSet<>();

public BaseFpRegisterFragmentPresenter(BaseFpRegisterFragmentContract.View view, BaseFpRegisterFragmentContract.Model model) {
this.viewReference = new WeakReference<>(view);
Expand All @@ -47,7 +49,7 @@ public String getDefaultSortQuery() {
@Override
public void processViewConfigurations() {

ViewConfiguration viewConfiguration = model.getViewConfiguration(FamilyPlanningConstants.CONFIGURATION.FAMILY_PLANNING_REGISTER);
IViewConfiguration viewConfiguration = model.getViewConfiguration(FamilyPlanningConstants.CONFIGURATION.FAMILY_PLANNING_REGISTER);
if (viewConfiguration != null) {
config = (RegisterConfiguration) viewConfiguration.getMetadata();
this.visibleColumns = model.getRegisterActiveColumns(FamilyPlanningConstants.CONFIGURATION.FAMILY_PLANNING_REGISTER);
Expand Down
Loading