Skip to content

Commit

Permalink
LMH1-58: update adding family members to be intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
LZRS committed Oct 18, 2021
1 parent 58b0693 commit b62ec38
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean showChildrenUnder5() {

@Override
public boolean launchChildClientsAtLogin() {
return true;
return false;
}

@Override
Expand Down Expand Up @@ -175,4 +175,24 @@ public boolean showReportsDescription() {
public boolean showReportsDivider() {
return true;
}

@Override
public boolean hideChildRegisterPreviousNextIcons() {
return true;
}

@Override
public boolean hideFamilyRegisterPreviousNextIcons() {
return true;
}

@Override
public boolean showFamilyRegisterNextInToolbar() {
return true;
}

@Override
public boolean onFamilySaveGoToProfile() {
return true;
}
}
4 changes: 4 additions & 0 deletions opensrp-chw/src/lmh/res/values/drawables.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="family_floating_fab_icon" type="drawable">@drawable/ic_input_add</item>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import android.content.Intent;

import com.vijay.jsonwizard.domain.Form;

import org.json.JSONObject;
import org.smartregister.chw.anc.util.Constants;
import org.smartregister.chw.application.ChwApplication;
import org.smartregister.chw.core.activity.CoreChildRegisterActivity;
import org.smartregister.chw.core.contract.CoreChildRegisterContract;
import org.smartregister.chw.core.utils.CoreConstants;
Expand Down Expand Up @@ -49,4 +52,14 @@ protected void onActivityResultExtended(int requestCode, int resultCode, Intent
}
}
}

@Override
public Form getFormConfig() {
Form currentConfig = super.getFormConfig();
if (ChwApplication.getApplicationFlavor().hideChildRegisterPreviousNextIcons()){
currentConfig.setHideNextIcon(true);
currentConfig.setHidePreviousIcon(true);
}
return currentConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import android.view.View;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.vijay.jsonwizard.domain.Form;

import org.smartregister.chw.R;
import org.smartregister.chw.application.ChwApplication;
import org.smartregister.chw.core.activity.CoreFamilyRegisterActivity;
import org.smartregister.chw.core.custom_views.NavigationMenu;
import org.smartregister.chw.fragment.FamilyRegisterFragment;
import org.smartregister.chw.listener.ChwBottomNavigationListener;
import org.smartregister.chw.presenter.FamilyRegisterPresenter;
import org.smartregister.chw.util.Constants;
import org.smartregister.chw.util.Utils;
import org.smartregister.family.model.BaseFamilyRegisterModel;
import org.smartregister.helper.BottomNavigationHelper;
import org.smartregister.view.fragment.BaseRegisterFragment;

Expand All @@ -35,6 +39,11 @@ public static void registerBottomNavigation(
}
}

@Override
protected void initializePresenter() {
this.presenter = new FamilyRegisterPresenter(this, new BaseFamilyRegisterModel());
}

@Override
protected void registerBottomNavigation() {
super.registerBottomNavigation();
Expand All @@ -57,4 +66,20 @@ protected void onCreate(Bundle savedInstanceState) {
protected BaseRegisterFragment getRegisterFragment() {
return new FamilyRegisterFragment();
}


@Override
public Form getFormConfig() {
Form currentConfig = super.getFormConfig();
if (ChwApplication.getApplicationFlavor().hideFamilyRegisterPreviousNextIcons()){
currentConfig.setHidePreviousIcon(true);
currentConfig.setHideNextIcon(true);
}
if (ChwApplication.getApplicationFlavor().showFamilyRegisterNextInToolbar()){
currentConfig.setHideNextButton(true);
currentConfig.setNextLabel(getString(R.string.next));
currentConfig.setShowNextInToolbarWhenWizard(true);
}
return currentConfig;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ public interface Flavor {

boolean showReportsDivider();

boolean hideChildRegisterPreviousNextIcons();

boolean hideFamilyRegisterPreviousNextIcons();

boolean showFamilyRegisterNextInToolbar();

boolean onFamilySaveGoToProfile();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,22 @@ public boolean showReportsDescription() {
public boolean showReportsDivider() {
return false;
}

public boolean hideChildRegisterPreviousNextIcons(){
return false;
}

public boolean hideFamilyRegisterPreviousNextIcons(){
return false;
}

@Override
public boolean showFamilyRegisterNextInToolbar() {
return false;
}

@Override
public boolean onFamilySaveGoToProfile() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.smartregister.chw.presenter;

import android.content.Intent;

import org.smartregister.chw.application.ChwApplication;
import org.smartregister.chw.interactor.FamilyProfileInteractor;
import org.smartregister.domain.FetchStatus;
import org.smartregister.family.contract.FamilyRegisterContract;
import org.smartregister.family.domain.FamilyEventClient;
import org.smartregister.family.presenter.BaseFamilyRegisterPresenter;
import org.smartregister.family.util.Constants;
import org.smartregister.family.util.Utils;
import org.smartregister.view.contract.BaseRegisterContract;

import java.util.List;

public class FamilyRegisterPresenter extends BaseFamilyRegisterPresenter {
public FamilyRegisterPresenter(FamilyRegisterContract.View view, FamilyRegisterContract.Model model) {
super(view, model);
}

@Override
public void onRegistrationSaved(boolean isEditMode, boolean isSaved, List<FamilyEventClient> familyEventClientList) {
if (ChwApplication.getApplicationFlavor().onFamilySaveGoToProfile()){
BaseRegisterContract.View view = viewReference == null? null : viewReference.get();
if (view != null && view.getContext() != null) {
// view.refreshList(FetchStatus.fetched);

FamilyEventClient familyEventClient = familyEventClientList.get(0);
FamilyEventClient headEventClient = familyEventClientList.get(1);
Intent intent = new Intent(view.getContext(), Utils.metadata().profileActivity);
intent.putExtra(Constants.INTENT_KEY.FAMILY_BASE_ENTITY_ID, familyEventClient.getClient().getBaseEntityId());
// intent.putExtra("family_head", Utils.getValue(patient.getColumnmaps(), "family_head", false));
// intent.putExtra("primary_caregiver", Utils.getValue(patient.getColumnmaps(), "primary_caregiver", false));
// intent.putExtra("village_town", Utils.getValue(patient.getColumnmaps(), "village_town", false));
// intent.putExtra("family_name", Utils.getValue(patient.getColumnmaps(), "first_name", false));
// intent.putExtra("go_to_due_page", goToDuePage);
view.getContext().startActivity(intent);
view.hideProgressDialog();
}
}else{
super.onRegistrationSaved(isEditMode, isSaved, familyEventClientList);
}
}
}

0 comments on commit b62ec38

Please sign in to comment.