fixed services page

This commit is contained in:
IvanaE 2018-11-13 21:54:44 -05:00
parent e96f837b57
commit 06310f1b90
6 changed files with 32 additions and 34 deletions

View file

@ -62,7 +62,7 @@ public class EditProfile extends AppCompatActivity {
TextView phonenumber = findViewById(R.id.PhoneNumberInput); TextView phonenumber = findViewById(R.id.PhoneNumberInput);
CheckBox licensed = findViewById(R.id.LicensedInput); CheckBox licensed = findViewById(R.id.LicensedInput);
if(password.getText().toString().length()>5 && firstname.getText().toString().length()>0 if(password.getText().toString().length()>=5 && firstname.getText().toString().length()>0
&& lastname.getText().toString().length()>0 && companyname.getText().toString().length()>0 && lastname.getText().toString().length()>0 && companyname.getText().toString().length()>0
&& address.getText().toString().length()>0 && phonenumber.getText().toString().length()>0 && address.getText().toString().length()>0 && phonenumber.getText().toString().length()>0
&& password.getText().toString().matches("[a-zA-Z0-9]*") && password.getText().toString().matches("[a-zA-Z0-9]*")
@ -73,9 +73,15 @@ public class EditProfile extends AppCompatActivity {
&& phonenumber.getText().toString().matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$") && phonenumber.getText().toString().matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")
) { ) {
dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(), if(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())); address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), licensed.isChecked())){
Toast.makeText(this, "Profile has been updated", Toast.LENGTH_LONG).show(); Toast.makeText(this, "Profile has been updated ", Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(this, "Could not update profile ", Toast.LENGTH_LONG).show();
}
} }
else{ else{
Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show(); Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show();

View file

@ -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;

View file

@ -79,7 +79,7 @@ public class NewServiceDialogFragment extends DialogFragment {
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
String name = nameInput.getText().toString(); String name = nameInput.getText().toString();
DBHelper dbHelper = new DBHelper(getContext()); 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()); Double rate = Double.parseDouble(rateInput.getText().toString());
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("name", name); args.putString("name", name);

View file

@ -133,9 +133,14 @@ public class ServiceProviderServicesList extends AppCompatActivity implements De
MaterialSpinner spinner = findViewById(R.id.ServicesInput); MaterialSpinner spinner = findViewById(R.id.ServicesInput);
String servicename = spinner.getText().toString(); String servicename = spinner.getText().toString();
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
dbHelper.addServiceProvidedByUser(servicename, username); if(dbHelper.addServiceProvidedByUser(username, servicename)){
this.recreate(); 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) { public void onDialogDelete(DialogFragment dialog) {
DBHelper dbHelper = new DBHelper(this); DBHelper dbHelper = new DBHelper(this);
String name = (String)dialog.getArguments().get("name"); String name = (String)dialog.getArguments().get("name");
//remove service from service provider dbHelper.deleteServiceProvidedByUser(username, name);
dialog.dismiss(); dialog.dismiss();
this.recreate(); this.recreate();
} }

View file

@ -80,14 +80,14 @@
<com.jaredrummler.materialspinner.MaterialSpinner <com.jaredrummler.materialspinner.MaterialSpinner
android:id="@+id/ServicesInput" android:id="@+id/ServicesInput"
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="45dp" android:layout_height="48dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginTop="5dp"/> android:layout_marginTop="4dp"/>
<Button <Button
android:id="@+id/newService" android:id="@+id/newService"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="55dp" android:layout_height="60dp"
android:layout_weight="1" android:layout_weight="1"
android:onClick="addService" android:onClick="addService"
android:text="Add" android:text="Add"

View file

@ -17,7 +17,7 @@
android:textSize="15sp" android:textSize="15sp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:textAlignment="center"/> />
</LinearLayout> </LinearLayout>