Skip to content

Commit

Permalink
Merge pull request #49 from OpenSRP/issue20-implement-record-malaria-…
Browse files Browse the repository at this point in the history
…follow-up-visit

Issue20 implement record malaria follow up visit
  • Loading branch information
JafariUCC authored Jul 26, 2019
2 parents 1eb6833 + 8a1346f commit 9daa7ff
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 27 deletions.
12 changes: 10 additions & 2 deletions opensrp-chw-malaria/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ android {
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}

Expand Down Expand Up @@ -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']) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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;
import android.view.View;
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;
Expand Down Expand Up @@ -85,20 +87,22 @@ 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());

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();
}
Expand All @@ -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));
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="40dp"
android:shape="rectangle">
<corners android:radius="35dp" />
<solid android:color="@color/visit_status_over_due" /> <!-- the button color -->

</shape>
2 changes: 1 addition & 1 deletion opensrp-chw-malaria/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

<color name="other_member_profile_bg">#FAFAFA</color>
<color name="due_profile_blue">#218CC5</color>
<color name="visit_status_over_due">#D13F3F</color>

<color name="customAppThemeBlue">#218CC5</color>
<color name="black">#000000</color>
<color name="light_gray">#FAFAFA</color>
<color name="visit_status_ok">@android:color/holo_blue_light</color>

<color name="visit_status_over_due">#D13F3F</color>
</resources>
Original file line number Diff line number Diff line change
@@ -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);
}
}

This file was deleted.

0 comments on commit 9daa7ff

Please sign in to comment.