fixed services page
This commit is contained in:
		
							parent
							
								
									0ae6c76777
								
							
						
					
					
						commit
						696c4e4e4b
					
				
					 6 changed files with 32 additions and 34 deletions
				
			
		| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,14 +80,14 @@
 | 
			
		|||
        <com.jaredrummler.materialspinner.MaterialSpinner
 | 
			
		||||
            android:id="@+id/ServicesInput"
 | 
			
		||||
            android:layout_width="250dp"
 | 
			
		||||
            android:layout_height="45dp"
 | 
			
		||||
            android:layout_height="48dp"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:layout_marginTop="5dp"/>
 | 
			
		||||
            android:layout_marginTop="4dp"/>
 | 
			
		||||
 | 
			
		||||
        <Button
 | 
			
		||||
            android:id="@+id/newService"
 | 
			
		||||
            android:layout_width="wrap_content"
 | 
			
		||||
            android:layout_height="55dp"
 | 
			
		||||
            android:layout_height="60dp"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
            android:onClick="addService"
 | 
			
		||||
            android:text="Add"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@
 | 
			
		|||
        android:textSize="15sp"
 | 
			
		||||
        android:layout_marginLeft="20dp"
 | 
			
		||||
        android:layout_marginRight="20dp"
 | 
			
		||||
        android:textAlignment="center"/>
 | 
			
		||||
        />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
</LinearLayout>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue