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

malaria profile with more than one visit #14

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.0.12-SNAPSHOT
VERSION_NAME=1.0.16-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library
Expand Down
4 changes: 2 additions & 2 deletions opensrp-chw-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ dependencies {
exclude group: 'org.smartregister', module: 'opensrp-client-immunization'
}

api('org.smartregister:opensrp-client-chw-malaria:1.0.12-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-chw-malaria:1.0.14-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand Down Expand Up @@ -203,4 +203,4 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
apply from: '../maven.gradle'
apply from: '../maven.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package org.smartregister.chw.core.custom_views;

import android.app.Activity;
import android.content.Context;
import android.support.design.widget.FloatingActionButton;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import org.smartregister.chw.core.R;
import org.smartregister.chw.core.listener.OnClickFloatingMenu;
import org.smartregister.chw.malaria.custom_views.BaseMalariaFloatingMenu;
import org.smartregister.chw.malaria.fragment.BaseMalariaCallDialogFragment;

import static org.smartregister.chw.core.utils.Utils.redrawWithOption;

public abstract class CoreMalariaFloatingMenu extends BaseMalariaFloatingMenu {
public FloatingActionButton fab;
private Animation fabOpen;
private Animation fabClose;
private Animation rotateForward;
private Animation rotateBack;
private View callLayout;
private View referLayout;
private RelativeLayout activityMain;
private boolean isFabMenuOpen = false;
private LinearLayout menuBar;
private OnClickFloatingMenu onClickFloatingMenu;

public CoreMalariaFloatingMenu(Context context, String clientName, String clientPhone,
String clientFamilyHeadName, String clientFamilyHeadPhone) {
super(context, clientName, clientPhone, clientFamilyHeadName, clientFamilyHeadPhone);
}

public CoreMalariaFloatingMenu(Context context, AttributeSet attrs) {
super(context, attrs);
}

public void setFloatMenuClickListener(OnClickFloatingMenu onClickFloatingMenu) {
this.onClickFloatingMenu = onClickFloatingMenu;
}

@Override
protected void initUi() {
inflate(getContext(), R.layout.view_malaria_floating_menu, this);

fabOpen = AnimationUtils.loadAnimation(getContext(), R.anim.fab_open);
fabClose = AnimationUtils.loadAnimation(getContext(), R.anim.fab_close);
rotateForward = AnimationUtils.loadAnimation(getContext(), R.anim.rotate_forward);
rotateBack = AnimationUtils.loadAnimation(getContext(), R.anim.rotate_back);

activityMain = findViewById(R.id.activity_main);
menuBar = findViewById(R.id.menu_bar);

fab = findViewById(R.id.malaria_fab);
fab.setOnClickListener(this);

callLayout = findViewById(R.id.call_layout);
callLayout.setOnClickListener(this);
callLayout.setClickable(false);

referLayout = findViewById(R.id.refer_to_facility_layout);
referLayout.setOnClickListener(this);
referLayout.setClickable(false);

menuBar.setVisibility(GONE);

}

@Override
public void onClick(View view) {
onClickFloatingMenu.onClickMenu(view.getId());
}

public void animateFAB() {
if (menuBar.getVisibility() == GONE) {
menuBar.setVisibility(VISIBLE);
}

if (isFabMenuOpen) {
activityMain.setBackgroundResource(R.color.transparent);
fab.startAnimation(rotateBack);
fab.setImageResource(R.drawable.ic_edit_white);

callLayout.startAnimation(fabClose);
callLayout.setClickable(false);

referLayout.startAnimation(fabClose);
referLayout.setClickable(false);
isFabMenuOpen = false;
} else {
activityMain.setBackgroundResource(R.color.grey_tranparent_50);
fab.startAnimation(rotateForward);
fab.setImageResource(R.drawable.ic_input_add);

callLayout.startAnimation(fabOpen);
callLayout.setClickable(true);

referLayout.startAnimation(fabOpen);
referLayout.setClickable(true);
isFabMenuOpen = true;
}
}


public void launchCallWidget() {
BaseMalariaCallDialogFragment.launchDialog((Activity) this.getContext(), getClientName(),
getPhoneNumber(), getFamilyHeadName(), getFamilyHeadPhone());
}

public void redraw(boolean hasPhoneNumber) {
redrawWithOption(this, hasPhoneNumber);
}

public View getCallLayout() {
return callLayout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.smartregister.chw.core.contract.FamilyCallDialogContract;
import org.smartregister.chw.core.custom_views.CoreAncFloatingMenu;
import org.smartregister.chw.core.custom_views.CoreFamilyMemberFloatingMenu;
import org.smartregister.chw.core.custom_views.CoreMalariaFloatingMenu;
import org.smartregister.chw.core.fragment.CopyToClipboardDialog;
import org.smartregister.clientandeventmodel.Obs;
import org.smartregister.commonregistry.CommonPersonObject;
Expand Down Expand Up @@ -478,6 +479,7 @@ public static void redrawWithOption(LinearLayout menu, boolean has_phone) {
private static void setCallLayoutListener(boolean has_phone, LinearLayout menu) {
CoreFamilyMemberFloatingMenu memberFloatingMenu;
CoreAncFloatingMenu ancFloatingMenu;
CoreMalariaFloatingMenu coreMalariaFloatingMenu;
if (has_phone && menu instanceof CoreFamilyMemberFloatingMenu) {
memberFloatingMenu = (CoreFamilyMemberFloatingMenu) menu;
memberFloatingMenu.getCallLayout().setOnClickListener(memberFloatingMenu);
Expand All @@ -490,6 +492,12 @@ private static void setCallLayoutListener(boolean has_phone, LinearLayout menu)
} else if (!has_phone && menu instanceof CoreFamilyMemberFloatingMenu) {
memberFloatingMenu = (CoreFamilyMemberFloatingMenu) menu;
memberFloatingMenu.getCallLayout().setOnClickListener(null);
} else if (has_phone && menu instanceof CoreMalariaFloatingMenu) {
coreMalariaFloatingMenu = (CoreMalariaFloatingMenu) menu;
coreMalariaFloatingMenu.getCallLayout().setOnClickListener(coreMalariaFloatingMenu);
} else if (!has_phone && menu instanceof CoreMalariaFloatingMenu) {
coreMalariaFloatingMenu = (CoreMalariaFloatingMenu) menu;
coreMalariaFloatingMenu.getCallLayout().setOnClickListener(null);
}
}

Expand Down
125 changes: 125 additions & 0 deletions opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/menu_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/malaria_fab"
android:layout_alignParentEnd="true"
android:layout_marginEnd="24dp"
android:orientation="vertical"
android:visibility="invisible">

<RelativeLayout
android:id="@+id/call_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="visible">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@+id/callFab"
android:background="@color/white"
android:elevation="2dp"
android:gravity="center"
android:minWidth="50dp"
android:padding="10dp">

<TextView
android:id="@+id/CallTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:text="@string/call"
android:textColor="@android:color/black" />

<TextView
android:id="@+id/CallTextViewHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_toEndOf="@+id/CallTextView"
android:layout_toRightOf="@+id/CallTextView"
android:text="@string/call_no_number_provided"
android:textColor="@color/grey"
android:textStyle="italic"
android:visibility="gone" />

</RelativeLayout>


<android.support.design.widget.FloatingActionButton
android:id="@+id/callFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
app:backgroundTint="@color/white"
app:fabSize="mini"
app:srcCompat="@drawable/floating_call" />

</RelativeLayout>

<RelativeLayout
android:id="@+id/refer_to_facility_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="visible">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_toLeftOf="@+id/refer_to_facility_fab"
android:background="@color/white"
android:elevation="2dp"
android:gravity="center"
android:minWidth="50dp"
android:padding="10dp"
android:text="@string/refer_to_facility"
android:textColor="@android:color/black" />


<android.support.design.widget.FloatingActionButton
android:id="@+id/refer_to_facility_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
app:backgroundTint="@color/white"
app:fabSize="mini"
app:srcCompat="@mipmap/ic_refer" />

</RelativeLayout>

</LinearLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/malaria_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:clickable="true"
android:tint="@android:color/white"
app:backgroundTint="@color/text_black"
app:fabSize="normal"
app:srcCompat="@drawable/ic_edit_white" />

</RelativeLayout>