diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java index caf9da2..94dee11 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java @@ -62,20 +62,26 @@ public class EditProfile extends AppCompatActivity { TextView phonenumber = findViewById(R.id.PhoneNumberInput); CheckBox licensed = findViewById(R.id.LicensedInput); - if(password.getText().toString().length()>5 && firstname.getText().toString().length()>0 - && lastname.getText().toString().length()>0 && companyname.getText().toString().length()>0 - && address.getText().toString().length()>0 && phonenumber.getText().toString().length()>0 - && password.getText().toString().matches("[a-zA-Z0-9]*") - && firstname.getText().toString().matches("[a-zA-Z]*") - && lastname.getText().toString().matches("[a-zA-Z]*") - && companyname.getText().toString().matches("^[a-zA-Z0-9_ ]*$") - && address.getText().toString().matches("^[a-zA-Z0-9_ ]*$") - && phonenumber.getText().toString().matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$") - ) { + if(password.getText().toString().length()>=5 && firstname.getText().toString().length()>0 + && lastname.getText().toString().length()>0 && companyname.getText().toString().length()>0 + && address.getText().toString().length()>0 && phonenumber.getText().toString().length()>0 + && password.getText().toString().matches("[a-zA-Z0-9]*") + && firstname.getText().toString().matches("[a-zA-Z]*") + && lastname.getText().toString().matches("[a-zA-Z]*") + && companyname.getText().toString().matches("^[a-zA-Z0-9_ ]*$") + && address.getText().toString().matches("^[a-zA-Z0-9_ ]*$") + && phonenumber.getText().toString().matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$") + ) { + + if(dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(), + address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), licensed.isChecked())){ + Toast.makeText(this, "Profile has been updated ", Toast.LENGTH_LONG).show(); + } + else{ + Toast.makeText(this, "Could not update profile ", Toast.LENGTH_LONG).show(); + + } - dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(), - address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), new Boolean(licensed.isChecked())); - Toast.makeText(this, "Profile has been updated", Toast.LENGTH_LONG).show(); } else{ Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show(); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java deleted file mode 100644 index 2855872..0000000 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/MyAdapter.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.uottawa.olympus.olympusservices; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java index c7f63cd..09cc543 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java @@ -79,7 +79,7 @@ public class NewServiceDialogFragment extends DialogFragment { EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); String name = nameInput.getText().toString(); DBHelper dbHelper = new DBHelper(getContext()); - if (rateInput.getText().toString().length()>0 && !rateInput.getText().toString().equals(".") && name.length()>0 && name.matches("[a-zA-Z]*")&& dbHelper.findService(name)==null){ + if (rateInput.getText().toString().length()>0 && !rateInput.getText().toString().equals(".") && name.length()>0 && name.matches("^[a-zA-Z0-9_ ]*$") && dbHelper.findService(name)==null){ Double rate = Double.parseDouble(rateInput.getText().toString()); Bundle args = new Bundle(); args.putString("name", name); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java index 43d6e7d..d2b8184 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderServicesList.java @@ -133,8 +133,13 @@ public class ServiceProviderServicesList extends AppCompatActivity implements De MaterialSpinner spinner = findViewById(R.id.ServicesInput); String servicename = spinner.getText().toString(); DBHelper dbHelper = new DBHelper(this); - dbHelper.addServiceProvidedByUser(servicename, username); - this.recreate(); + if(dbHelper.addServiceProvidedByUser(username, servicename)){ + this.recreate(); + } + else{ + Toast.makeText(this, "Could not add service", Toast.LENGTH_SHORT).show(); + } + } @@ -149,10 +154,7 @@ public class ServiceProviderServicesList extends AppCompatActivity implements De public void onDialogDelete(DialogFragment dialog) { DBHelper dbHelper = new DBHelper(this); String name = (String)dialog.getArguments().get("name"); - //remove service from service provider - - - + dbHelper.deleteServiceProvidedByUser(username, name); dialog.dismiss(); this.recreate(); } diff --git a/OlympusServices/app/src/main/res/layout/activity_service_provider_services_list.xml b/OlympusServices/app/src/main/res/layout/activity_service_provider_services_list.xml index 091116d..c6ee9c6 100644 --- a/OlympusServices/app/src/main/res/layout/activity_service_provider_services_list.xml +++ b/OlympusServices/app/src/main/res/layout/activity_service_provider_services_list.xml @@ -80,14 +80,14 @@ + android:layout_marginTop="4dp"/>