.
This commit is contained in:
@@ -10,6 +10,7 @@ import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -101,11 +101,8 @@ public class ProfileProgressFragment extends Fragment implements ProfileContract
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_routineFragment)
|
||||
);
|
||||
|
||||
binding.skipToDashboard.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), DashBoardActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivity(intent);
|
||||
requireActivity().finish();
|
||||
binding.proceed.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_registerCompleteFragment);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import android.animation.Animator;
|
||||
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 com.daimajia.androidanimations.library.Techniques;
|
||||
import com.daimajia.androidanimations.library.YoYo;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.RegisterationDoneFragmentBinding;
|
||||
|
||||
public class RegisterCompleteFragment extends Fragment {
|
||||
|
||||
public RegisterationDoneFragmentBinding binding;
|
||||
|
||||
public RegisterCompleteFragment(){
|
||||
// required
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RegisterationDoneFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
binding.animIv.setAnimation(R.raw.done_anim_2);
|
||||
binding.animIv.playAnimation();
|
||||
|
||||
binding.animIv.addAnimatorListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(@NonNull Animator animator) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(@NonNull Animator animator) {
|
||||
binding.title.setText(getString(R.string.your_profile_is_100_complete));
|
||||
YoYo.with(Techniques.FadeIn)
|
||||
.duration(100)
|
||||
.playOn(binding.title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(@NonNull Animator animator) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(@NonNull Animator animator) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
binding.proceed.setOnClickListener(v -> {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Ask Caregiver to register",
|
||||
"Kindly ask CareGiver to complete registeration.",
|
||||
"OK",
|
||||
((dialogInterface, i) -> {
|
||||
|
||||
}), null, null);
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
}
|
||||
@@ -180,9 +180,10 @@ public class AddMedicalInfoFragment extends Fragment implements
|
||||
binding.primaryDoc.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.docContact.getText().toString().trim().isEmpty()){
|
||||
if (binding.docContact.getText().toString().trim().isEmpty()
|
||||
|| binding.docContact.getText().toString().trim().length() < 10){
|
||||
allOkay = false;
|
||||
binding.docContact.setError("Required");
|
||||
binding.docContact.setError("Invalid");
|
||||
}
|
||||
|
||||
if (binding.hospitalPref.getText().toString().trim().isEmpty()){
|
||||
|
||||
@@ -170,6 +170,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
// this intent is to update the reminder
|
||||
reminderResult.is_update = "1";
|
||||
reminderResult.patientRemainderId = reminder.id;
|
||||
|
||||
reminderResult.reminder_marked = reminder.reminder_marked;
|
||||
} else {
|
||||
reminderResult.is_update = "0";
|
||||
}
|
||||
@@ -503,6 +505,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
|
||||
});
|
||||
|
||||
dpd.getDatePicker().setMinDate(System.currentTimeMillis());
|
||||
|
||||
dpd.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.ReminderViewholderBinding;
|
||||
import com.ssb.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.ssb.simplitend.patientprofile.setuproutine.mvvm.RoutineAdapter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
@@ -107,29 +106,22 @@ public class ReminderAdapter extends ListAdapter<ReminderResult, ReminderAdapter
|
||||
String quantity = reminder.medication_quantity + " capsules";
|
||||
binding.quantity.setText(quantity);
|
||||
|
||||
// static image
|
||||
if (position == 0){
|
||||
binding.medImg.setImageResource(R.drawable.img_med_type_1);
|
||||
if (reminder.medication_type != null && reminder.medication_type.size() > 0) {
|
||||
switch (reminder.medication_type.get(0).title){
|
||||
case "Capsule":
|
||||
binding.medImg.setImageResource(R.drawable.ic_capsules);
|
||||
break;
|
||||
case "Pill":
|
||||
binding.medImg.setImageResource(R.drawable.ic_pills);
|
||||
break;
|
||||
case "Drops":
|
||||
binding.medImg.setImageResource(R.drawable.ic_drops);
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
binding.medImg.setImageResource(R.drawable.img_med_type_2);
|
||||
binding.medImg.setImageResource(R.drawable.ic_capsules);
|
||||
}
|
||||
|
||||
// binding.done.setOnClickListener(v -> {
|
||||
// if (selection_state[position]){
|
||||
// // item selected. un-selecting now
|
||||
// binding.sideBar.setBackgroundTintList(null);
|
||||
// binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.white_bg));
|
||||
// binding.done.setImageResource(R.drawable.ic_done_accent);
|
||||
// }else{
|
||||
// // item un-selected. selecting now
|
||||
// binding.sideBar.setBackgroundTintList(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_primary));
|
||||
// binding.card.setCardBackgroundColor(AppCompatResources.getColorStateList(itemView.getContext(), R.color.color_accent));
|
||||
// binding.done.setImageResource(R.drawable.ic_done_accent_2);
|
||||
// }
|
||||
//
|
||||
// selection_state[position] = !selection_state[position];
|
||||
// });
|
||||
|
||||
if (reminder.reminder_marked != null){
|
||||
/*
|
||||
This routine is done for some day.
|
||||
|
||||
@@ -147,11 +147,38 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
|
||||
binding.startTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime(binding.startTime);
|
||||
binding.startTime.setError(null);
|
||||
|
||||
Date selected_date = null;
|
||||
|
||||
if (!binding.startTime.getText().toString().trim().isEmpty()){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
try {
|
||||
selected_date = sdf.parse(binding.startTime.getText().toString().trim());
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
getTime(binding.startTime, selected_date);
|
||||
});
|
||||
|
||||
binding.endTime.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
getTime(binding.endTime);
|
||||
binding.endTime.setError(null);
|
||||
|
||||
Date selected_date = null;
|
||||
|
||||
if (!binding.endTime.getText().toString().trim().isEmpty()){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
try {
|
||||
selected_date = sdf.parse(binding.endTime.getText().toString().trim());
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
getTime(binding.endTime, selected_date);
|
||||
});
|
||||
|
||||
binding.addRoutine.setOnClickListener(v -> {
|
||||
@@ -205,6 +232,7 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
// this intent is to update the reminder
|
||||
routineDetails.is_update = 1;
|
||||
routineDetails.patientRoutineId = routine.id;
|
||||
routineDetails.routine_marked = routine.routine_marked;
|
||||
} else {
|
||||
routineDetails.is_update = 0;
|
||||
}
|
||||
@@ -241,6 +269,26 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
binding.endTime.setError("Required");
|
||||
}
|
||||
|
||||
if (allOkay){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault());
|
||||
|
||||
try {
|
||||
Date start_date = sdf.parse(binding.startTime.getText().toString().trim());
|
||||
Date end_date = sdf.parse(binding.endTime.getText().toString().trim());
|
||||
|
||||
if (start_date == null || end_date == null) throw new Exception();
|
||||
|
||||
if (start_date.getTime() >= end_date.getTime()){
|
||||
Toast.makeText(requireContext(), "Emd time should be greater than start time.", Toast.LENGTH_SHORT).show();
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (allOkay) {
|
||||
boolean anyOneSelected = false;
|
||||
for (int i = 0; i < week_state.length; i++) {
|
||||
@@ -279,10 +327,14 @@ public class AddRoutineFragment extends Fragment implements CompoundButton.OnChe
|
||||
|
||||
// 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) {
|
||||
private void getTime(TextView textView, Date selected_date) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance(Locale.getDefault());
|
||||
|
||||
if (selected_date != null){
|
||||
calendar.setTime(selected_date);
|
||||
}
|
||||
|
||||
TimePickerDialog tpd = new TimePickerDialog(requireContext(),
|
||||
(view, hourOfDay, minute) -> {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ssb.simplitend.welcome.fragments.contacts;
|
||||
|
||||
import static com.ssb.simplitend.welcome.fragments.contacts.ContactInfoFragment.CONTACT_DATA_KEY;
|
||||
import static com.ssb.simplitend.welcome.fragments.contacts.CreateContactFragment.TO_EDIT_KEY;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
@@ -121,8 +122,26 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
|
||||
public void onContactClick(ContactData contactData, int position) {
|
||||
if (contactData.id == -1){
|
||||
// a new contact should be added
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_addContactFragment_to_contactListFragment);
|
||||
|
||||
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Select contact",
|
||||
"Add from contacts or manually?",
|
||||
"Contacts",
|
||||
((dialogInterface, i) -> {
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_addContactFragment_to_contactListFragment);
|
||||
}),
|
||||
"Manually",
|
||||
((dialogInterface, i) -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(TO_EDIT_KEY, false);
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_addContactFragment_to_createContactFragment, bundle);
|
||||
})
|
||||
);
|
||||
|
||||
}else{
|
||||
// show contact details
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
@@ -83,7 +83,19 @@ public class ContactInfoFragment extends Fragment implements WelcomeContracts.De
|
||||
binding.name.setText(contactData.first_name);
|
||||
binding.phoneNumber.setText(contactData.phone_number);
|
||||
binding.email.setText(contactData.email_address);
|
||||
binding.relationship.setText(contactData.relationship);
|
||||
|
||||
if (contactData.relationship == null || contactData.relationship.trim().isEmpty()){
|
||||
binding.relationship.setVisibility(View.GONE);
|
||||
binding.relationshipTag.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (contactData.is_sos.equals("1")){
|
||||
binding.relationship.setText(contactData.relationship + "( Emergency contact )");
|
||||
}else{
|
||||
binding.relationship.setText(contactData.relationship);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
@@ -156,8 +156,6 @@ public class ContactListFragment extends Fragment {
|
||||
binding.contactRv.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
binding.contactRv.setAdapter(contactListAdapter);
|
||||
|
||||
loadContacts();
|
||||
|
||||
permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(),
|
||||
granted -> {
|
||||
if (granted) {
|
||||
@@ -177,6 +175,8 @@ public class ContactListFragment extends Fragment {
|
||||
|
||||
});
|
||||
|
||||
loadContacts();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -83,6 +83,9 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
private ContactData contactData;
|
||||
|
||||
// Remote contact list
|
||||
protected List<ContactListResponse> contactList;
|
||||
|
||||
public CreateContactFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -323,9 +326,10 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
binding.name.setError("Required");
|
||||
}
|
||||
|
||||
if (binding.phoneNumber.getText().toString().trim().isEmpty()) {
|
||||
if (binding.phoneNumber.getText().toString().trim().isEmpty() ||
|
||||
binding.phoneNumber.getText().toString().trim().length() < 10) {
|
||||
allOkay = false;
|
||||
binding.phoneNumber.setError("Required");
|
||||
binding.phoneNumber.setError("Invalid");
|
||||
} else if (!Patterns.PHONE.matcher(binding.phoneNumber.getText().toString()).matches()) {
|
||||
allOkay = false;
|
||||
binding.phoneNumber.setError("Invalid number");
|
||||
@@ -347,6 +351,20 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
private boolean phoneAlreadyAdded() {
|
||||
|
||||
for (ContactListResponse contact: contactList){
|
||||
String contact_number = countryCodeList.get(binding.countryCodes.getSelectedIndex()) + " " +
|
||||
binding.phoneNumber.getText().toString();
|
||||
|
||||
if (contact.contact_data.phone_number.equals(contact_number)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gotoAddFragment(BottomSheetDialog bsd) {
|
||||
new Handler().postDelayed(() -> {
|
||||
@@ -367,6 +385,9 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
@Override
|
||||
public void onResponse(List<ContactListResponse> contactList) {
|
||||
Log.d(TAG, "onResponse: " + contactList);
|
||||
|
||||
this.contactList = contactList;
|
||||
|
||||
if (contactList.size() == 0) {
|
||||
// there are no contacts in remote database
|
||||
// thus, this contact has to be a caregiver
|
||||
@@ -376,6 +397,8 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
binding.caregiverCheckView.setVisibility(View.VISIBLE);
|
||||
this.mustBeeCaregiver = true;
|
||||
binding.caregiverCheck.setChecked(true);
|
||||
}else{
|
||||
binding.caregiverCheckView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// checking if there is any SOS contact already in list
|
||||
|
||||
@@ -10,11 +10,17 @@ import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
@@ -112,6 +118,15 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (getActivity() != null) {
|
||||
getActivity().getWindow()
|
||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
@@ -124,6 +139,8 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
loadCountriesAndStates();
|
||||
|
||||
inputFieldFocusManage();
|
||||
|
||||
try {
|
||||
loadPatientAddressSavedState();
|
||||
} catch (Exception e) {
|
||||
@@ -160,6 +177,17 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
}
|
||||
|
||||
private void inputFieldFocusManage() {
|
||||
|
||||
binding.town.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
binding.town.clearFocus();
|
||||
binding.countrySpinner.show();
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// load data from watcher
|
||||
private void loadPatientAddressSavedState() throws Exception {
|
||||
PatientData patientData = viewModel.getPatientData();
|
||||
@@ -461,15 +489,15 @@ 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));
|
||||
}
|
||||
}
|
||||
// selecting United States country as by default
|
||||
// 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);
|
||||
@@ -493,10 +521,18 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
binding.stateSpinner.setItems(stateList);
|
||||
binding.stateSpinner.clearSelectedItem();
|
||||
}
|
||||
|
||||
binding.stateSpinner.requestFocus();
|
||||
});
|
||||
|
||||
binding.stateSpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener<String>) (i, s, i1, t1) -> {
|
||||
binding.stateSpinner.setError(null);
|
||||
binding.zipCode.requestFocus();
|
||||
|
||||
if (getActivity() != null) {
|
||||
getActivity().getWindow()
|
||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -6,17 +6,13 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.PhoneNumberFormattingTextWatcher;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -26,7 +22,6 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.ssb.simplitend.R;
|
||||
@@ -57,6 +52,8 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private DatePickerDialog datePickerDialog;
|
||||
|
||||
public RegisterFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -75,10 +72,23 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (getActivity() != null) {
|
||||
getActivity().getWindow()
|
||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
datePickerDialog = new DatePickerDialog(requireContext());
|
||||
}
|
||||
|
||||
countryCodeList = viewModel.loadCountryCodeDropDown(requireContext());
|
||||
|
||||
binding.countryCodes.setLifecycleOwner(this);
|
||||
@@ -93,10 +103,23 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
loadPatientDataSavedState();
|
||||
|
||||
setFocusManager();
|
||||
|
||||
setErrorRemovers();
|
||||
|
||||
}
|
||||
|
||||
private void setFocusManager() {
|
||||
binding.name.setOnEditorActionListener((textView, i, keyEvent) -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
binding.name.clearFocus();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
pickDate();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// This adds textChangeListener to all the EditTexts available to remove error if available
|
||||
private void setErrorRemovers() {
|
||||
new EditTextErrorRemover(
|
||||
@@ -193,6 +216,7 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
binding.dob.setError(null);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
pickDate();
|
||||
}
|
||||
});
|
||||
@@ -244,8 +268,9 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.contactNumber.getText().toString().trim().isEmpty()) {
|
||||
binding.contactNumber.setError("Required");
|
||||
if (binding.contactNumber.getText().toString().trim().isEmpty() ||
|
||||
binding.contactNumber.getText().toString().trim().length() <10) {
|
||||
binding.contactNumber.setError("Invalid");
|
||||
allOkay = false;
|
||||
} else if (!Patterns.PHONE.matcher(binding.contactNumber.getText().toString()).matches()) {
|
||||
binding.contactNumber.setError("Invalid contact");
|
||||
@@ -261,7 +286,14 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
}
|
||||
|
||||
if (!binding.tncCheck.isChecked() && allOkay) {
|
||||
Toast.makeText(requireContext(), "Please check terms and conditions to continue.", Toast.LENGTH_SHORT).show();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Accept terms and conditions",
|
||||
"Please check terms and conditions to continue.",
|
||||
"Ok",
|
||||
((dialogInterface, i) -> {
|
||||
// do nothing
|
||||
}), null, null
|
||||
);
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
@@ -306,7 +338,7 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void pickDate() {
|
||||
|
||||
DatePickerDialog datePickerDialog = new DatePickerDialog(requireContext());
|
||||
if (datePickerDialog == null) return;
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 18);
|
||||
@@ -314,6 +346,13 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
datePickerDialog.setOnDateSetListener((view, year, month, dayOfMonth) -> {
|
||||
setDOB(year, month, dayOfMonth);
|
||||
|
||||
binding.contactNumber.requestFocus();
|
||||
|
||||
if (getActivity() != null) {
|
||||
getActivity().getWindow()
|
||||
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
datePickerDialog.show();
|
||||
|
||||
Reference in New Issue
Block a user