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
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -42,7 +40,6 @@ allprojects {

repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
maven { url 'https://maven.google.com' }
Expand All @@ -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/" }
}
}
Expand All @@ -68,7 +62,6 @@ configure(allprojects) { project ->
buildscript {
repositories {
google()
jcenter()
mavenCentral()
mavenLocal()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 10 additions & 2 deletions opensrp-chw-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ description = 'OpenSRP chw aggregated client library'
buildscript {
repositories {
google()
jcenter()
mavenLocal()
}

Expand Down Expand Up @@ -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') {
Expand All @@ -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') {
Expand All @@ -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') {
Expand All @@ -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') {
Expand All @@ -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') {
Expand All @@ -250,13 +254,15 @@ 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
exclude group: 'org.smartregister', module: 'opensrp-client-core'
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') {
Expand All @@ -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
Expand Down Expand Up @@ -348,4 +356,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 @@ -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.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());
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
});
}
}
Expand Down Expand Up @@ -289,7 +292,7 @@ private void registerNavigation(Activity parentActivity) {

List<NavigationOption> 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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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));
Expand All @@ -360,8 +373,7 @@ private void registerLanguageSwitcher(final Activity context) {
AlertDialog dialog = builder.create();
dialog.show();
});
}
else {
} else {
rlIconLang.setOnClickListener(null);
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -509,5 +521,9 @@ public interface Flavour {
String childNavigationMenuCountString();

Intent getHIA2ReportActivityIntent(Activity activity);

default AlertDialog doLogOutDialog(Activity activity){
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading