Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into #8-implement-malari…
Browse files Browse the repository at this point in the history
…a-profile-page

# Conflicts:
#	opensrp-chw-malaria/src/main/res/values/strings.xml
  • Loading branch information
whoisladleo committed May 29, 2019
2 parents eb23731 + 2bbebc5 commit 3c9aca8
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.MenuRes;
import android.support.design.bottomnavigation.LabelVisibilityMode;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.Menu;
Expand All @@ -17,9 +19,12 @@
import org.smartregister.Context;
import org.smartregister.chw.malaria.contract.MalariaRegisterContract;
import org.smartregister.chw.malaria.fragment.BaseMalariaRegisterFragment;
import org.smartregister.chw.malaria.listener.MalariaBottomNavigationListener;
import org.smartregister.chw.malaria.model.BaseMalariaRegisterModel;
import org.smartregister.chw.malaria.presenter.BaseMalariaRegisterPresenter;
import org.smartregister.chw.malaria.util.Constants;
import org.smartregister.helper.BottomNavigationHelper;
import org.smartregister.listener.BottomNavigationListener;
import org.smartregister.malaria.R;
import org.smartregister.view.activity.BaseRegisterActivity;
import org.smartregister.view.fragment.BaseRegisterFragment;
Expand Down Expand Up @@ -113,7 +118,33 @@ public String getRegisterEventType() {
*/
@Override
protected void registerBottomNavigation() {
// implement BottomNavigation
bottomNavigationHelper = new BottomNavigationHelper();
bottomNavigationView = findViewById(org.smartregister.R.id.bottom_navigation);

if (bottomNavigationView != null) {
bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
bottomNavigationView.getMenu().removeItem(R.id.action_clients);
bottomNavigationView.getMenu().removeItem(R.id.action_register);
bottomNavigationView.getMenu().removeItem(R.id.action_search);
bottomNavigationView.getMenu().removeItem(R.id.action_library);

bottomNavigationView.inflateMenu(getMenuResource());

bottomNavigationHelper.disableShiftMode(bottomNavigationView);

BottomNavigationListener familyBottomNavigationListener = getBottomNavigation(this);
bottomNavigationView.setOnNavigationItemSelectedListener(familyBottomNavigationListener);

}
}

@MenuRes
public int getMenuResource() {
return R.menu.bottom_nav_family_menu;
}

public BottomNavigationListener getBottomNavigation(Activity activity) {
return new MalariaBottomNavigationListener(activity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package org.smartregister.chw.malaria.fragment;

import android.widget.ImageView;
import android.widget.TextView;

import org.smartregister.chw.malaria.contract.MalariaRegisterFragmentContract;
import org.smartregister.chw.malaria.model.BaseMalariaRegisterFragmentModel;
import org.smartregister.chw.malaria.presenter.BaseMalariaRegisterFragmentPresenter;
import org.smartregister.chw.malaria.provider.MalariaRegisterProvider;
import org.smartregister.commonregistry.CommonPersonObjectClient;
import org.smartregister.configurableviews.model.View;
import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter;
import org.smartregister.malaria.R;
import org.smartregister.view.customcontrols.CustomFontTextView;
import org.smartregister.view.customcontrols.FontVariant;
import org.smartregister.view.fragment.BaseRegisterFragment;

import java.util.HashMap;
Expand All @@ -26,6 +32,45 @@ public void initializeAdapter(Set<View> visibleColumns) {
}
}

@Override
public void setupViews(android.view.View view) {
super.setupViews(view);

// Update top left icon
qrCodeScanImageView = view.findViewById(R.id.scanQrCode);
if (qrCodeScanImageView != null) {
qrCodeScanImageView.setVisibility(android.view.View.GONE);
}

// Update Search bar
android.view.View searchBarLayout = view.findViewById(R.id.search_bar_layout);
searchBarLayout.setBackgroundResource(R.color.customAppThemeBlue);

if (getSearchView() != null) {
getSearchView().setBackgroundResource(R.color.white);
getSearchView().setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_action_search, 0, 0, 0);
}

// Update sort filter
TextView filterView = view.findViewById(R.id.filter_text_view);
if (filterView != null) {
filterView.setText(getString(R.string.sort));
}

// Update title name
ImageView logo = view.findViewById(R.id.opensrp_logo_image_view);
if (logo != null) {
logo.setVisibility(android.view.View.GONE);
}

CustomFontTextView titleView = view.findViewById(R.id.txt_title_label);
if (titleView != null) {
titleView.setVisibility(android.view.View.VISIBLE);
titleView.setText(getString(R.string.malaria));
titleView.setFontVariant(FontVariant.REGULAR);
}
}

@Override
public MalariaRegisterFragmentContract.Presenter presenter() {
return (MalariaRegisterFragmentContract.Presenter) presenter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.smartregister.chw.malaria.listener;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.view.MenuItem;

import org.smartregister.listener.BottomNavigationListener;
import org.smartregister.malaria.R;
import org.smartregister.view.activity.BaseRegisterActivity;

public class MalariaBottomNavigationListener extends BottomNavigationListener {
private Activity context;

public MalariaBottomNavigationListener(Activity context) {
super(context);
this.context = context;
}

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
super.onNavigationItemSelected(item);

BaseRegisterActivity baseRegisterActivity = (BaseRegisterActivity) context;

if (item.getItemId() == R.id.action_family) {
baseRegisterActivity.switchToBaseFragment();
} else if (item.getItemId() == R.id.action_scan_qr) {
baseRegisterActivity.startQrCodeScanner();
}

return true;
}
}
29 changes: 29 additions & 0 deletions opensrp-chw-malaria/src/main/res/menu/bottom_nav_family_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_family"
android:enabled="true"
android:icon="@mipmap/ic_home"
android:title="@string/home"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_scan_qr"
android:enabled="true"
android:icon="@mipmap/ic_scan_qr"
android:title="@string/scan_qr"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_register"
android:enabled="true"
android:icon="@mipmap/ic_add_family"
android:title="@string/add_family"
app:showAsAction="ifRoom" />

<item
android:id="@+id/action_job_aids"
android:enabled="true"
android:icon="@mipmap/ic_jobaids"
android:title="@string/job_aids"
app:showAsAction="ifRoom" />
</menu>
14 changes: 11 additions & 3 deletions opensrp-chw-malaria/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<string name="app_name">malaria</string>
<string name="error_unable_to_start_form">An error occurred when starting the form</string>
<string name="any_changes_you_make">Any changes you have made will be lost</string>
<string name="home">Home</string>
<string name="scan_qr">Scan QR</string>
<string name="register_client">Register</string>
<string name="job_aids">job_aids</string>
<string name="no_unique_id">No unique IDs found</string>
<string name="profile_menu">Profile Menu</string>
<string name="return_to_profile">Return to Profile</string>
Expand All @@ -14,4 +11,15 @@
<string name="go_to_family_s_profile">go to family profile</string>
<string name="family_has_nothing_due">has nothing due</string>
<string name="record_visit">Record malaria follow up</string>
<string name="malaria">Malaria</string>

<!-- menu -->
<string name="add_member">Add Member</string>
<string name="sort">Sort</string>
<string name="home">Home</string>
<string name="add_family">Add family</string>
<string name="scan_qr">Scan QR</string>
<string name="job_aids">Job Aids</string>


</resources>

0 comments on commit 3c9aca8

Please sign in to comment.