Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lmh multiple fixes #460

Merged
merged 11 commits into from
Nov 4, 2021
4 changes: 2 additions & 2 deletions opensrp-chw-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.2-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
Expand Down Expand Up @@ -348,4 +348,4 @@ task javadoc(type: Javadoc) {
source = files([mainSrc])
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CommonPersonObjectClient> getChildren(MemberObject memberObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,12 +28,18 @@ public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.My
private View.OnClickListener onClickListener;
private Context context;
private Map<String, Class> registeredActivities;
private DrawerLayout drawerLayout;

public NavigationAdapter(List<NavigationOption> navigationOptions, Activity context, Map<String, Class> registeredActivities) {
this(navigationOptions, context, registeredActivities, null);
}

public NavigationAdapter(List<NavigationOption> navigationOptions, Activity context, Map<String, Class> registeredActivities, DrawerLayout drawerLayout) {
this.navigationOptionList = navigationOptions;
this.context = context;
this.onClickListener = new NavigationListener(context, this);
this.registeredActivities = registeredActivities;
this.drawerLayout = drawerLayout;
}

public String getSelectedView() {
Expand All @@ -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.hasRegisterCount()) {
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());
Expand Down Expand Up @@ -98,7 +116,12 @@ 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading