From 575ffb77867f1edb3a3666f9960a387e19cfe4dc Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Mon, 4 Oct 2021 19:05:09 +0300 Subject: [PATCH] move bottom navigation to side menu --- opensrp-chw/build.gradle | 2 +- .../chw/application/ChwApplicationFlv.java | 5 + .../chw/custom_view/NavigationMenuFlv.java | 27 ++ .../chw/model/NavigationModelFlv.java | 9 +- .../lmh/res/layout-w900dp/navigation_view.xml | 397 ++++++++++++++++ .../src/lmh/res/layout/navigation_view.xml | 427 ++++++++++++++++++ opensrp-chw/src/lmh/res/values/strings.xml | 4 + .../chw/activity/FamilyRegisterActivity.java | 5 + .../chw/activity/ReportsActivity.java | 13 +- .../chw/application/ChwApplication.java | 5 + .../application/DefaultChwApplicationFlv.java | 5 + .../chw/fragment/ReportsFragment.java | 4 + .../src/main/res/layout/activity_reports.xml | 41 +- .../src/main/res/layout/reports_fragment.xml | 15 +- opensrp-chw/src/main/res/values/colors.xml | 2 + opensrp-chw/src/main/res/values/styles.xml | 1 + 16 files changed, 937 insertions(+), 25 deletions(-) create mode 100644 opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml create mode 100644 opensrp-chw/src/lmh/res/layout/navigation_view.xml diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 8416ebf69f..34215b5e27 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -302,7 +302,7 @@ android { dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' - implementation('org.smartregister:opensrp-client-chw-core:1.5.25-LMH-Beta-01-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-chw-core:1.5.25-Beta-03-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'androidx.legacy', module: 'legacy-support-v4' diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java index 071e41b4ce..c85117cfc6 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/application/ChwApplicationFlv.java @@ -156,4 +156,9 @@ public boolean showChildrenAboveTwoDueStatus(){ public boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven(){ return true; } + + @Override + public boolean showBottomNavigation() { + return false; + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java index 443be8ac93..f11c514724 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/custom_view/NavigationMenuFlv.java @@ -1,6 +1,14 @@ package org.smartregister.chw.custom_view; +import android.app.Activity; +import android.content.DialogInterface; +import android.graphics.Color; +import android.widget.Button; + +import androidx.appcompat.app.AlertDialog; + import org.apache.commons.lang3.tuple.Pair; +import org.smartregister.chw.R; import java.util.Arrays; import java.util.List; @@ -37,4 +45,23 @@ public String childNavigationMenuCountString() { " and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = ec_child.mother_entity_id ) = 1)) \n" + " and (((julianday('now') - julianday(ec_child.dob))/365.25) < 2 or (ec_child.gender = 'Female' and (((julianday('now') - julianday(ec_child.dob))/365.25) BETWEEN 9 AND 11)))\n"; } + + @Override + public AlertDialog doLogOutDialog(Activity activity) { + AlertDialog dialog = new AlertDialog.Builder(activity) + .setTitle("Log Out?") + .setMessage("You will be returned to the PIN entry screen.") + .create(); + dialog.setOnShowListener(dialog1 -> { + Button positiveButton = ((AlertDialog) dialog1) + .getButton(AlertDialog.BUTTON_POSITIVE); + positiveButton.setTextColor(Color.RED); + + Button negativeButton = ((AlertDialog) dialog1) + .getButton(AlertDialog.BUTTON_NEGATIVE); + negativeButton.setTextColor(Color.GRAY); + }); + + return dialog; + } } diff --git a/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java b/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java index 13618faf6d..60562171d2 100644 --- a/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java +++ b/opensrp-chw/src/lmh/java/org/smartregister/chw/model/NavigationModelFlv.java @@ -2,6 +2,7 @@ import org.smartregister.chw.R; import org.smartregister.chw.core.model.NavigationOption; +import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.chw.util.Constants; import java.util.ArrayList; @@ -9,14 +10,16 @@ public class NavigationModelFlv extends DefaultNavigationModelFlv { - private List navigationOptions = new ArrayList<>(); + private final List navigationOptions = new ArrayList<>(); @Override public List getNavigationItems() { if (navigationOptions.size() == 0) { - navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_families, R.mipmap.sidemenu_families_active, R.string.menu_all_families, Constants.DrawerMenu.ALL_FAMILIES, 0)); - navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children_active, R.string.menu_child_clients, Constants.DrawerMenu.CHILD_CLIENTS, 0)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_families, R.mipmap.sidemenu_families, R.string.menu_all_families, Constants.DrawerMenu.ALL_FAMILIES, 0)); + navigationOptions.add(new NavigationOption(R.drawable.ic_input_add, R.drawable.ic_input_add, R.string.menu_add_new_family, "Add New Family", -1)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children, R.string.menu_child_clients, Constants.DrawerMenu.CHILD_CLIENTS, 0)); + navigationOptions.add(new NavigationOption(R.mipmap.ic_jobaids, R.mipmap.ic_jobaids, R.string.reports, "Reports", -1)); } return navigationOptions; diff --git a/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml b/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml new file mode 100644 index 0000000000..5249e0b3c8 --- /dev/null +++ b/opensrp-chw/src/lmh/res/layout-w900dp/navigation_view.xml @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opensrp-chw/src/lmh/res/layout/navigation_view.xml b/opensrp-chw/src/lmh/res/layout/navigation_view.xml new file mode 100644 index 0000000000..cfa6fc76ef --- /dev/null +++ b/opensrp-chw/src/lmh/res/layout/navigation_view.xml @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opensrp-chw/src/lmh/res/values/strings.xml b/opensrp-chw/src/lmh/res/values/strings.xml index 00e11fd350..8db5da557b 100644 --- a/opensrp-chw/src/lmh/res/values/strings.xml +++ b/opensrp-chw/src/lmh/res/values/strings.xml @@ -25,4 +25,8 @@ %s adults and %s U11 children Are you sure you want to go back? All data you have entered in this form will be cleared. + + Transfer Data + All Children + Add New Family \ No newline at end of file diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyRegisterActivity.java b/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyRegisterActivity.java index effd2a622e..c8afb3f9cd 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyRegisterActivity.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyRegisterActivity.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.view.View; import com.google.android.material.bottomnavigation.BottomNavigationView; @@ -28,6 +29,10 @@ public static void registerBottomNavigation( BottomNavigationHelper bottomNavigationHelper, BottomNavigationView bottomNavigationView, Activity activity ) { Utils.setupBottomNavigation(bottomNavigationHelper, bottomNavigationView, new ChwBottomNavigationListener(activity)); + if (!ChwApplication.getApplicationFlavor().showBottomNavigation() + && bottomNavigationView != null){ + bottomNavigationView.setVisibility(View.GONE); + } } @Override diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/activity/ReportsActivity.java b/opensrp-chw/src/main/java/org/smartregister/chw/activity/ReportsActivity.java index c37d784904..7b5c25531d 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/activity/ReportsActivity.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/activity/ReportsActivity.java @@ -2,11 +2,13 @@ import android.os.Bundle; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import com.google.android.material.bottomnavigation.BottomNavigationView; import org.smartregister.chw.R; +import org.smartregister.chw.core.custom_views.NavigationMenu; import org.smartregister.chw.core.job.ChwIndicatorGeneratingJob; import org.smartregister.chw.fragment.ReportsFragment; import org.smartregister.helper.BottomNavigationHelper; @@ -28,13 +30,20 @@ protected void onCreate(Bundle savedInstanceState) { switchToFragment(new ReportsFragment()); } + NavigationMenu.getInstance(this, null, null); + onCreation(); + + if (getSupportActionBar() != null){ + + } + ChwIndicatorGeneratingJob.scheduleJobImmediately(ChwIndicatorGeneratingJob.TAG); } private void switchToFragment(Fragment fragment) { getSupportFragmentManager().beginTransaction() - .add(R.id.content, fragment) + .add(R.id.main_content, fragment) .commit(); } @@ -44,7 +53,7 @@ protected void onCreation() { bottomNavigationView = findViewById(R.id.bottom_navigation); FamilyRegisterActivity.registerBottomNavigation(bottomNavigationHelper, bottomNavigationView, this); if (bottomNavigationView != null) - bottomNavigationView.getMenu().findItem(R.id.action_report).setChecked(true); + bottomNavigationView.getMenu().findItem(R.id.action_report).setChecked(true); } @Override diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java index 3d3b62a00b..980c57199d 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/ChwApplication.java @@ -33,6 +33,7 @@ import org.smartregister.chw.activity.MalariaRegisterActivity; import org.smartregister.chw.activity.PncRegisterActivity; import org.smartregister.chw.activity.ReferralRegisterActivity; +import org.smartregister.chw.activity.ReportsActivity; import org.smartregister.chw.activity.UpdatesRegisterActivity; import org.smartregister.chw.anc.AncLibrary; import org.smartregister.chw.anc.domain.Visit; @@ -294,6 +295,8 @@ public Map getRegisteredActivities() { } registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.FP_REGISTER_ACTIVITY, FpRegisterActivity.class); registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.UPDATES_REGISTER_ACTIVITY, UpdatesRegisterActivity.class); + registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY, ReportsActivity.class); + registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.ADD_NEW_FAMILY, FamilyRegisterActivity.class); return registeredActivities; } @@ -438,6 +441,8 @@ public interface Flavor { boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven(); + boolean showBottomNavigation(); + } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java b/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java index 06e6dae369..869b433eee 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/application/DefaultChwApplicationFlv.java @@ -216,4 +216,9 @@ public boolean showLastNameOnChildProfile() { public boolean showIconsForChildrenUnderTwoAndGirlsAgeNineToEleven(){ return false; } + + @Override + public boolean showBottomNavigation() { + return true; + } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/fragment/ReportsFragment.java b/opensrp-chw/src/main/java/org/smartregister/chw/fragment/ReportsFragment.java index 2ce8808407..7c90f54d95 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/fragment/ReportsFragment.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/fragment/ReportsFragment.java @@ -7,6 +7,7 @@ import android.widget.ProgressBar; import androidx.annotation.NonNull; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -16,6 +17,7 @@ import org.smartregister.chw.adapter.ListableAdapter; import org.smartregister.chw.adapter.ReportsFragmentAdapter; import org.smartregister.chw.contract.ListContract; +import org.smartregister.chw.core.custom_views.NavigationMenu; import org.smartregister.chw.domain.ReportType; import org.smartregister.chw.presenter.ListPresenter; import org.smartregister.chw.viewholder.ListableViewHolder; @@ -38,6 +40,8 @@ public class ReportsFragment extends Fragment implements ListContract.View - + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:openDrawer="start"> - + android:layout_height="match_parent"> - + + + + + - \ No newline at end of file + + \ No newline at end of file diff --git a/opensrp-chw/src/main/res/layout/reports_fragment.xml b/opensrp-chw/src/main/res/layout/reports_fragment.xml index f641ccdcea..e565485f37 100644 --- a/opensrp-chw/src/main/res/layout/reports_fragment.xml +++ b/opensrp-chw/src/main/res/layout/reports_fragment.xml @@ -2,14 +2,21 @@ + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto"> - + app:contentInsetLeft="0dp" + app:contentInsetStart="0dp" + app:contentInsetRight="0dp" + app:contentInsetEnd="0dp" + android:minHeight="?attr/actionBarSize" + app:popupTheme="@style/AppTheme.PopupOverlay" + android:theme="@style/AppTheme.AppBarOverlay"> - + #A64D79 #E69138 #803F04 + @color/accent + @color/white diff --git a/opensrp-chw/src/main/res/values/styles.xml b/opensrp-chw/src/main/res/values/styles.xml index 269ef676a4..818a40783a 100644 --- a/opensrp-chw/src/main/res/values/styles.xml +++ b/opensrp-chw/src/main/res/values/styles.xml @@ -6,6 +6,7 @@ @color/chw_primary @color/chw_primary_dark @color/chw_accent + true