This commit is contained in:
2023-07-28 21:52:37 +05:30
parent 78b2592d26
commit eca48d989f
24 changed files with 614 additions and 114 deletions

View File

@@ -30,11 +30,7 @@
android:name=".caregiverdashboard.CaregiverDashActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@@ -53,7 +49,11 @@
android:configChanges="orientation"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"

View File

@@ -23,12 +23,17 @@ import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderAdapter;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class ReminderFragment extends Fragment implements RecyclerTouchListener.OnSwipeOptionsClickListener,
ProfileContracts.GetRemindersListCallback, ProfileContracts.ReminderDeleteCallback {
ProfileContracts.GetRemindersListCallback, ProfileContracts.ReminderDeleteCallback,
ProfileContracts.AddReminderCallBack,
ReminderAdapter.ReminderCheckClickListener{
// view binding
protected RemindersFragmentBinding binding;
@@ -128,6 +133,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
binding.remindersRv.setLayoutManager(new LinearLayoutManager(requireContext()));
reminderAdapter = new ReminderAdapter();
reminderAdapter.setCheckClickListener(this);
binding.remindersRv.setAdapter(reminderAdapter);
recyclerTouchListener = new RecyclerTouchListener(requireActivity(), binding.remindersRv);
@@ -185,6 +191,7 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
dayViewHolder.day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
dayViewHolder.day.setText(reminderViewModel.getDayOfWeek(dayViewHolder.day_of_week - 1));
dayViewHolder.date.setText(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
dayViewHolder.mDate = calendar.getTime();
calendar.add(Calendar.DAY_OF_WEEK, 1);
}
@@ -238,6 +245,9 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
private void setDayOfWeek(int selection){
// setting selected date in adapter
reminderAdapter.setSelected_date(weekDayViewsList.get(selection).mDate);
clearSelection();
switch (reminderViewModel.selected_dow = selection){
@@ -378,4 +388,97 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
}
}
@Override
public void onReminderAdded(ReminderResult reminderDetails) {
progressDialog.dismiss();
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
}
@Override
public void onReminderAddFailed(Throwable t, String message) {
progressDialog.dismiss();
AppUtil.showAlert(requireContext(),
getString(R.string.something_went_wrong),
message,
getString(R.string.yes),
(dialog, which) -> {
dialog.dismiss();
}, null, null);
}
@Override
public void onCheck(ReminderResult reminderResult, int position) {
// is user checking only today's check
if (reminderResult.reminder_marked == null){
/*
now, we don't want to allow checking of routine of other day
*/
try {
int today_date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
int selected_date = Integer.parseInt(weekDayViewsList.get(reminderViewModel.selected_dow).date.getText().toString());
if (today_date == selected_date){
AppUtil.showAlert(requireContext(),
"Are you sure?",
"Do yuo want to check this routine?\nThis cannot be undone.",
getString(R.string.yes),
(dialog, which) -> {
dialog.dismiss();
updateRoutine(reminderResult, position);
}, getString(R.string.no),
(dialog, which) -> {
dialog.dismiss();
});
}else{
Toast.makeText(requireContext(), "Cannot done future routine.", Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
Toast.makeText(requireContext(), "Couldn't be done.", Toast.LENGTH_SHORT).show();
}
}
}
private void updateRoutine(ReminderResult reminderResult, int position) {
progressDialog.setTitle("Please wait...");
progressDialog.setMessage("saving your reminder");
progressDialog.setCancelable(false);
progressDialog.show();
Calendar current = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
reminderResult.patientRemainderId = reminderResult.id;
reminderResult.reminder_marked = sdf.format(current.getTime());
reminderResult.is_update = "1";
// need to change date format as backend accepts dd-MM-yyyy
// and responds as yyyy-dd-MM
SimpleDateFormat date_f1 = new SimpleDateFormat("yyyy-dd-MM", Locale.getDefault());
SimpleDateFormat date_f2 = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
String refill_date;
try {
Date date = date_f1.parse(reminderResult.medication_refill_date);
refill_date = date_f2.format(date);
}catch (Exception e){
refill_date = date_f2.format(Calendar.getInstance().getTime());
}
reminderResult.medication_refill_date = refill_date;
reminderViewModel.addReminder(
AppUtil.getPatientUid(requireContext()),
reminderResult,
"Bearer " + AppUtil.getUserToken(requireContext()),
this
);
}
}

View File

@@ -3,12 +3,17 @@ package com.ssb.simplitend.patientprofile.medreminder;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.Calendar;
import java.util.Date;
public class WeekDayViewHolder {
public LinearLayout card;
public TextView day, date;
public int day_of_week;
public Date mDate;
public WeekDayViewHolder() {
}

View File

@@ -2,6 +2,7 @@ package com.ssb.simplitend.patientprofile.medreminder.mvvm;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
@@ -11,10 +12,11 @@ import androidx.recyclerview.widget.RecyclerView;
import com.ssb.simplitend.R;
import com.ssb.simplitend.databinding.ReminderViewholderBinding;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Reminder;
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@@ -32,14 +34,30 @@ public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter
}
};
private ReminderCheckClickListener checkClickListener;
// static thing for selection status
public final boolean[] selection_state;
private volatile Date selected_date;
public ReminderAdapter(){
super(DIFF_CALLBACK);
this.selection_state = new boolean[2];
}
public void setCheckClickListener(ReminderCheckClickListener checkClickListener) {
this.checkClickListener = checkClickListener;
}
public void setSelected_date(Date selected_date) {
this.selected_date = selected_date;
}
public Date getSelected_date() {
return selected_date;
}
@NonNull
@Override
public ReminderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@@ -50,6 +68,11 @@ public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter
@Override
public void onBindViewHolder(@NonNull ReminderViewHolder holder, int position) {
holder.setReminder(getItem(position), position);
holder.binding.done.setOnClickListener(v -> {
if (checkClickListener != null) checkClickListener.onCheck(getItem(position), position);
});
}
public static class ReminderViewHolder extends RecyclerView.ViewHolder{
@@ -91,22 +114,69 @@ public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter
binding.medImg.setImageResource(R.drawable.img_med_type_2);
}
binding.done.setOnClickListener(v -> {
if (selection_state[position]){
// item selected. un-selecting now
binding.sideBar.setBackgroundTintList(null);
binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.white_bg));
binding.done.setImageResource(R.drawable.ic_done_accent);
}else{
// item un-selected. selecting now
binding.sideBar.setBackgroundTintList(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_primary));
binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_accent));
binding.done.setImageResource(R.drawable.ic_done_accent_2);
}
// binding.done.setOnClickListener(v -> {
// if (selection_state[position]){
// // item selected. un-selecting now
// binding.sideBar.setBackgroundTintList(null);
// binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.white_bg));
// binding.done.setImageResource(R.drawable.ic_done_accent);
// }else{
// // item un-selected. selecting now
// binding.sideBar.setBackgroundTintList(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_primary));
// binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_accent));
// binding.done.setImageResource(R.drawable.ic_done_accent_2);
// }
//
// selection_state[position] = !selection_state[position];
// });
selection_state[position] = !selection_state[position];
});
if (reminder.reminder_marked != null){
/*
This routine is done for some day.
New, checking if this routine done is done today or day before it
*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
try {
Date routine_date = sdf.parse(reminder.reminder_marked);
if (routine_date == null)
throw new Exception("Cannot parse routine marked date from Backend");
ReminderAdapter routineAdapter = (ReminderAdapter) getBindingAdapter();
if (routineAdapter == null) throw new Exception();
Date selected_date = routineAdapter.getSelected_date();
Calendar selected_calendar = Calendar.getInstance();
selected_calendar.setTime(selected_date);
Calendar routine_calendar = Calendar.getInstance();
routine_calendar.setTime(routine_date);
if (routine_calendar.get(Calendar.DAY_OF_MONTH) == selected_calendar.get(Calendar.DAY_OF_MONTH)){
// it is the same day on which routine is checked
// as routine done date is equal to selected_tab date
binding.sideBar.setBackgroundTintList(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_primary));
binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_accent));
binding.done.setImageResource(R.drawable.ic_done_accent_2);
}else{
// item selected. un-selecting now
binding.sideBar.setBackgroundTintList(null);
binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.white_bg));
binding.done.setImageResource(R.drawable.ic_done_accent);
}
} catch (Exception e) {
Toast.makeText(itemView.getContext(), "Couldn't mark it done.", Toast.LENGTH_SHORT).show();
}
}
}
}
public interface ReminderCheckClickListener{
void onCheck(ReminderResult reminderResult, int position);
}
}

View File

@@ -38,6 +38,8 @@ public class ReminderResult implements Serializable {
public ArrayList<MedicationType> medication_type;
public ArrayList<MedicationFrequency> medication_frequency;
public String reminder_marked;
public String is_update;
public ReminderResult(){}

View File

@@ -11,6 +11,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;
@@ -25,15 +26,26 @@ import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineViewModel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class RoutineFragment extends Fragment implements RoutineAdapter.ClickListener,
RoutineAdapter.DeleteClickListener,
RoutineAdapter.CheckClickListener,
ProfileContracts.GetRoutinesCallback,
ProfileContracts.RoutineDeleteCallback {
ProfileContracts.RoutineDeleteCallback,
ProfileContracts.AddNUpdateRoutineCallback {
private static final String TAG = "RoutineFragment";
// view binding
protected RoutineFragmentBinding binding;
@@ -124,6 +136,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
routineAdapter = new RoutineAdapter();
routineAdapter.setDeleteClickListener(this);
routineAdapter.setClickListener(this);
routineAdapter.setCheckClickListener(this);
binding.routineRv.setAdapter(routineAdapter);
Calendar calendar = Calendar.getInstance();
@@ -174,6 +187,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
dayViewHolder.day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
dayViewHolder.day.setText(routineViewModel.getDayOfWeek(dayViewHolder.day_of_week - 1));
dayViewHolder.date.setText(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
dayViewHolder.mDate = calendar.getTime();
calendar.add(Calendar.DAY_OF_WEEK, 1);
}
@@ -181,6 +195,9 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
private void setDayOfWeek(int selection){
// setting selected date in adapter
routineAdapter.setSelected_date(weekDayViewsList.get(selection).mDate);
clearSelection();
switch (routineViewModel.selected_dow = selection){
@@ -362,4 +379,84 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_routineFragment_to_addRoutineFragment, bundle);
}
@Override
public void onCheckClick(RoutineDetails routineDetails, int position) {
// is user checking only today's check
if (routineDetails.routine_marked == null){
/*
now, we don't want to allow checking of routine of other day
*/
try {
int today_date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
int selected_date = Integer.parseInt(weekDayViewsList.get(routineViewModel.selected_dow).date.getText().toString());
if (today_date == selected_date){
AppUtil.showAlert(requireContext(),
"Are you sure?",
"Do yuo want to check this routine?\nThis cannot be undone.",
getString(R.string.yes),
(dialog, which) -> {
dialog.dismiss();
updateRoutine(routineDetails, position);
}, getString(R.string.no),
(dialog, which) -> {
dialog.dismiss();
});
}else{
Toast.makeText(requireContext(), "Cannot done future routine.", Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
Toast.makeText(requireContext(), "Couldn't be done.", Toast.LENGTH_SHORT).show();
}
}
}
private void updateRoutine(RoutineDetails routine, int position) {
progressDialog.setTitle("Please wait...");
progressDialog.setMessage("saving your routine");
progressDialog.setCancelable(false);
progressDialog.show();
Calendar current = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
routine.patientRoutineId = routine.id;
routine.routine_marked = sdf.format(current.getTime());
routine.is_update = 1;
routineViewModel.addNUpdateRoutine(
AppUtil.getPatientUid(requireContext()),
routine,
"Bearer " + AppUtil.getUserToken(requireContext()),
this
);
}
@Override
public void onRoutineAdded(RoutineDetails medicationInfo) {
progressDialog.dismiss();
loadRoutineList(weekDayViewsList.get(routineViewModel.selected_dow).day_of_week);
}
@Override
public void onRoutineAddFailed(Throwable t, String message) {
progressDialog.dismiss();
AppUtil.showAlert(requireContext(),
getString(R.string.something_went_wrong),
message,
getString(R.string.yes),
(dialog, which) -> {
dialog.dismiss();
}, null, null);
}
}

View File

@@ -1,22 +1,28 @@
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;
import com.ssb.simplitend.R;
import com.ssb.simplitend.databinding.RoutineViewholderBinding;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;
public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.RoutineViewHolder> {
private static final String TAG = "RoutineAdapter";
private static final DiffUtil.ItemCallback<RoutineDetails> DIFF_UTIL = new DiffUtil.ItemCallback<RoutineDetails>() {
@Override
public boolean areItemsTheSame(@NonNull RoutineDetails oldItem, @NonNull RoutineDetails newItem) {
@@ -34,6 +40,10 @@ public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.R
private DeleteClickListener deleteClickListener;
private ClickListener clickListener;
private CheckClickListener checkClickListener;
private volatile Date selected_date;
public RoutineAdapter() {
super(DIFF_UTIL);
}
@@ -46,6 +56,18 @@ public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.R
this.clickListener = clickListener;
}
public void setCheckClickListener(CheckClickListener checkClickListener) {
this.checkClickListener = checkClickListener;
}
public void setSelected_date(Date selected_date) {
this.selected_date = selected_date;
}
public Date getSelected_date() {
return selected_date;
}
@NonNull
@Override
public RoutineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@@ -66,6 +88,11 @@ public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.R
if (clickListener != null) clickListener.onClick(getItem(position), position);
});
holder.binding.check.setOnClickListener(v -> {
if (checkClickListener != null)
checkClickListener.onCheckClick(getItem(position), position);
});
}
public static class RoutineViewHolder extends RecyclerView.ViewHolder {
@@ -110,6 +137,46 @@ public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.R
String end_slot = end_time.substring(0, 2) + " " + end_time.substring(end_time.length() - 2);
binding.endTimeStatic.setText(end_slot);
if (routine.routine_marked != null){
/*
This routine is done for some day.
New, checking if this routine done is done today or day before it
*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
try {
Date routine_date = sdf.parse(routine.routine_marked);
if (routine_date == null)
throw new Exception("Cannot parse routine marked date from Backend");
RoutineAdapter routineAdapter = (RoutineAdapter) getBindingAdapter();
if (routineAdapter == null) throw new Exception();
Date selected_date = routineAdapter.getSelected_date();
Calendar selected_calendar = Calendar.getInstance();
selected_calendar.setTime(selected_date);
Calendar routine_calendar = Calendar.getInstance();
routine_calendar.setTime(routine_date);
Log.d(TAG, "setData: " + routine_calendar.get(Calendar.DAY_OF_MONTH) + " " + selected_calendar.get(Calendar.DAY_OF_MONTH));
if (routine_calendar.get(Calendar.DAY_OF_MONTH) == selected_calendar.get(Calendar.DAY_OF_MONTH)){
// it is the same day on which routine is checked
// as routine done date is equal to selected_tab date
binding.check.setImageResource(R.drawable.ic_check_green);
}else{
binding.check.setImageResource(R.drawable.ic_un_check);
}
} catch (Exception e) {
Log.e(TAG, "setData: ", e);
Toast.makeText(itemView.getContext(), "Couldn't mark it done.", Toast.LENGTH_SHORT).show();
}
}
}
}
@@ -126,4 +193,9 @@ public class RoutineAdapter extends ListAdapter<RoutineDetails, RoutineAdapter.R
void onClick(RoutineDetails routineDetails, int position);
}
@FunctionalInterface
public interface CheckClickListener {
void onCheckClick(RoutineDetails routineDetails, int position);
}
}

View File

@@ -29,6 +29,8 @@ public class RoutineDetails implements Serializable {
public String created_at;
public String updated_at;
public String routine_marked;
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@@ -6,6 +6,9 @@ import androidx.lifecycle.ViewModel;
import com.ssb.simplitend.patientprofile.ProfileContracts;
import java.util.ArrayList;
import java.util.Map;
import okhttp3.RequestBody;
public class RoutineViewModel extends ViewModel {
@@ -43,6 +46,7 @@ public class RoutineViewModel extends ViewModel {
routinesRepository.deleteRoutine(patient_id, patient_routine_id, adapterPosition, token, deleteCallback);
}
public String getDayOfWeek(int position){
switch (position){
case 0:

View File

@@ -8,7 +8,9 @@ import com.ssb.simplitend.patientprofile.ProfileContracts;
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
import java.util.List;
import java.util.Map;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

View File

@@ -3,6 +3,8 @@ package com.ssb.simplitend.welcome.fragments;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
@@ -67,6 +69,25 @@ public class SignInFragment extends Fragment implements WelcomeContracts.Registe
binding.pin
);
binding.pin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() == 4){
AppUtil.closeKeyboard(requireActivity());
}
}
});
}
private void clickEvents() {

View File

@@ -7,6 +7,8 @@ import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.provider.ContactsContract;
import android.text.Editable;
import android.text.TextWatcher;
@@ -114,32 +116,38 @@ public class ContactListFragment extends Fragment{
// filters contact list w.r.t searchInput
private void filterContactList(String searchInput) {
if(searchInput.isEmpty()) {
contactListAdapter.submitList(contactList);
return;
}
new Thread(() -> {
ArrayList<Contact> filteredList = new ArrayList<>();
for (Contact contact: contactList){
if (contact.first_name != null && contact.first_name.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
}else if (contact.phone_number != null && contact.phone_number.trim().contains(searchInput)){
filteredList.add(contact);
}else if (contact.email_address != null && contact.email_address.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
}else if (contact.relationship != null && contact.relationship.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
if(searchInput.isEmpty()) {
contactListAdapter.submitList(contactList);
return;
}
}
if (filteredList.isEmpty()) {
Toast.makeText(requireContext(), "No match found", Toast.LENGTH_SHORT).show();
}
ArrayList<Contact> filteredList = new ArrayList<>();
contactListAdapter.submitList(filteredList);
for (Contact contact: contactList){
if (contact.first_name != null && contact.first_name.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
}else if (contact.phone_number != null && contact.phone_number.trim().contains(searchInput)){
filteredList.add(contact);
}else if (contact.email_address != null && contact.email_address.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
}else if (contact.relationship != null && contact.relationship.trim().toLowerCase().contains(searchInput)){
filteredList.add(contact);
}
}
binding.contactRv.smoothScrollToPosition(0);
if (filteredList.isEmpty()) {
new Handler(Looper.getMainLooper()).post(() -> {
Toast.makeText(requireContext(), "No match found", Toast.LENGTH_SHORT).show();
});
}
contactListAdapter.submitList(filteredList);
binding.contactRv.smoothScrollToPosition(0);
}).start();
}

View File

@@ -179,11 +179,9 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
InputFilter phoneFilter = (charSequence, i, i1, spanned, i2, i3) -> {
String phone_number_str = charSequence.toString();
String country_code;
String country_code = null;
if (binding.countryCodes.getSelectedIndex() == -2){
country_code = "+1";
}else{
if (binding.countryCodes.getSelectedIndex() != -1){
country_code = countryCodeList.get(binding.countryCodes.getSelectedIndex());
}
@@ -197,11 +195,13 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
// nothing
}
if (!countryCodeList.contains(country_code)){
if (country_code != null && !countryCodeList.contains(country_code)){
countryCodeList.add(country_code);
}
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(country_code));
if (country_code != null){
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(country_code));
}
if (phone_number_str.length() > 10){
// pasted number length is greater than 10
@@ -324,11 +324,6 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
binding.name.setError("Required");
}
if (binding.relationship.getText().toString().trim().isEmpty()) {
allOkay = false;
binding.relationship.setError("Required");
}
if (binding.phoneNumber.getText().toString().trim().isEmpty()) {
allOkay = false;
binding.phoneNumber.setError("Required");
@@ -443,6 +438,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
}
private void setDetails() {
if (contactData.contact_photo != null)
{
Glide.with(requireContext())
@@ -461,11 +457,20 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
// there is a country code
int index = countryCodeList.indexOf(code_phone[0]);
if (index >= 0) binding.countryCodes.selectItemByIndex(index);
else binding.countryCodes.clearSelectedItem();
int i;
if (index >= 0) {
// country code exits
binding.countryCodes.selectItemByIndex(index);
i = 1;
} else {
// country code doesn't exits
i = 0;
binding.countryCodes.clearSelectedItem();
}
contactData.phone_number = "";
for (int i = 1; i < code_phone.length; i++) {
for (; i < code_phone.length; i++) {
contactData.phone_number = contactData.phone_number.concat(code_phone[i]);
}
} else {

View File

@@ -4,6 +4,8 @@ import static com.ssb.simplitend.welcome.fragments.forgotpin.ForgotPinFragment.E
import android.app.ProgressDialog;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -85,6 +87,44 @@ public class ChangePinFragment extends Fragment implements WelcomeContracts.Upda
binding.pin,
binding.confirmPin
);
binding.pin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() == 4){
binding.confirmPin.requestFocus();
}
}
});
binding.confirmPin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() == 4){
AppUtil.closeKeyboard(requireActivity());
}
}
});
}
private void clickEvents() {

View File

@@ -2,6 +2,8 @@ package com.ssb.simplitend.welcome.fragments.register;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -57,6 +59,44 @@ public class CreatePinFragment extends Fragment implements WelcomeContracts.Regi
loadPinsSavedState();
progressDialog = new ProgressDialog(requireContext());
binding.pin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() == 4){
binding.confirmPin.requestFocus();
}
}
});
binding.confirmPin.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().length() == 4){
AppUtil.closeKeyboard(requireActivity());
}
}
});
}
private void loadPinsSavedState() {

View File

@@ -105,8 +105,6 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
viewModel = new ViewModelProvider(requireActivity()).get(WelcomeViewModel.class);
Log.d(TAG, "onCreateView: " + viewModel.getPatientData());
initViews();
clickEvents();
@@ -181,7 +179,7 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
currentLocation = new LatLng(lat, lng);
}else{
// default current location // washington DC
currentLocation = new LatLng(0, 0);
currentLocation = new LatLng(40.75796541422796, -73.98557368665934);
}
if (patientData.address_line1 != null){

View File

@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#16A53F"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/>
</vector>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="@dimen/_50sdp"
android:height="@dimen/_50sdp"
android:drawable="@drawable/ic_white_bg"
/>
<item
android:width="@dimen/_38sdp"
android:height="@dimen/_38sdp"
android:drawable="@drawable/ic_accent_bg"
android:gravity="center"
/>
</layer-list>

View File

@@ -2,14 +2,14 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="70dp"
android:height="70dp"
android:width="@dimen/_60sdp"
android:height="@dimen/_60sdp"
android:drawable="@drawable/ic_white_bg"
/>
<item
android:width="50dp"
android:height="50dp"
android:width="@dimen/_40sdp"
android:height="@dimen/_40sdp"
android:drawable="@drawable/ic_accent_bg"
android:gravity="center"

View File

@@ -73,7 +73,7 @@
android:background="@color/color_accent"
android:contentDescription="@string/how_to_setup"
android:layout_marginVertical="15dp"/>
android:layout_marginVertical="@dimen/_20sdp"/>
</LinearLayout>
@@ -151,7 +151,7 @@
android:contentDescription="@string/how_to_setup"
android:layout_marginVertical="15dp"/>
android:layout_marginVertical="@dimen/_20sdp"/>
</LinearLayout>
@@ -226,7 +226,7 @@
android:background="@color/color_accent"
android:contentDescription="@string/how_to_setup"
android:layout_marginVertical="15dp"/>
android:layout_marginVertical="@dimen/_20sdp"/>
</LinearLayout>

View File

@@ -48,8 +48,8 @@
android:orientation="vertical">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
@@ -58,10 +58,10 @@
<View
android:layout_width="3dp"
android:layout_height="15dp"
android:layout_height="@dimen/_20sdp"
android:background="@color/color_accent"
android:layout_marginVertical="5dp"
android:layout_marginVertical="@dimen/_5sdp"
/>
@@ -73,10 +73,10 @@
android:text="@string/personal_information"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="15dp"
android:layout_marginVertical="17dp"
/>
@@ -100,8 +100,8 @@
android:orientation="vertical">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
@@ -111,10 +111,12 @@
<View
android:layout_width="3dp"
android:layout_height="15dp"
android:layout_height="@dimen/_20sdp"
android:background="@color/color_accent"
android:layout_marginVertical="5dp"/>
android:layout_marginVertical="@dimen/_5sdp"
/>
</LinearLayout>
@@ -124,10 +126,10 @@
android:text="@string/family_and_friends_contacts"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="15dp"
android:layout_marginVertical="17dp"
/>
@@ -152,26 +154,28 @@
<ImageView
android:id="@+id/med_reminder_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
android:background="@drawable/ic_setup_bg"
android:background="@drawable/ic_progress_bg"
app:srcCompat="@drawable/ic_timer"
app:tint="@color/color_primary"
android:padding="25dp"
android:padding="15dp"
/>
<View
android:layout_width="3dp"
android:layout_height="15dp"
android:layout_height="@dimen/_20sdp"
android:background="@color/color_accent"
android:layout_marginVertical="5dp"/>
android:layout_marginVertical="@dimen/_5sdp"
/>
</LinearLayout>
@@ -181,10 +185,10 @@
android:text="@string/medication_reminder"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="25dp"
android:layout_marginVertical="17dp"
/>
@@ -209,26 +213,28 @@
<ImageView
android:id="@+id/med_info_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
android:background="@drawable/ic_setup_bg"
android:background="@drawable/ic_progress_bg"
app:srcCompat="@drawable/ic_medic"
app:tint="@color/color_primary"
android:padding="25dp"
android:padding="18dp"
/>
<View
android:layout_width="3dp"
android:layout_height="15dp"
android:layout_height="@dimen/_20sdp"
android:background="@color/color_accent"
android:layout_marginVertical="5dp"/>
android:layout_marginVertical="@dimen/_5sdp"
/>
</LinearLayout>
@@ -238,10 +244,10 @@
android:text="@string/medical_information"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="25dp"
android:layout_marginVertical="17dp"
/>
@@ -266,26 +272,28 @@
<ImageView
android:id="@+id/setup_routine_img"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
android:background="@drawable/ic_setup_bg"
android:background="@drawable/ic_progress_bg"
app:srcCompat="@drawable/ic_calender"
app:tint="@color/color_primary"
android:padding="25dp"
android:padding="16dp"
/>
<View
android:layout_width="3dp"
android:layout_height="15dp"
android:layout_height="@dimen/_20sdp"
android:background="@color/color_accent"
android:layout_marginVertical="5dp"/>
android:layout_marginVertical="@dimen/_5sdp"
/>
</LinearLayout>
@@ -295,10 +303,10 @@
android:text="@string/setup_routine"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="25dp"
android:layout_marginVertical="17dp"
/>
@@ -322,17 +330,17 @@
<ImageView
android:id="@+id/freq_apps"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_width="@dimen/_50sdp"
android:layout_height="@dimen/_50sdp"
android:gravity="center"
android:background="@drawable/ic_setup_bg"
android:background="@drawable/ic_progress_bg"
app:srcCompat="@drawable/ic_apps"
app:tint="@color/color_primary"
android:padding="25dp"
android:padding="18dp"
/>
@@ -344,10 +352,10 @@
android:text="@string/frequently_used_apps"
android:fontFamily="@font/nunito_semibold"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black"
android:layout_marginVertical="25dp"
android:layout_marginVertical="17dp"
/>

View File

@@ -128,13 +128,13 @@
<ImageView
android:id="@+id/check"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
android:layout_weight="1"
android:contentDescription="@string/delete"
app:srcCompat="@drawable/ic_check"
app:tint="@color/black"
app:srcCompat="@drawable/ic_un_check"
app:tint="@android:color/black"
android:padding="5dp"

View File

@@ -81,7 +81,7 @@
<string name="save">Save</string>
<string name="change_photo">Change photo</string>
<string name="add_photo">Add photo</string>
<string name="relationship">Relationship*</string>
<string name="relationship">Relationship</string>
<string name="relationship_">Relationship</string>
<string name="make_current_contact_as_a_caregiver">Make current contact as a caregiver</string>
<string name="make_current_contact_as_in_case_of_emergency_contact_sos">Make current contact as In Case Of Emergency Contact (SOS)</string>
@@ -116,7 +116,7 @@
<string name="take_your_time_and_finish_your_profile_add_contacts_reminders_and_so_on">Take your time and finish your profile, add contacts, reminders and so on.</string>
<string name="lets_complete_nthe_rest_of_your_profile">Lets complete\nthe rest of your profile</string>
<string name="personal_information">Personal information</string>
<string name="family_and_friends_contacts">Family and friends contacts</string>
<string name="family_and_friends_contacts">Family &amp; friends contacts</string>
<string name="medication_reminder">Medication Reminder</string>
<string name="medical_information">Medical Information</string>
<string name="setup_routine">Setup routine</string>