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

AC-620: Make UI more consistent #607

Merged
merged 1 commit into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added openmrs-client/src/main/ic_birthday-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added openmrs-client/src/main/ic_call-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added openmrs-client/src/main/ic_female-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added openmrs-client/src/main/ic_home_location-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added openmrs-client/src/main/ic_male-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ActiveVisitsRecyclerViewAdapter(Context context, List<Visit> items) {
@NonNull
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored name and Formatted using AS

@Override
public VisitViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.find_visits_row, parent, false);
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_find_visits, parent, false);
FontsUtil.setFont((ViewGroup) itemView);
return new VisitViewHolder(itemView);
}
Expand All @@ -71,11 +71,9 @@ public void onBindViewHolder(@NonNull VisitViewHolder visitViewHolder, final int
if (null != patient.getGender()) {
visitViewHolder.mGender.setText(patient.getGender());
}
try{
try {
visitViewHolder.mBirthDate.setText(DateUtils.convertTime(DateUtils.convertTime(patient.getBirthdate())));
}
catch (Exception e)
{
} catch (Exception e) {
visitViewHolder.mBirthDate.setText(" ");
}

Expand All @@ -96,7 +94,7 @@ public int getItemCount() {
return mVisits.size();
}

class VisitViewHolder extends RecyclerView.ViewHolder{
class VisitViewHolder extends RecyclerView.ViewHolder {
private TextView mIdentifier;
private TextView mDisplayName;
private TextView mGender;
Expand All @@ -113,6 +111,7 @@ public VisitViewHolder(View itemView) {
mBirthDate = (TextView) itemView.findViewById(R.id.findVisitsPatientBirthDate);
mGender = (TextView) itemView.findViewById(R.id.findVisitsPatientGender);
}

public void clearAnimation() {
mRelativeLayout.clearAnimation();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored name and formatted using AS

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import rx.android.schedulers.AndroidSchedulers;

public class SimilarPatientsRecyclerViewAdapter extends RecyclerView.Adapter<SimilarPatientsRecyclerViewAdapter.PatientViewHolder>{
public class SimilarPatientsRecyclerViewAdapter extends RecyclerView.Adapter<SimilarPatientsRecyclerViewAdapter.PatientViewHolder> {

private List<Patient> patientList;
private Patient newPatient;
Expand All @@ -56,7 +57,7 @@ public SimilarPatientsRecyclerViewAdapter(Activity mContext, List<Patient> patie
@NonNull
@Override
public PatientViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.similar_patient_row, parent, false);
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_similar_patient, parent, false);
FontsUtil.setFont((ViewGroup) itemView);
return new PatientViewHolder(itemView);
}
Expand Down Expand Up @@ -90,7 +91,7 @@ public int getItemCount() {
return patientList.size();
}

public class PatientViewHolder extends RecyclerView.ViewHolder{
public class PatientViewHolder extends RecyclerView.ViewHolder {

private LinearLayout mRowLayout;
private TextView mGivenName;
Expand All @@ -102,6 +103,7 @@ public class PatientViewHolder extends RecyclerView.ViewHolder{
private TextView mPostalCode;
private TextView mCity;
private TextView mCountry;

public PatientViewHolder(View itemView) {
super(itemView);
mRowLayout = (LinearLayout) itemView;
Expand All @@ -117,6 +119,7 @@ public PatientViewHolder(View itemView) {
}

}

private void downloadPatient(Patient patient) {
new PatientDAO().savePatient(patient)
.observeOn(AndroidSchedulers.mainThread())
Expand All @@ -127,14 +130,12 @@ private void downloadPatient(Patient patient) {
}

private void setBirthdate(PatientViewHolder holder, Patient patient) {
try{
try {
holder.mBirthDate.setText(DateUtils.convertTime(DateUtils.convertTime(patient.getBirthdate())));
if (Objects.equal(patient.getBirthdate(), newPatient.getBirthdate())) {
setStyleForMatchedPatientFields(holder.mBirthDate);
}
}
catch (Exception e)
{
} catch (Exception e) {
holder.mBirthDate.setText(" ");
}
}
Expand All @@ -143,7 +144,8 @@ private void setGender(PatientViewHolder holder, Patient patient) {
if (null != patient.getGender()) {
holder.mGender.setText(patient.getGender());
if (Objects.equal(patient.getGender(), newPatient.getGender())) {
setStyleForMatchedPatientFields(holder.mGender); }
setStyleForMatchedPatientFields(holder.mGender);
}
}
}

Expand Down Expand Up @@ -195,8 +197,8 @@ private void setPatientName(PatientViewHolder holder, Patient patient) {
}
}

private void setStyleForMatchedPatientFields(TextView textView){
textView.setTypeface(null , Typeface.BOLD);
private void setStyleForMatchedPatientFields(TextView textView) {
textView.setTypeface(null, Typeface.BOLD);
textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored name and formatted using AS

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import rx.android.schedulers.AndroidSchedulers;

public class FormEntryPatientListAdapter extends RecyclerView.Adapter<FormEntryPatientListAdapter.PatientViewHolder> {
Expand All @@ -46,7 +47,7 @@ public FormEntryPatientListAdapter(FormEntryPatientListFragment context, List<Pa
@NonNull
@Override
public PatientViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.patient_details_row, parent, false);
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_patient_details, parent, false);
FontsUtil.setFont((ViewGroup) itemView);
return new PatientViewHolder(itemView);
}
Expand Down Expand Up @@ -97,7 +98,7 @@ public int getItemCount() {
return mItems.size();
}

class PatientViewHolder extends RecyclerView.ViewHolder{
class PatientViewHolder extends RecyclerView.ViewHolder {
private LinearLayout mRowLayout;
private TextView mIdentifier;
private TextView mDisplayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored name and formatted using AS

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import rx.android.schedulers.AndroidSchedulers;

class LastViewedPatientRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Expand Down Expand Up @@ -78,21 +79,21 @@ public void setSelectedPatientPositions(Set<Integer> selectedPatientPositions) {
this.selectedPatientPositions = selectedPatientPositions;
}

public void addPatients(List<Patient> patients){
public void addPatients(List<Patient> patients) {
this.patients.addAll(patients);
notifyDataSetChanged();
}

public void deleteLastItem(){
patients.remove(getItemCount()-1);
public void deleteLastItem() {
patients.remove(getItemCount() - 1);
notifyItemRemoved(getItemCount());
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if( viewType == VIEW_TYPE_ITEM ) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.find_last_viewed_patients_row, parent, false);
if (viewType == VIEW_TYPE_ITEM) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_find_last_viewed_patients, parent, false);
FontsUtil.setFont((ViewGroup) itemView);
return new PatientViewHolder(itemView);
} else {
Expand Down Expand Up @@ -130,8 +131,8 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
((PatientViewHolder) holder).mBirthDate.setText(" ");
}

if (null != ((PatientViewHolder) holder).mAvailableOfflineCheckbox) {
setUpCheckBoxLogic( ((PatientViewHolder) holder), patient);
if (null != ((PatientViewHolder) holder).mAvailableOfflineCheckbox) {
setUpCheckBoxLogic(((PatientViewHolder) holder), patient);
}
} else {
((ProgressBarViewHolder) holder).progressBar.setIndeterminate(true);
Expand All @@ -140,7 +141,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi

private boolean isPatientSelected(int position) {
for (Integer selectedPatientPosition : selectedPatientPositions) {
if(selectedPatientPosition.equals(position)){
if (selectedPatientPosition.equals(position)) {
return true;
}
}
Expand All @@ -160,7 +161,7 @@ public int getItemCount() {
return patients == null ? 0 : patients.size();
}

class PatientViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener{
class PatientViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnClickListener {
private LinearLayout mRowLayout;
private TextView mIdentifier;
private TextView mDisplayName;
Expand All @@ -186,13 +187,13 @@ public void clearAnimation() {

@Override
public void onClick(View view) {
if(isLongClicked){
if (isLongClicked) {
setSelected(!mRowLayout.isSelected());
}
}

private void setSelected(boolean select) {
if(select){
if (select) {
if (!enableDownload)
toggleDownloadButton();
selectedPatientPositions.add(getAdapterPosition());
Expand Down Expand Up @@ -225,20 +226,20 @@ class ProgressBarViewHolder extends RecyclerView.ViewHolder {

public ProgressBarViewHolder(View itemView) {
super(itemView);
progressBar = (ProgressBar)itemView.findViewById(R.id.recycleviewProgressbar);
progressBar = (ProgressBar) itemView.findViewById(R.id.recycleviewProgressbar);
}
}

private void removeIdFromSelectedIds(Integer position) {
Set<Integer> newSet = new HashSet<>();
for (Integer selectedPatientsId : selectedPatientPositions) {
if(!selectedPatientsId.equals(position)){
if (!selectedPatientsId.equals(position)) {
newSet.add(selectedPatientsId);
}
}
selectedPatientPositions = newSet;
if (selectedPatientPositions.size() == 0 && isLongClicked && enableDownload)
toggleDownloadButton();
toggleDownloadButton();
}

private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
Expand Down Expand Up @@ -285,7 +286,7 @@ public void onDestroyActionMode(ActionMode mode) {
isLongClicked = false;
}

public void finish(ActionMode mode){
public void finish(ActionMode mode) {
mode.finish();
isLongClicked = false;
}
Expand All @@ -296,15 +297,15 @@ public void startActionMode() {
isLongClicked = true;
}

public void finishActionMode(){
public void finishActionMode() {
if (actionMode != null) {
actionMode.finish();
isLongClicked = false;
}
}

public void selectAll() {
for(int i = 0; i < patients.size(); i++){
for (int i = 0; i < patients.size(); i++) {
selectedPatientPositions.add(i);
}
isAllSelected = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import androidx.core.content.ContextCompat;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored name and formatted using AS

import androidx.recyclerview.widget.RecyclerView;

public class MergePatientsRecycleViewAdapter extends RecyclerView.Adapter<MergePatientsRecycleViewAdapter.PatientViewHolder>{
public class MergePatientsRecycleViewAdapter extends RecyclerView.Adapter<MergePatientsRecycleViewAdapter.PatientViewHolder> {

private List<Patient> patientList;
private Patient newPatient;
Expand All @@ -56,7 +56,7 @@ public MergePatientsRecycleViewAdapter(Activity mContext, MatchingPatientsContra
@NonNull
@Override
public PatientViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.similar_patient_row, parent, false);
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_similar_patient, parent, false);
FontsUtil.setFont((ViewGroup) itemView);
return new PatientViewHolder(itemView);
}
Expand All @@ -76,7 +76,7 @@ public int getItemCount() {
return patientList.size();
}

public class PatientViewHolder extends RecyclerView.ViewHolder{
public class PatientViewHolder extends RecyclerView.ViewHolder {

private TextView mGivenName;
private TextView mMiddleName;
Expand All @@ -87,6 +87,7 @@ public class PatientViewHolder extends RecyclerView.ViewHolder{
private TextView mPostalCode;
private TextView mCity;
private TextView mCountry;

public PatientViewHolder(View itemView) {
super(itemView);
mGivenName = (TextView) itemView.findViewById(R.id.patientGivenName);
Expand All @@ -99,12 +100,12 @@ public PatientViewHolder(View itemView) {
mCity = (TextView) itemView.findViewById(R.id.patientCity);
mCountry = (TextView) itemView.findViewById(R.id.patientCountry);
itemView.setOnClickListener(view -> {
CardView cardView = (CardView)view.findViewById(R.id.cardView);
CardView cardView = (CardView) view.findViewById(R.id.cardView);
if (selectedPosition == -1) {
selectedPosition = getAdapterPosition();
mPresenter.setSelectedPatient(patientList.get(selectedPosition));
cardView.setCardBackgroundColor(ContextCompat.getColor(mContext, R.color.patient_selected_highlight));
} else if(selectedPosition == getAdapterPosition()){
} else if (selectedPosition == getAdapterPosition()) {
selectedPosition = -1;
mPresenter.removeSelectedPatient();
cardView.setCardBackgroundColor(Color.WHITE);
Expand All @@ -117,14 +118,12 @@ public PatientViewHolder(View itemView) {
}

private void setBirthdate(PatientViewHolder holder, Patient patient) {
try{
try {
holder.mBirthDate.setText(DateUtils.convertTime(DateUtils.convertTime(patient.getBirthdate())));
if (Objects.equal(patient.getBirthdate(), newPatient.getBirthdate())) {
setStyleForMatchedPatientFields(holder.mBirthDate);
}
}
catch (Exception e)
{
} catch (Exception e) {
holder.mBirthDate.setText(" ");
}
}
Expand All @@ -133,7 +132,8 @@ private void setGender(PatientViewHolder holder, Patient patient) {
if (null != patient.getGender()) {
holder.mGender.setText(patient.getGender());
if (Objects.equal(patient.getGender(), newPatient.getGender())) {
setStyleForMatchedPatientFields(holder.mGender); }
setStyleForMatchedPatientFields(holder.mGender);
}
}
}

Expand Down Expand Up @@ -185,8 +185,8 @@ private void setPatientName(PatientViewHolder holder, Patient patient) {
}
}

private void setStyleForMatchedPatientFields(TextView textView){
textView.setTypeface(null , Typeface.BOLD);
private void setStyleForMatchedPatientFields(TextView textView) {
textView.setTypeface(null, Typeface.BOLD);
textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
}
Loading