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

Form configurability compatibility update #523

Open
wants to merge 6 commits into
base: develop
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android.debug.obsoleteApi=true

## PUBLISHING VARS
VERSION_NAME=2.0.0-SNAPSHOT
VERSION_NAME=2.0.1-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client ANC Library
Expand Down
14 changes: 2 additions & 12 deletions opensrp-anc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,8 @@ dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation('org.smartregister:opensrp-client-native-form:1.7.28-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'
exclude group: 'com.android.support', module: 'support-media-compat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
}
implementation('org.smartregister:opensrp-client-core:1.9.4-SNAPSHOT@aar') {

implementation('org.smartregister:opensrp-client-core:1.11.3-doc-config-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import android.widget.TextView;

import com.google.android.gms.vision.barcode.Barcode;
import com.vijay.jsonwizard.activities.JsonFormActivity;

import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
Expand Down Expand Up @@ -50,6 +49,7 @@
import org.smartregister.helper.BottomNavigationHelper;
import org.smartregister.listener.BottomNavigationListener;
import org.smartregister.view.activity.BaseRegisterActivity;
import org.smartregister.view.activity.DynamicJsonFormActivity;
import org.smartregister.view.fragment.BaseRegisterFragment;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -193,7 +193,7 @@ public void startFormActivity(String formName, String entityId, String metaData)

@Override
public void startFormActivity(JSONObject form) {
Intent intent = new Intent(this, JsonFormActivity.class);
Intent intent = new Intent(this, DynamicJsonFormActivity.class);
intent.putExtra(ConstantsUtils.JsonFormExtraUtils.JSON, form.toString());
startActivityForResult(intent, ANCJsonFormUtils.REQUEST_CODE_GET_JSON);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;
import com.vijay.jsonwizard.fragments.JsonWizardFormFragment;
Expand All @@ -22,8 +21,9 @@
import org.smartregister.anc.library.fragment.ContactWizardJsonFormFragment;
import org.smartregister.anc.library.helper.AncRulesEngineFactory;
import org.smartregister.anc.library.task.BackPressedPersistPartialTask;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.ANCFormUtils;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.view.activity.DynamicJsonFormActivity;

import java.util.HashMap;
import java.util.List;
Expand All @@ -34,7 +34,7 @@
* Created by ndegwamartin on 30/06/2018.
*/

public class ContactJsonFormActivity extends JsonFormActivity {
public class ContactJsonFormActivity extends DynamicJsonFormActivity {
protected AncRulesEngineFactory rulesEngineFactory = null;
private ProgressDialog progressDialog;
private String formName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import android.os.Bundle;

import com.vijay.jsonwizard.activities.JsonFormActivity;

import org.smartregister.anc.library.R;
import org.smartregister.view.activity.DynamicJsonFormActivity;

public class EditJsonFormActivity extends JsonFormActivity {
public class EditJsonFormActivity extends DynamicJsonFormActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.widget.TextView;
import android.widget.Toast;

import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.fragments.JsonWizardFormFragment;
import com.vijay.jsonwizard.interactors.JsonFormInteractor;

Expand All @@ -30,11 +29,12 @@
import org.smartregister.anc.library.domain.Contact;
import org.smartregister.anc.library.presenter.ContactWizardJsonFormFragmentPresenter;
import org.smartregister.anc.library.task.ANCNextProgressDialogTask;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.ANCFormUtils;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.DBConstantsUtils;
import org.smartregister.anc.library.util.Utils;
import org.smartregister.anc.library.viewstate.ContactJsonFormFragmentViewState;
import org.smartregister.view.activity.DynamicJsonFormActivity;

import java.util.HashMap;

Expand Down Expand Up @@ -88,7 +88,7 @@ private Contact getContact() {
private void quickCheckClose() {
AlertDialog dialog = new AlertDialog.Builder(getContext(), R.style.AppThemeAlertDialog)
.setTitle(getJsonApi().getConfirmCloseTitle()).setMessage(getJsonApi().getConfirmCloseMessage())
.setNegativeButton(R.string.yes, (dialog1, which) -> ((ContactJsonFormActivity) getActivity()).finishInitialQuickCheck()).setPositiveButton(R.string.no, (dialog12, which) -> Timber.d("No button on dialog in %s", JsonFormActivity.class.getCanonicalName())).create();
.setNegativeButton(R.string.yes, (dialog1, which) -> ((ContactJsonFormActivity) getActivity()).finishInitialQuickCheck()).setPositiveButton(R.string.no, (dialog12, which) -> Timber.d("No button on dialog in %s", DynamicJsonFormActivity.class.getCanonicalName())).create();

dialog.show();
}
Expand Down Expand Up @@ -327,15 +327,15 @@ private void setQuickCheckButtonsInvisible(boolean none, boolean other, LinearLa
}
}

public void setJsonFormFragment(ContactWizardJsonFormFragment formFragment) {
this.formFragment = formFragment;
}

@Override
public ContactWizardJsonFormFragment getJsonFormFragment() {
return formFragment;
}

public void setJsonFormFragment(ContactWizardJsonFormFragment formFragment) {
this.formFragment = formFragment;
}

private class BottomNavigationListener implements View.OnClickListener {
@Override
public void onClick(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v4.content.Loader;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -29,6 +30,8 @@
import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter;
import org.smartregister.cursoradapter.SmartRegisterQueryBuilder;
import org.smartregister.domain.FetchStatus;
import org.smartregister.job.DocumentConfigurationServiceJob;
import org.smartregister.job.SyncSettingsServiceJob;
import org.smartregister.receiver.SyncStatusBroadcastReceiver;
import org.smartregister.view.activity.BaseRegisterActivity;
import org.smartregister.view.fragment.BaseRegisterFragment;
Expand Down Expand Up @@ -109,6 +112,13 @@ public void setupViews(View view) {
if (attentionFlag != null) {
attentionFlag.setOnClickListener(registerActionHandler);
}
ImageView imageView = view.findViewById(R.id.sync_refresh);
if (imageView != null) {
imageView.setOnClickListener(v -> {
SyncSettingsServiceJob.scheduleJobImmediately(SyncSettingsServiceJob.TAG);
DocumentConfigurationServiceJob.scheduleJobImmediately(DocumentConfigurationServiceJob.TAG);
});
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.widget.Button;
import android.widget.TextView;

import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;

Expand All @@ -26,11 +25,12 @@
import org.smartregister.anc.library.domain.ButtonAlertStatus;
import org.smartregister.anc.library.model.Task;
import org.smartregister.anc.library.presenter.ProfileFragmentPresenter;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.ANCFormUtils;
import org.smartregister.anc.library.util.DBConstantsUtils;
import org.smartregister.anc.library.util.ANCJsonFormUtils;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.DBConstantsUtils;
import org.smartregister.anc.library.util.Utils;
import org.smartregister.view.activity.DynamicJsonFormActivity;
import org.smartregister.view.fragment.BaseProfileFragment;

import java.util.ArrayList;
Expand Down Expand Up @@ -165,7 +165,7 @@ private void toggleViews(List<Task> taskList) {
public void startTaskForm(JSONObject jsonForm, Task task) {
setCurrentTask(task);

Intent intent = new Intent(getActivity(), JsonFormActivity.class);
Intent intent = new Intent(getActivity(), DynamicJsonFormActivity.class);
intent.putExtra(ConstantsUtils.JsonFormExtraUtils.JSON, String.valueOf(jsonForm));
intent.putExtra(ConstantsUtils.IntentKeyUtils.BASE_ENTITY_ID, baseEntityId);
intent.putExtra(ConstantsUtils.IntentKeyUtils.CLIENT_MAP, clientDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Set<View> getRegisterActiveColumns(String viewConfigurationIdentifier) {
@Override
public String countSelect(String tableName, String mainCondition) {
SmartRegisterQueryBuilder countQueryBuilder = new SmartRegisterQueryBuilder();
countQueryBuilder.SelectInitiateMainTableCounts(tableName);
countQueryBuilder.selectInitiateMainTableCounts(tableName);
return countQueryBuilder.mainCondition(mainCondition);
}

Expand All @@ -73,7 +73,7 @@ public String mainSelect(String tableName, String mainCondition) {
getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.YELLOW_FLAG_COUNT, getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.CONTACT_STATUS,
getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.NEXT_CONTACT, getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.NEXT_CONTACT_DATE,
getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.LAST_CONTACT_RECORD_DATE};
queryBuilder.SelectInitiateMainTable(tableName, columns);
queryBuilder.selectInitiateMainTable(tableName, columns);
queryBuilder.customJoin(" join " + getRegisterQueryProvider().getDetailsTable()
+ " on " + getRegisterQueryProvider().getDemographicTable() + "." + DBConstantsUtils.KeyUtils.BASE_ENTITY_ID + "= " + getRegisterQueryProvider().getDetailsTable() + "." + DBConstantsUtils.KeyUtils.BASE_ENTITY_ID);
return queryBuilder.mainCondition(mainCondition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getCountExecuteQuery(String mainCondition, String filters) {

public String mainRegisterQuery() {
SmartRegisterQueryBuilder queryBuilder = new SmartRegisterQueryBuilder();
queryBuilder.SelectInitiateMainTable(getDemographicTable(), mainColumns());
queryBuilder.selectInitiateMainTable(getDemographicTable(), mainColumns());
queryBuilder.customJoin(" join " + getDetailsTable()
+ " on " + getDemographicTable() + "." + DBConstantsUtils.KeyUtils.BASE_ENTITY_ID + "= " + getDetailsTable() + "." + DBConstantsUtils.KeyUtils.BASE_ENTITY_ID + " ");
return queryBuilder.getSelectquery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.widget.TextView;

import com.google.common.reflect.TypeToken;
import com.vijay.jsonwizard.activities.JsonFormActivity;
import com.vijay.jsonwizard.constants.JsonFormConstants;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -50,6 +49,7 @@
import org.smartregister.util.ImageUtils;
import org.smartregister.view.LocationPickerView;
import org.smartregister.view.activity.DrishtiApplication;
import org.smartregister.view.activity.DynamicJsonFormActivity;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -617,7 +617,7 @@ public static Triple<Boolean, Event, Event> saveRemovedFromANCRegister(AllShared

public static void launchANCCloseForm(Activity activity) {
try {
Intent intent = new Intent(activity, JsonFormActivity.class);
Intent intent = new Intent(activity, DynamicJsonFormActivity.class);
JSONObject form = FormUtils.getInstance(activity).getFormJson(ConstantsUtils.JsonFormUtils.ANC_CLOSE);
if (form != null) {
form.put(ConstantsUtils.JsonFormKeyUtils.ENTITY_ID,
Expand All @@ -632,7 +632,7 @@ public static void launchANCCloseForm(Activity activity) {

public static void launchSiteCharacteristicsForm(Activity activity) {
try {
Intent intent = new Intent(activity, JsonFormActivity.class);
Intent intent = new Intent(activity, DynamicJsonFormActivity.class);
JSONObject form = FormUtils.getInstance(activity).getFormJson(ConstantsUtils.JsonFormUtils.ANC_SITE_CHARACTERISTICS);
if (form != null) {
form.put(ConstantsUtils.JsonFormKeyUtils.ENTITY_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testInitializeQueries() {

private String countSelect(String tableName, String mainCondition) {
SmartRegisterQueryBuilder countQueryBuilder = new SmartRegisterQueryBuilder();
countQueryBuilder.SelectInitiateMainTableCounts(tableName);
countQueryBuilder.selectInitiateMainTableCounts(tableName);
return countQueryBuilder.mainCondition(mainCondition);
}

Expand All @@ -104,7 +104,7 @@ private String mainSelect(String tableName, String mainCondition) {
tableName + "." + DBConstantsUtils.KeyUtils.ANC_ID,
tableName + "." + DBConstantsUtils.KeyUtils.DOB,
tableName + "." + DBConstantsUtils.KeyUtils.DATE_REMOVED};
queryBUilder.SelectInitiateMainTable(tableName, columns);
queryBUilder.selectInitiateMainTable(tableName, columns);
return queryBUilder.mainCondition(mainCondition);
}

Expand Down
14 changes: 2 additions & 12 deletions reference-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,8 @@ tasks.withType(Test) {
dependencies {
def powerMockVersion = '2.0.4'
implementation project(":opensrp-anc")
implementation('org.smartregister:opensrp-client-native-form:1.7.28-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'
exclude group: 'com.android.support', module: 'support-media-compat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
}
implementation('org.smartregister:opensrp-client-core:1.9.4-SNAPSHOT@aar') {

implementation('org.smartregister:opensrp-client-core:1.11.3-doc-config-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
Expand Down
3 changes: 2 additions & 1 deletion reference-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</intent-filter>
</activity>
<activity
android:name="com.vijay.jsonwizard.activities.JsonFormActivity"
android:name="org.smartregister.view.activity.DynamicJsonFormActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AncAppTheme.NoActionBar"
Expand Down Expand Up @@ -138,6 +138,7 @@
<service android:name="org.smartregister.sync.intent.ValidateIntentService" />
<service android:name="org.smartregister.sync.intent.ExtendedSyncIntentService" />
<service android:name="org.smartregister.sync.intent.SettingsSyncIntentService" />
<service android:name="org.smartregister.sync.intent.DocumentConfigurationIntentService" />

<uses-library
android:name="org.apache.http.legacy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.smartregister.anc.BuildConfig;
import org.smartregister.anc.library.AncLibrary;
import org.smartregister.domain.LoginResponse;
import org.smartregister.job.DocumentConfigurationServiceJob;
import org.smartregister.job.ImageUploadServiceJob;
import org.smartregister.job.PullUniqueIdsServiceJob;
import org.smartregister.job.SyncServiceJob;
Expand Down Expand Up @@ -33,16 +34,19 @@ protected void scheduleJobsPeriodically() {
SyncSettingsServiceJob
.scheduleJob(SyncSettingsServiceJob.TAG, TimeUnit.MINUTES.toMillis(BuildConfig.CLIENT_SETTINGS_SYNC_MINUTES),
getFlexValue(BuildConfig.CLIENT_SETTINGS_SYNC_MINUTES));
DocumentConfigurationServiceJob
.scheduleJob(DocumentConfigurationServiceJob.TAG, TimeUnit.MINUTES.toMillis(BuildConfig.CLIENT_SETTINGS_SYNC_MINUTES),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the job to run immediately after login?? I'll see if I can direct you to the exact location

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekigamba In the LoginInteractor#scheduleJobsImmediately() ? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allan-allay Yea, I think that's it. Also add it to run when the sync button on the register is clicked

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Let me implement the changes

getFlexValue((int) BuildConfig.CLIENT_SETTINGS_SYNC_MINUTES));
}

@Override
protected void scheduleJobsImmediately() {
super.scheduleJobsImmediately();
DocumentConfigurationServiceJob.scheduleJobImmediately(DocumentConfigurationServiceJob.TAG);
}

@Override
protected void processServerSettings(LoginResponse loginResponse) {

super.processServerSettings(loginResponse);
AncLibrary.getInstance().populateGlobalSettings();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.evernote.android.job.Job;
import com.evernote.android.job.JobCreator;

import org.smartregister.job.DocumentConfigurationServiceJob;
import org.smartregister.job.ExtendedSyncServiceJob;
import org.smartregister.job.ImageUploadServiceJob;
import org.smartregister.job.PullUniqueIdsServiceJob;
import org.smartregister.job.SyncServiceJob;
import org.smartregister.job.SyncSettingsServiceJob;
import org.smartregister.job.ValidateSyncDataServiceJob;
import org.smartregister.sync.intent.DocumentConfigurationIntentService;
import org.smartregister.sync.intent.SyncIntentService;

import timber.log.Timber;
Expand All @@ -38,6 +40,8 @@ public Job create(@NonNull String tag) {
return new ViewConfigurationsServiceJob();
case SyncSettingsServiceJob.TAG:
return new SyncSettingsServiceJob();
case DocumentConfigurationServiceJob.TAG:
return new DocumentConfigurationServiceJob(DocumentConfigurationIntentService.class);
default:
Timber.d("Looks like you tried to create a job " + tag + " that is not declared in the Anc Job Creator");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.smartregister.anc.library.repository.PreviousContactRepository;
import org.smartregister.anc.library.repository.ContactTasksRepository;
import org.smartregister.configurableviews.repository.ConfigurableViewsRepository;
import org.smartregister.repository.ClientFormRepository;
import org.smartregister.repository.EventClientRepository;
import org.smartregister.repository.ManifestRepository;
import org.smartregister.repository.Repository;
import org.smartregister.repository.SettingsRepository;
import org.smartregister.repository.UniqueIdRepository;
Expand Down Expand Up @@ -47,6 +49,8 @@ public void onCreate(SQLiteDatabase database) {
PartialContactRepository.createTable(database);
PreviousContactRepository.createTable(database);
ContactTasksRepository.createTable(database);
ClientFormRepository.createTable(database);
ManifestRepository.createTable(database);
}

@Override
Expand Down
Loading