This commit is contained in:
ADITYA
2023-07-29 03:32:28 +05:30
parent eca48d989f
commit 374cc95c36
11 changed files with 87 additions and 27 deletions

View File

@@ -207,16 +207,21 @@ public class AddMedicalInfoFragment extends Fragment implements
public void onMedicalInfoAdded(MedicationInfo medicationInfo) {
progressDialog.dismiss();
String title;
if (this.medicalInfo == null){
Toast.makeText(requireContext(), "Medical information added successfully", Toast.LENGTH_SHORT).show();
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.medicalInfoFragment, false);
title = getString(R.string.med_added_successful);
}else{
AppUtil.showAnimateDBS(requireContext(), getString(R.string.changes_successful),
R.raw.done_anim_primary, 3000,
yes -> {
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.medicalInfoFragment, false);
});
title = getString(R.string.changes_successful);
}
AppUtil.showAnimateDBS(requireContext(),
title,
R.raw.done_anim_primary, 3000,
yes -> {
Navigation.findNavController(binding.getRoot()).popBackStack(R.id.medicalInfoFragment, false);
});
}
@Override

View File

@@ -568,6 +568,12 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
Bundle bundle = getArguments();
if (bundle != null) {
setLayoutDetails(reminder = (ReminderResult) bundle.getSerializable(REMINDER_KEY));
}else{
// selecting default week day as current
Calendar calendar = Calendar.getInstance();
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
setSelectionState(day_of_week, week_state[day_of_week] = true);
}
progressDialog.dismiss();

View File

@@ -77,6 +77,12 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
if (bundle != null && bundle.getSerializable(ROUTINE_KEY) != null){
routine = (RoutineDetails) bundle.getSerializable(ROUTINE_KEY);
setLayoutDetails();
}else{
// selecting default week day as current
Calendar calendar = Calendar.getInstance();
int day_of_week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
setSelectionState(day_of_week, week_state[day_of_week] = true);
}
// scrolling instruction edit text

View File

@@ -4,6 +4,7 @@ import static com.ssb.simplitend.welcome.fragments.contacts.CreateContactFragmen
import static com.ssb.simplitend.welcome.fragments.contacts.CreateContactFragment.TO_EDIT_KEY;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
@@ -35,7 +36,7 @@ import com.ssb.simplitend.welcome.fragments.contacts.mvvm.models.ContactData;
import java.util.ArrayList;
public class ContactListFragment extends Fragment{
public class ContactListFragment extends Fragment {
private static final String TAG = "aditya";
@@ -48,18 +49,14 @@ public class ContactListFragment extends Fragment{
protected ActivityResultLauncher<String> permissionLauncher;
protected ActivityResultLauncher<Intent> insertContactLauncher;
private ArrayList<Contact> contactList;
public ContactListFragment() {
// required empty const.
}
@Override
public void onStart() {
super.onStart();
loadContacts();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -79,9 +76,10 @@ public class ContactListFragment extends Fragment{
binding.createContact.setOnClickListener(v ->
{
// insert contact intent
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivity(intent);
Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
insertContactLauncher.launch(intent);
}
);
@@ -92,7 +90,7 @@ public class ContactListFragment extends Fragment{
bundle.putSerializable(CONTACT_KEY, new ContactData(contact));
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_contactListFragment_to_createContactFragment, bundle);
}
);
);
binding.search.addTextChangedListener(new TextWatcher() {
@Override
@@ -118,21 +116,21 @@ public class ContactListFragment extends Fragment{
new Thread(() -> {
if(searchInput.isEmpty()) {
if (searchInput.isEmpty()) {
contactListAdapter.submitList(contactList);
return;
}
ArrayList<Contact> filteredList = new ArrayList<>();
for (Contact contact: contactList){
if (contact.first_name != null && contact.first_name.trim().toLowerCase().contains(searchInput)){
for (Contact contact : contactList) {
if (contact.first_name != null && contact.first_name.trim().toLowerCase().contains(searchInput)) {
filteredList.add(contact);
}else if (contact.phone_number != null && contact.phone_number.trim().contains(searchInput)){
} else if (contact.phone_number != null && contact.phone_number.trim().contains(searchInput)) {
filteredList.add(contact);
}else if (contact.email_address != null && contact.email_address.trim().toLowerCase().contains(searchInput)){
} else if (contact.email_address != null && contact.email_address.trim().toLowerCase().contains(searchInput)) {
filteredList.add(contact);
}else if (contact.relationship != null && contact.relationship.trim().toLowerCase().contains(searchInput)){
} else if (contact.relationship != null && contact.relationship.trim().toLowerCase().contains(searchInput)) {
filteredList.add(contact);
}
}
@@ -151,12 +149,15 @@ public class ContactListFragment extends Fragment{
}
@SuppressLint("Range")
private void initializeViews() {
// initiating recycler view for contact list
contactListAdapter = new ContactListAdapter();
binding.contactRv.setLayoutManager(new LinearLayoutManager(requireContext()));
binding.contactRv.setAdapter(contactListAdapter);
loadContacts();
permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
granted -> {
if (granted) {
@@ -169,6 +170,13 @@ public class ContactListFragment extends Fragment{
}
);
insertContactLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
loadContacts();
});
}
/*

View File

@@ -133,17 +133,16 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
} else {
setLayoutDetails(getString(R.string.create_contact), getString(R.string.add_photo), getString(R.string.create_contact));
loadRemoteContactList();
}
if (bundle.getSerializable(CONTACT_KEY) != null) {
contactData = (ContactData) bundle.getSerializable(CONTACT_KEY);
setDetails();
}
} else {
loadRemoteContactList();
}
loadRemoteContactList();
binding.sosCheck.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (isChecked) {
contactViewModel.showSOSDecision(requireContext());
@@ -379,6 +378,31 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
binding.caregiverCheck.setChecked(true);
}
// checking if there is any SOS contact already in list
boolean isSosSet = false;
int sos_contact_id = -1;
for (ContactListResponse contact: contactList){
if (contact.is_sos_contact.equals("1")) {
isSosSet = true;
sos_contact_id = contact.contact_data.id;
break;
}
}
if (isSosSet){
binding.sosCheckView.setVisibility(View.GONE);
if (contactData != null && sos_contact_id != -1 && sos_contact_id == contactData.id){
// current contact being edited is the SOS contact
// thus, sos switch can be edited
binding.sosCheckView.setVisibility(View.VISIBLE);
}
}else{
binding.sosCheckView.setVisibility(View.VISIBLE);
}
progressDialog.dismiss();
}