diff --git a/opensrp-chw-malaria/build.gradle b/opensrp-chw-malaria/build.gradle index f4d368c..3a5bd61 100644 --- a/opensrp-chw-malaria/build.gradle +++ b/opensrp-chw-malaria/build.gradle @@ -60,6 +60,7 @@ android { testOptions { unitTests { includeAndroidResources = true + returnDefaultValues = true } } @@ -110,10 +111,17 @@ dependencies { implementation 'id.zelory:compressor:1.0.4' testImplementation 'junit:junit:4.12' - testImplementation 'org.mockito:mockito-core:2.+' + testImplementation 'org.mockito:mockito-core:3.0.0' testImplementation 'org.robolectric:robolectric:3.8' - androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + + androidTestImplementation 'com.android.support:support-annotations:28.0.0' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test:rules:1.0.2' + + configurations.all { + resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' + } } task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { diff --git a/opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/activity/BaseMalariaProfileActivity.java b/opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/activity/BaseMalariaProfileActivity.java index 9ef9e27..35426eb 100644 --- a/opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/activity/BaseMalariaProfileActivity.java +++ b/opensrp-chw-malaria/src/main/java/org/smartregister/chw/malaria/activity/BaseMalariaProfileActivity.java @@ -1,11 +1,11 @@ package org.smartregister.chw.malaria.activity; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; -import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.support.v7.widget.Toolbar; @@ -13,6 +13,8 @@ import android.widget.TextView; import org.joda.time.DateTime; +import org.joda.time.Days; +import org.joda.time.LocalDateTime; import org.joda.time.Period; import org.smartregister.chw.malaria.contract.MalariaProfileContract; import org.smartregister.chw.malaria.domain.MemberObject; @@ -85,10 +87,12 @@ public void onClick(View v) { } + @SuppressLint("DefaultLocale") @Override public void setProfileViewWithData() { int age = new Period(new DateTime(MEMBER_OBJECT.getAge()), new DateTime()).getYears(); - textViewName.setText(String.format("%s %s %s, %d", MEMBER_OBJECT.getFirstName(), MEMBER_OBJECT.getMiddleName(), MEMBER_OBJECT.getLastName(), age)); + textViewName.setText(String.format("%s %s %s, %d", MEMBER_OBJECT.getFirstName(), + MEMBER_OBJECT.getMiddleName(), MEMBER_OBJECT.getLastName(), age)); textViewGender.setText(MEMBER_OBJECT.getGender()); textViewLocation.setText(MEMBER_OBJECT.getAddress()); textViewUniqueID.setText(MEMBER_OBJECT.getUniqueId()); @@ -96,9 +100,9 @@ public void setProfileViewWithData() { if (MEMBER_OBJECT.getMalariaTestDate() != null) { try { Date date = - new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).parse((MEMBER_OBJECT.getMalariaTestDate())); - int malaria_test_date_processed = new Period(new DateTime(date), new DateTime()).getDays(); - profilePresenter.recordMalariaButton(malaria_test_date_processed); + new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).parse(MEMBER_OBJECT.getMalariaTestDate()); + Days days = Days.daysBetween(new LocalDateTime(date), LocalDateTime.now()); + profilePresenter.recordMalariaButton(days.getDays()); } catch (ParseException e) { e.printStackTrace(); } @@ -113,12 +117,12 @@ public void hideView() { @Override public void setDueColor() { - textViewRecordMalaria.setBackgroundColor(ContextCompat.getColor(this, R.color.due_profile_blue)); + textViewRecordMalaria.setBackground(getResources().getDrawable(R.drawable.record_btn_selector)); } @Override public void setOverDueColor() { - textViewRecordMalaria.setBackgroundColor(ContextCompat.getColor(this, R.color.visit_status_over_due)); + textViewRecordMalaria.setBackground(getResources().getDrawable(R.drawable.record_btn_selector_overdue)); } diff --git a/opensrp-chw-malaria/src/main/res/drawable/record_btn_selector_overdue.xml b/opensrp-chw-malaria/src/main/res/drawable/record_btn_selector_overdue.xml new file mode 100644 index 0000000..283861c --- /dev/null +++ b/opensrp-chw-malaria/src/main/res/drawable/record_btn_selector_overdue.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/opensrp-chw-malaria/src/main/res/values/colors.xml b/opensrp-chw-malaria/src/main/res/values/colors.xml index 37f0001..1ab1efd 100644 --- a/opensrp-chw-malaria/src/main/res/values/colors.xml +++ b/opensrp-chw-malaria/src/main/res/values/colors.xml @@ -18,11 +18,11 @@ #FAFAFA #218CC5 + #D13F3F #218CC5 #000000 #FAFAFA @android:color/holo_blue_light - #D13F3F diff --git a/opensrp-chw-malaria/src/test/java/org/smartregister/activity/BaseMalariaProfileActivityTest.java b/opensrp-chw-malaria/src/test/java/org/smartregister/activity/BaseMalariaProfileActivityTest.java new file mode 100644 index 0000000..078c559 --- /dev/null +++ b/opensrp-chw-malaria/src/test/java/org/smartregister/activity/BaseMalariaProfileActivityTest.java @@ -0,0 +1,23 @@ +package org.smartregister.activity; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.smartregister.chw.malaria.activity.BaseMalariaProfileActivity; + +public class BaseMalariaProfileActivityTest { + @Mock + protected BaseMalariaProfileActivity baseMalariaProfileActivity; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void assertNotNull() { + Assert.assertNotNull(baseMalariaProfileActivity); + } +} diff --git a/opensrp-chw-malaria/src/test/java/org/smartregister/malaria/ExampleUnitTest.java b/opensrp-chw-malaria/src/test/java/org/smartregister/malaria/ExampleUnitTest.java deleted file mode 100644 index 7066f62..0000000 --- a/opensrp-chw-malaria/src/test/java/org/smartregister/malaria/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.smartregister.malaria; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file