.
This commit is contained in:
@@ -40,7 +40,7 @@ public abstract class AppUtil {
|
||||
|
||||
BottomSheetDialog bsd = new BottomSheetDialog(context, R.style.BottomSheetDialog);
|
||||
bsd.setContentView(binding.getRoot());
|
||||
bsd.setCancelable(false);
|
||||
bsd.setCancelable(true);
|
||||
|
||||
binding.text.setText(decisionText);
|
||||
|
||||
|
||||
@@ -9,4 +9,6 @@ public class ProfileProgress {
|
||||
|
||||
public static final boolean[] PROFILE_PROGRESS = {false, false, false, false};
|
||||
|
||||
public static boolean MEDICAL_INFO_ADDED = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ssb.simplitend.careperson_dashboard;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
|
||||
public class DashBoardActivityCP extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dash_board_cp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ssb.simplitend.careperson_dashboard.chats;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ssb.simplitend.careperson_dashboard.chats.mvvm.ChatItem;
|
||||
import com.ssb.simplitend.databinding.ChatCardViewholderBinding;
|
||||
|
||||
public class ChatListAdapter extends ListAdapter<ChatItem, ChatListAdapter.ChatCardViewHolder> {
|
||||
|
||||
private static final DiffUtil.ItemCallback<ChatItem> DIFF_UTIL = new DiffUtil.ItemCallback<ChatItem>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull ChatItem oldItem, @NonNull ChatItem newItem) {
|
||||
// TODO: 11-07-2023
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull ChatItem oldItem, @NonNull ChatItem newItem) {
|
||||
// TODO: 11-07-2023
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public ChatListAdapter(){
|
||||
super(DIFF_UTIL);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ChatCardViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ChatCardViewholderBinding binding = ChatCardViewholderBinding.inflate(LayoutInflater.from(parent.getContext()));
|
||||
return new ChatCardViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ChatCardViewHolder holder, int position) {
|
||||
holder.setData(getItem(position), position);
|
||||
}
|
||||
|
||||
public static class ChatCardViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
ChatCardViewholderBinding binding;
|
||||
|
||||
public ChatCardViewHolder(ChatCardViewholderBinding binding){
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public void setData(ChatItem chatItem, int position){
|
||||
binding.type.setText(chatItem.type);
|
||||
binding.time.setText(chatItem.time);
|
||||
binding.name.setText(chatItem.name);
|
||||
binding.lastMsg.setText(chatItem.last_message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ssb.simplitend.careperson_dashboard.chats;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
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 androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.careperson_dashboard.chats.mvvm.ChatListViewModel;
|
||||
import com.ssb.simplitend.databinding.ChatListFragmentBinding;
|
||||
|
||||
public class ChatListFragment extends Fragment {
|
||||
|
||||
// view binding
|
||||
protected ChatListFragmentBinding binding;
|
||||
|
||||
// view model
|
||||
private ChatListViewModel viewModel;
|
||||
|
||||
public ChatListFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = ChatListFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(ChatListViewModel.class);
|
||||
|
||||
binding.chatsRv.setLayoutManager(new LinearLayoutManager(requireActivity()));
|
||||
binding.chatsRv.setAdapter(viewModel.getChatListAdapter());
|
||||
|
||||
viewModel.getChatListAdapter().submitList(viewModel.getChatItemList());
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
Navigation.findNavController(v).popBackStack(R.id.CPDashboardFragment, false, true);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ssb.simplitend.careperson_dashboard.chats.mvvm;
|
||||
|
||||
public class ChatItem {
|
||||
|
||||
public String type, name, time, last_message;
|
||||
|
||||
public ChatItem() {
|
||||
}
|
||||
|
||||
public ChatItem(String type, String name, String time, String last_message) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.time = time;
|
||||
this.last_message = last_message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.ssb.simplitend.careperson_dashboard.chats.mvvm;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.ssb.simplitend.careperson_dashboard.chats.ChatListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ChatListViewModel extends ViewModel {
|
||||
|
||||
private final ArrayList<ChatItem> chatItemList;
|
||||
private final ChatListAdapter chatListAdapter;
|
||||
|
||||
public ChatListViewModel(){
|
||||
this.chatListAdapter = new ChatListAdapter();
|
||||
|
||||
// static data
|
||||
this.chatItemList = new ArrayList<>();
|
||||
|
||||
this.chatItemList.add(new ChatItem("Caregiver", "Akanksha surve", "09:00 am", "I hope you are doing alright"));
|
||||
this.chatItemList.add(new ChatItem("Doctor", "Chaitali tatkare", "11:00 am", "How was your weekend?"));
|
||||
}
|
||||
|
||||
public ChatListAdapter getChatListAdapter() {
|
||||
return chatListAdapter;
|
||||
}
|
||||
|
||||
public ArrayList<ChatItem> getChatItemList() {
|
||||
return chatItemList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ssb.simplitend.careperson_dashboard.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.CaregiverDashboardFragmentBinding;
|
||||
|
||||
public class CPDashboardFragment extends Fragment {
|
||||
|
||||
// view binding
|
||||
protected CaregiverDashboardFragmentBinding binding;
|
||||
|
||||
public CPDashboardFragment() {
|
||||
// required
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CaregiverDashboardFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.chats.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_CPDashboardFragment_to_chatListFragment)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,12 @@ import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
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.databinding.AddMedicalInfoBinding;
|
||||
|
||||
public class AddMedicalInfoFragment extends Fragment {
|
||||
@@ -16,6 +21,9 @@ public class AddMedicalInfoFragment extends Fragment {
|
||||
// view binding
|
||||
protected AddMedicalInfoBinding binding;
|
||||
|
||||
private MedicalInfo medicalInfo;
|
||||
public static final String MEDICAL_INFO_KEY = "medical_info";
|
||||
|
||||
public AddMedicalInfoFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
@@ -25,6 +33,65 @@ public class AddMedicalInfoFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddMedicalInfoBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle != null){
|
||||
medicalInfo = (MedicalInfo) bundle.getSerializable(MEDICAL_INFO_KEY);
|
||||
if (medicalInfo != null){
|
||||
binding.title.setText(getString(R.string.edit_medical_information));
|
||||
setLayoutInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayoutInfo() {
|
||||
if (medicalInfo == null) return;
|
||||
|
||||
binding.diagnosis.setText(medicalInfo.diagnosis);
|
||||
binding.primaryDoc.setText(medicalInfo.primary_doc);
|
||||
binding.docContact.setText(medicalInfo.doc_contact);
|
||||
binding.hospitalPref.setText(medicalInfo.hospital_pref);
|
||||
binding.allergies.setText(medicalInfo.allergies);
|
||||
binding.dietRestrict.setText(medicalInfo.diet_restriction);
|
||||
|
||||
binding.addBtn.setText(getString(R.string.save));
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.addBtn.setOnClickListener(v -> {
|
||||
ProfileProgress.MEDICAL_INFO_ADDED = true;
|
||||
|
||||
if (medicalInfo != null){
|
||||
// save changes animation
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.make_changes), getString(R.string.yes), getString(R.string.no),
|
||||
v2 -> {
|
||||
// yes click
|
||||
AppUtil.showAnimateDBS(requireContext(), getString(R.string.changes_successful),
|
||||
R.raw.done_anim_primary, 3000,
|
||||
v4 -> {
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
});
|
||||
|
||||
}, v3 -> {
|
||||
// no click
|
||||
});
|
||||
|
||||
}else{
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ssb.simplitend.medicalinfo;
|
||||
|
||||
import static com.ssb.simplitend.medicalinfo.AddMedicalInfoFragment.MEDICAL_INFO_KEY;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -11,6 +13,8 @@ import androidx.fragment.app.Fragment;
|
||||
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;
|
||||
|
||||
public class MedicalInfoFragment extends Fragment {
|
||||
@@ -27,18 +31,48 @@ public class MedicalInfoFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = MedicalIntoFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
if (ProfileProgress.MEDICAL_INFO_ADDED){
|
||||
binding.medicalInfo.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.GONE);
|
||||
}else{
|
||||
binding.noData.setVisibility(View.VISIBLE);
|
||||
binding.medicalInfo.setVisibility(View.GONE);
|
||||
binding.addMedInfo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.addMedInfo.setOnClickListener(v ->
|
||||
{
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.addMedInfo.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).navigate(R.id.action_medicalInfoFragment_to_addMedicalInfoFragment);
|
||||
}
|
||||
);
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
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);
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_medicalInfoFragment_to_addMedicalInfoFragment, bundle);
|
||||
});
|
||||
|
||||
binding.done.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ssb.simplitend.medicalinfo.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MedicalInfo implements Serializable {
|
||||
|
||||
public String diagnosis, primary_doc, doc_contact, hospital_pref
|
||||
, allergies, diet_restriction;
|
||||
|
||||
public MedicalInfo() {}
|
||||
|
||||
public MedicalInfo(String diagnosis, String primary_doc, String doc_contact, String hospital_pref, String allergies, String diet_restriction) {
|
||||
this.diagnosis = diagnosis;
|
||||
this.primary_doc = primary_doc;
|
||||
this.doc_contact = doc_contact;
|
||||
this.hospital_pref = hospital_pref;
|
||||
this.allergies = allergies;
|
||||
this.diet_restriction = diet_restriction;
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.getTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime();
|
||||
@@ -131,6 +133,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
binding.medicName.setText(reminder.dosage_name);
|
||||
binding.quantity.setText(reminder.quantity);
|
||||
binding.getTime.setText(reminder.time);
|
||||
|
||||
binding.addReminder.setText(getString(R.string.save_reminder));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.ssb.simplitend.setuproutine;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
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 android.widget.TextView;
|
||||
|
||||
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.AddRoutineFragmentBinding;
|
||||
import com.ssb.simplitend.setuproutine.mvvm.Routine;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AddRoutineFragment extends Fragment implements CompoundButton.OnCheckedChangeListener{
|
||||
|
||||
// view binding
|
||||
protected AddRoutineFragmentBinding binding;
|
||||
|
||||
private boolean[] week_state;
|
||||
|
||||
public static final String ROUTINE_KEY = "routine_key";
|
||||
private Routine routine;
|
||||
|
||||
public AddRoutineFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = AddRoutineFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initViews() {
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle != null){
|
||||
routine = (Routine) bundle.getSerializable(ROUTINE_KEY);
|
||||
setLayoutDetails();
|
||||
}
|
||||
|
||||
// scrolling instruction edit text
|
||||
binding.routineDescription.setOnTouchListener((v, event) -> {
|
||||
if (binding.routineDescription.hasFocus()) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_SCROLL) {
|
||||
v.getParent().requestDisallowInterceptTouchEvent(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
binding.everydayCheck.setOnCheckedChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
private void setLayoutDetails() {
|
||||
if (routine == null) return;
|
||||
|
||||
binding.title.setText(getString(R.string.edit_routine));
|
||||
binding.addRoutine.setText(getString(R.string.save));
|
||||
|
||||
binding.routineName.setText(routine.routine_name);
|
||||
binding.routineDescription.setText(routine.routine_description);
|
||||
|
||||
binding.startTime.setText(routine.start_time_str);
|
||||
binding.endTime.setText(routine.end_time_str);
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.startTime.setOnClickListener(v -> getTime(binding.startTime));
|
||||
binding.endTime.setOnClickListener(v -> getTime(binding.endTime));
|
||||
|
||||
binding.addRoutine.setOnClickListener(v -> {
|
||||
if (routine == null){
|
||||
Navigation.findNavController(v).popBackStack(R.id.routineFragment, 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.routineFragment, false, true);
|
||||
});
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setUpWeekSelection();
|
||||
|
||||
}
|
||||
|
||||
// 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]));
|
||||
|
||||
}
|
||||
|
||||
// shows time picker and sets the time picked into @textview
|
||||
// shows time picker to pick time and set to textview
|
||||
private void getTime(TextView textView) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance(Locale.getDefault());
|
||||
|
||||
TimePickerDialog tpd = new TimePickerDialog(requireContext(),
|
||||
(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());
|
||||
textView.setText(selected_time);
|
||||
|
||||
}, calendar.getTime().getHours(), calendar.getTime().getMinutes(), false);
|
||||
|
||||
tpd.show();
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
setSelectionState(i, week_state[i] = isChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.ssb.simplitend.setuproutine;
|
||||
|
||||
import static com.ssb.simplitend.setuproutine.AddRoutineFragment.ROUTINE_KEY;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
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 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;
|
||||
|
||||
public class RoutineFragment extends Fragment implements RoutineAdapter.ClickListener, RoutineAdapter.DeleteClickListener {
|
||||
|
||||
// view binding
|
||||
protected RoutineFragmentBinding binding;
|
||||
|
||||
// selection state for week days
|
||||
/*
|
||||
true -> date selected
|
||||
false -> date unselected
|
||||
*/
|
||||
private boolean[] selection_state;
|
||||
|
||||
private RoutineViewModel viewModel;
|
||||
|
||||
public RoutineFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RoutineFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.addRoutine.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).navigate(R.id.action_routineFragment_to_addRoutineFragment);
|
||||
});
|
||||
|
||||
// date selections
|
||||
binding.sun.setOnClickListener(v -> {
|
||||
setSelectionState(0, selection_state[0] = !selection_state[0]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.mon.setOnClickListener(v -> {
|
||||
setSelectionState(1, selection_state[1] = !selection_state[1]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.tue.setOnClickListener(v -> {
|
||||
setSelectionState(2, selection_state[2] = !selection_state[2]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.wed.setOnClickListener(v -> {
|
||||
setSelectionState(3, selection_state[3] = !selection_state[3]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.thu.setOnClickListener(v -> {
|
||||
setSelectionState(4, selection_state[4] = !selection_state[4]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.fri.setOnClickListener(v -> {
|
||||
setSelectionState(5, selection_state[5] = !selection_state[5]);
|
||||
loadRoutineList();
|
||||
});
|
||||
binding.sat.setOnClickListener(v -> {
|
||||
setSelectionState(6, selection_state[6] = !selection_state[6]);
|
||||
loadRoutineList();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
selection_state = new boolean[7];
|
||||
|
||||
viewModel = new ViewModelProvider(this).get(RoutineViewModel.class);
|
||||
}
|
||||
|
||||
private void loadRoutineList() {
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
binding.routineRv.setVisibility(View.VISIBLE);
|
||||
binding.routineRv.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
binding.routineRv.setAdapter(viewModel.getRoutineAdapter());
|
||||
|
||||
viewModel.getRoutineAdapter().setDeleteClickListener(this);
|
||||
viewModel.getRoutineAdapter().setClickListener(this);
|
||||
|
||||
viewModel.getRoutineAdapter().submitList(viewModel.getRoutines());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete(Routine routine, int position) {
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(), getString(R.string.delete_med_routine),
|
||||
getString(R.string.yes), getString(R.string.no),
|
||||
v1-> {
|
||||
// yes click
|
||||
}, v2 -> {
|
||||
// no click
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Routine routine, int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(ROUTINE_KEY, routine);
|
||||
|
||||
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_routineFragment_to_addRoutineFragment, bundle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Routine implements Serializable {
|
||||
|
||||
public String routine_name, routine_description, start_time_str, end_time_str;
|
||||
|
||||
public Routine() {}
|
||||
|
||||
public Routine(String routine_name, String routine_description, String start_time_str, String end_time_str) {
|
||||
this.routine_name = routine_name;
|
||||
this.routine_description = routine_description;
|
||||
this.start_time_str = start_time_str;
|
||||
this.end_time_str = end_time_str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.ssb.simplitend.databinding.RoutineViewholderBinding;
|
||||
|
||||
public class RoutineAdapter extends ListAdapter<Routine, RoutineAdapter.RoutineViewHolder> {
|
||||
|
||||
private static final DiffUtil.ItemCallback<Routine> DIFF_UTIL = new DiffUtil.ItemCallback<Routine>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull Routine oldItem, @NonNull Routine newItem) {
|
||||
// TODO: 10-07-2023
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull Routine oldItem, @NonNull Routine newItem) {
|
||||
// TODO: 10-07-2023
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private DeleteClickListener deleteClickListener;
|
||||
private ClickListener clickListener;
|
||||
|
||||
public RoutineAdapter(){
|
||||
super(DIFF_UTIL);
|
||||
}
|
||||
|
||||
public void setDeleteClickListener(DeleteClickListener deleteClickListener) {
|
||||
this.deleteClickListener = deleteClickListener;
|
||||
}
|
||||
|
||||
public void setClickListener(ClickListener clickListener) {
|
||||
this.clickListener = clickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RoutineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
RoutineViewholderBinding binding = RoutineViewholderBinding.inflate(LayoutInflater.from(parent.getContext()));
|
||||
return new RoutineViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RoutineViewHolder holder, int position) {
|
||||
holder.setData(getItem(position), position);
|
||||
|
||||
holder.binding.delete.setOnClickListener(v -> {
|
||||
if (deleteClickListener != null) deleteClickListener.onDelete(getItem(position), position);
|
||||
});
|
||||
|
||||
holder.binding.card.setOnClickListener(v -> {
|
||||
if (clickListener != null) clickListener.onClick(getItem(position), position);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static class RoutineViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
RoutineViewholderBinding binding;
|
||||
|
||||
public RoutineViewHolder(RoutineViewholderBinding binding){
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public void setData(Routine routine, int position){
|
||||
|
||||
binding.routineName.setText(routine.routine_name);
|
||||
binding.description.setText(routine.routine_description);
|
||||
|
||||
String time_slot = routine.start_time_str + " - " + routine.end_time_str;
|
||||
binding.timeSlot.setText(time_slot);
|
||||
|
||||
// static
|
||||
String start_slot = routine.start_time_str.substring(0, 2) + " " + routine.start_time_str.substring(routine.start_time_str.length()-2);
|
||||
binding.startTimeStatic.setText(start_slot);
|
||||
|
||||
String end_slot = routine.end_time_str.substring(0, 2) + " " + routine.end_time_str.substring(routine.end_time_str.length()-2);
|
||||
binding.endTimeStatic.setText(end_slot);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// interfaces
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DeleteClickListener{
|
||||
void onDelete(Routine routine, int position);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClickListener{
|
||||
void onClick(Routine routine, int position);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ssb.simplitend.setuproutine.mvvm;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RoutineViewModel extends ViewModel {
|
||||
|
||||
private final ArrayList<Routine> routines;
|
||||
private final RoutineAdapter routineAdapter;
|
||||
|
||||
public RoutineViewModel(){
|
||||
this.routineAdapter = new RoutineAdapter();
|
||||
|
||||
// init static data in routine list
|
||||
this.routines = new ArrayList<>();
|
||||
routines.add(new Routine("Doctor appointment", "Meet your heart specialist Abraham at 4:00 pm", "07 : 00 AM", "09 : 00 AM"));
|
||||
routines.add(new Routine("Take medicines", "Lorem Ipsum is simply dummy.", "11 : 00 AM", "12 : 00 PM"));
|
||||
}
|
||||
|
||||
public RoutineAdapter getRoutineAdapter() {
|
||||
return routineAdapter;
|
||||
}
|
||||
|
||||
public ArrayList<Routine> getRoutines() {
|
||||
return routines;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ssb.simplitend.userprofile;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -11,6 +12,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.careperson_dashboard.DashBoardActivityCP;
|
||||
import com.ssb.simplitend.databinding.ProfileProgressFragmentBinding;
|
||||
|
||||
public class ProfileProgressFragment extends Fragment {
|
||||
@@ -47,5 +49,16 @@ public class ProfileProgressFragment extends Fragment {
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_medicalInfoFragment)
|
||||
);
|
||||
|
||||
binding.setUpRoutine.setOnClickListener(v ->
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_routineFragment)
|
||||
);
|
||||
|
||||
binding.skipToDashboard.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), DashBoardActivityCP.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user