From 2ab225836c52792aa3a4d978e3b2679fb7cb1343 Mon Sep 17 00:00:00 2001 From: Denis R Date: Tue, 8 Oct 2019 10:42:51 +0300 Subject: [PATCH 1/5] implement call and refer fab --- .../custom_views/CoreMalariaFloatingMenu.java | 121 +++++++++++++++++ .../res/layout/view_malaria_floating_menu.xml | 125 ++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/CoreMalariaFloatingMenu.java create mode 100644 opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml 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/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 From 943da3c5e389182479b3c1811c6c74f33c989756 Mon Sep 17 00:00:00 2001 From: Denis R Date: Tue, 8 Oct 2019 11:27:18 +0300 Subject: [PATCH 2/5] malaria profile with more than one visit --- .../smartregister/chw/core/utils/Utils.java | 8 ++ .../res/layout/view_malaria_floating_menu.xml | 125 ++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 opensrp-chw-core/src/main/res/layout/view_malaria_floating_menu.xml 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 f5383c9ad8..85d4709480 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; @@ -467,6 +468,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); @@ -479,6 +481,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 From 98f7bc66cde5f74e185cb6069a6b4e030d99d46f Mon Sep 17 00:00:00 2001 From: Denis rwelamila Date: Tue, 15 Oct 2019 09:37:55 +0300 Subject: [PATCH 3/5] Update build.gradle --- opensrp-chw-core/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index a813b98f12..afca32dac3 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.1.20-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' From 0bdb58ea5c1ebbc3e624c80b86c4ae0fdfcfa924 Mon Sep 17 00:00:00 2001 From: Denis R Date: Tue, 15 Oct 2019 09:53:55 +0300 Subject: [PATCH 4/5] update version --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 60bdbf726c..8a8fa2e85b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.0.9-SNAPSHOT +VERSION_NAME=1.0.10-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 a813b98f12..f870e1349c 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.1.20-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-core' exclude group: 'org.smartregister', module: 'opensrp-client-native-form' From fe342ab34d1d1ece284536c4e1e44e81fde2a501 Mon Sep 17 00:00:00 2001 From: Denis R Date: Tue, 15 Oct 2019 13:10:19 +0300 Subject: [PATCH 5/5] update version and fix gradle --- gradle.properties | 2 +- opensrp-chw-core/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 8a8fa2e85b..342c4c5ac4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.0.10-SNAPSHOT +VERSION_NAME=1.0.11-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 afca32dac3..50996888a8 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.1.20-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'