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

Fix reference and integration issues #20

Merged
merged 28 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
adb262f
Fix reference errors and android Ids in switch-case statements
ekigamba Aug 3, 2020
cf06031
Fix errors in TaskRegisterFragment & fragment_task_register
ekigamba Aug 4, 2020
224538d
Fix errors in OfflineMapsActivity
ekigamba Aug 4, 2020
928bb21
Fix reference error in AvailableOfflineMapViewHolder
ekigamba Aug 4, 2020
aa49d1d
Fix reference error in DownloadedOfflineMapAdapter
ekigamba Aug 4, 2020
232e3ec
Fix reference error in AvailableOfflineMapsPresenter
ekigamba Aug 4, 2020
e891af3
Fix reference error in DownloadedOfflineMapsPresenter
ekigamba Aug 4, 2020
8581e43
Change ValidateUserLocationPresenter constructor scope to public
ekigamba Aug 4, 2020
4d7cc00
Fix init method for TaskingLibrary
ekigamba Aug 5, 2020
f478d65
Move configurable properties & behaviours to TaskingLibraryConfiguration
ekigamba Aug 6, 2020
39fa881
Fix commented out functionality
ekigamba Aug 7, 2020
40bfa8d
Fix interface methods with missing params
ekigamba Aug 10, 2020
41b5700
Fix colors, strings, layout & broken drawable references
ekigamba Aug 12, 2020
09c6264
Add tests for classes
ekigamba Aug 12, 2020
a69992f
Fix missing implementations
ekigamba Aug 13, 2020
d82c9e6
Fix tests in FilterTasksPresenterTest
ekigamba Aug 14, 2020
3e07eba
Fix tests in BaseInteractorTest
ekigamba Aug 14, 2020
3d6b174
Fix tests in DownloadedOfflineMapsInteractorTest by fixing RealmDatab…
ekigamba Aug 14, 2020
f8ec45f
Fix labels in TestRevealApplication to fix tests in FilterTasksPresenter
ekigamba Aug 14, 2020
9dbae9b
Fix 2 failing tests in TaskRegisterFragmentTest
ekigamba Aug 14, 2020
4ba7bc9
Fix 3 failing tests in TaskRegisterFragmentInteractorTest
ekigamba Aug 14, 2020
05ecc15
Fix 2 failing tests in TaskRegisterFragmentPresenterTest
ekigamba Aug 14, 2020
653ac0c
Fix ~13 failing tests in TaskRegisterViewHolderTest
ekigamba Aug 14, 2020
98a9825
Fix tasking sample module integration after changes
ekigamba Sep 4, 2020
3eda93c
Merge branch 'master' into fix-reference-and-integration-issues
githengi Nov 3, 2020
d96480a
Remove Task Utils
githengi Nov 3, 2020
e58be9c
Merge branch 'master' into fix-reference-and-integration-issues
githengi Nov 5, 2020
1a6fc75
Correct coveralls configuration
githengi Nov 5, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ build/
.externalNativeBuild
.cxx
**/build
**/jacoco.exec
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.0.1-SNAPSHOT
VERSION_NAME=0.0.3-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Tasking Library
Expand Down Expand Up @@ -29,4 +29,4 @@ org.gradle.jvmargs=-Xmx2048m
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.enableJetifier=true
33 changes: 28 additions & 5 deletions opensrp-tasking/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

dexOptions {
Expand All @@ -50,8 +55,8 @@ android {
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
coreLibraryDesugaringEnabled true
}

Expand Down Expand Up @@ -88,9 +93,11 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'

api 'org.smartregister:opensrp-client-core:1.13.4-SNAPSHOT'
api ('org.smartregister:opensrp-client-native-form:1.13.2-SNAPSHOT'){
api 'org.smartregister:opensrp-client-core:1.15.3-SNAPSHOT'
api ('org.smartregister:opensrp-client-native-form:1.13.2-SNAPSHOT') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-simprints'
exclude group: 'com.ibm.fhir', module: 'fhir-model'
exclude group: 'org.smartregister', module: 'opensrp-client-core'
}

Expand All @@ -100,7 +107,13 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

api 'io.ona.kujaku:library:0.8.3'
implementation 'org.smartregister:opensrp-client-reporting:0.0.6-RVL-SNAPSHOT@aar'

implementation ('io.ona.kujaku:library:0.8.3') {
transitive = true
exclude group: 'com.android.volley'
exclude group: 'stax', module: 'stax-api'
}
implementation 'xerces:xercesImpl:2.12.0'

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
Expand All @@ -116,6 +129,16 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

testImplementation 'org.mockito:mockito-inline:2.13.0'
testImplementation 'org.robolectric:robolectric:4.2'
testImplementation 'org.robolectric:shadows-multidex:4.2'
// PowerMock
def powerMockVersion = '2.0.0'
testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion"
testImplementation "org.powermock:powermock-classloading-xstream:$powerMockVersion"

}

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.smartregister.tasking;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.smartregister.CoreLibrary;
import org.smartregister.repository.AllSharedPreferences;
Expand All @@ -9,7 +12,11 @@
import org.smartregister.repository.StructureRepository;
import org.smartregister.repository.TaskNotesRepository;
import org.smartregister.repository.TaskRepository;
import org.smartregister.tasking.util.TaskingLibraryConfiguration;
import org.smartregister.util.AppExecutors;
import org.smartregister.view.activity.DrishtiApplication;

import io.ona.kujaku.data.realm.RealmDatabase;

/**
* Created by samuelgithengi on 6/10/20.
Expand All @@ -24,23 +31,27 @@ public class TaskingLibrary {
private EventClientRepository eventClientRepository;
private AllSharedPreferences allSharedPreferences;

private float locationBuffer;
private String digitalGlobeConnectId;
private String mapboxAccessToken;

private RealmDatabase realmDatabase;
private TaskingLibraryConfiguration taskingLibraryConfiguration;

public void init() {
instance = new TaskingLibrary();
public static void init(@NonNull TaskingLibraryConfiguration taskingLibraryConfiguration) {
instance = new TaskingLibrary(taskingLibraryConfiguration);
}

public static TaskingLibrary getInstance() {
return instance;
}

public TaskingLibrary(@NonNull TaskingLibraryConfiguration taskingLibraryConfiguration) {
this.taskingLibraryConfiguration = taskingLibraryConfiguration;
}

@NonNull
public AppExecutors getAppExecutors() {
if (appExecutors == null) {
appExecutors = new AppExecutors();
}

return appExecutors;
return taskingLibraryConfiguration.getAppExecutors();
}

@NonNull
Expand Down Expand Up @@ -86,8 +97,36 @@ public AllSharedPreferences getAllSharedPreferences() {

@NonNull
public Repository getRepository() {
//return CoreLibrary.getInstance().context().
return null;
return DrishtiApplication.getInstance().getRepository();
}

@Nullable
public String getDigitalGlobeConnectId() {
return digitalGlobeConnectId;
}

public void setDigitalGlobeConnectId(@Nullable String digitalGlobeConnectId) {
this.digitalGlobeConnectId = digitalGlobeConnectId;
}

@Nullable
public String getMapboxAccessToken() {
return mapboxAccessToken;
}

public void setMapboxAccessToken(String mapboxAccessToken) {
this.mapboxAccessToken = mapboxAccessToken;
}

public RealmDatabase getRealmDatabase(@NonNull Context context) {
if (realmDatabase == null) {
realmDatabase = RealmDatabase.init(context);
}

return realmDatabase;
}

public TaskingLibraryConfiguration getTaskingLibraryConfiguration() {
return taskingLibraryConfiguration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
import java.util.List;

import timber.log.Timber;
//import static org.smartregister.tasking.util.FamilyConstants.Intent.START_REGISTRATION;

/**
* Created by samuelgithengi on 3/11/19.
*/
public class TaskRegisterActivity extends BaseRegisterActivity implements BaseRegisterContract.View {
public abstract class TaskRegisterActivity extends BaseRegisterActivity implements BaseRegisterContract.View {

private RevealJsonFormUtils jsonFormUtils;

Expand Down Expand Up @@ -94,15 +93,14 @@ public TaskRegisterContract.Presenter getPresenter() {
return (TaskRegisterContract.Presenter) presenter;
}

public void startFamilyRegistration(BaseTaskDetails taskDetails) {
public abstract void startFamilyRegistration(BaseTaskDetails taskDetails);
/*Intent intent = new Intent(this, FamilyRegisterActivity.class);
intent.putExtra(START_REGISTRATION, true);
intent.putExtra(Properties.LOCATION_UUID, taskDetails.getStructureId());
intent.putExtra(Properties.TASK_IDENTIFIER, taskDetails.getTaskId());
intent.putExtra(Properties.TASK_BUSINESS_STATUS, taskDetails.getBusinessStatus());
intent.putExtra(Properties.TASK_STATUS, taskDetails.getTaskStatus());
startActivity(intent);*/
}

public void displayIndexCaseFragment(JSONObject indexCase) {
((CaseClassificationContract.View) caseClassificationFragment).displayIndexCase(indexCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
import com.mapbox.mapboxsdk.offline.OfflineRegion;
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus;

import org.smartregister.reveal.R;
import org.smartregister.reveal.model.OfflineMapModel;
import org.smartregister.reveal.util.Utils;
import org.smartregister.reveal.viewholder.DownloadedOfflineMapViewHolder;
import org.smartregister.tasking.R;
import org.smartregister.tasking.model.OfflineMapModel;
import org.smartregister.tasking.util.Utils;
import org.smartregister.tasking.viewholder.DownloadedOfflineMapViewHolder;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import org.apache.commons.lang3.StringUtils;
import org.smartregister.domain.Task;
import org.smartregister.tasking.R;
import org.smartregister.tasking.TaskingLibrary;
import org.smartregister.tasking.model.CardDetails;
import org.smartregister.tasking.model.TaskDetails;
import org.smartregister.tasking.util.CardDetailsUtil;
import org.smartregister.tasking.util.Constants.Intervention;
import org.smartregister.tasking.viewholder.TaskRegisterViewHolder;
import org.smartregister.tasking.model.TaskDetails;
import org.smartregister.tasking.viewholder.TaskRegisterViewHolder;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -47,7 +50,7 @@ public TaskRegisterViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int

@Override
public void onBindViewHolder(@NonNull TaskRegisterViewHolder viewHolder, int position) {
TaskDetails task = taskDetails.get(position);
/*TaskDetails task = taskDetails.get(position);
Float distance = task.getDistanceFromUser();
String name = task.getStructureName();
String action = null;
Expand All @@ -57,6 +60,28 @@ public void onBindViewHolder(@NonNull TaskRegisterViewHolder viewHolder, int pos
name = task.getFamilyName() != null ? task.getFamilyName() : task.getStructureName() != null ? task.getStructureName() : context.getString(R.string.unenumerated_structure);
}
action = context.getString(R.string.record_status);
} else if (Intervention.MOSQUITO_COLLECTION.equals(task.getTaskCode())) {
name = context.getString(R.string.mosquito_collection_point);
action = context.getString(R.string.record_mosquito_collection);
} else if (Intervention.LARVAL_DIPPING.equals(task.getTaskCode())) {
name = context.getString(R.string.larval_breeding_site);
action = context.getString(R.string.record_larvacide);
} else if (Intervention.BCC.equals(task.getTaskCode())) {
viewHolder.setIcon(R.drawable.ic_bcc);
name = context.getString(R.string.bcc);
action = context.getString(R.string.record_bcc);
hasIcon = true;
} else if (Intervention.CASE_CONFIRMATION.equals(task.getTaskCode()) && task.getTaskCount() == null) {
viewHolder.setIcon(R.drawable.ic_classification_details);
viewHolder.setItemViewListener(task, registerActionHandler);
name = context.getString(R.string.classification_details);
action = context.getString(R.string.view);
hasIcon = true;
} else if (Intervention.PAOT.equals(task.getTaskCode())) {
name = context.getString(R.string.card_view_paot);
if (task.getBusinessStatus() != null) {
action = CardDetailsUtil.getTranslatedBusinessStatus(task.getBusinessStatus()).replaceAll(" ", "\n");
}
} else {
name = NOT_ELIGIBLE.equals(task.getBusinessStatus()) ? context.getString(R.string.ineligible_location) : task.getFamilyName();
if (name == null) {
Expand Down Expand Up @@ -88,7 +113,9 @@ public void onBindViewHolder(@NonNull TaskRegisterViewHolder viewHolder, int pos
viewHolder.setHouseNumber(context.getString(R.string.numero_sign) + " " + task.getHouseNumber());
} else {
viewHolder.hideHouseNumber();
}
}*/

TaskingLibrary.getInstance().getTaskingLibraryConfiguration().onTaskRegisterBindViewHolder(context, viewHolder, registerActionHandler, taskDetails.get(position), position);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.mapbox.geojson.Feature;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.domain.Task;

Expand All @@ -28,5 +30,15 @@ void onFormSaved(@NonNull String structureId,
interface BaseInteractor {

void saveJsonForm(String json);

org.smartregister.domain.Event saveEvent(JSONObject jsonForm, String encounterType, String bindType) throws JSONException;

void saveRegisterStructureForm(JSONObject jsonForm);

void saveMemberForm(JSONObject jsonForm, String eventType, String intervention);

void saveCaseConfirmation(JSONObject jsonForm, String eventType);

void saveLocationInterventionForm(JSONObject jsonForm);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ public class AvailableOfflineMapsFragment extends BaseOfflineMapsFragment implem

private Button btnDownloadMap;

private String mapStyleAssetPath;

private static Gson gson = new GsonBuilder().setDateFormat(Constants.DateFormat.EVENT_DATE_FORMAT_Z)
.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter())
.registerTypeAdapter(LocationProperty.class, new PropertiesConverter()).create();


public static AvailableOfflineMapsFragment newInstance(Bundle bundle) {
public static AvailableOfflineMapsFragment newInstance(Bundle bundle, @NonNull String mapStyleAssetPath) {

AvailableOfflineMapsFragment fragment = new AvailableOfflineMapsFragment();
if (bundle != null) {
fragment.setArguments(bundle);
}

fragment.setPresenter(new AvailableOfflineMapsPresenter(fragment));
fragment.setMapStyleAssetPath(mapStyleAssetPath);

return fragment;
}
Expand All @@ -73,9 +76,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
btnDownloadMap = null;

new FileHttpServerTask(getContext()).execute();


new FileHttpServerTask(getContext(), getMapStyleAssetPath()).execute();
}

@Nullable
Expand Down Expand Up @@ -247,15 +248,20 @@ public void setPresenter(AvailableOfflineMapsPresenter presenter) {

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.offline_map_checkbox:
updateOperationalAreasToDownload(view);
break;
case R.id.download_map:
initiateMapDownload();
break;
default:
break;
int viewId = view.getId();
if (viewId == R.id.offline_map_checkbox) {
updateOperationalAreasToDownload(view);
} else if (viewId == R.id.download_map) {
initiateMapDownload();
}
}

@NonNull
public String getMapStyleAssetPath() {
return mapStyleAssetPath;
}

public void setMapStyleAssetPath(String mapStyleAssetPath) {
this.mapStyleAssetPath = mapStyleAssetPath;
}
}
Loading