From 3b41ec52b628771d2e8cfc75af8e38f82827e8c8 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Thu, 23 Sep 2021 17:04:36 +0300 Subject: [PATCH 01/11] add tests for CoreChildRegisterActivityTest --- build.gradle | 7 -- opensrp-chw-core/build.gradle | 12 ++- .../CoreChildRegisterActivityTest.java | 96 +++++++++++++++++++ 3 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildRegisterActivityTest.java diff --git a/build.gradle b/build.gradle index f19c7f0975..1d652087aa 100644 --- a/build.gradle +++ b/build.gradle @@ -4,14 +4,12 @@ buildscript { repositories { google() - jcenter() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { url 'https://jitpack.io' } maven { url "https://repo.maven.apache.org/maven2" } maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" } maven{ url "https://plugins.gradle.org/m2/" } - maven { url "https://dl.bintray.com/ona/kujaku" } mavenLocal() } dependencies { @@ -42,7 +40,6 @@ allprojects { repositories { google() - jcenter() mavenLocal() mavenCentral() maven { url 'https://maven.google.com' } @@ -54,9 +51,6 @@ allprojects { maven { url 'https://maven.fabric.io/public' } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } - maven { url "https://dl.bintray.com/ona/rdt-capture" } - maven { url "http://dl.bintray.com/ona/kujaku" } - maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases'} maven{ url "https://plugins.gradle.org/m2/" } } } @@ -68,7 +62,6 @@ configure(allprojects) { project -> buildscript { repositories { google() - jcenter() mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 6ceb7ba1ec..605a9ef625 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -3,7 +3,6 @@ description = 'OpenSRP chw aggregated client library' buildscript { repositories { google() - jcenter() mavenLocal() } @@ -190,6 +189,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-immunization:2.0.3-beta2-SNAPSHOT@aar') { @@ -206,6 +206,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-v4' exclude group: 'com.android.support', module: 'design' exclude group: 'com.github.lecho', module: 'hellocharts-library' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-growth-monitoring:1.1.23-SNAPSHOT@aar') { @@ -224,6 +225,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-pnc:1.0.3-SNAPSHOT@aar') { @@ -234,6 +236,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-malaria:1.2.18-SNAPSHOT@aar') { @@ -242,6 +245,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-chw-family-planning:1.0.26-SNAPSHOT@aar') { @@ -250,6 +254,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-referral:1.3.5-SNAPSHOT@aar') { transitive = true @@ -257,6 +262,7 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' + exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-opd:0.0.13-SNAPSHOT@aar') { @@ -269,6 +275,8 @@ dependencies { exclude group: 'id.zelory', module: 'compressor' } + implementation "id.zelory:compressor:2.1.1" + api 'com.google.guava:guava:20.0' api 'io.reactivex.rxjava2:rxandroid:2.1.1' // Because RxAndroid releases are few and far between, it is recommended you also @@ -348,4 +356,4 @@ task javadoc(type: Javadoc) { source = files([mainSrc]) classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile -} \ No newline at end of file +} diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildRegisterActivityTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildRegisterActivityTest.java new file mode 100644 index 0000000000..7d118fe157 --- /dev/null +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/CoreChildRegisterActivityTest.java @@ -0,0 +1,96 @@ +package org.smartregister.chw.core.activity; + +import android.content.Intent; + +import com.google.android.material.bottomnavigation.BottomNavigationView; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.MockitoAnnotations; +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; +import org.powermock.reflect.Whitebox; +import org.robolectric.Robolectric; +import org.robolectric.android.controller.ActivityController; +import org.robolectric.util.ReflectionHelpers; +import org.smartregister.Context; +import org.smartregister.CoreLibrary; +import org.smartregister.chw.core.BaseUnitTest; +import org.smartregister.chw.core.R; +import org.smartregister.chw.core.custom_views.NavigationMenu; +import org.smartregister.chw.core.fragment.CoreChildRegisterFragment; +import org.smartregister.chw.core.presenter.CoreChildRegisterPresenter; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; + +public class CoreChildRegisterActivityTest extends BaseUnitTest { + + @Rule + public MockitoRule rule = MockitoJUnit.rule(); + + private CoreChildRegisterActivity activity; + private ActivityController controller; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + + Context context = Context.getInstance(); + CoreLibrary.init(context); + + //Auto login by default + String password = "pwd"; + context.session().start(context.session().lengthInMilliseconds()); + context.configuration().getDrishtiApplication().setPassword(password); + context.session().setPassword(password); + + controller = Robolectric.buildActivity(CoreChildRegisterActivity.class, new Intent()); + activity = controller.get(); + controller + .create() + .start(); + } + + @Test + public void testNavigationMenuInstanceNotNull() { + assertNotNull(ReflectionHelpers.getStaticField(NavigationMenu.class, "instance")); + } + + @Test + public void testPresenterIsInitialized() { + assertTrue(activity.presenter() instanceof CoreChildRegisterPresenter); + } + + @Test + public void testRegisterFragmentIsInitialized() { + assertTrue(Whitebox.getInternalState(activity, "mBaseFragment") instanceof CoreChildRegisterFragment); + } + + @Test + public void switchToBaseFragment() { + CoreChildRegisterActivity spyActivity = spy(activity); + doNothing().when(spyActivity).startActivity(any(Intent.class)); + doNothing().when(spyActivity).finish(); + spyActivity.switchToBaseFragment(); + verify(spyActivity).finish(); + ArgumentCaptor intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class); + verify(spyActivity).startActivity(intentArgumentCaptor.capture()); + assertEquals(CoreFamilyRegisterActivity.class.getName(), intentArgumentCaptor.getValue().getComponent().getClassName()); + } + + @Test + public void openFamilyListView() { + activity.openFamilyListView(); + BottomNavigationView navigationView = Whitebox.getInternalState(activity, "bottomNavigationView"); + assertEquals(R.id.action_family, navigationView.getSelectedItemId()); + } + +} \ No newline at end of file From 3510208fa1518a07170066faac064882e1e017eb Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Mon, 4 Oct 2021 19:01:08 +0300 Subject: [PATCH 02/11] Updates to VTS navigations --- gradle.properties | 2 +- .../chw/core/adapter/NavigationAdapter.java | 27 +- .../chw/core/custom_views/NavigationMenu.java | 32 +- .../chw/core/listener/NavigationListener.java | 17 + .../chw/core/utils/CoreConstants.java | 5 + .../main/res/layout-w900dp/activity_base.xml | 396 +--------------- .../res/layout-w900dp/navigation_item.xml | 1 + .../res/layout-w900dp/navigation_view.xml | 395 ++++++++++++++++ .../src/main/res/layout/activity_base.xml | 432 +----------------- .../src/main/res/layout/navigation_item.xml | 1 + .../src/main/res/layout/navigation_view.xml | 432 ++++++++++++++++++ .../src/main/res/values/colors.xml | 1 + 12 files changed, 904 insertions(+), 837 deletions(-) create mode 100644 opensrp-chw-core/src/main/res/layout-w900dp/navigation_view.xml create mode 100644 opensrp-chw-core/src/main/res/layout/navigation_view.xml diff --git a/gradle.properties b/gradle.properties index aaeadd1e7c..3f9b3bdb72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.25-Beta-01-SNAPSHOT +VERSION_NAME=1.5.25-Beta-03-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java index 4b8a4cc028..080c7bde39 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java @@ -9,6 +9,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.drawerlayout.widget.DrawerLayout; import androidx.recyclerview.widget.RecyclerView; import org.smartregister.chw.core.R; @@ -27,12 +28,18 @@ public class NavigationAdapter extends RecyclerView.Adapter registeredActivities; + private DrawerLayout drawerLayout; public NavigationAdapter(List navigationOptions, Activity context, Map registeredActivities) { + this(navigationOptions, context, registeredActivities, null); + } + + public NavigationAdapter(List navigationOptions, Activity context, Map registeredActivities, DrawerLayout drawerLayout) { this.navigationOptionList = navigationOptions; this.context = context; this.onClickListener = new NavigationListener(context, this); this.registeredActivities = registeredActivities; + this.drawerLayout = drawerLayout; } public String getSelectedView() { @@ -59,17 +66,28 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { NavigationOption model = navigationOptionList.get(position); holder.tvName.setText(context.getResources().getText(model.getTitleID())); - holder.tvCount.setText(String.format(Locale.getDefault(), "%d", model.getRegisterCount())); + if (model.getRegisterCount() >= 0) { + holder.tvCount.setText(String.format(Locale.getDefault(), "%d", model.getRegisterCount())); + }else{ + holder.tvCount.setText(null); + } holder.ivIcon.setImageResource(model.getResourceID()); holder.getView().setTag(model.getMenuTitle()); - if (selectedView != null && selectedView.equals(model.getMenuTitle())) { + if (selectedView != null && selectedView.equals(model.getMenuTitle()) && model.getResourceID() == model.getResourceActiveID()) { + holder.itemView.setBackgroundColor(context.getResources().getColor(R.color.navigation_item_selected)); + holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); + holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); + holder.ivIcon.setImageResource(model.getResourceID()); + }else if (selectedView != null && selectedView.equals(model.getMenuTitle())){ + holder.itemView.setBackgroundColor(context.getResources().getColor(android.R.color.transparent)); holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); holder.ivIcon.setImageResource(model.getResourceActiveID()); } else { + holder.itemView.setBackgroundColor(context.getResources().getColor(android.R.color.transparent)); holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); holder.ivIcon.setImageResource(model.getResourceID()); @@ -98,7 +116,10 @@ private MyViewHolder(View view) { ivIcon = view.findViewById(R.id.ivIcon); if (onClickListener != null) { - view.setOnClickListener(onClickListener); + view.setOnClickListener(v -> { + if (drawerLayout != null) drawerLayout.closeDrawers(); + onClickListener.onClick(v); + }); } myView = view; diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java index ee89067d1e..a15e41bfd1 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java @@ -2,8 +2,11 @@ import android.Manifest; import android.app.Activity; +import android.app.Dialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -245,7 +248,7 @@ private void registerServiceActivity(Activity activity) { View rlIconServiceReport = rootView.findViewById(R.id.rlServiceReport); rlIconServiceReport.setVisibility(View.VISIBLE); rlIconServiceReport.setOnClickListener(view -> { - activity.startActivity( menuFlavor.getHIA2ReportActivityIntent(activity)); + activity.startActivity(menuFlavor.getHIA2ReportActivityIntent(activity)); }); } } @@ -289,7 +292,7 @@ private void registerNavigation(Activity parentActivity) { List navigationOptions = mPresenter.getOptions(); if (navigationAdapter == null) { - navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities); + navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities, drawer); } RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(parentActivity); @@ -301,7 +304,17 @@ private void registerNavigation(Activity parentActivity) { private void registerLogout(final Activity parentActivity) { mPresenter.displayCurrentUser(); - tvLogout.setOnClickListener(v -> logout(parentActivity)); + AlertDialog logOutDialog = menuFlavor.doLogOutDialog(parentActivity); + tvLogout.setOnClickListener(v -> { +// drawer.closeDrawers(); + if (logOutDialog != null) { + logOutDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Log Out", (dialog, which) -> logout(parentActivity)); + logOutDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> dialog.dismiss()); + logOutDialog.show(); + }else { + logout(parentActivity); + } + }); } private void registerSync(final Activity parentActivity) { @@ -339,7 +352,7 @@ private void registerLanguageSwitcher(final Activity context) { } x++; } - if(menuFlavor.hasMultipleLanguages()){ + if (menuFlavor.hasMultipleLanguages()) { rlIconLang.setOnClickListener(v -> { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.choose_language)); @@ -360,8 +373,7 @@ private void registerLanguageSwitcher(final Activity context) { AlertDialog dialog = builder.create(); dialog.show(); }); - } - else { + } else { rlIconLang.setOnClickListener(null); } } @@ -485,8 +497,8 @@ public DrawerLayout getDrawer() { return drawer; } - public static String getChildNavigationCountString(){ - return menuFlavor.childNavigationMenuCountString(); + public static String getChildNavigationCountString() { + return menuFlavor.childNavigationMenuCountString(); } public interface Flavour { @@ -509,5 +521,9 @@ public interface Flavour { String childNavigationMenuCountString(); Intent getHIA2ReportActivityIntent(Activity activity); + + default AlertDialog doLogOutDialog(Activity activity){ + return null; + } } } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java index 93032d8d48..7597d657c5 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java @@ -9,6 +9,7 @@ import org.smartregister.chw.core.adapter.NavigationAdapter; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.util.Utils; +import org.smartregister.view.activity.BaseRegisterActivity; public class NavigationListener implements View.OnClickListener { @@ -26,6 +27,7 @@ public void onClick(View v) { String tag = (String) v.getTag(); switch (tag) { case CoreConstants.DrawerMenu.CHILD_CLIENTS: + case CoreConstants.DrawerMenu.ALL_CHILDREN: startRegisterActivity(getActivity(CoreConstants.REGISTERED_ACTIVITIES.CHILD_REGISTER_ACTIVITY)); break; case CoreConstants.DrawerMenu.ALL_FAMILIES: @@ -66,6 +68,21 @@ public void onClick(View v) { case CoreConstants.DrawerMenu.UPDATES: startRegisterActivity(getActivity(CoreConstants.REGISTERED_ACTIVITIES.UPDATES_REGISTER_ACTIVITY)); break; + case CoreConstants.DrawerMenu.REPORTS: + activity.startActivity(new Intent(activity, getActivity(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY))); + activity.overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); + activity.finish(); + break; + case CoreConstants.DrawerMenu.ADD_NEW_FAMILY: + if (activity instanceof BaseRegisterActivity) { + BaseRegisterActivity baseRegisterActivity = (BaseRegisterActivity) activity; + baseRegisterActivity.startRegistration(); + } else { + Intent intent = new Intent(activity, getActivity(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY)); + intent.putExtra(CoreConstants.ACTIVITY_PAYLOAD.ACTION, CoreConstants.ACTION.START_REGISTRATION); + activity.startActivity(intent); + } + break; default: Utils.showShortToast(activity.getApplicationContext(), "Unspecified navigation action"); break; diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java index f55c9167f6..1703b0d39a 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java @@ -725,6 +725,9 @@ public static final class DrawerMenu { public static final String REFERRALS = "Referrals"; public static final String STOCK_USAGE_REPORT = "StockUsageItemModel usage report"; public static final String UPDATES = "Updates"; + public static final String ALL_CHILDREN = "All Children"; + public static final String REPORTS = "Reports"; + public static final String ADD_NEW_FAMILY = "Add New Family"; } public static final class RULE_FILE { @@ -952,6 +955,8 @@ public static final class REGISTERED_ACTIVITIES { public static final String FP_REGISTER_ACTIVITY = "FP_REGISTER_ACTIVITY"; public static final String ALL_CLIENTS_REGISTERED_ACTIVITY = "ALL_CLIENTS"; public static final String UPDATES_REGISTER_ACTIVITY = "UPDATES_REGISTER_ACTIVITY"; + public static final String REPORTS_ACTIVITY = "REPORTS_ACTIVITY"; + public static final String ADD_NEW_FAMILY = "ADD_NEW_FAMILY"; } public static final class BUSINESS_STATUS { diff --git a/opensrp-chw-core/src/main/res/layout-w900dp/activity_base.xml b/opensrp-chw-core/src/main/res/layout-w900dp/activity_base.xml index bf68faab4d..59f3dc999e 100644 --- a/opensrp-chw-core/src/main/res/layout-w900dp/activity_base.xml +++ b/opensrp-chw-core/src/main/res/layout-w900dp/activity_base.xml @@ -8,400 +8,6 @@ android:fitsSystemWindows="true" tools:openDrawer="start"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/opensrp-chw-core/src/main/res/layout-w900dp/navigation_item.xml b/opensrp-chw-core/src/main/res/layout-w900dp/navigation_item.xml index 60a262235a..7c126ac128 100644 --- a/opensrp-chw-core/src/main/res/layout-w900dp/navigation_item.xml +++ b/opensrp-chw-core/src/main/res/layout-w900dp/navigation_item.xml @@ -11,6 +11,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" + app:tint="@color/navigation_item_icon_tint" app:srcCompat="@drawable/child_boy_infant" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opensrp-chw-core/src/main/res/layout/activity_base.xml b/opensrp-chw-core/src/main/res/layout/activity_base.xml index 3ca25b3e62..9cc4b85ea5 100644 --- a/opensrp-chw-core/src/main/res/layout/activity_base.xml +++ b/opensrp-chw-core/src/main/res/layout/activity_base.xml @@ -1,6 +1,5 @@ + android:layout_height="match_parent"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/opensrp-chw-core/src/main/res/layout/navigation_item.xml b/opensrp-chw-core/src/main/res/layout/navigation_item.xml index ef49e97005..6854adea68 100644 --- a/opensrp-chw-core/src/main/res/layout/navigation_item.xml +++ b/opensrp-chw-core/src/main/res/layout/navigation_item.xml @@ -13,6 +13,7 @@ android:layout_height="33dp" android:layout_alignParentStart="true" android:scaleType="fitXY" + app:tint="@color/navigation_item_icon_tint" app:srcCompat="@drawable/child_boy_infant" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/opensrp-chw-core/src/main/res/values/colors.xml b/opensrp-chw-core/src/main/res/values/colors.xml index fa246924c5..cedf0b42de 100644 --- a/opensrp-chw-core/src/main/res/values/colors.xml +++ b/opensrp-chw-core/src/main/res/values/colors.xml @@ -8,6 +8,7 @@ #575757 #FCEEF5 + @color/transparent #81D4FA #FFFFFF From 6a1ac6e573bf3b78cfaa53c0d66cf9aaf5232ac4 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Tue, 5 Oct 2021 11:30:03 +0300 Subject: [PATCH 03/11] update gradle.properties file --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3f9b3bdb72..aaeadd1e7c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.5.25-Beta-03-SNAPSHOT +VERSION_NAME=1.5.25-Beta-01-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library From 7b0884840ff6846b28ea2ea654a8a93acad58aa8 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Tue, 5 Oct 2021 12:39:22 +0300 Subject: [PATCH 04/11] remove .gradle files from pr --- build.gradle | 7 +++++++ opensrp-chw-core/build.gradle | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 1d652087aa..f19c7f0975 100644 --- a/build.gradle +++ b/build.gradle @@ -4,12 +4,14 @@ buildscript { repositories { google() + jcenter() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } maven { url 'https://jitpack.io' } maven { url "https://repo.maven.apache.org/maven2" } maven { url "http://cloudant.github.io/cloudant-sync-eap/repository" } maven{ url "https://plugins.gradle.org/m2/" } + maven { url "https://dl.bintray.com/ona/kujaku" } mavenLocal() } dependencies { @@ -40,6 +42,7 @@ allprojects { repositories { google() + jcenter() mavenLocal() mavenCentral() maven { url 'https://maven.google.com' } @@ -51,6 +54,9 @@ allprojects { maven { url 'https://maven.fabric.io/public' } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } maven { url "https://s3.amazonaws.com/repo.commonsware.com" } + maven { url "https://dl.bintray.com/ona/rdt-capture" } + maven { url "http://dl.bintray.com/ona/kujaku" } + maven { url 'https://dl.bintray.com/ibm-watson-health/ibm-fhir-server-releases'} maven{ url "https://plugins.gradle.org/m2/" } } } @@ -62,6 +68,7 @@ configure(allprojects) { project -> buildscript { repositories { google() + jcenter() mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 605a9ef625..6ceb7ba1ec 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -3,6 +3,7 @@ description = 'OpenSRP chw aggregated client library' buildscript { repositories { google() + jcenter() mavenLocal() } @@ -189,7 +190,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-immunization:2.0.3-beta2-SNAPSHOT@aar') { @@ -206,7 +206,6 @@ dependencies { exclude group: 'com.android.support', module: 'support-v4' exclude group: 'com.android.support', module: 'design' exclude group: 'com.github.lecho', module: 'hellocharts-library' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-growth-monitoring:1.1.23-SNAPSHOT@aar') { @@ -225,7 +224,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-pnc:1.0.3-SNAPSHOT@aar') { @@ -236,7 +234,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'org.smartregister', module: 'opensrp-client-immunization' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-malaria:1.2.18-SNAPSHOT@aar') { @@ -245,7 +242,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-chw-family-planning:1.0.26-SNAPSHOT@aar') { @@ -254,7 +250,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-chw-referral:1.3.5-SNAPSHOT@aar') { transitive = true @@ -262,7 +257,6 @@ dependencies { exclude group: 'org.smartregister', module: 'opensrp-client-native-form' exclude group: 'org.smartregister', module: 'opensrp-client-configurable-views' exclude group: 'com.android.support', module: 'appcompat-v7' - exclude group: 'id.zelory', module: 'compressor' } api('org.smartregister:opensrp-client-opd:0.0.13-SNAPSHOT@aar') { @@ -275,8 +269,6 @@ dependencies { exclude group: 'id.zelory', module: 'compressor' } - implementation "id.zelory:compressor:2.1.1" - api 'com.google.guava:guava:20.0' api 'io.reactivex.rxjava2:rxandroid:2.1.1' // Because RxAndroid releases are few and far between, it is recommended you also @@ -356,4 +348,4 @@ task javadoc(type: Javadoc) { source = files([mainSrc]) classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile -} +} \ No newline at end of file From 25cd03a0a2795485f1758be74ea1933123c7c9b6 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Tue, 5 Oct 2021 15:14:12 +0300 Subject: [PATCH 05/11] fix 'add new family' to check instance from class --- .../smartregister/chw/core/listener/NavigationListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java index 7597d657c5..d73530ba23 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java @@ -74,11 +74,12 @@ public void onClick(View v) { activity.finish(); break; case CoreConstants.DrawerMenu.ADD_NEW_FAMILY: - if (activity instanceof BaseRegisterActivity) { + Class newFamilyRegisterClass = getActivity(CoreConstants.REGISTERED_ACTIVITIES.ADD_NEW_FAMILY); + if (newFamilyRegisterClass.isInstance(activity)) { BaseRegisterActivity baseRegisterActivity = (BaseRegisterActivity) activity; baseRegisterActivity.startRegistration(); } else { - Intent intent = new Intent(activity, getActivity(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY)); + Intent intent = new Intent(activity, newFamilyRegisterClass); intent.putExtra(CoreConstants.ACTIVITY_PAYLOAD.ACTION, CoreConstants.ACTION.START_REGISTRATION); activity.startActivity(intent); } From e72708a7ad52a88e28fcce7ea9c77111be6da8d2 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Wed, 13 Oct 2021 11:34:30 +0300 Subject: [PATCH 06/11] LMH1-104: switch navigation adapters to pick current activity to avoid nullpointer exceptions for an already destroyed activity --- .../chw/core/adapter/NavigationAdapter.java | 10 +++--- .../chw/core/custom_views/NavigationMenu.java | 14 +++++--- .../chw/core/listener/NavigationListener.java | 35 +++++++++++++++---- .../chw/core/model/NavigationOption.java | 4 +++ .../core/presenter/NavigationPresenter.java | 33 +++++++++-------- .../chw/core/utils/CoreConstants.java | 1 - 6 files changed, 67 insertions(+), 30 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java index 080c7bde39..4e48f3bc2b 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/adapter/NavigationAdapter.java @@ -66,9 +66,9 @@ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { NavigationOption model = navigationOptionList.get(position); holder.tvName.setText(context.getResources().getText(model.getTitleID())); - if (model.getRegisterCount() >= 0) { + if (model.hasRegisterCount()) { holder.tvCount.setText(String.format(Locale.getDefault(), "%d", model.getRegisterCount())); - }else{ + } else { holder.tvCount.setText(null); } holder.ivIcon.setImageResource(model.getResourceID()); @@ -81,7 +81,7 @@ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_unselected)); holder.ivIcon.setImageResource(model.getResourceID()); - }else if (selectedView != null && selectedView.equals(model.getMenuTitle())){ + } else if (selectedView != null && selectedView.equals(model.getMenuTitle())) { holder.itemView.setBackgroundColor(context.getResources().getColor(android.R.color.transparent)); holder.tvCount.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); holder.tvName.setTextColor(context.getResources().getColor(R.color.navigation_item_selected)); @@ -117,7 +117,9 @@ private MyViewHolder(View view) { if (onClickListener != null) { view.setOnClickListener(v -> { - if (drawerLayout != null) drawerLayout.closeDrawers(); + if (drawerLayout != null) { + drawerLayout.closeDrawers(); + } onClickListener.onClick(v); }); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java index a15e41bfd1..c25de0c662 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/NavigationMenu.java @@ -289,16 +289,20 @@ private void registerDrawer(Activity parentActivity) { private void registerNavigation(Activity parentActivity) { if (recyclerView != null) { + RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(parentActivity); + recyclerView.setLayoutManager(mLayoutManager); + recyclerView.setItemAnimator(new DefaultItemAnimator()); List navigationOptions = mPresenter.getOptions(); if (navigationAdapter == null) { navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities, drawer); + recyclerView.setAdapter(navigationAdapter); + }else { + NavigationAdapter previous = navigationAdapter; + navigationAdapter = new NavigationAdapter(navigationOptions, parentActivity, registeredActivities, drawer); + recyclerView.swapAdapter(navigationAdapter, true); + navigationAdapter.setSelectedView(previous.getSelectedView()); } - - RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(parentActivity); - recyclerView.setLayoutManager(mLayoutManager); - recyclerView.setItemAnimator(new DefaultItemAnimator()); - recyclerView.setAdapter(navigationAdapter); } } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java index d73530ba23..68fd1a8f01 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/listener/NavigationListener.java @@ -5,6 +5,9 @@ import android.view.View; import android.widget.Toast; +import androidx.annotation.NonNull; + +import org.jetbrains.annotations.NotNull; import org.smartregister.chw.core.R; import org.smartregister.chw.core.adapter.NavigationAdapter; import org.smartregister.chw.core.utils.CoreConstants; @@ -27,7 +30,6 @@ public void onClick(View v) { String tag = (String) v.getTag(); switch (tag) { case CoreConstants.DrawerMenu.CHILD_CLIENTS: - case CoreConstants.DrawerMenu.ALL_CHILDREN: startRegisterActivity(getActivity(CoreConstants.REGISTERED_ACTIVITIES.CHILD_REGISTER_ACTIVITY)); break; case CoreConstants.DrawerMenu.ALL_FAMILIES: @@ -69,9 +71,7 @@ public void onClick(View v) { startRegisterActivity(getActivity(CoreConstants.REGISTERED_ACTIVITIES.UPDATES_REGISTER_ACTIVITY)); break; case CoreConstants.DrawerMenu.REPORTS: - activity.startActivity(new Intent(activity, getActivity(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY))); - activity.overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); - activity.finish(); + startRegisterActivity(getActivity(CoreConstants.REGISTERED_ACTIVITIES.REPORTS_ACTIVITY)); break; case CoreConstants.DrawerMenu.ADD_NEW_FAMILY: Class newFamilyRegisterClass = getActivity(CoreConstants.REGISTERED_ACTIVITIES.ADD_NEW_FAMILY); @@ -81,7 +81,7 @@ public void onClick(View v) { } else { Intent intent = new Intent(activity, newFamilyRegisterClass); intent.putExtra(CoreConstants.ACTIVITY_PAYLOAD.ACTION, CoreConstants.ACTION.START_REGISTRATION); - activity.startActivity(intent); + startRegisterActivity(intent, false); } break; default: @@ -92,11 +92,34 @@ public void onClick(View v) { } } - public void startRegisterActivity(Class registerClass) { + private boolean isClassCurrentActivity(Class klass){ + return klass.getName().equals(activity.getClass().getName()); + } + + private boolean isIntentForCurrentActivity(Intent intent) { + return intent.getComponent().getClassName().equals(activity.getClass().getName()); + } + + public void startRegisterActivity(@NotNull @NonNull Class registerClass) { + startRegisterActivity(registerClass, true); + } + + public void startRegisterActivity(@NotNull @NonNull Class registerClass, boolean finish) { if (registerClass != null) { Intent intent = new Intent(activity, registerClass); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.startActivity(intent); + if (!isClassCurrentActivity(registerClass) && finish) { + activity.overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); + activity.finish(); + } + } + } + + public void startRegisterActivity(@NonNull @NotNull Intent intent, boolean finish) { + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + activity.startActivity(intent); + if (!isIntentForCurrentActivity(intent) && finish) { activity.overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); activity.finish(); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/NavigationOption.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/NavigationOption.java index ea302701c2..add77ab3dd 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/NavigationOption.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/model/NavigationOption.java @@ -56,4 +56,8 @@ public void setRegisterCount(long registerCount) { RegisterCount = registerCount; } + public boolean hasRegisterCount() { + return this.RegisterCount >= 0; + } + } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/NavigationPresenter.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/NavigationPresenter.java index 918cc9865a..cbae37357e 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/NavigationPresenter.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/NavigationPresenter.java @@ -82,20 +82,25 @@ public void refreshNavigationCount(final Activity activity) { int x = 0; while (x < mModel.getNavigationItems().size()) { - final int finalX = x; - mInteractor.getRegisterCount(tableMap.get(mModel.getNavigationItems().get(x).getMenuTitle()), new NavigationContract.InteractorCallback() { - @Override - public void onResult(Integer result) { - mModel.getNavigationItems().get(finalX).setRegisterCount(result); - getNavigationView().refreshCount(); - } - - @Override - public void onError(Exception e) { - // getNavigationView().displayToast(activity, "Error retrieving count for " + tableMap.get(mModel.getNavigationItems().get(finalX).getMenuTitle())); - Timber.e("Error retrieving count for %s", tableMap.get(mModel.getNavigationItems().get(finalX).getMenuTitle())); - } - }); + final NavigationOption navigationOption = mModel.getNavigationItems().get(x); + final String navTitle = navigationOption.getMenuTitle(); + if (tableMap.containsKey(navTitle)) { + mInteractor.getRegisterCount(tableMap.get(navTitle), new NavigationContract.InteractorCallback() { + @Override + public void onResult(Integer result) { + navigationOption.setRegisterCount(result); + getNavigationView().refreshCount(); + } + + @Override + public void onError(Exception e) { + // getNavigationView().displayToast(activity, "Error retrieving count for " + tableMap.get(mModel.getNavigationItems().get(finalX).getMenuTitle())); + Timber.e("Error retrieving count for %s", tableMap.get(navTitle)); + } + }); + }else if (navigationOption.hasRegisterCount()){ + Timber.e("Error retrieving count for %s, table not defined in 'tableMap'", navTitle); + } x++; } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java index 1703b0d39a..72a120bd1b 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreConstants.java @@ -725,7 +725,6 @@ public static final class DrawerMenu { public static final String REFERRALS = "Referrals"; public static final String STOCK_USAGE_REPORT = "StockUsageItemModel usage report"; public static final String UPDATES = "Updates"; - public static final String ALL_CHILDREN = "All Children"; public static final String REPORTS = "Reports"; public static final String ADD_NEW_FAMILY = "Add New Family"; } From 36a61c4e84277eb8dc9c4bc71e519b3ac485a749 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Mon, 18 Oct 2021 16:48:51 +0300 Subject: [PATCH 07/11] LMH1-58: ALlow config of forms' next icons/button Depends on: https://github.com/opensrp/opensrp-client-native-form/pull/607 --- opensrp-chw-core/build.gradle | 2 +- .../activity/CoreChildRegisterActivity.java | 17 +++++++---- .../activity/CoreFamilyRegisterActivity.java | 28 +++++++++++++++++++ .../core/custom_views/FamilyFloatingMenu.java | 2 +- .../res/layout/view_family_floating_menu.xml | 2 +- .../src/main/res/values/drawables.xml | 4 +++ 6 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 opensrp-chw-core/src/main/res/values/drawables.xml diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 6ceb7ba1ec..2e57af8a52 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -348,4 +348,4 @@ task javadoc(type: Javadoc) { source = files([mainSrc]) classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) classpath += configurations.compile -} \ No newline at end of file +} diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java index c9ec7fe2d0..480d7ab5b9 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildRegisterActivity.java @@ -99,17 +99,22 @@ public void startFormActivity(String formName, String entityId, String metaData) } } - @Override - public void startFormActivity(JSONObject jsonForm) { - Intent intent = new Intent(this, Utils.metadata().familyFormActivity); - intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); - + public Form getFormConfig(){ Form form = new Form(); form.setName(getString(R.string.add_fam)); form.setActionBarBackground(R.color.family_actionbar); form.setNavigationBackground(R.color.family_navigation); form.setHomeAsUpIndicator(R.mipmap.ic_cross_white); - intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form); + return form; + } + + @Override + public void startFormActivity(JSONObject jsonForm) { + Intent intent = new Intent(this, Utils.metadata().familyFormActivity); + intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); + + + intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getFormConfig()); startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java index c27ac79f7f..cc93e824c9 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyRegisterActivity.java @@ -7,13 +7,20 @@ import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; +import com.vijay.jsonwizard.constants.JsonFormConstants; +import com.vijay.jsonwizard.domain.Form; + import org.apache.commons.lang3.StringUtils; +import org.json.JSONObject; +import org.smartregister.chw.core.R; import org.smartregister.chw.core.custom_views.NavigationMenu; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.family.activity.BaseFamilyRegisterActivity; import org.smartregister.family.model.BaseFamilyRegisterModel; import org.smartregister.family.presenter.BaseFamilyRegisterPresenter; +import org.smartregister.family.util.Constants; import org.smartregister.family.util.JsonFormUtils; +import org.smartregister.family.util.Utils; import org.smartregister.view.fragment.BaseRegisterFragment; public abstract class CoreFamilyRegisterActivity extends BaseFamilyRegisterActivity { @@ -54,6 +61,27 @@ protected void onResumption() { } } + public Form getFormConfig(){ + Form form = new Form(); + form.setName(getString(R.string.add_fam)); + form.setActionBarBackground(R.color.family_actionbar); + form.setNavigationBackground(R.color.family_navigation); + form.setHomeAsUpIndicator(R.mipmap.ic_cross_white); + form.setPreviousLabel(getResources().getString(R.string.back)); + return form; + } + + @Override + public void startFormActivity(JSONObject jsonForm) { + Intent intent = new Intent(this, Utils.metadata().familyFormActivity); + intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); + + + intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getFormConfig()); + + startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenu.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenu.java index 1ca91f6083..57d589ade3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenu.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/custom_views/FamilyFloatingMenu.java @@ -81,7 +81,7 @@ public void animateFAB() { activityMain.setBackgroundResource(R.color.transparent); fab.startAnimation(rotateBack); - fab.setImageResource(R.drawable.ic_edit_white); + fab.setImageResource(R.drawable.family_floating_fab_icon); callLayout.startAnimation(fabClose); addNewMember.startAnimation(fabClose); diff --git a/opensrp-chw-core/src/main/res/layout/view_family_floating_menu.xml b/opensrp-chw-core/src/main/res/layout/view_family_floating_menu.xml index 28cbb4cb8d..8bbacd16a6 100644 --- a/opensrp-chw-core/src/main/res/layout/view_family_floating_menu.xml +++ b/opensrp-chw-core/src/main/res/layout/view_family_floating_menu.xml @@ -18,7 +18,7 @@ android:tint="@android:color/white" app:backgroundTint="@color/text_black" app:fabSize="normal" - app:srcCompat="@drawable/ic_edit_white" /> + app:srcCompat="@drawable/family_floating_fab_icon" /> + + @drawable/ic_edit_white + From 402d114a0937e21f07330fb65eb6d7f5fb52a553 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Tue, 19 Oct 2021 12:25:30 +0300 Subject: [PATCH 08/11] Update native-forms to v1.14.5.5.1-SNAPSHOT --- opensrp-chw-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 2e57af8a52..6ca0403be4 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -143,7 +143,7 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } - api('org.smartregister:opensrp-client-native-form:1.14.5.5-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.5.5.1-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7' From e18d335eb6edbec8594578ab2eb8ed993bc1d623 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Mon, 25 Oct 2021 17:08:32 +0300 Subject: [PATCH 09/11] LMH1-64: allow set initial check state for vaccine --- .../src/main/res/layout/custom_vaccine_name_check.xml | 2 +- opensrp-chw-core/src/main/res/values/booleans.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 opensrp-chw-core/src/main/res/values/booleans.xml diff --git a/opensrp-chw-core/src/main/res/layout/custom_vaccine_name_check.xml b/opensrp-chw-core/src/main/res/layout/custom_vaccine_name_check.xml index 18d2bb741c..1a120474fa 100644 --- a/opensrp-chw-core/src/main/res/layout/custom_vaccine_name_check.xml +++ b/opensrp-chw-core/src/main/res/layout/custom_vaccine_name_check.xml @@ -13,7 +13,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="3dp" - android:checked="true" + android:checked="@bool/initial_vaccine_checked_state" android:clickable="true" /> + + true + From 5e5f5ab90c58690579bf5db3f6383bc4daa3f7ef Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Wed, 27 Oct 2021 16:24:18 +0300 Subject: [PATCH 10/11] LMH1-73: Allow config for form started in family profile Upgrade native forms to 1.14.5.5.2-TEST-SNAPSHOT [draft commit] Please edit --- opensrp-chw-core/build.gradle | 2 +- .../CoreAncMemberProfileActivity.java | 14 +++++++++++-- .../activity/CoreChildProfileActivity.java | 13 ++++++++++-- .../CoreFamilyOtherMemberProfileActivity.java | 13 +++++++----- .../activity/CoreFamilyProfileActivity.java | 20 +++++++++++++++++++ .../CorePncMemberProfileActivity.java | 14 +++++++++++-- .../chw/core/utils/CoreJsonFormUtils.java | 10 +++++++--- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 6ca0403be4..8cc289fb0c 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -143,7 +143,7 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } - api('org.smartregister:opensrp-client-native-form:1.14.5.5.1-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.5.5.2-TEST-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7' diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java index 843c3bfe6f..0580d6f3ac 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreAncMemberProfileActivity.java @@ -13,6 +13,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.vijay.jsonwizard.domain.Form; + import org.jeasy.rules.api.Rules; import org.joda.time.LocalDate; import org.joda.time.Months; @@ -109,9 +111,17 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { } } + public Form getForm(){ + Form form = new Form(); + form.setActionBarBackground(R.color.family_actionbar); + form.setWizard(false); + return form; + } + public void startFormActivity(JSONObject formJson) { - startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, formJson, - Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON); + startActivityForResult( + CoreJsonFormUtils.getJsonIntent(this, formJson,Utils.metadata().familyMemberFormActivity, getForm()), + JsonFormUtils.REQUEST_CODE_GET_JSON); } // to chw diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildProfileActivity.java index 4c8d5b97a2..08cc5cafc8 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreChildProfileActivity.java @@ -28,6 +28,7 @@ import androidx.viewpager.widget.ViewPager; import com.google.android.material.appbar.AppBarLayout; +import com.vijay.jsonwizard.domain.Form; import org.apache.commons.lang3.tuple.Triple; import org.jetbrains.annotations.NotNull; @@ -323,10 +324,18 @@ public Context getContext() { return this; } + public Form getForm(){ + Form form = new Form(); + form.setActionBarBackground(R.color.family_actionbar); + form.setWizard(false); + return form; + } + @Override public void startFormActivity(JSONObject jsonForm) { - startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, jsonForm, - Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON); + startActivityForResult( + CoreJsonFormUtils.getJsonIntent(this, jsonForm,Utils.metadata().familyMemberFormActivity, getForm()), + JsonFormUtils.REQUEST_CODE_GET_JSON); } @Override diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivity.java index da00022be2..9e7a34e7d2 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyOtherMemberProfileActivity.java @@ -213,16 +213,19 @@ protected abstract BaseProfileContract.Presenter getFamilyOtherMemberActivityPre protected abstract CoreFamilyMemberFloatingMenu getFamilyMemberFloatingMenu(); + public Form getForm(){ + Form form = new Form(); + form.setActionBarBackground(R.color.family_actionbar); + form.setWizard(false); + return form; + } + public void startFormActivity(JSONObject jsonForm) { Intent intent = new Intent(this, Utils.metadata().familyMemberFormActivity); intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); - - Form form = new Form(); - form.setActionBarBackground(R.color.family_actionbar); - form.setWizard(false); - intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form); + intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getForm()); startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON); } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivity.java index e6d2c22615..707f47e1cd 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CoreFamilyProfileActivity.java @@ -18,6 +18,9 @@ import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; +import com.vijay.jsonwizard.constants.JsonFormConstants; +import com.vijay.jsonwizard.domain.Form; + import org.apache.commons.lang3.StringUtils; import org.greenrobot.eventbus.EventBus; import org.json.JSONObject; @@ -278,6 +281,23 @@ public void updateHasPhone(boolean hasPhone) { } } + public Form getFormConfig(){ + Form form = new Form(); + form.setActionBarBackground(R.color.family_actionbar); + form.setWizard(false); + return form; + } + + @Override + public void startFormActivity(JSONObject jsonForm) { + Intent intent = new Intent(this, Utils.metadata().familyMemberFormActivity); + intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); + + intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getFormConfig()); + + startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON); + } + @Override protected void initializePresenter() { familyBaseEntityId = getIntent().getStringExtra(Constants.INTENT_KEY.FAMILY_BASE_ENTITY_ID); diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivity.java index 9ccb3b797b..f94f5ac3f1 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/CorePncMemberProfileActivity.java @@ -13,6 +13,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.vijay.jsonwizard.domain.Form; + import org.json.JSONObject; import org.smartregister.chw.anc.domain.MemberObject; import org.smartregister.chw.anc.util.NCUtils; @@ -101,10 +103,18 @@ protected static CommonPersonObjectClient getClientDetailsByBaseEntityID(@NonNul return getCommonPersonObjectClient(baseEntityId); } + public Form getForm(){ + Form form = new Form(); + form.setActionBarBackground(R.color.family_actionbar); + form.setWizard(false); + return form; + } + @Override public void startFormActivity(JSONObject formJson) { - startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, formJson, - org.smartregister.family.util.Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON); + startActivityForResult( + CoreJsonFormUtils.getJsonIntent(this, formJson,org.smartregister.family.util.Utils.metadata().familyMemberFormActivity, getForm()), + JsonFormUtils.REQUEST_CODE_GET_JSON); } protected List getChildren(MemberObject memberObject) { diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreJsonFormUtils.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreJsonFormUtils.java index e81bed6462..8f369b081e 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreJsonFormUtils.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/CoreJsonFormUtils.java @@ -76,12 +76,16 @@ public class CoreJsonFormUtils extends org.smartregister.family.util.JsonFormUti private static final String LOCATION_UUIDS = "location_uuids"; public static Intent getJsonIntent(Context context, JSONObject jsonForm, Class activityClass) { - Intent intent = new Intent(context, activityClass); - intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); Form form = new Form(); form.setActionBarBackground(R.color.family_actionbar); form.setWizard(false); - intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form); + return getJsonIntent(context, jsonForm, activityClass, form); + } + + public static Intent getJsonIntent(Context context, JSONObject jsonForm, Class activityClass, Form formConfig){ + Intent intent = new Intent(context, activityClass); + intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString()); + intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, formConfig); return intent; } From 1d2df2bd61b76b3610d488a5af3bd34ac772cb39 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Thu, 4 Nov 2021 10:13:26 +0300 Subject: [PATCH 11/11] Update native-forms to v1.14.5.5.2-SNAPSHOT --- opensrp-chw-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw-core/build.gradle b/opensrp-chw-core/build.gradle index 8cc289fb0c..21711e4a02 100644 --- a/opensrp-chw-core/build.gradle +++ b/opensrp-chw-core/build.gradle @@ -143,7 +143,7 @@ dependencies { exclude group: 'xpp3', module: 'xpp3' } - api('org.smartregister:opensrp-client-native-form:1.14.5.5.2-TEST-SNAPSHOT@aar') { + api('org.smartregister:opensrp-client-native-form:1.14.5.5.2-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'cardview-v7'