.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.ssb.simplitend.patientprofile;
|
||||
|
||||
import static com.ssb.simplitend.patientprofile.RegisterCompleteFragment.PROFILE_PROGRESS;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -30,6 +32,8 @@ public class ProfileProgressFragment extends Fragment implements ProfileContract
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
int profile_progress;
|
||||
|
||||
public ProfileProgressFragment() {
|
||||
// required empty const.
|
||||
}
|
||||
@@ -100,30 +104,43 @@ public class ProfileProgressFragment extends Fragment implements ProfileContract
|
||||
);
|
||||
|
||||
binding.proceed.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_registerCompleteFragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(PROFILE_PROGRESS, profile_progress);
|
||||
|
||||
Navigation.findNavController(v).navigate(R.id.action_profileProgressFragment_to_registerCompleteFragment, bundle);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileProgressFetched(@NonNull PatientData patientData) {
|
||||
|
||||
profile_progress = 0;
|
||||
|
||||
if (patientData.isCareGiverLink == 1) {
|
||||
// TODO: 25-07-2023 look into this
|
||||
profile_progress++;
|
||||
}
|
||||
|
||||
if (patientData.isPatientReminderData == 1) {
|
||||
profile_progress++;
|
||||
|
||||
binding.medReminderImg.setImageResource(0);
|
||||
binding.medReminderImg.setBackgroundResource(R.drawable.ic_done);
|
||||
binding.medReminderImg.setPaddingRelative(15, 15, 15, 15);
|
||||
}
|
||||
|
||||
if (patientData.isPatientMedicalData == 1) {
|
||||
profile_progress++;
|
||||
|
||||
binding.medInfoImg.setImageResource(0);
|
||||
binding.medInfoImg.setBackgroundResource(R.drawable.ic_done);
|
||||
binding.medInfoImg.setPadding(15, 15, 15, 15);
|
||||
}
|
||||
|
||||
if (patientData.isPatientRoutineData == 1) {
|
||||
profile_progress++;
|
||||
|
||||
binding.setupRoutineImg.setImageResource(0);
|
||||
binding.setupRoutineImg.setBackgroundResource(R.drawable.ic_done);
|
||||
binding.setupRoutineImg.setPadding(15, 15, 15, 15);
|
||||
|
||||
@@ -20,6 +20,10 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
|
||||
public RegisterationDoneFragmentBinding binding;
|
||||
|
||||
public static final String PROFILE_PROGRESS = "profile_progress";
|
||||
|
||||
int profile_progress;
|
||||
|
||||
public RegisterCompleteFragment(){
|
||||
// required
|
||||
}
|
||||
@@ -29,6 +33,10 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = RegisterationDoneFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
if (getArguments() != null){
|
||||
profile_progress = getArguments().getInt(PROFILE_PROGRESS, 20);
|
||||
}
|
||||
|
||||
binding.animIv.setAnimation(R.raw.done_anim_2);
|
||||
binding.animIv.playAnimation();
|
||||
|
||||
@@ -40,7 +48,10 @@ public class RegisterCompleteFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(@NonNull Animator animator) {
|
||||
binding.title.setText(getString(R.string.your_profile_is_100_complete));
|
||||
|
||||
String title = "Your profile is " + (profile_progress * 20) + "% complete!";
|
||||
|
||||
binding.title.setText(title);
|
||||
YoYo.with(Techniques.FadeIn)
|
||||
.duration(100)
|
||||
.playOn(binding.title);
|
||||
|
||||
@@ -14,6 +14,7 @@ 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;
|
||||
@@ -147,7 +148,10 @@ public class AddMedicalInfoFragment extends Fragment implements
|
||||
binding.diagnosis.setText(medicalInfo.diagnosis);
|
||||
binding.primaryDoc.setText(medicalInfo.primary_care_doctor);
|
||||
|
||||
binding.phoneNumber.setText(medicalInfo.doctor_phone_number);
|
||||
if (medicalInfo.doctor_phone_number != null)
|
||||
{
|
||||
binding.phoneNumber.setText(medicalInfo.doctor_phone_number);
|
||||
}
|
||||
|
||||
binding.hospitalPref.setText(medicalInfo.hospital_preference);
|
||||
binding.allergies.setText(medicalInfo.allergies);
|
||||
@@ -161,7 +165,6 @@ public class AddMedicalInfoFragment extends Fragment implements
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.addBtn.setOnClickListener(v -> {
|
||||
ProfileProgress.MEDICAL_INFO_ADDED = true;
|
||||
|
||||
if (allOkay()){
|
||||
if (medicalInfo != null){
|
||||
@@ -268,6 +271,24 @@ public class AddMedicalInfoFragment extends Fragment implements
|
||||
|| binding.phoneNumber.getText().toString().trim().length() < 10){
|
||||
allOkay = false;
|
||||
binding.phoneNumber.setError("Invalid");
|
||||
}else if (binding.countryCodes.getSelectedIndex() == -1 ||
|
||||
binding.countryCodes.getSelectedIndex() >= countryCodeList.size()){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Select a coutnry code.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
// validating phone number
|
||||
try {
|
||||
Phonenumber.PhoneNumber phone_number = PhoneNumberUtil.getInstance().parse(countryCodeList.get(binding.countryCodes.getSelectedIndex())+
|
||||
binding.phoneNumber.getText().toString(), "US");
|
||||
|
||||
if (!PhoneNumberUtil.getInstance().isValidNumber(phone_number)) {
|
||||
binding.phoneNumber.setError("Invalid phone number");
|
||||
allOkay = false;
|
||||
}
|
||||
} catch (NumberParseException e) {
|
||||
// do nothing as we couldn't validate phone number
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.hospitalPref.getText().toString().trim().isEmpty()){
|
||||
|
||||
@@ -109,7 +109,6 @@ ReminderAdapter.ReminderCheckClickListener{
|
||||
|
||||
binding.done.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v).popBackStack();
|
||||
ProfileProgress.PROFILE_PROGRESS[0] = true;
|
||||
});
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
@@ -156,7 +155,7 @@ ReminderAdapter.ReminderCheckClickListener{
|
||||
// show days of week
|
||||
setDayOfWeekViews();
|
||||
|
||||
setDayOfWeek(reminderViewModel.selected_dow);
|
||||
setDayOfWeek(reminderViewModel.selected_dow = 0);
|
||||
|
||||
loadReminderList(weekDayViewsList.get(reminderViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
// show days of week
|
||||
setDayOfWeekViews();
|
||||
|
||||
setDayOfWeek(routineViewModel.selected_dow);
|
||||
setDayOfWeek(routineViewModel.selected_dow = 0);
|
||||
|
||||
loadRoutineList(weekDayViewsList.get(routineViewModel.selected_dow).day_of_week);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ 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.apputils.AppUtil;
|
||||
@@ -346,9 +347,24 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
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");
|
||||
} else if (binding.countryCodes.getSelectedIndex() == -1 ||
|
||||
binding.countryCodes.getSelectedIndex() >= countryCodeList.size()){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Select a country code.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
// validating phone number
|
||||
try {
|
||||
Phonenumber.PhoneNumber phone_number = PhoneNumberUtil.getInstance().parse(countryCodeList.get(binding.countryCodes.getSelectedIndex())+
|
||||
binding.contactNumber.getText().toString(), "US");
|
||||
|
||||
if (!PhoneNumberUtil.getInstance().isValidNumber(phone_number)) {
|
||||
binding.contactNumber.setError("Invalid phone number");
|
||||
allOkay = false;
|
||||
}
|
||||
} catch (NumberParseException e) {
|
||||
// do nothing as we couldn't validate phone number
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.navigation.Navigation;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.ssb.simplitend.R;
|
||||
@@ -117,11 +118,11 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
binding.countryCodes.setItems(countryCodeList);
|
||||
|
||||
if (!countryCodeList.contains("+1")){
|
||||
if (!countryCodeList.contains("+1")) {
|
||||
countryCodeList.add("+1");
|
||||
}
|
||||
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf("+91"));
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf("+1"));
|
||||
|
||||
binding.countryCodes.setDismissWhenNotifiedItemSelected(true);
|
||||
|
||||
@@ -136,7 +137,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
String country_code = null;
|
||||
|
||||
if (binding.countryCodes.getSelectedIndex() != -1){
|
||||
if (binding.countryCodes.getSelectedIndex() != -1) {
|
||||
country_code = countryCodeList.get(binding.countryCodes.getSelectedIndex());
|
||||
}
|
||||
|
||||
@@ -150,25 +151,25 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
// nothing
|
||||
}
|
||||
|
||||
if (country_code != null && !countryCodeList.contains(country_code)){
|
||||
if (country_code != null && !countryCodeList.contains(country_code)) {
|
||||
countryCodeList.add(country_code);
|
||||
}
|
||||
|
||||
if (country_code != null){
|
||||
if (country_code != null) {
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(country_code));
|
||||
}
|
||||
|
||||
if (phone_number_str.length() > 10){
|
||||
if (phone_number_str.length() > 10) {
|
||||
// pasted number length is greater than 10
|
||||
return phone_number_str.substring(0, 10);
|
||||
}
|
||||
|
||||
String total_phone_number = binding.phoneNumber.getText().toString() + phone_number_str;
|
||||
|
||||
if (total_phone_number.length() > 10){
|
||||
if (total_phone_number.length() > 10) {
|
||||
// max length should be 10
|
||||
return "";
|
||||
}else{
|
||||
} else {
|
||||
return phone_number_str;
|
||||
}
|
||||
};
|
||||
@@ -233,23 +234,21 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
binding.nextBtn.setOnClickListener(v -> {
|
||||
|
||||
if (to_edit) {
|
||||
// editing existing contact
|
||||
if (allOkay()) {
|
||||
if (to_edit) {
|
||||
// editing existing contact
|
||||
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.make_changes),
|
||||
getString(R.string.yes),
|
||||
getString(R.string.no),
|
||||
yes -> {
|
||||
if (allOkay()){
|
||||
createEditContact("While we update your contact details.", true, UPDATE_CONTACT + contactData.contact_id);
|
||||
}
|
||||
}, no -> {
|
||||
AppUtil.showSOSDecision(requireContext(),
|
||||
getString(R.string.make_changes),
|
||||
getString(R.string.yes),
|
||||
getString(R.string.no),
|
||||
yes -> {
|
||||
createEditContact("While we update your contact details.", true, UPDATE_CONTACT + contactData.contact_id);
|
||||
}, no -> {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
if (allOkay()) {
|
||||
} else {
|
||||
createEditContact("While we save the contact details.", false, CREATE_CONTACT);
|
||||
}
|
||||
}
|
||||
@@ -280,20 +279,20 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
RequestBody user_first_name = RequestBody.create(binding.name.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8") );
|
||||
body.put("full_name", user_first_name );
|
||||
RequestBody user_first_name = RequestBody.create(binding.name.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("full_name", user_first_name);
|
||||
|
||||
String contact_number = countryCodeList.get(binding.countryCodes.getSelectedIndex()) + " " +
|
||||
binding.phoneNumber.getText().toString();
|
||||
|
||||
RequestBody contact_number_part = RequestBody.create(contact_number, MediaType.parse("text/plain;charset=utf-8") );
|
||||
RequestBody contact_number_part = RequestBody.create(contact_number, MediaType.parse("text/plain;charset=utf-8"));
|
||||
|
||||
body.put("contact_number", contact_number_part);
|
||||
|
||||
RequestBody email_ = RequestBody.create(binding.email.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8") );
|
||||
RequestBody email_ = RequestBody.create(binding.email.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("email_address", email_);
|
||||
|
||||
RequestBody relationship_ = RequestBody.create(binding.relationship.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8") );
|
||||
RequestBody relationship_ = RequestBody.create(binding.relationship.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("relationship", relationship_);
|
||||
|
||||
Map<String, Integer> intBody = new HashMap<>();
|
||||
@@ -334,17 +333,29 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
binding.phoneNumber.getText().toString().trim().length() < 10) {
|
||||
allOkay = false;
|
||||
binding.phoneNumber.setError("Invalid");
|
||||
} else if (!Patterns.PHONE.matcher(binding.phoneNumber.getText().toString()).matches()) {
|
||||
}else if (binding.countryCodes.getSelectedIndex() == -1||
|
||||
binding.countryCodes.getSelectedIndex() >= countryCodeList.size()){
|
||||
allOkay = false;
|
||||
binding.phoneNumber.setError("Invalid number");
|
||||
Toast.makeText(requireContext(), "Select a coutnry code.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
// validating phone number
|
||||
try {
|
||||
Phonenumber.PhoneNumber phone_number = PhoneNumberUtil.getInstance().parse(countryCodeList.get(binding.countryCodes.getSelectedIndex())+
|
||||
binding.phoneNumber.getText().toString(), "US");
|
||||
|
||||
if (!PhoneNumberUtil.getInstance().isValidNumber(phone_number)) {
|
||||
binding.phoneNumber.setError("Invalid phone number");
|
||||
allOkay = false;
|
||||
}
|
||||
} catch (NumberParseException e) {
|
||||
// do nothing as we couldn't validate phone number
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.email.setError("Required");
|
||||
} else if (!Patterns.EMAIL_ADDRESS.matcher(binding.email.getText().toString()).matches()) {
|
||||
allOkay = false;
|
||||
binding.email.setError("Invalid email");
|
||||
}
|
||||
|
||||
if (binding.countryCodes.getSelectedIndex() == -1 && allOkay) {
|
||||
@@ -357,11 +368,11 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
private boolean phoneAlreadyAdded() {
|
||||
|
||||
for (ContactListResponse contact: contactList){
|
||||
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)){
|
||||
if (contact.contact_data.phone_number.equals(contact_number)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -401,7 +412,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
binding.caregiverCheckView.setVisibility(View.VISIBLE);
|
||||
this.mustBeeCaregiver = true;
|
||||
binding.caregiverCheck.setChecked(true);
|
||||
}else{
|
||||
} else {
|
||||
binding.caregiverCheckView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -409,7 +420,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
boolean isSosSet = false;
|
||||
int sos_contact_id = -1;
|
||||
|
||||
for (ContactListResponse contact: contactList){
|
||||
for (ContactListResponse contact : contactList) {
|
||||
if (contact.is_sos_contact.equals("1")) {
|
||||
isSosSet = true;
|
||||
sos_contact_id = contact.contact_data.id;
|
||||
@@ -417,17 +428,17 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
}
|
||||
}
|
||||
|
||||
if (isSosSet){
|
||||
if (isSosSet) {
|
||||
binding.sosCheckView.setVisibility(View.GONE);
|
||||
binding.defaultSos.setVisibility(View.GONE);
|
||||
|
||||
if (contactData != null && sos_contact_id != -1 && sos_contact_id == contactData.id){
|
||||
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{
|
||||
} else {
|
||||
binding.sosCheckView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -491,8 +502,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
|
||||
private void setDetails() {
|
||||
|
||||
if (contactData.contact_photo != null)
|
||||
{
|
||||
if (contactData.contact_photo != null) {
|
||||
Glide.with(requireContext())
|
||||
.load("https://simplitend.betadelivery.com/storage/upload/" + contactData.contact_photo)
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
@@ -501,11 +511,12 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
}
|
||||
|
||||
if (contactData.first_name != null)
|
||||
{
|
||||
binding.name.setText(contactData.first_name);
|
||||
}
|
||||
|
||||
binding.phoneNumber.setText(contactData.phone_number);
|
||||
if (contactData.country_code != null && countryCodeList.contains(contactData.country_code)){
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(contactData.country_code));
|
||||
if (contactData.phone_number != null){
|
||||
binding.phoneNumber.setText(contactData.phone_number);
|
||||
}
|
||||
|
||||
if (contactData.email_address != null)
|
||||
@@ -514,7 +525,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
if (contactData.relationship != null)
|
||||
binding.relationship.setText(contactData.relationship);
|
||||
|
||||
if (contactData.is_sos != null && contactData.is_sos.equals("1")){
|
||||
if (contactData.is_sos != null && contactData.is_sos.equals("1")) {
|
||||
binding.sosCheck.setChecked(true);
|
||||
}
|
||||
|
||||
@@ -532,7 +543,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
binding.caregiverCheck.setChecked(true);
|
||||
binding.caregiverCheck.setEnabled(false);
|
||||
binding.relationship.setEnabled(false);
|
||||
}else{
|
||||
} else {
|
||||
binding.caregiverCheckView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class UserContactRepository {
|
||||
final int nameIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
|
||||
final int numberIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
|
||||
|
||||
String name, number, country_code = null;
|
||||
String name, number;
|
||||
while (cursor.moveToNext()) {
|
||||
name = cursor.getString(nameIndex);
|
||||
number = cursor.getString(numberIndex);
|
||||
@@ -194,24 +194,7 @@ public class UserContactRepository {
|
||||
if (number == null) continue;
|
||||
|
||||
if (!mobileNoSet.contains(number)) {
|
||||
try {
|
||||
PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
|
||||
Phonenumber.PhoneNumber phoneNumber = phoneNumberUtil.parse(number, "US");
|
||||
|
||||
number = String.valueOf(phoneNumber.getNationalNumber());
|
||||
country_code = "+" + phoneNumber.getCountryCode();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
number = number.replace("-", "");
|
||||
number = number.replace("(", "");
|
||||
number = number.replace(")", "");
|
||||
}catch (Exception e2){
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
Contact contact = new Contact(name, number);
|
||||
contact.country_code = country_code;
|
||||
|
||||
contactList.add(contact);
|
||||
mobileNoSet.add(number);
|
||||
|
||||
@@ -17,8 +17,6 @@ public class ContactData implements Serializable {
|
||||
public String contact_photo;
|
||||
public CareGiverData care_giver_data;
|
||||
|
||||
public String country_code;
|
||||
|
||||
public int contact_id;
|
||||
|
||||
public ContactData() {
|
||||
@@ -27,7 +25,6 @@ public class ContactData implements Serializable {
|
||||
public ContactData(Contact contact){
|
||||
this.first_name = contact.first_name;
|
||||
this.phone_number = contact.phone_number;
|
||||
this.country_code = contact.country_code;
|
||||
}
|
||||
|
||||
public ContactData(int id) {
|
||||
|
||||
@@ -22,6 +22,7 @@ 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;
|
||||
@@ -38,7 +39,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class RegisterFragment extends Fragment implements WelcomeContracts.VerifyEmailCallBack{
|
||||
public class RegisterFragment extends Fragment implements WelcomeContracts.VerifyEmailCallBack {
|
||||
|
||||
private static final String TAG = "RegisterFragment";
|
||||
|
||||
@@ -95,7 +96,7 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
binding.countryCodes.setItems(countryCodeList);
|
||||
|
||||
if (!countryCodeList.contains("+1")){
|
||||
if (!countryCodeList.contains("+1")) {
|
||||
countryCodeList.add("+1");
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
binding.countryCodes.setIsFocusable(true);
|
||||
|
||||
setErrorRemovers();
|
||||
setPhoneNumberInputFilter();
|
||||
|
||||
loadPatientDataSavedState();
|
||||
|
||||
@@ -125,13 +126,7 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
}
|
||||
|
||||
// This adds textChangeListener to all the EditTexts available to remove error if available
|
||||
private void setErrorRemovers() {
|
||||
new EditTextErrorRemover(
|
||||
binding.name,
|
||||
binding.contactNumber,
|
||||
binding.email
|
||||
);
|
||||
|
||||
private void setPhoneNumberInputFilter() {
|
||||
// phone number formatting
|
||||
// to deal with input pasting in the edit text
|
||||
InputFilter phoneFilter = (charSequence, i, i1, spanned, i2, i3) -> {
|
||||
@@ -139,9 +134,9 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
String country_code;
|
||||
|
||||
if (binding.countryCodes.getSelectedIndex() == -1){
|
||||
if (binding.countryCodes.getSelectedIndex() == -1) {
|
||||
country_code = "+1";
|
||||
}else{
|
||||
} else {
|
||||
country_code = countryCodeList.get(binding.countryCodes.getSelectedIndex());
|
||||
}
|
||||
|
||||
@@ -155,23 +150,23 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
// nothing
|
||||
}
|
||||
|
||||
if (!countryCodeList.contains(country_code)){
|
||||
if (!countryCodeList.contains(country_code)) {
|
||||
countryCodeList.add(country_code);
|
||||
}
|
||||
|
||||
binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(country_code));
|
||||
|
||||
if (phone_number_str.length() > 10){
|
||||
if (phone_number_str.length() > 10) {
|
||||
// pasted number length is greater than 10
|
||||
return phone_number_str.substring(0, 10);
|
||||
}
|
||||
|
||||
String total_phone_number = binding.contactNumber.getText().toString() + phone_number_str;
|
||||
|
||||
if (total_phone_number.length() > 10){
|
||||
if (total_phone_number.length() > 10) {
|
||||
// max length should be 10
|
||||
return "";
|
||||
}else{
|
||||
} else {
|
||||
return phone_number_str;
|
||||
}
|
||||
};
|
||||
@@ -199,6 +194,9 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
binding.backBtn.setOnClickListener(v -> Navigation.findNavController(v).popBackStack());
|
||||
|
||||
binding.nextBtn.setOnClickListener(v -> {
|
||||
|
||||
removeExistingErrors();
|
||||
|
||||
if (allOkay()) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
@@ -236,6 +234,13 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
|
||||
}
|
||||
|
||||
private void removeExistingErrors() {
|
||||
binding.name.setError(null);
|
||||
binding.dob.setError(null);
|
||||
binding.contactNumber.setError(null);
|
||||
binding.email.setError(null);
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
|
||||
boolean allOkay = true;
|
||||
@@ -272,12 +277,27 @@ public class RegisterFragment extends Fragment implements WelcomeContracts.Verif
|
||||
}
|
||||
|
||||
if (binding.contactNumber.getText().toString().trim().isEmpty() ||
|
||||
binding.contactNumber.getText().toString().trim().length() <10) {
|
||||
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");
|
||||
}else if (binding.countryCodes.getSelectedIndex() == -1 ||
|
||||
binding.countryCodes.getSelectedIndex() >= countryCodeList.size()){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Select a coutnry code.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
// validating phone number
|
||||
try {
|
||||
Phonenumber.PhoneNumber phone_number = PhoneNumberUtil.getInstance().parse(countryCodeList.get(binding.countryCodes.getSelectedIndex())+
|
||||
binding.contactNumber.getText().toString(), "US");
|
||||
|
||||
if (!PhoneNumberUtil.getInstance().isValidNumber(phone_number)) {
|
||||
binding.contactNumber.setError("Invalid phone number");
|
||||
allOkay = false;
|
||||
}
|
||||
} catch (NumberParseException e) {
|
||||
// do nothing as we couldn't validate phone number
|
||||
}
|
||||
}
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user