diff --git a/gradle.properties b/gradle.properties index a5236ec..4e924a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.1.16-SNAPSHOT +VERSION_NAME=1.1.17-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Growth Monitoring Application diff --git a/opensrp-growth-monitoring/build.gradle b/opensrp-growth-monitoring/build.gradle index 105e9a5..1a89af4 100644 --- a/opensrp-growth-monitoring/build.gradle +++ b/opensrp-growth-monitoring/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { classpath "com.android.tools.build:gradle:$androidToolsBuildGradle" - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.3' } } @@ -16,7 +16,7 @@ apply plugin: 'jacoco' apply plugin: 'com.github.kt3k.coveralls' jacoco { - toolVersion = "0.8.0" + toolVersion = "0.8.5" } android { @@ -87,10 +87,16 @@ allprojects { } dependencies { - implementation('org.smartregister:opensrp-client-core:1.8.16-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-core:1.8.25-SNAPSHOT@aar') { transitive = true exclude group: 'com.github.bmelnychuk', module: 'atv' } + + implementation('org.smartregister:opensrp-client-native-form:1.7.15-SNAPSHOT@aar') { + transitive = true + exclude group: 'com.android.support', module: 'recyclerview-v7' + } + implementation 'com.android.support:design:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0' diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/EditGrowthDialogFragment.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/EditGrowthDialogFragment.java index 4811536..c11188f 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/EditGrowthDialogFragment.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/EditGrowthDialogFragment.java @@ -19,6 +19,8 @@ import android.widget.TextView; import android.widget.Toast; +import com.vijay.jsonwizard.utils.NativeFormsProperties; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.joda.time.DateTime; @@ -61,15 +63,11 @@ public class EditGrowthDialogFragment extends DialogFragment { private Button cancel; private LinearLayout heightEntryLayout; private CustomFontTextView recordHeight; - private boolean hasProperty; - private boolean monitorGrowth = false; + private final boolean monitorGrowth = GrowthMonitoringLibrary.getInstance().getAppProperties().isTrue(AppProperties.KEY.MONITOR_GROWTH); + private boolean isNumericDatePicker = GrowthMonitoringLibrary.getInstance().getAppProperties().isTrue(NativeFormsProperties.KEY.WIDGET_DATEPICKER_IS_NUMERIC); private EditGrowthDialogFragment(Date dateOfBirth, WeightWrapper weightWrapper, HeightWrapper heightWrapper) { HeightWrapper heightWrapperTemp; - hasProperty = GrowthMonitoringLibrary.getInstance().getAppProperties().hasProperty(AppProperties.KEY.MONITOR_GROWTH); - if (hasProperty) { - monitorGrowth = GrowthMonitoringLibrary.getInstance().getAppProperties().getPropertyBoolean(AppProperties.KEY.MONITOR_GROWTH); - } this.dateOfBirth = dateOfBirth; if (weightWrapper == null) { @@ -79,7 +77,7 @@ private EditGrowthDialogFragment(Date dateOfBirth, WeightWrapper weightWrapper, } heightWrapperTemp = null; - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { if (heightWrapper == null) { heightWrapperTemp = new HeightWrapper(); } else { @@ -142,7 +140,7 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe ViewGroup dialogView = setUpViews(inflater, container); - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { recordHeight.setVisibility(View.VISIBLE); heightEntryLayout.setVisibility(View.VISIBLE); @@ -215,7 +213,7 @@ private ViewGroup setUpViews(LayoutInflater inflater, ViewGroup container) { editWeight = dialogView.findViewById(R.id.edit_weight); editHeight = dialogView.findViewById(R.id.edit_height); - earlierDatePicker = dialogView.findViewById(R.id.earlier_date_picker); + earlierDatePicker = dialogView.findViewById(isNumericDatePicker ? R.id.earlier_date_picker_numeric :R.id.earlier_date_picker); nameView = dialogView.findViewById(R.id.child_name); numberView = dialogView.findViewById(R.id.child_zeir_id); ageView = dialogView.findViewById(R.id.child_age); @@ -251,7 +249,7 @@ public void onClick(View view) { return; } String heightString = null; - if (hasProperty & monitorGrowth) { + if (monitorGrowth) { heightString = editHeight.getText().toString(); } dismiss(); @@ -271,13 +269,13 @@ public void onClick(View view) { DateTime updateTime = new DateTime(calendar.getTime()); if (currentGrowthDate != null && !org.apache.commons.lang3.time.DateUtils.isSameDay(calendar.getTime(), currentGrowthDate.toDate())) { weightWrapper.setUpdatedWeightDate(updateTime, false); - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { heightWrapper.setUpdatedHeightDate(updateTime, false); } dateChanged = true; } - if (hasProperty & monitorGrowth && heightString != null && !heightString.isEmpty()) { + if (monitorGrowth && heightString != null && !heightString.isEmpty()) { updateHeightWrapperForBlankHeightEdit(updateTime); } } diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/GrowthDialogFragment.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/GrowthDialogFragment.java index 56cca36..3750484 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/GrowthDialogFragment.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/GrowthDialogFragment.java @@ -4,6 +4,7 @@ import android.graphics.Point; import android.os.Bundle; import android.os.Handler; +import android.support.annotation.VisibleForTesting; import android.support.design.widget.TabLayout; import android.support.v4.app.DialogFragment; import android.support.v4.view.ViewPager; @@ -84,6 +85,7 @@ public void setPersonDetails(CommonPersonObjectClient personDetails) { this.personDetails = personDetails; } + @VisibleForTesting protected void sortWeights() { HashMap weightHashMap = new HashMap<>(); for (Weight curWeight : getWeights()) { @@ -111,6 +113,7 @@ protected void sortWeights() { setWeights(weightList); } + @VisibleForTesting protected void sortHeights() { HashMap heightHashMap = new HashMap<>(); for (Height curHeight : getHeights()) { diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/RecordGrowthDialogFragment.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/RecordGrowthDialogFragment.java index 21b7538..233c7f7 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/RecordGrowthDialogFragment.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/fragment/RecordGrowthDialogFragment.java @@ -20,6 +20,8 @@ import android.widget.TextView; import android.widget.Toast; +import com.vijay.jsonwizard.utils.NativeFormsProperties; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.joda.time.DateTime; @@ -62,16 +64,10 @@ public class RecordGrowthDialogFragment extends DialogFragment { private Button set; private LinearLayout heightEntryLayout; private CustomFontTextView recordHeight; - private static Boolean hasProperty; - private static Boolean monitorGrowth = false; - - public static RecordGrowthDialogFragment newInstance(Date dateOfBirth, WeightWrapper weightWrapper, - HeightWrapper heightWrapper) { + private static final boolean monitorGrowth = GrowthMonitoringLibrary.getInstance().getAppProperties().isTrue(AppProperties.KEY.MONITOR_GROWTH); + private static final boolean isNumericDatePicker = GrowthMonitoringLibrary.getInstance().getAppProperties().isTrue(NativeFormsProperties.KEY.WIDGET_DATEPICKER_IS_NUMERIC); - hasProperty = GrowthMonitoringLibrary.getInstance().getAppProperties().hasProperty(AppProperties.KEY.MONITOR_GROWTH); - if (hasProperty) { - monitorGrowth = GrowthMonitoringLibrary.getInstance().getAppProperties().getPropertyBoolean(AppProperties.KEY.MONITOR_GROWTH); - } + public static RecordGrowthDialogFragment newInstance(Date dateOfBirth, WeightWrapper weightWrapper, HeightWrapper heightWrapper) { WeightWrapper weightToSend; if (weightWrapper == null) { @@ -81,7 +77,7 @@ public static RecordGrowthDialogFragment newInstance(Date dateOfBirth, WeightWra } HeightWrapper heightToSend = null; - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { if (heightWrapper == null) { heightToSend = new HeightWrapper(); } else { @@ -94,7 +90,7 @@ public static RecordGrowthDialogFragment newInstance(Date dateOfBirth, WeightWra Bundle args = new Bundle(); args.putSerializable(DATE_OF_BIRTH_TAG, dateOfBirth); args.putSerializable(WEIGHT_WRAPPER_TAG, weightToSend); - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { args.putSerializable(HEIGHT_WRAPPER_TAG, heightToSend); } recordGrowthDialogFragment.setArguments(args); @@ -185,7 +181,7 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe } private void setHeight() { - if (hasProperty && monitorGrowth && heightWrapper.getHeight() != null) { + if (monitorGrowth && heightWrapper.getHeight() != null) { editHeight.setText(heightWrapper.getHeight().toString()); editHeight.setSelection(editHeight.getText().length()); } @@ -199,7 +195,7 @@ private void setWeight() { } private void setVisibility() { - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { recordHeight.setVisibility(View.VISIBLE); heightEntryLayout.setVisibility(View.VISIBLE); } @@ -208,7 +204,7 @@ private void setVisibility() { private boolean getBundle() { Bundle bundle = getArguments(); if (getWeightBundle(bundle)) return true; - if (hasProperty && monitorGrowth && getHeightBundle(bundle)) { + if (monitorGrowth && getHeightBundle(bundle)) { return true; } @@ -223,7 +219,7 @@ private ViewGroup setUpViews(LayoutInflater inflater, ViewGroup container) { getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); editWeight = dialogView.findViewById(R.id.edit_weight); - earlierDatePicker = dialogView.findViewById(R.id.earlier_date_picker); + earlierDatePicker = dialogView.findViewById(isNumericDatePicker ? R.id.earlier_date_picker_numeric : R.id.earlier_date_picker); nameView = dialogView.findViewById(R.id.child_name); numberView = dialogView.findViewById(R.id.child_zeir_id); ageView = dialogView.findViewById(R.id.child_age); @@ -287,14 +283,14 @@ private void saveGrowthRecord() { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); weightWrapper.setUpdatedWeightDate(new DateTime(calendar.getTime()), false); - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { heightWrapper.setUpdatedHeightDate(new DateTime(calendar.getTime()), false); } Float weight = Float.valueOf(weightString); weightWrapper.setWeight(weight); - if (hasProperty && monitorGrowth) { + if (monitorGrowth) { String heightString = editHeight.getText().toString(); if (!heightString.isEmpty()) { Float height = Float.valueOf(heightString); diff --git a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/AppProperties.java b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/AppProperties.java index 32a5d3f..653f91b 100644 --- a/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/AppProperties.java +++ b/opensrp-growth-monitoring/src/main/java/org/smartregister/growthmonitoring/util/AppProperties.java @@ -1,19 +1,11 @@ package org.smartregister.growthmonitoring.util; -import java.util.Properties; +import com.vijay.jsonwizard.utils.NativeFormsProperties; /** * Created by ndegwamartin on 2019-06-07. */ -public class AppProperties extends Properties { - - public Boolean getPropertyBoolean(String key) { - return Boolean.valueOf(getProperty(key)); - } - - public Boolean hasProperty(String key) { - return getProperty(key) != null; - } +public class AppProperties extends NativeFormsProperties { public static class KEY { public static final String MONITOR_GROWTH = "monitor.height"; diff --git a/opensrp-growth-monitoring/src/main/res/layout/edit_growth_dialog_view.xml b/opensrp-growth-monitoring/src/main/res/layout/edit_growth_dialog_view.xml index 9b54ad1..406769d 100644 --- a/opensrp-growth-monitoring/src/main/res/layout/edit_growth_dialog_view.xml +++ b/opensrp-growth-monitoring/src/main/res/layout/edit_growth_dialog_view.xml @@ -219,7 +219,18 @@ android:calendarViewShown="false" android:descendantFocusability="blocksDescendants" android:focusable="true" - android:focusableInTouchMode="true" /> + android:focusableInTouchMode="true" + android:visibility="gone" /> + +