diff --git a/gradle.properties b/gradle.properties index 9d085fead0..a6861c7ec9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 42f76385a3..93ca0839cb 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -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' @@ -203,4 +203,4 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { tasks.withType(Test) { jacoco.includeNoLocationClasses = true } -apply from: '../maven.gradle' \ No newline at end of file +apply from: '../maven.gradle' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/CoreMalariaFloatingMenu.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/CoreMalariaFloatingMenu.java new file mode 100644 index 0000000000..4f78c53768 --- /dev/null +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/CoreMalariaFloatingMenu.java @@ -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; + } +} \ No newline at end of file diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java index a5de6daa95..db3bbde4da 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/Utils.java @@ -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; @@ -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); @@ -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); } } diff --git a/opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml b/opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml new file mode 100644 index 0000000000..a0e36b8df0 --- /dev/null +++ b/opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file