Skip to content

Commit

Permalink
AC-627: Change color of Dashboard icons (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak140596 authored and f4ww4z committed Jul 30, 2019
1 parent 222d206 commit 5fe4a36
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.openmrs.mobile.activities.syncedpatients.SyncedPatientsActivity;
import org.openmrs.mobile.utilities.FontsUtil;
import org.openmrs.mobile.utilities.ImageUtils;
import org.openmrs.mobile.utilities.ThemeUtils;

public class DashboardFragment extends ACBaseFragment<DashboardContract.Presenter> implements DashboardContract.View, View.OnClickListener {

Expand All @@ -52,6 +53,7 @@ public class DashboardFragment extends ACBaseFragment<DashboardContract.Presente
private ImageView mRegistryPatientButton;
private ImageView mActiveVisitsButton;
private ImageView mCaptureVitalsButton;
private ImageView mProviderManagementButton;
private RelativeLayout mFindPatientView;
private RelativeLayout mRegistryPatientView;
private RelativeLayout mActiveVisitsView;
Expand Down Expand Up @@ -228,6 +230,7 @@ private void initFragmentFields(View root) {
mRegistryPatientButton = root.findViewById(R.id.registryPatientButton);
mActiveVisitsButton = root.findViewById(R.id.activeVisitsButton);
mCaptureVitalsButton = root.findViewById(R.id.captureVitalsButton);
mProviderManagementButton = root.findViewById(R.id.dashboardProviderManagementButton);
mFindPatientView = root.findViewById(R.id.findPatientView);
mRegistryPatientView = root.findViewById(R.id.registryPatientView);
mCaptureVitalsView = root.findViewById(R.id.captureVitalsView);
Expand Down Expand Up @@ -260,6 +263,10 @@ public void bindDrawableResources() {
bindDrawableResource(mRegistryPatientButton, R.drawable.ico_registry);
bindDrawableResource(mActiveVisitsButton, R.drawable.ico_visits);
bindDrawableResource(mCaptureVitalsButton, R.drawable.ico_vitals);

if (ThemeUtils.isDarkModeActivated()) {
changeColorOfDashboardIcons();
}
}

/**
Expand Down Expand Up @@ -333,4 +340,14 @@ public void onClick(View v) {
break;
}
}

private void changeColorOfDashboardIcons() {
final int greenColorResId = R.color.green;
ImageUtils.changeImageViewTint(getContext(), mActiveVisitsButton, greenColorResId);
ImageUtils.changeImageViewTint(getContext(), mCaptureVitalsButton, greenColorResId);
ImageUtils.changeImageViewTint(getContext(), mFindPatientButton, greenColorResId);
ImageUtils.changeImageViewTint(getContext(), mRegistryPatientButton, greenColorResId);
ImageUtils.changeImageViewTint(getContext(), mProviderManagementButton, greenColorResId);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.widget.ImageView;

import androidx.core.content.ContextCompat;
import androidx.core.widget.ImageViewCompat;

import org.openmrs.mobile.R;
import org.openmrs.mobile.activities.patientdashboard.details.PatientPhotoActivity;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -94,4 +100,9 @@ public static void showPatientPhoto(Context context, Bitmap photo, String patien
intent.putExtra("name", patientName);
context.startActivity(intent);
}

public static void changeImageViewTint(Context context, ImageView imageView, int color) {
ImageViewCompat.setImageTintList(imageView, ColorStateList.valueOf(ContextCompat.getColor(context, color)));

}
}

0 comments on commit 5fe4a36

Please sign in to comment.