.
This commit is contained in:
@@ -2,12 +2,8 @@ package com.ssb.simplitend.apputils;
|
||||
|
||||
import com.ssb.simplitend.BuildConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@@ -17,16 +13,11 @@ public abstract class RetrofitHelper {
|
||||
// urls
|
||||
public static final String BASE_URL = "https://simplitend.betadelivery.com/";
|
||||
|
||||
public static final String REGISTER_PATIENT = "api/auth/patient-register";
|
||||
|
||||
public static final String GET_CONTACT_LIST = "api/patients-contact-list";
|
||||
|
||||
public static final String CREATE_CONTACT = "api/contact-create";
|
||||
|
||||
public static final String UPDATE_CONTACT = "api/patient-contact-update/";
|
||||
|
||||
// util functions
|
||||
|
||||
private static Retrofit retrofit;
|
||||
|
||||
public static synchronized Retrofit getRetrofit(){
|
||||
@@ -47,8 +38,8 @@ public abstract class RetrofitHelper {
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
builder.addInterceptor(interceptor);
|
||||
|
||||
}
|
||||
|
||||
retrofit = new Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ChatListFragment extends Fragment implements ChatListAdapter.OnChat
|
||||
|
||||
private void initViews() {
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(ChatListViewModel.class);
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(ChatListViewModel.class);
|
||||
|
||||
binding.chatsRv.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
binding.chatsRv.setAdapter(viewModel.getChatListAdapter());
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
package com.ssb.simplitend.medreminder;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.AddReminderFragmentBinding;
|
||||
import com.ssb.simplitend.medreminder.mvvm.Reminder;
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.Contact;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AddReminderFragment extends Fragment implements CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
// view binding
|
||||
protected AddReminderFragmentBinding binding;
|
||||
|
||||
/*
|
||||
week day selection states
|
||||
true -> selected
|
||||
false -> un-selected
|
||||
*/
|
||||
boolean[] week_state;
|
||||
|
||||
// arguments keys
|
||||
public static final String REMINDER_KEY = "reminder_key";
|
||||
|
||||
// model
|
||||
private Reminder reminder;
|
||||
|
||||
public AddReminderFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddReminderFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.getTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime();
|
||||
});
|
||||
|
||||
binding.getDate.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getDate();
|
||||
});
|
||||
|
||||
binding.addReminder.setOnClickListener(v -> {
|
||||
if (reminder == null){
|
||||
Navigation.findNavController(v).popBackStack(R.id.reminderFragment, false, true);
|
||||
}else{
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(v).popBackStack(R.id.reminderFragment, false, true);
|
||||
});
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initViews() {
|
||||
|
||||
// checking if intent to EDIT or ADD reminder
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) setLayoutDetails(reminder = (Reminder) bundle.getSerializable(REMINDER_KEY));
|
||||
|
||||
// scrolling instruction edit text
|
||||
binding.instructions.setOnTouchListener((v, event) -> {
|
||||
if (binding.instructions.hasFocus()) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_SCROLL) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// load into spinner
|
||||
loadMedType();
|
||||
loadFrequency();
|
||||
|
||||
setUpWeekSelection();
|
||||
|
||||
binding.everydayCheck.setOnCheckedChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
private void setLayoutDetails(Reminder reminder){
|
||||
if (reminder != null){
|
||||
// intent is to edit the reminder
|
||||
binding.title.setText(getString(R.string.edit_reminder));
|
||||
binding.medicName.setText(reminder.dosage_name);
|
||||
binding.quantity.setText(reminder.quantity);
|
||||
binding.getTime.setText(reminder.time);
|
||||
|
||||
binding.addReminder.setText(getString(R.string.save_reminder));
|
||||
}
|
||||
}
|
||||
|
||||
// every-dau toggle listener
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
setSelectionState(i, week_state[i] = isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
// set selection and un-selection of week day
|
||||
private void setUpWeekSelection() {
|
||||
|
||||
week_state = new boolean[7];
|
||||
|
||||
// week day selections
|
||||
binding.sun.setOnClickListener(v -> setSelectionState(0, week_state[0] = !week_state[0]));
|
||||
binding.mon.setOnClickListener(v -> setSelectionState(1, week_state[1] = !week_state[1]));
|
||||
binding.tue.setOnClickListener(v -> setSelectionState(2, week_state[2] = !week_state[2]));
|
||||
binding.wed.setOnClickListener(v -> setSelectionState(3, week_state[3] = !week_state[3]));
|
||||
binding.thu.setOnClickListener(v -> setSelectionState(4, week_state[4] = !week_state[4]));
|
||||
binding.fri.setOnClickListener(v -> setSelectionState(5, week_state[5] = !week_state[5]));
|
||||
binding.sat.setOnClickListener(v -> setSelectionState(6, week_state[6] = !week_state[6]));
|
||||
|
||||
}
|
||||
|
||||
private void setSelectionState(int position, boolean selection) {
|
||||
if (selection) {
|
||||
// selection has to be made
|
||||
switch (position) {
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.sun.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.mon.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.tue.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.wed.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.thu.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.fri.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.sat.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// un-selection has to be made
|
||||
switch (position) {
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundTintList(null);
|
||||
binding.sun.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundTintList(null);
|
||||
binding.mon.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundTintList(null);
|
||||
binding.tue.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundTintList(null);
|
||||
binding.wed.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundTintList(null);
|
||||
binding.thu.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundTintList(null);
|
||||
binding.fri.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundTintList(null);
|
||||
binding.sat.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// checking if all days are selected or not
|
||||
// thus, updating the Everyday switch accordingly
|
||||
boolean isEveryDay = true;
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (!week_state[i]) {
|
||||
// some day is not selected thus not everyday selection
|
||||
isEveryDay = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
binding.everydayCheck.setOnCheckedChangeListener(null);
|
||||
binding.everydayCheck.setChecked(isEveryDay);
|
||||
binding.everydayCheck.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
// shows date picker to pick date and set to tv
|
||||
private void getDate() {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
DatePickerDialog dpd = new DatePickerDialog(requireContext());
|
||||
|
||||
dpd.setOnDateSetListener((view, year, month, dayOfMonth) -> {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, year);
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
binding.getDate.setText(selected_time);
|
||||
|
||||
});
|
||||
|
||||
dpd.show();
|
||||
}
|
||||
|
||||
// TODO: 05-07-2023 for lower version
|
||||
|
||||
}
|
||||
|
||||
// shows time picker to pick time and set to textview
|
||||
private void getTime() {
|
||||
|
||||
Calendar calendar = Calendar.getInstance(Locale.getDefault());
|
||||
|
||||
TimePickerDialog tpd = new TimePickerDialog(requireContext(),
|
||||
(TimePickerDialog.OnTimeSetListener) (view, hourOfDay, minute) -> {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
cal.set(Calendar.MINUTE, minute);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
binding.getTime.setText(selected_time);
|
||||
|
||||
}, calendar.getTime().getHours(), calendar.getTime().getMinutes(), false);
|
||||
|
||||
tpd.show();
|
||||
|
||||
}
|
||||
|
||||
// loading freq. into its resp. spinner
|
||||
private void loadFrequency() {
|
||||
|
||||
// static data
|
||||
ArrayList<String> medTypeList = new ArrayList<>();
|
||||
medTypeList.add("1 time, Daily");
|
||||
medTypeList.add("2 time, Daily");
|
||||
medTypeList.add("3 time, Daily");
|
||||
|
||||
binding.frequencySpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.frequencySpinner.setItems(medTypeList);
|
||||
|
||||
binding.frequencySpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
binding.frequencySpinner.setIsFocusable(true);
|
||||
|
||||
}
|
||||
|
||||
// loads med types into its resp. apinner
|
||||
private void loadMedType() {
|
||||
|
||||
// static data
|
||||
ArrayList<String> medTypeList = new ArrayList<>();
|
||||
medTypeList.add("Lorem ipsum");
|
||||
medTypeList.add("Lorem ipsum");
|
||||
medTypeList.add("Lorem ipsum");
|
||||
|
||||
binding.medicationsSpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.medicationsSpinner.setItems(medTypeList);
|
||||
|
||||
binding.medicationsSpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
binding.medicationsSpinner.setIsFocusable(true);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
package com.ssb.simplitend.medreminder;
|
||||
|
||||
import static com.ssb.simplitend.medreminder.AddReminderFragment.REMINDER_KEY;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.databinding.RemindersFragmentBinding;
|
||||
import com.ssb.simplitend.medreminder.mvvm.Reminder;
|
||||
import com.ssb.simplitend.medreminder.mvvm.ReminderViewModel;
|
||||
|
||||
public class ReminderFragment extends Fragment implements RecyclerTouchListener.OnSwipeOptionsClickListener {
|
||||
|
||||
// view binding
|
||||
protected RemindersFragmentBinding binding;
|
||||
|
||||
// reminders viewmodel
|
||||
protected ReminderViewModel reminderViewModel;
|
||||
|
||||
// recycler touch listener for swipe menu
|
||||
protected RecyclerTouchListener recyclerTouchListener;
|
||||
|
||||
// selection state for week days
|
||||
/*
|
||||
true -> date selected
|
||||
false -> date unselected
|
||||
*/
|
||||
private boolean[] selection_state;
|
||||
private static final String SELECTION_STATE_KEY = "selection_state";
|
||||
|
||||
public ReminderFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RemindersFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews(savedInstanceState);
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBooleanArray(SELECTION_STATE_KEY, selection_state);
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
// date selections
|
||||
binding.sun.setOnClickListener(v -> {
|
||||
setSelectionState(0, selection_state[0] = !selection_state[0]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.mon.setOnClickListener(v -> {
|
||||
setSelectionState(1, selection_state[1] = !selection_state[1]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.tue.setOnClickListener(v -> {
|
||||
setSelectionState(2, selection_state[2] = !selection_state[2]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.wed.setOnClickListener(v -> {
|
||||
setSelectionState(3, selection_state[3] = !selection_state[3]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.thu.setOnClickListener(v -> {
|
||||
setSelectionState(4, selection_state[4] = !selection_state[4]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.fri.setOnClickListener(v -> {
|
||||
setSelectionState(5, selection_state[5] = !selection_state[5]);
|
||||
loadReminderList();
|
||||
});
|
||||
binding.sat.setOnClickListener(v -> {
|
||||
setSelectionState(6, selection_state[6] = !selection_state[6]);
|
||||
loadReminderList();
|
||||
});
|
||||
|
||||
// add button
|
||||
binding.addReminder.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_reminderFragment_to_addReminderFragment)
|
||||
);
|
||||
|
||||
binding.done.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
ProfileProgress.PROFILE_PROGRESS[0] = true;
|
||||
});
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
Reminder reminder = new Reminder("Vitamin D3", "05:00 PM", "5 Capsules");
|
||||
|
||||
bundle.putSerializable(REMINDER_KEY, reminder);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadReminderList(){
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.remindersRv.setVisibility(View.VISIBLE);
|
||||
reminderViewModel.getReminderAdapter().submitList(reminderViewModel.getRemindersList());
|
||||
|
||||
// static
|
||||
binding.done.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
private void initViews(Bundle savedInstanceState) {
|
||||
|
||||
if (savedInstanceState != null){
|
||||
selection_state = savedInstanceState.getBooleanArray(SELECTION_STATE_KEY);
|
||||
|
||||
for (int i = 0; i < selection_state.length; i++) {
|
||||
setSelectionState(i, selection_state[i]);
|
||||
}
|
||||
|
||||
}else{
|
||||
selection_state = new boolean[7];
|
||||
}
|
||||
|
||||
reminderViewModel = new ViewModelProvider(this).get(ReminderViewModel.class);
|
||||
|
||||
binding.remindersRv.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
binding.remindersRv.setAdapter(reminderViewModel.getReminderAdapter());
|
||||
|
||||
recyclerTouchListener = new RecyclerTouchListener(requireActivity(), binding.remindersRv);
|
||||
|
||||
recyclerTouchListener.setSwipeOptionViews(R.id.reminder_edit, R.id.reminder_delete)
|
||||
.setSwipeable(R.id.rowFG, R.id.rowBG, this);
|
||||
|
||||
binding.remindersRv.addOnItemTouchListener(recyclerTouchListener);
|
||||
|
||||
}
|
||||
|
||||
private void setSelectionState(int position, boolean selection){
|
||||
if (selection){
|
||||
switch (position){
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.sunT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sunT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.monT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.monT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.tue1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.tue2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.wed1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.wed2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.thu1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.thu2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.fri1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.fri2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.sat1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sat2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch (position){
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sunT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.sunT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.monT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.monT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.tue1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.tue2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.wed1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.wed2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.thu1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.thu2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.fri1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.fri2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.sat1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.sat2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// swipe option menu click listener for reminder list
|
||||
@Override
|
||||
public void onSwipeOptionClicked(int viewID, int position) {
|
||||
if (viewID == R.id.reminder_delete){
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.delete_med_reminder),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v -> {
|
||||
// yes button clicked
|
||||
Toast.makeText(requireContext(), "Delete " + position, Toast.LENGTH_SHORT).show();
|
||||
}, v -> {
|
||||
// no button clicked
|
||||
});
|
||||
|
||||
}else if (viewID == R.id.reminder_edit){
|
||||
Bundle bundle = new Bundle();
|
||||
Reminder reminder = reminderViewModel.getRemindersList().get(position);
|
||||
|
||||
bundle.putSerializable(REMINDER_KEY, reminder);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.ssb.simplitend.medreminder.mvvm;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ReminderViewModel extends ViewModel {
|
||||
|
||||
private final ArrayList<Reminder> remindersList;
|
||||
|
||||
// reminder list adapter
|
||||
private final ReminderAdapter reminderAdapter;
|
||||
|
||||
public ReminderViewModel(){
|
||||
// fetch reminder list
|
||||
|
||||
reminderAdapter = new ReminderAdapter();
|
||||
|
||||
// static for now
|
||||
// TODO: 06-07-2023
|
||||
|
||||
remindersList = new ArrayList<>();
|
||||
remindersList.add(new Reminder("Vitamin D3", "02:00 pm", "2 capsules"));
|
||||
remindersList.add(new Reminder("Sinupret", "09:00 pm", "1 capsules"));
|
||||
}
|
||||
|
||||
public ArrayList<Reminder> getRemindersList() {
|
||||
return remindersList;
|
||||
}
|
||||
|
||||
public ReminderAdapter getReminderAdapter() {
|
||||
return reminderAdapter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Reminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
import retrofit2.http.Path;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface PatientProfileAPIService {
|
||||
|
||||
@GET("api/patient-reminder-list/{id}")
|
||||
Call<CallResponse<List<ReminderResult>>> getRemindersList(@Path("id") int patient_id,
|
||||
@Query("weekday") int week_day,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@POST("api/patient-reminder-store/{id}")
|
||||
Call<CallResponse<ReminderResult>> addReminder(@Path("id") int patient_id,
|
||||
@Body ReminderResult reminder,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@GET("api/master-frequency-types")
|
||||
Call<CallResponse<FreqNMedTypeResult>> getFreqNMedTypes(@Header("Authorization") String token);
|
||||
|
||||
@POST("api/patient-reminder-delete")
|
||||
Call<CallResponse<List<Void>>> deleteReminder(@Header("patientId") int patient_id,
|
||||
@Header("patientReminderId") int patient_reminder_id,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProfileContracts {
|
||||
|
||||
|
||||
interface GetRemindersListCallback {
|
||||
void onRemindersListFetched(List<ReminderResult> reminderResult);
|
||||
|
||||
void onFetchRemindersListFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface AddReminderCallBack {
|
||||
void onReminderAdded(ReminderResult reminderDetails);
|
||||
|
||||
void onReminderAddFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface FreqNMedTypesCallback{
|
||||
void onFreqNMedTypeLoaded(FreqNMedTypeResult result);
|
||||
|
||||
void onFreqNMedTypeLoadFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface ReminderDeleteCallback{
|
||||
void onReminderDeleted(int adapterPostion);
|
||||
|
||||
void onReminderDeleteFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.userprofile;
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -29,6 +29,9 @@ public class ProfileProgressFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ProfileProgressFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
// binding.medReminderImg.setImageResource(0);
|
||||
// binding.medReminderImg.setBackgroundResource(R.drawable.ic_done);
|
||||
|
||||
initProgress();
|
||||
|
||||
clickEvents();
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medicalinfo;
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -13,7 +13,7 @@ import androidx.navigation.Navigation;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.medicalinfo.mvvm.MedicalInfo;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfo;
|
||||
import com.ssb.simplitend.databinding.AddMedicalInfoBinding;
|
||||
|
||||
public class AddMedicalInfoFragment extends Fragment {
|
||||
@@ -1,6 +1,4 @@
|
||||
package com.ssb.simplitend.medicalinfo;
|
||||
|
||||
import static com.ssb.simplitend.medicalinfo.AddMedicalInfoFragment.MEDICAL_INFO_KEY;
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -14,8 +12,8 @@ import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.medicalinfo.mvvm.MedicalInfo;
|
||||
import com.ssb.simplitend.databinding.MedicalIntoFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.medicalinfo.mvvm.MedicalInfo;
|
||||
|
||||
public class MedicalInfoFragment extends Fragment {
|
||||
|
||||
@@ -67,7 +65,7 @@ public class MedicalInfoFragment extends Fragment {
|
||||
MedicalInfo medicalInfo = new MedicalInfo("Cognitive impairment and memeory loss.",
|
||||
"Dr. Sandeep Kanojia", "+63456398456", "Baycrest Health Sciences",
|
||||
"Latex allergy", "Lorum ipsum dummy is simple dummy");
|
||||
bundle.putSerializable(MEDICAL_INFO_KEY, medicalInfo);
|
||||
bundle.putSerializable(AddMedicalInfoFragment.MEDICAL_INFO_KEY, medicalInfo);
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_medicalInfoFragment_to_addMedicalInfoFragment, bundle);
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medicalinfo.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.medicalinfo.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -0,0 +1,615 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.skydoves.powerspinner.OnSpinnerItemSelectedListener;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.AddReminderFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Frequency;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.MedicationType;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AddReminderFragment extends Fragment implements CompoundButton.OnCheckedChangeListener,
|
||||
ProfileContracts.FreqNMedTypesCallback,
|
||||
ProfileContracts.AddReminderCallBack {
|
||||
|
||||
private static final String TAG = "AddReminderFragment";
|
||||
|
||||
// view binding
|
||||
protected AddReminderFragmentBinding binding;
|
||||
|
||||
/*
|
||||
week day selection states
|
||||
true -> selected
|
||||
false -> un-selected
|
||||
*/
|
||||
boolean[] week_state;
|
||||
|
||||
// arguments keys
|
||||
public static final String REMINDER_KEY = "reminder_key";
|
||||
|
||||
// model
|
||||
private ReminderResult reminder;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private ReminderViewModel viewModel;
|
||||
|
||||
private ArrayList<Frequency> frequencyList;
|
||||
private ArrayList<MedicationType> medicationTypeList;
|
||||
|
||||
public AddReminderFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddReminderFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(ReminderViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.getTime.setOnClickListener(v -> {
|
||||
binding.getTime.setError(null);
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime();
|
||||
});
|
||||
|
||||
binding.getDate.setOnClickListener(v -> {
|
||||
binding.getDate.setError(null);
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getDate();
|
||||
});
|
||||
|
||||
// TODO: 20-07-2023 remove
|
||||
binding.getDate.setOnLongClickListener(v -> {
|
||||
binding.getDate.setText("20-07-2023");
|
||||
return false;
|
||||
});
|
||||
|
||||
binding.addReminder.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
if (allOkay()) {
|
||||
adReminder();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void adReminder() {
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we save your reminder.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
ReminderResult reminderResult = new ReminderResult();
|
||||
|
||||
reminderResult.medicine_name = binding.medicName.getText().toString().trim();
|
||||
reminderResult.dosage = binding.dosage.getText().toString();
|
||||
|
||||
try {
|
||||
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(binding.frequencySpinner.getSelectedIndex()).id);
|
||||
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(binding.medicationsSpinner.getSelectedIndex()).id);
|
||||
} catch (Exception e) {
|
||||
reminderResult.medication_frequency_xid = String.valueOf(frequencyList.get(0).id);
|
||||
reminderResult.medication_type_xid = String.valueOf(medicationTypeList.get(0).id);
|
||||
}
|
||||
|
||||
// saving the actual format of time i.e. HH:mm:ss as hint
|
||||
// and saving the formatted time as text i.e. hh:mm a
|
||||
reminderResult.time1 = binding.getTime.getHint().toString();
|
||||
|
||||
reminderResult.medication_quantity = binding.quantity.getText().toString();
|
||||
reminderResult.medication_refill_date = binding.getDate.getText().toString();
|
||||
reminderResult.medication_instruction = binding.instructions.getText().toString().trim();
|
||||
|
||||
reminderResult.sun = week_state[0] ? "1" : "0";
|
||||
reminderResult.mon = week_state[1] ? "1" : "0";
|
||||
reminderResult.tue = week_state[2] ? "1" : "0";
|
||||
reminderResult.wed = week_state[3] ? "1" : "0";
|
||||
reminderResult.thu = week_state[4] ? "1" : "0";
|
||||
reminderResult.fri = week_state[5] ? "1" : "0";
|
||||
reminderResult.sat = week_state[6] ? "1" : "0";
|
||||
|
||||
if (reminder != null) {
|
||||
// this intent is to update the reminder
|
||||
reminderResult.is_update = "1";
|
||||
reminderResult.patientRemainderId = reminder.id;
|
||||
} else {
|
||||
reminderResult.is_update = "0";
|
||||
}
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
viewModel.addReminder(AppUtil.getPatientUid(requireContext()),
|
||||
reminderResult,
|
||||
token,
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
frequencyList = new ArrayList<>();
|
||||
|
||||
medicationTypeList = new ArrayList<>();
|
||||
|
||||
// scrolling instruction edit text
|
||||
binding.instructions.setOnTouchListener((v, event) -> {
|
||||
if (binding.instructions.hasFocus()) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_SCROLL) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
binding.frequencySpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
binding.frequencySpinner.setIsFocusable(true);
|
||||
binding.frequencySpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.medicationsSpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
binding.medicationsSpinner.setIsFocusable(true);
|
||||
binding.medicationsSpinner.setLifecycleOwner(this);
|
||||
|
||||
binding.frequencySpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener<String>) (i, s, i1, item) -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
binding.frequencySpinner.setError(null);
|
||||
});
|
||||
|
||||
binding.medicationsSpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener<String>) (i, s, i1, item) -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
binding.medicationsSpinner.setError(null);
|
||||
});
|
||||
|
||||
// load into spinner
|
||||
loadFreqNMedType();
|
||||
|
||||
setUpWeekSelection();
|
||||
|
||||
binding.everydayCheck.setOnCheckedChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.medicName.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.medicName.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.dosage.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.dosage.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.frequencySpinner.getSelectedIndex() == -1) {
|
||||
allOkay = false;
|
||||
binding.frequencySpinner.setError("Select frequency");
|
||||
}
|
||||
|
||||
if (binding.medicationsSpinner.getSelectedIndex() == -1) {
|
||||
allOkay = false;
|
||||
binding.medicationsSpinner.setError("Select medication type");
|
||||
}
|
||||
|
||||
if (binding.getTime.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.getTime.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.quantity.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.quantity.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.getDate.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.getDate.setError("Required");
|
||||
}
|
||||
|
||||
if (allOkay) {
|
||||
boolean anyOneSelected = false;
|
||||
for (int i = 0; i < week_state.length; i++) {
|
||||
if (week_state[i]) {
|
||||
// this week day is selected
|
||||
anyOneSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyOneSelected) {
|
||||
// none are selected
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Select a week day.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
private void setLayoutDetails(ReminderResult reminder) {
|
||||
if (reminder != null) {
|
||||
// intent is to edit the reminder
|
||||
binding.title.setText(getString(R.string.edit_reminder));
|
||||
|
||||
binding.medicName.setText(reminder.medicine_name);
|
||||
binding.quantity.setText(reminder.medication_quantity);
|
||||
binding.dosage.setText(reminder.dosage);
|
||||
binding.getDate.setText(formatDate(reminder.medication_refill_date));
|
||||
binding.instructions.setText(reminder.medication_instruction);
|
||||
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String refill_time;
|
||||
|
||||
try {
|
||||
Date date = input_sdf.parse(reminder.time1);
|
||||
refill_time = output_sdf.format(date);
|
||||
} catch (Exception e) {
|
||||
refill_time = reminder.time1;
|
||||
}
|
||||
|
||||
binding.getTime.setText(refill_time);
|
||||
binding.getTime.setHint(reminder.time1);
|
||||
|
||||
for (int i = 0; i < frequencyList.size(); i++) {
|
||||
if (String.valueOf(frequencyList.get(i).id).equals(reminder.medication_frequency_xid)) {
|
||||
binding.frequencySpinner.selectItemByIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < medicationTypeList.size(); i++) {
|
||||
if (String.valueOf(medicationTypeList.get(i).id).equals(reminder.medication_type_xid)) {
|
||||
binding.medicationsSpinner.selectItemByIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// week day selection
|
||||
setSelectionState(0, week_state[0] = reminder.sun.equals("1"));
|
||||
setSelectionState(1, week_state[1] = reminder.mon.equals("1"));
|
||||
setSelectionState(2, week_state[2] = reminder.tue.equals("1"));
|
||||
setSelectionState(3, week_state[3] = reminder.wed.equals("1"));
|
||||
setSelectionState(4, week_state[4] = reminder.thu.equals("1"));
|
||||
setSelectionState(5, week_state[5] = reminder.fri.equals("1"));
|
||||
setSelectionState(6, week_state[6] = reminder.sat.equals("1"));
|
||||
|
||||
binding.addReminder.setText(getString(R.string.save_reminder));
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDate(String medication_refill_date) {
|
||||
String inputPattern = "yyyy-dd-MM";
|
||||
String outputPattern = "dd-MM-yyyy";
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern, Locale.getDefault());
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern, Locale.getDefault());
|
||||
|
||||
Date date = null;
|
||||
String str = null;
|
||||
|
||||
try {
|
||||
date = inputFormat.parse(medication_refill_date);
|
||||
str = outputFormat.format(date);
|
||||
} catch (ParseException e) {
|
||||
Log.e(TAG, "formatDate: ", e);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// every-dau toggle listener
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
setSelectionState(i, week_state[i] = isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
// set selection and un-selection of week day
|
||||
private void setUpWeekSelection() {
|
||||
|
||||
week_state = new boolean[7];
|
||||
|
||||
// week day selections
|
||||
binding.sun.setOnClickListener(v -> setSelectionState(0, week_state[0] = !week_state[0]));
|
||||
binding.mon.setOnClickListener(v -> setSelectionState(1, week_state[1] = !week_state[1]));
|
||||
binding.tue.setOnClickListener(v -> setSelectionState(2, week_state[2] = !week_state[2]));
|
||||
binding.wed.setOnClickListener(v -> setSelectionState(3, week_state[3] = !week_state[3]));
|
||||
binding.thu.setOnClickListener(v -> setSelectionState(4, week_state[4] = !week_state[4]));
|
||||
binding.fri.setOnClickListener(v -> setSelectionState(5, week_state[5] = !week_state[5]));
|
||||
binding.sat.setOnClickListener(v -> setSelectionState(6, week_state[6] = !week_state[6]));
|
||||
|
||||
}
|
||||
|
||||
private void setSelectionState(int position, boolean selection) {
|
||||
if (selection) {
|
||||
// selection has to be made
|
||||
switch (position) {
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.sun.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.mon.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.tue.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.wed.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.thu.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.fri.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundTintList(AppCompatResources.getColorStateList(requireContext(), R.color.color_primary));
|
||||
binding.sat.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// un-selection has to be made
|
||||
switch (position) {
|
||||
case 0:
|
||||
// sun
|
||||
binding.sun.setBackgroundTintList(null);
|
||||
binding.sun.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
// mon
|
||||
binding.mon.setBackgroundTintList(null);
|
||||
binding.mon.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
// tue
|
||||
binding.tue.setBackgroundTintList(null);
|
||||
binding.tue.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
// wed
|
||||
binding.wed.setBackgroundTintList(null);
|
||||
binding.wed.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
// thu
|
||||
binding.thu.setBackgroundTintList(null);
|
||||
binding.thu.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
// fri
|
||||
binding.fri.setBackgroundTintList(null);
|
||||
binding.fri.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
// sat
|
||||
binding.sat.setBackgroundTintList(null);
|
||||
binding.sat.setTextColor(AppCompatResources.getColorStateList(requireContext(), R.color.black));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// checking if all days are selected or not
|
||||
// thus, updating the Everyday switch accordingly
|
||||
boolean isEveryDay = true;
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (!week_state[i]) {
|
||||
// some day is not selected thus not everyday selection
|
||||
isEveryDay = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
binding.everydayCheck.setOnCheckedChangeListener(null);
|
||||
binding.everydayCheck.setChecked(isEveryDay);
|
||||
binding.everydayCheck.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
// shows date picker to pick date and set to tv
|
||||
private void getDate() {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
DatePickerDialog dpd = new DatePickerDialog(requireContext());
|
||||
|
||||
dpd.setOnDateSetListener((view, year, month, dayOfMonth) -> {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, year);
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
binding.getDate.setText(selected_time);
|
||||
|
||||
});
|
||||
|
||||
dpd.show();
|
||||
}
|
||||
|
||||
// TODO: 05-07-2023 for lower version
|
||||
|
||||
}
|
||||
|
||||
// shows time picker to pick time and set to textview
|
||||
private void getTime() {
|
||||
|
||||
Calendar calendar = Calendar.getInstance(Locale.getDefault());
|
||||
|
||||
TimePickerDialog tpd = new TimePickerDialog(requireContext(),
|
||||
(TimePickerDialog.OnTimeSetListener) (view, hourOfDay, minute) -> {
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
cal.set(Calendar.MINUTE, minute);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
binding.getTime.setText(selected_time);
|
||||
binding.getTime.setHint(sdf2.format(cal.getTime()));
|
||||
|
||||
}, calendar.getTime().getHours(), calendar.getTime().getMinutes(), false);
|
||||
|
||||
tpd.show();
|
||||
|
||||
}
|
||||
|
||||
// loading freq. into its resp. spinner
|
||||
private void loadFreqNMedType() {
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we load details for you.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
viewModel.fetchFreqNMedTypes(token, this);
|
||||
}
|
||||
|
||||
// frequencies and medication types loading call back
|
||||
@Override
|
||||
public void onFreqNMedTypeLoaded(FreqNMedTypeResult result) {
|
||||
frequencyList.addAll(result.frequencies);
|
||||
medicationTypeList.addAll(result.medicationTypes);
|
||||
|
||||
ArrayList<String> frequencies = new ArrayList<>();
|
||||
for (Frequency frequency : frequencyList) {
|
||||
frequencies.add(frequency.title);
|
||||
}
|
||||
binding.frequencySpinner.setItems(frequencies);
|
||||
|
||||
ArrayList<String> medicationTypes = new ArrayList<>();
|
||||
for (MedicationType type : medicationTypeList) {
|
||||
medicationTypes.add(type.title);
|
||||
}
|
||||
binding.medicationsSpinner.setItems(medicationTypes);
|
||||
|
||||
// checking if intent to EDIT or ADD reminder
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
setLayoutDetails(reminder = (ReminderResult) bundle.getSerializable(REMINDER_KEY));
|
||||
}
|
||||
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFreqNMedTypeLoadFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
// add reminder call back
|
||||
@Override
|
||||
public void onReminderAdded(ReminderResult reminderDetails) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (reminder == null) {
|
||||
Toast.makeText(requireContext(), "Reminder added successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.popBackStack(R.id.reminderFragment, false, true);
|
||||
|
||||
} else {
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.make_changes),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(),
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3000, v3 -> {
|
||||
// here v3 is null
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.reminderFragment, false, true);
|
||||
});
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReminderAddFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medreminder;
|
||||
package com.ssb.simplitend.patientprofile.medreminder;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medreminder;
|
||||
package com.ssb.simplitend.patientprofile.medreminder;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
@@ -0,0 +1,393 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.ProfileProgress;
|
||||
import com.ssb.simplitend.databinding.RemindersFragmentBinding;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderAdapter;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.ReminderViewModel;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.Reminder;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class ReminderFragment extends Fragment implements RecyclerTouchListener.OnSwipeOptionsClickListener,
|
||||
ProfileContracts.GetRemindersListCallback, ProfileContracts.ReminderDeleteCallback {
|
||||
|
||||
// view binding
|
||||
protected RemindersFragmentBinding binding;
|
||||
|
||||
// reminders viewmodel
|
||||
protected ReminderViewModel reminderViewModel;
|
||||
|
||||
// recycler touch listener for swipe menu
|
||||
protected RecyclerTouchListener recyclerTouchListener;
|
||||
|
||||
private ArrayList<WeekDayViewHolder> weekDayViewsList;
|
||||
|
||||
private ReminderAdapter reminderAdapter;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public ReminderFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RemindersFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
reminderViewModel = new ViewModelProvider(requireActivity()).get(ReminderViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
// date selections
|
||||
binding.day.setOnClickListener(v -> {
|
||||
setDayOfWeek(0);
|
||||
loadReminderList(weekDayViewsList.get(0).day_of_week);
|
||||
});
|
||||
binding.day2.setOnClickListener(v -> {
|
||||
setDayOfWeek(1);
|
||||
loadReminderList(weekDayViewsList.get(1).day_of_week);
|
||||
});
|
||||
binding.day3.setOnClickListener(v -> {
|
||||
setDayOfWeek(2);
|
||||
loadReminderList(weekDayViewsList.get(2).day_of_week);
|
||||
});
|
||||
binding.day4.setOnClickListener(v -> {
|
||||
setDayOfWeek(3);
|
||||
loadReminderList(weekDayViewsList.get(3).day_of_week);
|
||||
});
|
||||
binding.day5.setOnClickListener(v -> {
|
||||
setDayOfWeek(4);
|
||||
loadReminderList(weekDayViewsList.get(4).day_of_week);
|
||||
});
|
||||
binding.day6.setOnClickListener(v -> {
|
||||
setDayOfWeek(5);
|
||||
loadReminderList(weekDayViewsList.get(5).day_of_week);
|
||||
});
|
||||
binding.day7.setOnClickListener(v -> {
|
||||
setDayOfWeek(6);
|
||||
loadReminderList(weekDayViewsList.get(6).day_of_week);
|
||||
});
|
||||
|
||||
// add button
|
||||
binding.addReminder.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_reminderFragment_to_addReminderFragment)
|
||||
);
|
||||
|
||||
binding.done.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
ProfileProgress.PROFILE_PROGRESS[0] = true;
|
||||
});
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
Reminder reminder = new Reminder("Vitamin D3", "05:00 PM", "5 Capsules");
|
||||
|
||||
bundle.putSerializable(AddReminderFragment.REMINDER_KEY, reminder);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void loadReminderList(int day_of_week){
|
||||
Toast.makeText(requireContext(), "loading for " + reminderViewModel.getDayOfWeek(day_of_week-1), Toast.LENGTH_SHORT).show();
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we fetch reminders list for you.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
day_of_week--; // because, at server side day_of_week starts from 0
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
int patient_uid = AppUtil.getPatientUid(requireContext());
|
||||
reminderViewModel.getRemindersList(patient_uid, day_of_week, token, this);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
binding.remindersRv.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
reminderAdapter = new ReminderAdapter();
|
||||
binding.remindersRv.setAdapter(reminderAdapter);
|
||||
|
||||
recyclerTouchListener = new RecyclerTouchListener(requireActivity(), binding.remindersRv);
|
||||
|
||||
recyclerTouchListener.setSwipeOptionViews(R.id.reminder_edit, R.id.reminder_delete)
|
||||
.setSwipeable(R.id.rowFG, R.id.rowBG, this);
|
||||
|
||||
binding.remindersRv.addOnItemTouchListener(recyclerTouchListener);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
String today_date = reminderViewModel.getMonthOfYear(calendar.get(Calendar.MONTH));
|
||||
today_date = today_date.concat(", " + calendar.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
binding.todayDate.setText(today_date);
|
||||
|
||||
// show days of week
|
||||
setDayOfWeekViews();
|
||||
|
||||
setDayOfWeek(reminderViewModel.selected_dow);
|
||||
|
||||
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
private void setDayOfWeekViews() {
|
||||
weekDayViewsList = new ArrayList<>();
|
||||
|
||||
// adding all day_views to the list
|
||||
WeekDayViewHolder day1 = new WeekDayViewHolder(binding.day, binding.dayT1, binding.dayT2);
|
||||
weekDayViewsList.add(day1);
|
||||
|
||||
WeekDayViewHolder day2 = new WeekDayViewHolder(binding.day2, binding.day2T1, binding.day2T2);
|
||||
weekDayViewsList.add(day2);
|
||||
|
||||
WeekDayViewHolder day3 = new WeekDayViewHolder(binding.day3, binding.day31, binding.day32);
|
||||
weekDayViewsList.add(day3);
|
||||
|
||||
WeekDayViewHolder day4 = new WeekDayViewHolder(binding.day4, binding.day41, binding.day42);
|
||||
weekDayViewsList.add(day4);
|
||||
|
||||
WeekDayViewHolder day5 = new WeekDayViewHolder(binding.day5, binding.day51, binding.day52);
|
||||
weekDayViewsList.add(day5);
|
||||
|
||||
WeekDayViewHolder day6 = new WeekDayViewHolder(binding.day6, binding.day61, binding.day62);
|
||||
weekDayViewsList.add(day6);
|
||||
|
||||
WeekDayViewHolder day7 = new WeekDayViewHolder(binding.day7, binding.day71, binding.day72);
|
||||
weekDayViewsList.add(day7);
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
for (int i = 0; i<7; i++){
|
||||
WeekDayViewHolder dayViewHolder = weekDayViewsList.get(i);
|
||||
|
||||
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)));
|
||||
|
||||
calendar.add(Calendar.DAY_OF_WEEK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSelection(){
|
||||
switch (reminderViewModel.selected_dow){
|
||||
case 0:
|
||||
binding.day.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.dayT1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.dayT2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 1:
|
||||
|
||||
binding.day2.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day2T1.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day2T2.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 2:
|
||||
|
||||
binding.day3.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day31.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day32.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 3:
|
||||
|
||||
binding.day4.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day41.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day42.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 4:
|
||||
|
||||
binding.day5.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day51.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day52.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 5:
|
||||
|
||||
binding.day6.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day61.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day62.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
case 6:
|
||||
|
||||
binding.day7.setBackgroundColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day71.setTextColor(getResources().getColor(R.color.black));
|
||||
binding.day72.setTextColor(getResources().getColor(R.color.black));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setDayOfWeek(int selection){
|
||||
|
||||
clearSelection();
|
||||
|
||||
switch (reminderViewModel.selected_dow = selection){
|
||||
case 0:
|
||||
binding.day.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.dayT1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.dayT2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 1:
|
||||
|
||||
binding.day2.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day2T1.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day2T2.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 2:
|
||||
|
||||
binding.day3.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day31.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day32.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 3:
|
||||
|
||||
binding.day4.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day41.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day42.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 4:
|
||||
|
||||
binding.day5.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day51.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day52.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 5:
|
||||
|
||||
binding.day6.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day61.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day62.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
case 6:
|
||||
|
||||
binding.day7.setBackgroundResource(R.drawable.seleted_item_primary);
|
||||
binding.day71.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
binding.day72.setTextColor(getResources().getColor(R.color.white_bg));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// fetching list of reminders callback
|
||||
@Override
|
||||
public void onRemindersListFetched(List<ReminderResult> reminderResultList) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
if (reminderResultList != null && reminderResultList.size() > 0){
|
||||
// reminders are present
|
||||
binding.remindersRv.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
|
||||
reminderAdapter.submitList(reminderResultList);
|
||||
|
||||
}else{
|
||||
binding.remindersRv.setVisibility(View.GONE);
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchRemindersListFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
binding.remindersRv.setVisibility(View.GONE);
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
// delete reminder callback
|
||||
@Override
|
||||
public void onReminderDeleted(int adapterPos) {
|
||||
Toast.makeText(requireContext(), "Reminder deleted.", Toast.LENGTH_SHORT).show();
|
||||
progressDialog.dismiss();
|
||||
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReminderDeleteFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
|
||||
// swipe option menu click listener for reminder list
|
||||
@Override
|
||||
public void onSwipeOptionClicked(int viewID, int position) {
|
||||
if (viewID == R.id.reminder_delete){
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.delete_med_reminder),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v -> {
|
||||
// yes button clicked
|
||||
int patientReminderId = reminderAdapter.getCurrentList().get(position).id;
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we delete the reminder for you.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
reminderViewModel.deleteReminder(AppUtil.getPatientUid(requireContext()),
|
||||
patientReminderId,
|
||||
position,
|
||||
token,
|
||||
this);
|
||||
|
||||
}, v -> {
|
||||
// no button clicked
|
||||
});
|
||||
|
||||
}else if (viewID == R.id.reminder_edit){
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putSerializable(AddReminderFragment.REMINDER_KEY, reminderAdapter.getCurrentList().get(position));
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_reminderFragment_to_addReminderFragment, bundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class WeekDayViewHolder {
|
||||
public LinearLayout card;
|
||||
public TextView day, date;
|
||||
|
||||
public int day_of_week;
|
||||
|
||||
public WeekDayViewHolder() {
|
||||
}
|
||||
|
||||
public WeekDayViewHolder(LinearLayout card, TextView day, TextView date) {
|
||||
this.card = card;
|
||||
this.day = day;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeekDayViewHolder{" +
|
||||
"day=" + day +
|
||||
", date=" + date +
|
||||
", day_of_week=" + day_of_week +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medreminder.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,17 +11,23 @@ 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;
|
||||
|
||||
public class ReminderAdapter extends ListAdapter<Reminder, ReminderAdapter.ReminderViewHolder> {
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
private static final DiffUtil.ItemCallback<Reminder> DIFF_CALLBACK = new DiffUtil.ItemCallback<Reminder>() {
|
||||
public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter.ReminderViewHolder> {
|
||||
|
||||
private static final DiffUtil.ItemCallback<ReminderResult> DIFF_CALLBACK = new DiffUtil.ItemCallback<ReminderResult>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull Reminder oldItem, @NonNull Reminder newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
public boolean areItemsTheSame(@NonNull ReminderResult oldItem, @NonNull ReminderResult newItem) {
|
||||
return oldItem.id == newItem.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull Reminder oldItem, @NonNull Reminder newItem) {
|
||||
public boolean areContentsTheSame(@NonNull ReminderResult oldItem, @NonNull ReminderResult newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
}
|
||||
};
|
||||
@@ -58,10 +64,25 @@ public class ReminderAdapter extends ListAdapter<Reminder, ReminderAdapter.Remin
|
||||
this.selection_state = selection_state;
|
||||
}
|
||||
|
||||
public void setReminder(Reminder reminder, int position){
|
||||
binding.medName.setText(reminder.dosage_name);
|
||||
binding.time.setText(reminder.time);
|
||||
binding.quantity.setText(reminder.quantity);
|
||||
public void setReminder(ReminderResult reminder, int position){
|
||||
binding.medName.setText(reminder.medicine_name);
|
||||
|
||||
SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||
SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
String refill_time;
|
||||
|
||||
try {
|
||||
Date date = input_sdf.parse(reminder.time1);
|
||||
refill_time = output_sdf.format(date);
|
||||
}catch (Exception e){
|
||||
refill_time = reminder.time1;
|
||||
}
|
||||
|
||||
binding.time.setText(refill_time);
|
||||
|
||||
String quantity = reminder.medication_quantity + " capsules";
|
||||
binding.quantity.setText(quantity);
|
||||
|
||||
// static image
|
||||
if (position == 0){
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.patientprofile.PatientProfileAPIService;
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeResult;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ReminderRepository {
|
||||
|
||||
private static ReminderRepository reminderRepository;
|
||||
|
||||
private final PatientProfileAPIService apiService;
|
||||
|
||||
private ReminderRepository(){
|
||||
apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
}
|
||||
|
||||
public static synchronized ReminderRepository getReminderRepository(){
|
||||
if (reminderRepository == null){
|
||||
reminderRepository = new ReminderRepository();
|
||||
}
|
||||
|
||||
return reminderRepository;
|
||||
}
|
||||
|
||||
public void getRemindersList(int patient_id, int day_of_week, String token,
|
||||
@NonNull ProfileContracts.GetRemindersListCallback remindersListCallback){
|
||||
|
||||
apiService.getRemindersList(patient_id, day_of_week, token)
|
||||
.enqueue(new Callback<CallResponse<List<ReminderResult>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<ReminderResult>>> call, Response<CallResponse<List<ReminderResult>>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null){
|
||||
remindersListCallback.onRemindersListFetched(response.body().result);
|
||||
}
|
||||
else if (response.body() != null){
|
||||
remindersListCallback.onFetchRemindersListFailed(new Exception(response.raw().toString()), response.body().message);
|
||||
}
|
||||
else{
|
||||
remindersListCallback.onFetchRemindersListFailed(new Exception(), "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<List<ReminderResult>>> call, Throwable t) {
|
||||
remindersListCallback.onFetchRemindersListFailed(t, "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addReminder(int patient_id,
|
||||
ReminderResult body,
|
||||
String token, @NonNull ProfileContracts.AddReminderCallBack addReminderCallBack){
|
||||
|
||||
apiService.addReminder(patient_id, body, token)
|
||||
.enqueue(new Callback<CallResponse<ReminderResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<ReminderResult>> call, Response<CallResponse<ReminderResult>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null){
|
||||
if (response.body().status != 200){
|
||||
addReminderCallBack.onReminderAddFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
addReminderCallBack.onReminderAdded(response.body().result);
|
||||
}
|
||||
else if (response.body() != null){
|
||||
addReminderCallBack.onReminderAddFailed(new Exception(response.raw().toString()), response.body().message);
|
||||
}
|
||||
else{
|
||||
addReminderCallBack.onReminderAddFailed(new Exception(), "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<ReminderResult>> call, Throwable t) {
|
||||
addReminderCallBack.onReminderAddFailed(t, "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void fetchFreqNMedTypes(String token,
|
||||
@NonNull ProfileContracts.FreqNMedTypesCallback freqNMedTypesCallback){
|
||||
apiService.getFreqNMedTypes(token)
|
||||
.enqueue(new Callback<CallResponse<FreqNMedTypeResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<FreqNMedTypeResult>> call, Response<CallResponse<FreqNMedTypeResult>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null){
|
||||
freqNMedTypesCallback.onFreqNMedTypeLoaded(response.body().result);
|
||||
}
|
||||
else if (response.body() != null){
|
||||
freqNMedTypesCallback.onFreqNMedTypeLoadFailed(new Exception(response.raw().toString()), response.body().message);
|
||||
}
|
||||
else{
|
||||
freqNMedTypesCallback.onFreqNMedTypeLoadFailed(new Exception(), "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<FreqNMedTypeResult>> call, Throwable t) {
|
||||
freqNMedTypesCallback.onFreqNMedTypeLoadFailed(t, "It's not you, it's us.\nPlease try again later");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteReminder(int patient_id,
|
||||
int patient_reminder_id,
|
||||
final int adapterPos,
|
||||
String token,
|
||||
@NonNull ProfileContracts.ReminderDeleteCallback deleteCallback){
|
||||
apiService.deleteReminder(patient_id, patient_reminder_id, token)
|
||||
.enqueue(new Callback<CallResponse<List<Void>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<Void>>> call, Response<CallResponse<List<Void>>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
deleteCallback.onReminderDeleteFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
deleteCallback.onReminderDeleted(adapterPos);
|
||||
}else{
|
||||
deleteCallback.onReminderDeleteFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<List<Void>>> call, Throwable t) {
|
||||
deleteCallback.onReminderDeleteFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.patientprofile.ProfileContracts;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReminderViewModel extends ViewModel {
|
||||
|
||||
private final ReminderRepository reminderRepository;
|
||||
|
||||
// selected day of week
|
||||
public int selected_dow;
|
||||
|
||||
public ReminderViewModel(){
|
||||
|
||||
// selection state default
|
||||
selected_dow = 0;
|
||||
|
||||
reminderRepository = ReminderRepository.getReminderRepository();
|
||||
}
|
||||
|
||||
public void getRemindersList(int patient_id, int day_of_week, String token,
|
||||
@NonNull ProfileContracts.GetRemindersListCallback remindersListCallback) {
|
||||
reminderRepository.getRemindersList(patient_id, day_of_week, token, remindersListCallback);
|
||||
}
|
||||
|
||||
public void addReminder(int patient_id, ReminderResult body, String token,
|
||||
@NonNull ProfileContracts.AddReminderCallBack addReminderCallBack){
|
||||
reminderRepository.addReminder(patient_id, body, token, addReminderCallBack);
|
||||
}
|
||||
|
||||
public void fetchFreqNMedTypes(String token,
|
||||
@NonNull ProfileContracts.FreqNMedTypesCallback freqNMedTypesCallback){
|
||||
reminderRepository.fetchFreqNMedTypes(token, freqNMedTypesCallback);
|
||||
}
|
||||
|
||||
public void deleteReminder(int patient_id,
|
||||
int patient_reminder_id,
|
||||
int adapterPos,
|
||||
String token,
|
||||
@NonNull ProfileContracts.ReminderDeleteCallback deleteCallback){
|
||||
reminderRepository.deleteReminder(patient_id, patient_reminder_id, adapterPos, token, deleteCallback);
|
||||
}
|
||||
|
||||
public String getDayOfWeek(int position){
|
||||
switch (position){
|
||||
case 0:
|
||||
return "Sun";
|
||||
case 1:
|
||||
return "Mon";
|
||||
case 2:
|
||||
return "Tue";
|
||||
case 3:
|
||||
return "Wed";
|
||||
case 4:
|
||||
return "Thu";
|
||||
case 5:
|
||||
return "Fri";
|
||||
case 6:
|
||||
return "Sat";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getMonthOfYear(int month){
|
||||
switch (month){
|
||||
case 1:
|
||||
return "January";
|
||||
case 2:
|
||||
return "February";
|
||||
case 3:
|
||||
return "March";
|
||||
case 4:
|
||||
return "April";
|
||||
case 5:
|
||||
return "May";
|
||||
case 6:
|
||||
return "June";
|
||||
case 7:
|
||||
return "July";
|
||||
case 8:
|
||||
return "August";
|
||||
case 9:
|
||||
return "September";
|
||||
case 10:
|
||||
return "October";
|
||||
case 11:
|
||||
return "November";
|
||||
case 12:
|
||||
return "December";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FreqNMedTypeResult{
|
||||
public ArrayList<Frequency> frequencies;
|
||||
public ArrayList<MedicationType> medicationTypes;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Frequency {
|
||||
public int id;
|
||||
public String title;
|
||||
public String value;
|
||||
public String sort_order;
|
||||
public Object small_image_url;
|
||||
public Object large_image_url;
|
||||
public String active;
|
||||
public Object deleted_at;
|
||||
public Object created_by;
|
||||
public Object updated_by;
|
||||
public Object created_at;
|
||||
public Object updated_at;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Frequency{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Frequency frequency = (Frequency) o;
|
||||
return id == frequency.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MedicationFrequency implements Serializable {
|
||||
public int id;
|
||||
public String title;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MedicationType implements Serializable {
|
||||
public int id;
|
||||
public String title;
|
||||
public String value;
|
||||
public String sort_order;
|
||||
public Object small_image_url;
|
||||
public Object large_image_url;
|
||||
public String active;
|
||||
public Object deleted_at;
|
||||
public Object created_by;
|
||||
public Object updated_by;
|
||||
public Object created_at;
|
||||
public Object updated_at;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MedicationType{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.medreminder.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ssb.simplitend.patientprofile.medreminder.mvvm.models;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ReminderResult implements Serializable {
|
||||
public int patientRemainderId;
|
||||
public int id;
|
||||
public String patient_xid;
|
||||
public String medicine_name;
|
||||
public String dosage;
|
||||
public String dosage_unit;
|
||||
public String medication_type_xid;
|
||||
public String medication_frequency_xid;
|
||||
public String reminder_everyday_flag;
|
||||
public String reminder_weekday_flag;
|
||||
public String reminder_time;
|
||||
public String medication_quantity;
|
||||
public String medication_refill_date;
|
||||
public String medication_instruction;
|
||||
public String mon;
|
||||
public String tue;
|
||||
public String wed;
|
||||
public String thu;
|
||||
public String fri;
|
||||
public String sat;
|
||||
public String sun;
|
||||
public String time1;
|
||||
public String time2;
|
||||
public String time3;
|
||||
public String active;
|
||||
public String deleted_at;
|
||||
public String created_by;
|
||||
public String updated_by;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
public ArrayList<MedicationType> medication_type;
|
||||
public ArrayList<MedicationFrequency> medication_frequency;
|
||||
|
||||
public String is_update;
|
||||
|
||||
public ReminderResult(){}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ReminderResult that = (ReminderResult) o;
|
||||
return id == that.id && Objects.equals(patient_xid, that.patient_xid) && Objects.equals(medicine_name, that.medicine_name) && Objects.equals(dosage, that.dosage) && Objects.equals(dosage_unit, that.dosage_unit) && Objects.equals(medication_type_xid, that.medication_type_xid) && Objects.equals(medication_frequency_xid, that.medication_frequency_xid) && Objects.equals(reminder_everyday_flag, that.reminder_everyday_flag) && Objects.equals(reminder_weekday_flag, that.reminder_weekday_flag) && Objects.equals(reminder_time, that.reminder_time) && Objects.equals(medication_quantity, that.medication_quantity) && Objects.equals(medication_refill_date, that.medication_refill_date) && Objects.equals(medication_instruction, that.medication_instruction) && Objects.equals(mon, that.mon) && Objects.equals(tue, that.tue) && Objects.equals(wed, that.wed) && Objects.equals(thu, that.thu) && Objects.equals(fri, that.fri) && Objects.equals(sat, that.sat) && Objects.equals(sun, that.sun) && Objects.equals(time1, that.time1) && Objects.equals(time2, that.time2) && Objects.equals(time3, that.time3) && Objects.equals(active, that.active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, patient_xid, medicine_name, dosage, dosage_unit, medication_type_xid, medication_frequency_xid, reminder_everyday_flag, reminder_weekday_flag, reminder_time, medication_quantity, medication_refill_date, medication_instruction, mon, tue, wed, thu, fri, sat, sun, time1, time2, time3, active);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.setuproutine;
|
||||
package com.ssb.simplitend.patientprofile.setuproutine;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.TimePickerDialog;
|
||||
@@ -19,7 +19,7 @@ import androidx.navigation.Navigation;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.AddRoutineFragmentBinding;
|
||||
import com.ssb.simplitend.setuproutine.mvvm.Routine;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.Routine;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ssb.simplitend.setuproutine;
|
||||
package com.ssb.simplitend.patientprofile.setuproutine;
|
||||
|
||||
import static com.ssb.simplitend.setuproutine.AddRoutineFragment.ROUTINE_KEY;
|
||||
import static com.ssb.simplitend.patientprofile.setuproutine.AddRoutineFragment.ROUTINE_KEY;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -17,9 +17,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.RoutineFragmentBinding;
|
||||
import com.ssb.simplitend.setuproutine.mvvm.Routine;
|
||||
import com.ssb.simplitend.setuproutine.mvvm.RoutineAdapter;
|
||||
import com.ssb.simplitend.setuproutine.mvvm.RoutineViewModel;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.Routine;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineViewModel;
|
||||
|
||||
public class RoutineFragment extends Fragment implements RoutineAdapter.ClickListener, RoutineAdapter.DeleteClickListener {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
private void initViews() {
|
||||
selection_state = new boolean[7];
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(RoutineViewModel.class);
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(RoutineViewModel.class);
|
||||
}
|
||||
|
||||
private void loadRoutineList() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
package com.ssb.simplitend.patientprofile.setuproutine.mvvm;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.ssb.simplitend.welcome.fragments;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -14,10 +16,21 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.careperson_dashboard.DashBoardActivityCP;
|
||||
import com.ssb.simplitend.databinding.SignInFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientResult;
|
||||
|
||||
public class SignInFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class SignInFragment extends Fragment implements WelcomeContracts.RegisterPatientContract {
|
||||
|
||||
// view binding
|
||||
protected SignInFragmentBinding binding;
|
||||
@@ -25,6 +38,8 @@ public class SignInFragment extends Fragment {
|
||||
// view model
|
||||
private WelcomeViewModel welcomeViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public SignInFragment(){
|
||||
// required empty constructor
|
||||
}
|
||||
@@ -44,6 +59,7 @@ public class SignInFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
@@ -52,14 +68,36 @@ public class SignInFragment extends Fragment {
|
||||
Navigation.findNavController(v).navigate(R.id.action_signInFragment_to_forgotPinFragment));
|
||||
|
||||
binding.signInBtn.setOnClickListener(v -> {
|
||||
if (allOkay()){
|
||||
|
||||
try {
|
||||
if (allOkay()){
|
||||
signIn();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(requireContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
private void signIn() throws Exception {
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we sign you in.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody email_body = RequestBody.create(binding.email.getText().toString().trim(), MediaType.parse("text/plain"));
|
||||
body.put("email", email_body);
|
||||
|
||||
RequestBody pin_body = RequestBody.create(Objects.requireNonNull(binding.pin.getText()).toString().trim(), MediaType.parse("text/plain"));
|
||||
body.put("pin", pin_body);
|
||||
|
||||
welcomeViewModel.loginPatient(body, this);
|
||||
}
|
||||
|
||||
private boolean allOkay() throws Exception{
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()){
|
||||
@@ -70,7 +108,7 @@ public class SignInFragment extends Fragment {
|
||||
binding.email.setError("Invalid email");
|
||||
}
|
||||
|
||||
if (binding.pin.getText().toString().trim().isEmpty()){
|
||||
if (Objects.requireNonNull(binding.pin.getText()).toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.pin.setError("Required");
|
||||
}else if (binding.pin.getText().toString().trim().length() != 4){
|
||||
@@ -80,4 +118,35 @@ public class SignInFragment extends Fragment {
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(PatientResult patientResult, String token) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
progressDialog.setMessage("Almost there...");
|
||||
|
||||
AppUtil.saveUserCache(token, patientResult.patientId, requireContext());
|
||||
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "Log in successful.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent intent = new Intent(requireActivity(), DashBoardActivityCP.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t, String message, int error_code) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
|
||||
private void loadContacts() {
|
||||
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
contactViewModel.getRemoteContactList(RetrofitHelper.GET_CONTACT_LIST, this,
|
||||
contactViewModel.getRemoteContactList(this,
|
||||
"Bearer " + AppUtil.getUserToken(requireContext()));
|
||||
|
||||
contactAdapter.setContactClickListener(this);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.ssb.simplitend.welcome.fragments.contacts;
|
||||
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.CREATE_CONTACT;
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.GET_CONTACT_LIST;
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.UPDATE_CONTACT;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -391,7 +390,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
progressDialog.show();
|
||||
|
||||
String token = "Bearer " + AppUtil.getUserToken(requireContext());
|
||||
contactViewModel.getRemoteContactList(GET_CONTACT_LIST, this, token);
|
||||
contactViewModel.getRemoteContactList(this, token);
|
||||
}
|
||||
|
||||
private void setDetails() {
|
||||
|
||||
@@ -60,8 +60,8 @@ public class ContactViewModel extends AndroidViewModel {
|
||||
this.sosCheckInterface = sosCheckInterface;
|
||||
}
|
||||
|
||||
public void getRemoteContactList(String URL, WelcomeContracts.ContactListContracts contactListContracts, String token){
|
||||
contactRepository.getRemoteContactList(URL, contactListContracts, token);
|
||||
public void getRemoteContactList(WelcomeContracts.ContactListContracts contactListContracts, String token){
|
||||
contactRepository.getRemoteContactList(contactListContracts, token);
|
||||
}
|
||||
|
||||
public void createEditContact(@NonNull String URL,
|
||||
|
||||
@@ -9,10 +9,9 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ssb.simplitend.apputils.RetrofitHelper;
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.models.ContactListResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.APIService;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeApiService;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
|
||||
@@ -22,10 +21,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@@ -42,10 +39,10 @@ public class UserContactRepository {
|
||||
};
|
||||
|
||||
private static UserContactRepository contactRepository;
|
||||
private final APIService apiService;
|
||||
private final WelcomeApiService apiService;
|
||||
|
||||
private UserContactRepository(){
|
||||
apiService = RetrofitHelper.getRetrofit().create(APIService.class);
|
||||
apiService = RetrofitHelper.getRetrofit().create(WelcomeApiService.class);
|
||||
}
|
||||
|
||||
public static synchronized UserContactRepository getContactRepository(){
|
||||
@@ -56,9 +53,9 @@ public class UserContactRepository {
|
||||
return contactRepository;
|
||||
}
|
||||
|
||||
public void getRemoteContactList(String URL, WelcomeContracts.ContactListContracts contactListContracts, String token){
|
||||
public void getRemoteContactList(WelcomeContracts.ContactListContracts contactListContracts, String token){
|
||||
|
||||
apiService.getContactList(URL, token).enqueue(new Callback<CallResponse<List<ContactListResponse>>>() {
|
||||
apiService.getContactList(token).enqueue(new Callback<CallResponse<List<ContactListResponse>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<ContactListResponse>>> call, Response<CallResponse<List<ContactListResponse>>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null){
|
||||
|
||||
@@ -1,22 +1,48 @@
|
||||
package com.ssb.simplitend.welcome.fragments.forgotpin;
|
||||
|
||||
import static com.ssb.simplitend.welcome.fragments.forgotpin.ForgotPinFragment.EMAIL_KEY;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.ChangePinFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
|
||||
public class ChangePinFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class ChangePinFragment extends Fragment implements WelcomeContracts.UpdatePinCallback {
|
||||
|
||||
private static final String TAG = "ChangePinFragment";
|
||||
|
||||
// view binding
|
||||
protected ChangePinFragmentBinding binding;
|
||||
|
||||
private WelcomeViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private String email_id;
|
||||
|
||||
public ChangePinFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
@@ -26,15 +52,105 @@ public class ChangePinFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ChangePinFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(WelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle == null || bundle.getString(EMAIL_KEY) == null){
|
||||
Toast.makeText(requireContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack();
|
||||
return;
|
||||
}
|
||||
|
||||
email_id = bundle.getString(EMAIL_KEY);
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.resetPin.setOnClickListener(v -> {
|
||||
if (allOkay()){
|
||||
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("while we reset your pin.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
try {
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody pin_body = RequestBody.create(Objects.requireNonNull(binding.pin.getText()).toString().trim(), MediaType.parse("text/plain"));
|
||||
body.put("pin", pin_body);
|
||||
|
||||
RequestBody c_pin_body = RequestBody.create(Objects.requireNonNull(binding.confirmPin.getText()).toString().trim(), MediaType.parse("text/plain"));
|
||||
body.put("cpin", c_pin_body);
|
||||
|
||||
RequestBody email_body = RequestBody.create(Objects.requireNonNull(email_id), MediaType.parse("text/plain"));
|
||||
body.put("email", email_body);
|
||||
|
||||
viewModel.updatePin(body, this);
|
||||
}catch (NullPointerException e){
|
||||
Log.e(TAG, "clickEvents: ", e);
|
||||
Toast.makeText(requireContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.pin.getText() == null || binding.pin.getText().toString().length() != 4) {
|
||||
allOkay = false;
|
||||
binding.pin.setError("Invalid pin");
|
||||
} else if (binding.confirmPin.getText() == null ||
|
||||
!binding.confirmPin.getText().toString().equals(binding.pin.getText().toString())) {
|
||||
allOkay = false;
|
||||
binding.confirmPin.setError("Pin doesn't match");
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinUpdated(PatientData patientData) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "PIN changed successfully", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.popBackStack(R.id.signInFragment, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinUpdateFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,49 @@
|
||||
package com.ssb.simplitend.welcome.fragments.forgotpin;
|
||||
|
||||
import static com.ssb.simplitend.welcome.fragments.forgotpin.ForgotPinFragment.EMAIL_KEY;
|
||||
import static com.ssb.simplitend.welcome.fragments.forgotpin.ForgotPinFragment.USER_ID_KEY;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.CheckMailFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
|
||||
public class CheckMailFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class CheckMailFragment extends Fragment implements WelcomeContracts.VerifyOTPCallback {
|
||||
|
||||
// view binding
|
||||
protected CheckMailFragmentBinding binding;
|
||||
|
||||
private WelcomeViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private String user_id;
|
||||
|
||||
private String email_id;
|
||||
|
||||
public CheckMailFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -31,6 +53,8 @@ public class CheckMailFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CheckMailFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(WelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -38,8 +62,31 @@ public class CheckMailFragment extends Fragment {
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle == null || bundle.getString(USER_ID_KEY) == null || bundle.getString(EMAIL_KEY) == null) {
|
||||
Toast.makeText(requireContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack();
|
||||
return;
|
||||
}
|
||||
|
||||
user_id = bundle.getString(USER_ID_KEY);
|
||||
email_id = bundle.getString(EMAIL_KEY);
|
||||
try {
|
||||
binding.email.setText(encodeEmail(bundle.getString(EMAIL_KEY)));
|
||||
}catch (Exception e){
|
||||
binding.email.setText(email_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// showing gif
|
||||
Glide.with(binding.image)
|
||||
.asGif()
|
||||
@@ -71,6 +118,9 @@ public class CheckMailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp2.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
}
|
||||
|
||||
// check if all otp boxes are filled
|
||||
@@ -93,6 +143,9 @@ public class CheckMailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp3.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
} else {
|
||||
binding.otp1.requestFocus();
|
||||
}
|
||||
@@ -117,6 +170,9 @@ public class CheckMailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp4.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
} else {
|
||||
binding.otp2.requestFocus();
|
||||
}
|
||||
@@ -157,8 +213,88 @@ public class CheckMailFragment extends Fragment {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.submit.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_checkMailFragment_to_changePinFragment));
|
||||
binding.submit.setOnClickListener(v -> {
|
||||
|
||||
if (checkOTPInputs()){
|
||||
verifyOTP();
|
||||
}else {
|
||||
Toast.makeText(requireContext(), "Enter OTP received on your email.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verifyOTP() {
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("while we verify your OTP.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody otp_body = RequestBody.create(getOTPFromInputs(), MediaType.parse("text/plain"));
|
||||
body.put("otp_code", otp_body);
|
||||
RequestBody user_id_body = RequestBody.create(user_id, MediaType.parse("text/plain"));
|
||||
body.put("user_id", user_id_body);
|
||||
|
||||
viewModel.verifyOTP(body, this);
|
||||
}
|
||||
|
||||
private String getOTPFromInputs() {
|
||||
return binding.otp1.getText().toString() +
|
||||
binding.otp2.getText().toString() +
|
||||
binding.otp3.getText().toString() +
|
||||
binding.otp4.getText().toString();
|
||||
}
|
||||
|
||||
public boolean checkOTPInputs(){
|
||||
|
||||
if (binding.otp3.getText().toString().trim().length() != 1){
|
||||
return false;
|
||||
}else if (binding.otp2.getText().toString().trim().length() != 1){
|
||||
return false;
|
||||
}else if (binding.otp3.getText().toString().trim().length() != 1){
|
||||
return false;
|
||||
}else if (binding.otp4.getText().toString().trim().length() != 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String encodeEmail(String email) throws Exception{
|
||||
String[] arr = email.split("@");
|
||||
String email_name = arr[0];
|
||||
|
||||
StringBuilder encoded_email = new StringBuilder();
|
||||
|
||||
for (int i = 0; i<email_name.length()-1; i++){
|
||||
encoded_email.append("*");
|
||||
}
|
||||
|
||||
encoded_email.append(email_name.charAt(email_name.length()-1));
|
||||
|
||||
return encoded_email + "@" + arr[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPVerified() {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "OTP verified successfully", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EMAIL_KEY, email_id);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_checkMailFragment_to_changePinFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPVerificationFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ssb.simplitend.welcome.fragments.forgotpin;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -8,16 +10,28 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.ForgotPinFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.OTPSentResponse;
|
||||
|
||||
public class ForgotPinFragment extends Fragment {
|
||||
public class ForgotPinFragment extends Fragment implements WelcomeContracts.SendOTPToEmailCallback {
|
||||
|
||||
protected ForgotPinFragmentBinding binding;
|
||||
|
||||
private WelcomeViewModel welcomeViewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public static final String USER_ID_KEY = "user_id_key";
|
||||
public static final String EMAIL_KEY = "email_key";
|
||||
|
||||
public ForgotPinFragment(){
|
||||
// required empty constructor
|
||||
}
|
||||
@@ -27,6 +41,8 @@ public class ForgotPinFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ForgotPinFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
welcomeViewModel = new ViewModelProvider(requireActivity()).get(WelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -35,6 +51,9 @@ public class ForgotPinFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// showing gif
|
||||
Glide.with(binding.image)
|
||||
.asGif()
|
||||
@@ -48,8 +67,65 @@ public class ForgotPinFragment extends Fragment {
|
||||
binding.backBtn.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.submit.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_forgotPinFragment_to_checkMailFragment));
|
||||
binding.submit.setOnClickListener(v -> {
|
||||
|
||||
if (allOkay()){
|
||||
sendOTP();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void sendOTP() {
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("A 4-digit One Time Password will be sent to your email.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
welcomeViewModel.sendOTPToEmail(binding.emailAddress.getText().toString().trim(),
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.emailAddress.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.emailAddress.setError("Required");
|
||||
}else if (!Patterns.EMAIL_ADDRESS.matcher(binding.emailAddress.getText().toString().trim()).matches()){
|
||||
allOkay = false;
|
||||
binding.emailAddress.setError("Invalid email");
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPSent(OTPSentResponse otpSentResponse) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putString(USER_ID_KEY, otpSentResponse.principal_xid);
|
||||
bundle.putString(EMAIL_KEY, binding.emailAddress.getText().toString().trim());
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_forgotPinFragment_to_checkMailFragment, bundle);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPSentFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CreatePinFragment extends Fragment implements WelcomeContracts.Regi
|
||||
|
||||
progressDialog.show();
|
||||
|
||||
welcomeViewModel.registerPatient(RetrofitHelper.REGISTER_PATIENT, this);
|
||||
welcomeViewModel.registerPatient(this);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -66,6 +66,8 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
private static final String TAG = "LocationFragment";
|
||||
|
||||
private static final String UNITED_STATES = "United States";
|
||||
|
||||
// view binding
|
||||
protected LocationFragmentBinding binding;
|
||||
|
||||
@@ -145,9 +147,6 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
getLocationPermission();
|
||||
|
||||
// default current location // Mumbai marine drive
|
||||
currentLocation = new LatLng(19.026452, 72.838845);
|
||||
|
||||
// initializing maps
|
||||
GoogleMapOptions gmo = new GoogleMapOptions();
|
||||
gmo.mapType(GoogleMap.MAP_TYPE_NORMAL)
|
||||
@@ -181,6 +180,9 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
double lng = Double.parseDouble(patientData.lng);
|
||||
|
||||
currentLocation = new LatLng(lat, lng);
|
||||
}else{
|
||||
// default current location // washington DC
|
||||
currentLocation = new LatLng(38.9072, 77.0369);
|
||||
}
|
||||
|
||||
if (patientData.address_line1 != null){
|
||||
@@ -250,7 +252,7 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
patientData.post_code = binding.zipCode.getText().toString();
|
||||
|
||||
patientData.country = countryList.get(binding.countrySpinner.getSelectedIndex());
|
||||
patientData.state = country_N_states_map.get(patientData.country).get(binding.countrySpinner.getSelectedIndex());
|
||||
patientData.state = country_N_states_map.get(patientData.country).get(binding.stateSpinner.getSelectedIndex());
|
||||
|
||||
patientData.lat = String.valueOf(currentLocation.latitude);
|
||||
patientData.lng = String.valueOf(currentLocation.longitude);
|
||||
@@ -461,6 +463,17 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
binding.countrySpinner.setItems(countryList);
|
||||
|
||||
|
||||
|
||||
if (countryList.contains(UNITED_STATES)){
|
||||
binding.countrySpinner.selectItemByIndex(countryList.indexOf(UNITED_STATES));
|
||||
|
||||
if (country_N_states_map.containsKey(UNITED_STATES))
|
||||
{
|
||||
binding.stateSpinner.setItems(country_N_states_map.get(UNITED_STATES));
|
||||
}
|
||||
}
|
||||
|
||||
binding.stateSpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
binding.countrySpinner.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.ssb.simplitend.welcome.fragments.register;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -23,25 +23,17 @@ import androidx.navigation.Navigation;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.RegisterFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.mvvm.WelcomeViewModel;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class RegisterFragment extends Fragment {
|
||||
public class RegisterFragment extends Fragment implements WelcomeContracts.VerifyEmailCallBack {
|
||||
|
||||
private static final String TAG = "RegisterFragment";
|
||||
|
||||
@@ -53,6 +45,8 @@ public class RegisterFragment extends Fragment {
|
||||
|
||||
private ArrayList<String> countryCodeList;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public RegisterFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -73,7 +67,19 @@ public class RegisterFragment extends Fragment {
|
||||
|
||||
private void initViews() {
|
||||
|
||||
loadCountryCodeDropDown();
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
countryCodeList = viewModel.loadCountryCodeDropDown(requireContext());
|
||||
|
||||
binding.countryCodes.setLifecycleOwner(this);
|
||||
|
||||
binding.countryCodes.setItems(countryCodeList);
|
||||
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf("+1"));
|
||||
|
||||
binding.countryCodes.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
binding.countryCodes.setIsFocusable(true);
|
||||
|
||||
loadPatientDataSavedState();
|
||||
|
||||
@@ -86,9 +92,9 @@ public class RegisterFragment extends Fragment {
|
||||
binding.name.setText(patientData.first_name);
|
||||
binding.dob.setText(patientData.date_of_birth);
|
||||
|
||||
if (patientData.phone_number != null){
|
||||
if (patientData.phone_number != null) {
|
||||
String[] contact = patientData.phone_number.split(" ");
|
||||
if (contact.length == 2){
|
||||
if (contact.length == 2) {
|
||||
binding.contactNumber.setText(contact[1]);
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(contact[0]));
|
||||
}
|
||||
@@ -102,18 +108,16 @@ public class RegisterFragment extends Fragment {
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.nextBtn.setOnClickListener(v -> {
|
||||
if (allOkay()){
|
||||
if (allOkay()) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
PatientData patientData = viewModel.getPatientData();
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we verify your entered email.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
patientData.first_name = patientData.user_name = binding.name.getText().toString();
|
||||
patientData.phone_number = countryCodeList.get(binding.countryCodes.getSelectedIndex())
|
||||
+ " " + binding.contactNumber.getText().toString();
|
||||
patientData.date_of_birth = binding.dob.getText().toString();
|
||||
patientData.email = binding.email.getText().toString();
|
||||
viewModel.verifyEmail(binding.email.getText().toString().trim(), this);
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_registerFragment_to_locationFragment);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -144,15 +148,15 @@ public class RegisterFragment extends Fragment {
|
||||
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.name.getText().toString().trim().isEmpty()){
|
||||
if (binding.name.getText().toString().trim().isEmpty()) {
|
||||
binding.name.setError("Required");
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
if (binding.dob.getText().toString().trim().isEmpty()){
|
||||
if (binding.dob.getText().toString().trim().isEmpty()) {
|
||||
binding.dob.setError("Required");
|
||||
allOkay = false;
|
||||
}else {
|
||||
} else {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
|
||||
try {
|
||||
Date selected_date = sdf.parse(binding.dob.getText().toString().trim());
|
||||
@@ -162,7 +166,7 @@ public class RegisterFragment extends Fragment {
|
||||
Calendar minAdultAge = Calendar.getInstance();
|
||||
minAdultAge.add(Calendar.YEAR, -18);
|
||||
|
||||
if (minAdultAge.before(selected_calender)){
|
||||
if (minAdultAge.before(selected_calender)) {
|
||||
Toast.makeText(requireContext(), "Age must be above 18+ years", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@@ -172,23 +176,23 @@ public class RegisterFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.contactNumber.getText().toString().trim().isEmpty()){
|
||||
if (binding.contactNumber.getText().toString().trim().isEmpty()) {
|
||||
binding.contactNumber.setError("Required");
|
||||
allOkay = false;
|
||||
}else if (!Patterns.PHONE.matcher(binding.contactNumber.getText().toString()).matches()){
|
||||
} else if (!Patterns.PHONE.matcher(binding.contactNumber.getText().toString()).matches()) {
|
||||
binding.contactNumber.setError("Invalid contact");
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()){
|
||||
if (binding.email.getText().toString().trim().isEmpty()) {
|
||||
binding.email.setError("Required");
|
||||
allOkay = false;
|
||||
}else if (!Patterns.EMAIL_ADDRESS.matcher(binding.email.getText().toString()).matches()){
|
||||
} else if (!Patterns.EMAIL_ADDRESS.matcher(binding.email.getText().toString()).matches()) {
|
||||
binding.email.setError("Invalid email");
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
if (!binding.tncCheck.isChecked() && allOkay){
|
||||
if (!binding.tncCheck.isChecked() && allOkay) {
|
||||
Toast.makeText(requireContext(), "Please check terms and conditions to continue.", Toast.LENGTH_SHORT).show();
|
||||
allOkay = false;
|
||||
}
|
||||
@@ -196,70 +200,40 @@ public class RegisterFragment extends Fragment {
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
private void loadCountryCodeDropDown() {
|
||||
public void goForward() {
|
||||
PatientData patientData = viewModel.getPatientData();
|
||||
|
||||
countryCodeList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
String countryCodeStr = readCountryCodes(requireContext());
|
||||
JSONArray jsonArray = new JSONArray(countryCodeStr);
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
|
||||
JSONObject code = jsonArray.getJSONObject(i);
|
||||
|
||||
countryCodeList.add(code.getString("dial_code"));
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
// if cannot load all country codes showing only india's dial code
|
||||
countryCodeList.add("+91");
|
||||
|
||||
Log.e(TAG, "loadCountryCodeDropDown: ", e);
|
||||
}
|
||||
|
||||
binding.countryCodes.setLifecycleOwner(this);
|
||||
|
||||
binding.countryCodes.setItems(countryCodeList);
|
||||
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf("+91"));
|
||||
|
||||
binding.countryCodes.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
binding.countryCodes.setIsFocusable(true);
|
||||
patientData.first_name = patientData.user_name = binding.name.getText().toString();
|
||||
patientData.phone_number = countryCodeList.get(binding.countryCodes.getSelectedIndex())
|
||||
+ " " + binding.contactNumber.getText().toString();
|
||||
patientData.date_of_birth = binding.dob.getText().toString();
|
||||
patientData.email = binding.email.getText().toString();
|
||||
|
||||
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_registerFragment_to_locationFragment);
|
||||
}
|
||||
|
||||
public String readCountryCodes(Context context) throws IOException {
|
||||
StringBuilder returnString = new StringBuilder();
|
||||
|
||||
InputStream fIn = context.getResources().openRawResource(R.raw.country_code);
|
||||
InputStreamReader isr = new InputStreamReader(fIn);
|
||||
BufferedReader input = new BufferedReader(isr);
|
||||
|
||||
String line = "";
|
||||
|
||||
while ((line = input.readLine()) != null) {
|
||||
returnString.append(line);
|
||||
@Override
|
||||
public void onEmailVerified(boolean exists, String message) {
|
||||
progressDialog.dismiss();
|
||||
if (exists) {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Email already exists.",
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
}), null, null);
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Email verification success.", Toast.LENGTH_SHORT).show();
|
||||
goForward();
|
||||
}
|
||||
|
||||
try {
|
||||
isr.close();
|
||||
|
||||
if (fIn != null) fIn.close();
|
||||
|
||||
input.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readCountryCodes: ", e);
|
||||
}
|
||||
|
||||
return returnString.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVerificationFailed() {
|
||||
progressDialog.dismiss();
|
||||
goForward();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void pickDate() {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.ssb.simplitend.welcome.mvvm;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.Contact;
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.models.ContactListResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.OTPSentResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientResult;
|
||||
|
||||
import java.util.List;
|
||||
@@ -11,6 +14,7 @@ import java.util.Map;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Multipart;
|
||||
@@ -20,17 +24,19 @@ import retrofit2.http.PartMap;
|
||||
import retrofit2.http.Path;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
public interface APIService {
|
||||
public interface WelcomeApiService {
|
||||
|
||||
@Multipart
|
||||
@POST
|
||||
Call<CallResponse<PatientResult>> registerPatient(@Url String URL,
|
||||
@PartMap Map<String, RequestBody> body);
|
||||
@POST("api/auth/patient-register")
|
||||
Call<CallResponse<PatientResult>> registerPatient(@PartMap Map<String, RequestBody> body);
|
||||
|
||||
@Multipart
|
||||
@POST("api/auth/patient-login")
|
||||
Call<CallResponse<PatientResult>> loginPatient(@PartMap Map<String, RequestBody> credentials);
|
||||
|
||||
@POST("api/auth/verify-patient-exists")
|
||||
Call<CallResponse<PatientResult>> verifyEmail(@Body Map<String, String> body);
|
||||
|
||||
@Multipart
|
||||
@POST
|
||||
Call<CallResponse<Contact>> createEditContact(@Url String URL,
|
||||
@@ -39,9 +45,20 @@ public interface APIService {
|
||||
@Part MultipartBody.Part userImage,
|
||||
@Header("Authorization") String token);
|
||||
|
||||
@GET
|
||||
Call<CallResponse<List<ContactListResponse>>> getContactList(@Url String URL, @Header("Authorization") String token);
|
||||
@GET("api/patients-contact-list")
|
||||
Call<CallResponse<List<ContactListResponse>>> getContactList(@Header("Authorization") String token);
|
||||
|
||||
@POST("api/patient-contact-delete/{id}")
|
||||
Call<CallResponse<String>> deleteContact(@Header("Authorization") String token, @Path("id") int contact_id);
|
||||
|
||||
@GET("api/auth/forgot-pin-enter-email")
|
||||
Call<CallResponse<OTPSentResponse>> sendOTPToEmail(@Header("email") String email_address);
|
||||
|
||||
@Multipart
|
||||
@POST("api/auth/verify-patient-otp")
|
||||
Call<CallResponse<List<String>>> verifyOTP(@PartMap Map<String, RequestBody> body);
|
||||
|
||||
@Multipart
|
||||
@POST("api/auth/change-patient-pin")
|
||||
Call<CallResponse<PatientData>> updatePin(@PartMap Map<String, RequestBody> body);
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.ssb.simplitend.welcome.mvvm;
|
||||
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.Contact;
|
||||
import com.ssb.simplitend.welcome.fragments.contacts.mvvm.models.ContactListResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.OTPSentResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientResult;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,4 +49,30 @@ public interface WelcomeContracts {
|
||||
|
||||
}
|
||||
|
||||
interface VerifyEmailCallBack {
|
||||
|
||||
void onEmailVerified(boolean exists, String message);
|
||||
|
||||
void onVerificationFailed();
|
||||
|
||||
}
|
||||
|
||||
interface SendOTPToEmailCallback{
|
||||
void onOTPSent(OTPSentResponse otpSentResponse);
|
||||
|
||||
void onOTPSentFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface VerifyOTPCallback{
|
||||
void onOTPVerified();
|
||||
|
||||
void onOTPVerificationFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface UpdatePinCallback{
|
||||
void onPinUpdated(PatientData patientData);
|
||||
|
||||
void onPinUpdateFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.ssb.simplitend.welcome.mvvm;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.*;
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.getRetrofit;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ssb.simplitend.welcome.mvvm.models.CallResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.OTPSentResponse;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@@ -22,7 +25,11 @@ public class WelcomeRepository {
|
||||
|
||||
private static WelcomeRepository welcomeRepository;
|
||||
|
||||
private WelcomeRepository() {}
|
||||
private final WelcomeApiService welcomeApiService;
|
||||
|
||||
private WelcomeRepository() {
|
||||
welcomeApiService = getRetrofit().create(WelcomeApiService.class);
|
||||
}
|
||||
|
||||
public static synchronized WelcomeRepository getWelcomeRepository(){
|
||||
if (welcomeRepository == null){
|
||||
@@ -35,20 +42,18 @@ public class WelcomeRepository {
|
||||
public void loginPatient(@NonNull Map<String, RequestBody> credentials,
|
||||
@NonNull WelcomeContracts.RegisterPatientContract loginCallback){
|
||||
|
||||
APIService welcomeService = getRetrofit().create(APIService.class);
|
||||
|
||||
welcomeService.loginPatient(credentials).enqueue(new Callback<CallResponse<PatientResult>>() {
|
||||
welcomeApiService.loginPatient(credentials).enqueue(new Callback<CallResponse<PatientResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientResult>> call, Response<CallResponse<PatientResult>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null)
|
||||
{
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
loginCallback.onFailure(new Exception(), response.body().message, response.body().status);
|
||||
return;
|
||||
}
|
||||
|
||||
loginCallback.onResponse(response.body().result, response.body().token);
|
||||
}else if (response.body() != null){
|
||||
Log.e(TAG, "onResponse: login patient " + response);
|
||||
loginCallback.onFailure(new Exception(response.toString()), response.body().message, response.code());
|
||||
}else{
|
||||
Log.e(TAG, "onResponse: login patient :no success response and also response body is null");
|
||||
loginCallback.onFailure(new Exception("no success response and also response body is null"), "It's not you, it's us.\nPlease try again later", 1);
|
||||
loginCallback.onFailure(new Exception(), "Please try again later.", response.code());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +66,12 @@ public class WelcomeRepository {
|
||||
|
||||
}
|
||||
|
||||
public void registerPatient(@NonNull String URL,
|
||||
@NonNull Map<String, RequestBody> body,
|
||||
public void registerPatient(@NonNull Map<String, RequestBody> body,
|
||||
@NonNull WelcomeContracts.RegisterPatientContract registerPatient){
|
||||
|
||||
APIService welcomeService = getRetrofit().create(APIService.class);
|
||||
|
||||
welcomeService.registerPatient(URL, body).enqueue(new Callback<CallResponse<PatientResult>>() {
|
||||
|
||||
welcomeApiService.registerPatient(body).enqueue(new Callback<CallResponse<PatientResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientResult>> call, Response<CallResponse<PatientResult>> response) {
|
||||
if (response.isSuccessful() && response.body() != null && response.body().result != null)
|
||||
@@ -91,4 +95,108 @@ public class WelcomeRepository {
|
||||
|
||||
}
|
||||
|
||||
public void verifyEmail(Map<String, String> email_address, WelcomeContracts.VerifyEmailCallBack emailCallBack){
|
||||
|
||||
welcomeApiService.verifyEmail(email_address).enqueue(new Callback<CallResponse<PatientResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientResult>> call, Response<CallResponse<PatientResult>> response) {
|
||||
Log.d(TAG, "onResponse: ");
|
||||
if (response.isSuccessful() && response.body() != null){
|
||||
// error_cede
|
||||
// 0 -> email is not exist in database
|
||||
// 1 -> email is present in database
|
||||
emailCallBack.onEmailVerified(response.body().error_code == 1, response.body().message);
|
||||
}else{
|
||||
emailCallBack.onVerificationFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<PatientResult>> call, Throwable t) {
|
||||
Log.e(TAG, "onFailure: verify email ", t);
|
||||
emailCallBack.onVerificationFailed();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void sendOTPToEmail(String email_address,
|
||||
@NonNull WelcomeContracts.SendOTPToEmailCallback otpToEmailCallback){
|
||||
|
||||
welcomeApiService.sendOTPToEmail(email_address)
|
||||
.enqueue(new Callback<CallResponse<OTPSentResponse>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<OTPSentResponse>> call, Response<CallResponse<OTPSentResponse>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
otpToEmailCallback.onOTPSentFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
otpToEmailCallback.onOTPSent(response.body().result);
|
||||
}else{
|
||||
otpToEmailCallback.onOTPSentFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<OTPSentResponse>> call, Throwable t) {
|
||||
otpToEmailCallback.onOTPSentFailed(t, "Please try again later.");
|
||||
Log.e(TAG, "onFailure: ", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void verifyOTP(Map<String, RequestBody> body,
|
||||
@NonNull WelcomeContracts.VerifyOTPCallback verifyOTPCallback){
|
||||
welcomeApiService.verifyOTP(body).enqueue(new Callback<CallResponse<List<String>>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<List<String>>> call, Response<CallResponse<List<String>>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
verifyOTPCallback.onOTPVerificationFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
verifyOTPCallback.onOTPVerified();
|
||||
}else{
|
||||
verifyOTPCallback.onOTPVerificationFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<List<String>>> call, Throwable t) {
|
||||
verifyOTPCallback.onOTPVerificationFailed(t, "Please try again later.");
|
||||
Log.e(TAG, "onFailure: ", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updatePin(Map<String, RequestBody> body,
|
||||
@NonNull WelcomeContracts.UpdatePinCallback updatePinCallback){
|
||||
|
||||
welcomeApiService.updatePin(body)
|
||||
.enqueue(new Callback<CallResponse<PatientData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<PatientData>> call, Response<CallResponse<PatientData>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
updatePinCallback.onPinUpdateFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
updatePinCallback.onPinUpdated(response.body().result);
|
||||
}else{
|
||||
updatePinCallback.onPinUpdateFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<PatientData>> call, Throwable t) {
|
||||
updatePinCallback.onPinUpdateFailed(t, "Please try again later.");
|
||||
Log.e(TAG, "onFailure: ", t);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
package com.ssb.simplitend.welcome.mvvm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.welcome.mvvm.models.PatientData;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,7 +34,7 @@ public class WelcomeViewModel extends ViewModel {
|
||||
this.welcomeRepository = WelcomeRepository.getWelcomeRepository();
|
||||
}
|
||||
|
||||
public void registerPatient(@NonNull String URL, @NonNull WelcomeContracts.RegisterPatientContract registerPatientContract){
|
||||
public void registerPatient(@NonNull WelcomeContracts.RegisterPatientContract registerPatientContract){
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
PatientData patientData = getPatientData();
|
||||
@@ -66,10 +78,15 @@ public class WelcomeViewModel extends ViewModel {
|
||||
RequestBody lng_body = RequestBody.create(patientData.lng, MediaType.parse("text/plain;charset=utf-8") );
|
||||
body.put("lng", lng_body);
|
||||
|
||||
welcomeRepository.registerPatient(URL, body, registerPatientContract);
|
||||
welcomeRepository.registerPatient(body, registerPatientContract);
|
||||
|
||||
}
|
||||
|
||||
public void sendOTPToEmail(String emailAddress,
|
||||
@NonNull WelcomeContracts.SendOTPToEmailCallback otpToEmailCallback){
|
||||
welcomeRepository.sendOTPToEmail(emailAddress, otpToEmailCallback);
|
||||
}
|
||||
|
||||
public void loginPatient(@NonNull Map<String, RequestBody> credentials,
|
||||
@NonNull WelcomeContracts.RegisterPatientContract loginCallback){
|
||||
|
||||
@@ -77,6 +94,22 @@ public class WelcomeViewModel extends ViewModel {
|
||||
|
||||
}
|
||||
|
||||
public void verifyOTP(Map<String, RequestBody> body,
|
||||
@NonNull WelcomeContracts.VerifyOTPCallback verifyOTPCallback){
|
||||
welcomeRepository.verifyOTP(body, verifyOTPCallback);
|
||||
}
|
||||
|
||||
public void updatePin(Map<String, RequestBody> body,
|
||||
@NonNull WelcomeContracts.UpdatePinCallback updatePinCallback){
|
||||
welcomeRepository.updatePin(body, updatePinCallback);
|
||||
}
|
||||
|
||||
public void verifyEmail(String email_address, WelcomeContracts.VerifyEmailCallBack emailCallBack){
|
||||
Map<String, String> body = new HashMap<>();
|
||||
body.put("email", email_address);
|
||||
welcomeRepository.verifyEmail(body, emailCallBack);
|
||||
}
|
||||
|
||||
public synchronized PatientData getPatientData(){
|
||||
|
||||
if (patientData == null){
|
||||
@@ -86,4 +119,62 @@ public class WelcomeViewModel extends ViewModel {
|
||||
return patientData;
|
||||
}
|
||||
|
||||
private static final String TAG = "WelcomeViewModel";
|
||||
|
||||
public ArrayList<String> loadCountryCodeDropDown(Context context) {
|
||||
|
||||
ArrayList<String> countryCodeList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
String countryCodeStr = readCountryCodes(context);
|
||||
JSONArray jsonArray = new JSONArray(countryCodeStr);
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
|
||||
JSONObject code = jsonArray.getJSONObject(i);
|
||||
|
||||
countryCodeList.add(code.getString("dial_code"));
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
// if cannot load all country codes showing only india's dial code
|
||||
countryCodeList.add("+91");
|
||||
countryCodeList.add("+1");
|
||||
|
||||
Log.e(TAG, "loadCountryCodeDropDown: ", e);
|
||||
}
|
||||
|
||||
return countryCodeList;
|
||||
}
|
||||
|
||||
public String readCountryCodes(Context context) throws IOException {
|
||||
StringBuilder returnString = new StringBuilder();
|
||||
|
||||
InputStream fIn = context.getResources().openRawResource(R.raw.country_code);
|
||||
InputStreamReader isr = new InputStreamReader(fIn);
|
||||
BufferedReader input = new BufferedReader(isr);
|
||||
|
||||
String line = "";
|
||||
|
||||
while ((line = input.readLine()) != null) {
|
||||
returnString.append(line);
|
||||
}
|
||||
|
||||
try {
|
||||
isr.close();
|
||||
|
||||
if (fIn != null) fIn.close();
|
||||
|
||||
input.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "readCountryCodes: ", e);
|
||||
}
|
||||
|
||||
return returnString.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ssb.simplitend.welcome.mvvm.models;
|
||||
|
||||
public class OTPSentResponse{
|
||||
public int id;
|
||||
public String principal_xid;
|
||||
public String pin;
|
||||
public String photo;
|
||||
public String is_archived;
|
||||
public String archived_datetime;
|
||||
public String is_suspended;
|
||||
public String active;
|
||||
public String deleted_at;
|
||||
public String created_by;
|
||||
public String updated_by;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
}
|
||||
22
app/src/main/res/drawable/ic_done.xml
Normal file
22
app/src/main/res/drawable/ic_done.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
|
||||
<solid android:color="@color/color_accent"/>
|
||||
|
||||
<size android:width="70dp"
|
||||
android:height="70dp"/>
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:width="40dp"
|
||||
android:height="40dp"
|
||||
android:gravity="center"
|
||||
android:drawable="@drawable/ic_done_outline"
|
||||
>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
@@ -2,14 +2,14 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:width="80dp"
|
||||
android:height="80dp"
|
||||
android:width="70dp"
|
||||
android:height="70dp"
|
||||
android:drawable="@drawable/ic_white_bg"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:width="60dp"
|
||||
android:height="60dp"
|
||||
android:width="50dp"
|
||||
android:height="50dp"
|
||||
|
||||
android:drawable="@drawable/ic_accent_bg"
|
||||
android:gravity="center"
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<vector android:height="21dp" android:viewportHeight="120"
|
||||
android:viewportWidth="120" android:width="21dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#000000"
|
||||
android:pathData="M45.2,1.4c-16.3,4 -31.8,16.5 -39,31.7 -4.8,9.9 -6.2,16.2 -6.2,26.9 0,10.7 1.4,17 6.2,26.9 7.4,15.6 23.9,28.6 40.6,32 6.7,1.4 21.2,1.3 27.7,-0.3 4.6,-1 5,-1.3 5,-4.1 0,-3.4 0.2,-3.4 -11.8,-1.4 -28.2,4.7 -56.3,-16.3 -60.9,-45.5 -4.4,-28.4 16.5,-56.3 45.6,-60.8 27.9,-4.3 55.7,16.1 60.7,44.6 2.9,16.8 -2.3,32.5 -15.2,46.1 -9.6,10.1 -9.4,10.9 4,11.3 9.8,0.3 13.1,-0.5 13.1,-2.9 0,-2 -3.5,-3.9 -7.1,-3.9l-4,-0 4,-5.3c8.1,-10.7 12.1,-22.8 12.1,-36.7 0,-10.7 -1.4,-17 -6.2,-26.9 -7.4,-15.6 -23.9,-28.6 -40.6,-32 -7,-1.4 -21.3,-1.3 -28,0.3z" android:strokeColor="#00000000"/>
|
||||
<path android:fillColor="#000000"
|
||||
android:pathData="M49.3,12.5c-24.4,5.3 -41.1,29.8 -37.4,54.7 5.9,39.3 54.4,55.2 82.4,27.1 27.1,-27.1 13.3,-73.9 -24,-81.8 -8.2,-1.8 -12.9,-1.8 -21,-0zM62,41.3l0,17.2 11.5,11.5c6.3,6.3 11.5,12.1 11.5,12.8 0,0.7 -0.7,1.5 -1.6,1.9 -1.1,0.4 -5.1,-2.9 -13.5,-11.3l-11.9,-11.9 0,-18.7c0,-18.1 0.1,-18.8 2,-18.8 1.9,-0 2,0.7 2,17.3z" android:strokeColor="#00000000"/>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="120"
|
||||
android:viewportHeight="120">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M45.2,1.4c-16.3,4 -31.8,16.5 -39,31.7 -4.8,9.9 -6.2,16.2 -6.2,26.9 0,10.7 1.4,17 6.2,26.9 7.4,15.6 23.9,28.6 40.6,32 6.7,1.4 21.2,1.3 27.7,-0.3 4.6,-1 5,-1.3 5,-4.1 0,-3.4 0.2,-3.4 -11.8,-1.4 -28.2,4.7 -56.3,-16.3 -60.9,-45.5 -4.4,-28.4 16.5,-56.3 45.6,-60.8 27.9,-4.3 55.7,16.1 60.7,44.6 2.9,16.8 -2.3,32.5 -15.2,46.1 -9.6,10.1 -9.4,10.9 4,11.3 9.8,0.3 13.1,-0.5 13.1,-2.9 0,-2 -3.5,-3.9 -7.1,-3.9l-4,-0 4,-5.3c8.1,-10.7 12.1,-22.8 12.1,-36.7 0,-10.7 -1.4,-17 -6.2,-26.9 -7.4,-15.6 -23.9,-28.6 -40.6,-32 -7,-1.4 -21.3,-1.3 -28,0.3z"
|
||||
android:strokeColor="#00000000" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M49.3,12.5c-24.4,5.3 -41.1,29.8 -37.4,54.7 5.9,39.3 54.4,55.2 82.4,27.1 27.1,-27.1 13.3,-73.9 -24,-81.8 -8.2,-1.8 -12.9,-1.8 -21,-0zM62,41.3l0,17.2 11.5,11.5c6.3,6.3 11.5,12.1 11.5,12.8 0,0.7 -0.7,1.5 -1.6,1.9 -1.1,0.4 -5.1,-2.9 -13.5,-11.3l-11.9,-11.9 0,-18.7c0,-18.1 0.1,-18.8 2,-18.8 1.9,-0 2,0.7 2,17.3z"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/dosage"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="8"
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
</ScrollView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/reset_pin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
|
||||
@@ -41,12 +41,39 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/please_enter_the_temporary_pin_recieved_at_email_address_at_k_gmail_com"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:id="@+id/email_at"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/at"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/email"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:layout_marginStart="10dp"
|
||||
tools:text="************57@gmail.com"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="150dp"
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/email_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/edit_text_bg"
|
||||
|
||||
@@ -52,12 +52,7 @@
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
android:background="@drawable/ic_accent_bg"
|
||||
|
||||
android:src="@drawable/ic_done_outline"
|
||||
|
||||
android:padding="15dp"
|
||||
|
||||
android:src="@drawable/ic_done"
|
||||
/>
|
||||
|
||||
<View
|
||||
@@ -108,11 +103,7 @@
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
android:background="@drawable/ic_accent_bg"
|
||||
|
||||
android:src="@drawable/ic_done_outline"
|
||||
|
||||
android:padding="15dp"
|
||||
app:srcCompat="@drawable/ic_done"
|
||||
|
||||
/>
|
||||
|
||||
@@ -152,15 +143,15 @@
|
||||
|
||||
android:gravity="center_horizontal"
|
||||
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/med_reminder_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
|
||||
android:gravity="center"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/white_bg"
|
||||
android:overScrollMode="never">
|
||||
|
||||
@@ -87,7 +88,7 @@
|
||||
android:weightSum="7">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sun"
|
||||
android:id="@+id/day"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -100,25 +101,25 @@
|
||||
android:paddingVertical="15dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sun_t1"
|
||||
android:id="@+id/day_t1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/sun"
|
||||
tools:text="@string/sun"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sun_t2"
|
||||
android:id="@+id/day_t2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -136,7 +137,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/mon"
|
||||
android:id="@+id/day2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -153,25 +154,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mon_t1"
|
||||
android:id="@+id/day2_t1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/mon"
|
||||
tools:text="@string/mon"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mon_t2"
|
||||
android:id="@+id/day2_t2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -189,7 +190,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tue"
|
||||
android:id="@+id/day3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -206,25 +207,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tue_1"
|
||||
android:id="@+id/day3_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/tue"
|
||||
tools:text="@string/tue"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tue_2"
|
||||
android:id="@+id/day3_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -242,7 +243,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wed"
|
||||
android:id="@+id/day4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -259,25 +260,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wed_1"
|
||||
android:id="@+id/day4_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/wed"
|
||||
tools:text="@string/wed"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wed_2"
|
||||
android:id="@+id/day4_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -295,7 +296,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/thu"
|
||||
android:id="@+id/day5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -312,25 +313,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thu_1"
|
||||
android:id="@+id/day5_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/thu"
|
||||
tools:text="@string/thu"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thu_2"
|
||||
android:id="@+id/day5_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -348,7 +349,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fri"
|
||||
android:id="@+id/day6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -365,25 +366,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fri_1"
|
||||
android:id="@+id/day6_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/fri"
|
||||
tools:text="@string/fri"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fri_2"
|
||||
android:id="@+id/day6_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
@@ -401,7 +402,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sat"
|
||||
android:id="@+id/day7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
@@ -416,25 +417,25 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sat_1"
|
||||
android:id="@+id/day7_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:fontFamily="@font/nunito_regular"
|
||||
android:text="@string/sat"
|
||||
tools:text="@string/sat"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
android:textColor="@color/black"
|
||||
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sat_2"
|
||||
android:id="@+id/day7_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:layout_marginVertical="5dp"
|
||||
android:fontFamily="@font/nunito_semibold"
|
||||
android:text="12"
|
||||
tools:text="12"
|
||||
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
|
||||
|
||||
android:textColor="@color/black"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/welcome_nav_graph"
|
||||
app:startDestination="@id/addContactFragment">
|
||||
app:startDestination="@id/splashFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/welcomeFragment"
|
||||
@@ -151,7 +151,7 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/profileProgressFragment"
|
||||
android:name="com.ssb.simplitend.userprofile.ProfileProgressFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.ProfileProgressFragment"
|
||||
android:label="ProfileProgressFragment" >
|
||||
<action
|
||||
android:id="@+id/action_profileProgressFragment_to_reminderFragment"
|
||||
@@ -165,7 +165,7 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/reminderFragment"
|
||||
android:name="com.ssb.simplitend.medreminder.ReminderFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.medreminder.ReminderFragment"
|
||||
android:label="ReminderFragment" >
|
||||
<action
|
||||
android:id="@+id/action_reminderFragment_to_addReminderFragment"
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/addReminderFragment"
|
||||
android:name="com.ssb.simplitend.medreminder.AddReminderFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.medreminder.AddReminderFragment"
|
||||
android:label="AddReminderFragment" />
|
||||
<fragment
|
||||
android:id="@+id/splashFragment"
|
||||
@@ -186,7 +186,7 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/medicalInfoFragment"
|
||||
android:name="com.ssb.simplitend.medicalinfo.MedicalInfoFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.medicalinfo.MedicalInfoFragment"
|
||||
android:label="MedicalInfoFragment" >
|
||||
<action
|
||||
android:id="@+id/action_medicalInfoFragment_to_addMedicalInfoFragment"
|
||||
@@ -194,11 +194,11 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/addMedicalInfoFragment"
|
||||
android:name="com.ssb.simplitend.medicalinfo.AddMedicalInfoFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.medicalinfo.AddMedicalInfoFragment"
|
||||
android:label="AddMedicalInfoFragment" />
|
||||
<fragment
|
||||
android:id="@+id/routineFragment"
|
||||
android:name="com.ssb.simplitend.setuproutine.RoutineFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.setuproutine.RoutineFragment"
|
||||
android:label="RoutineFragment" >
|
||||
<action
|
||||
android:id="@+id/action_routineFragment_to_addRoutineFragment"
|
||||
@@ -206,6 +206,6 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/addRoutineFragment"
|
||||
android:name="com.ssb.simplitend.setuproutine.AddRoutineFragment"
|
||||
android:name="com.ssb.simplitend.patientprofile.setuproutine.AddRoutineFragment"
|
||||
android:label="AddRoutineFragment" />
|
||||
</navigation>
|
||||
@@ -36,7 +36,7 @@
|
||||
<string name="enter_email_address">Enter email address</string>
|
||||
<string name="submit">Submit</string>
|
||||
<string name="check_your_mail">Check your mail</string>
|
||||
<string name="please_enter_the_temporary_pin_recieved_at_email_address_at_k_gmail_com">Please enter the temporary pin recieved at email address at ******k@gmail.com</string>
|
||||
<string name="please_enter_the_temporary_pin_recieved_at_email_address_at_k_gmail_com">Please enter the temporary pin recieved at email address</string>
|
||||
<string name="didn_t_your_receive_any_code">Didn\'t your receive any code?</string>
|
||||
<string name="resend">Resend</string>
|
||||
<string name="change_your_pin">Change your Pin</string>
|
||||
@@ -231,5 +231,8 @@
|
||||
<string name="OK">Ok</string>
|
||||
<string name="add_contact">Add contact</string>
|
||||
<string name="sure_delete">Are you sure you want to delete this contact?</string>
|
||||
<string name="ok">Ok</string>
|
||||
<string name="something_went_wrong">Something went wrong</string>
|
||||
<string name="at">at</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user