From ef7d9db62b51e8594cf304826e63c7558eb50019 Mon Sep 17 00:00:00 2001 From: IvanaE Date: Sun, 18 Nov 2018 15:35:32 -0500 Subject: [PATCH] added more of the finding and edit profile --- .../.idea/caches/build_file_checksums.ser | Bin 537 -> 537 bytes .../app/src/main/AndroidManifest.xml | 5 +- .../olympusservices/HomeOwnerEditProfile.java | 82 ++++++++++++++++++ ...e.java => ServiceProviderEditProfile.java} | 6 +- .../ServiceProviderWelcome.java | 2 +- .../olympus/olympusservices/Welcome.java | 9 +- .../layout/activity_find_service_provider.xml | 4 +- .../activity_home_owner_edit_profile.xml | 71 +++++++++++++++ .../main/res/layout/activity_make_booking.xml | 15 ++-- ...ctivity_service_provider_edit_profile.xml} | 4 +- .../src/main/res/layout/activity_welcome.xml | 1 + 11 files changed, 183 insertions(+), 16 deletions(-) create mode 100644 OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java rename OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/{EditProfile.java => ServiceProviderEditProfile.java} (93%) create mode 100644 OlympusServices/app/src/main/res/layout/activity_home_owner_edit_profile.xml rename OlympusServices/app/src/main/res/layout/{activity_edit_profile.xml => activity_service_provider_edit_profile.xml} (98%) diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 3825acd18d8a8678b7c2c143ba9a9a8bbe850458..7c3c27aeed1c7ed32d5cb9338130854e772cd470 100644 GIT binary patch delta 14 WcmbQqGLvP(Oy;T?dp6FgWdr~#HU @@ -73,7 +73,8 @@ - + + \ No newline at end of file diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java new file mode 100644 index 0000000..2819c18 --- /dev/null +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/HomeOwnerEditProfile.java @@ -0,0 +1,82 @@ +package com.uottawa.olympus.olympusservices; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.CheckBox; +import android.widget.TextView; +import android.widget.Toast; + +public class HomeOwnerEditProfile extends AppCompatActivity { + String username; + DBHelper dbHelper; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_home_owner_edit_profile); + + Bundle bundle = getIntent().getExtras(); + username = bundle.getString("username"); + dbHelper = new DBHelper(this); + UserType user; + user = dbHelper.findUserByUsername(username); + TextView firstname = findViewById(R.id.FirstNameInput); + TextView lastname = findViewById(R.id.LastNameInput); + TextView password = findViewById(R.id.PasswordInput); + + + firstname.setText(user.getFirstname()); + lastname.setText(user.getLastname()); + password.setText(user.getPassword()); + + } + /** + * Override so that previous screen refreshes when pressing the + * back button on this activity of the app. + * + */ + @Override + public void onBackPressed(){ + Intent intent = new Intent(getApplicationContext(),ServiceProviderWelcome.class); + intent.putExtra("username", username); + startActivity(intent); + finish(); + } + + + /** + * Saves updated user information to the database + * @param view + */ + public void Save(View view){ + TextView firstname = findViewById(R.id.FirstNameInput); + TextView lastname = findViewById(R.id.LastNameInput); + TextView password = findViewById(R.id.PasswordInput); + + //Checks for the fields + if(password.getText().toString().length()>=5 && firstname.getText().toString().length()>0 + && lastname.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]*") + ) { + + if(dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString() + )){ + //add comment method here + Toast.makeText(this, "Profile has been updated", Toast.LENGTH_LONG).show(); + } + else{ + Toast.makeText(this, "Could not update profile ", 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/EditProfile.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderEditProfile.java similarity index 93% rename from OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java rename to OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderEditProfile.java index 57ebfe9..cf3dc49 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditProfile.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderEditProfile.java @@ -8,7 +8,7 @@ import android.widget.CheckBox; import android.widget.TextView; import android.widget.Toast; -public class EditProfile extends AppCompatActivity { +public class ServiceProviderEditProfile extends AppCompatActivity { String username; DBHelper dbHelper; @@ -19,7 +19,7 @@ public class EditProfile extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_edit_profile); + setContentView(R.layout.activity_service_provider_edit_profile); Bundle bundle = getIntent().getExtras(); username = bundle.getString("username"); dbHelper = new DBHelper(this); @@ -100,7 +100,7 @@ public class EditProfile extends AppCompatActivity { } else{ - Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show(); + Toast.makeText(this, "Fields cannot be empty (other than description) and must be formatted correctly", Toast.LENGTH_LONG).show(); } } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java index 448c1d9..73a3e8a 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServiceProviderWelcome.java @@ -60,7 +60,7 @@ public class ServiceProviderWelcome extends AppCompatActivity { } public void EditProfile(View view){ - Intent intent = new Intent(getApplicationContext(),EditProfile.class); + Intent intent = new Intent(getApplicationContext(),ServiceProviderEditProfile.class); intent.putExtra("username", username); startActivity(intent); finish(); diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java index a054142..ffe91bb 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/Welcome.java @@ -32,7 +32,7 @@ public class Welcome extends AppCompatActivity { UserType user; user = dbHelper.findUserByUsername(username); TextView welcome = findViewById(R.id.Welcome); - welcome.setText("Welcome "+user.getFirstname()+ " you are logged in as a Service Provider"); + welcome.setText("Welcome "+user.getFirstname()+ " you are logged in as a Home Owner"); @@ -73,6 +73,11 @@ public class Welcome extends AppCompatActivity { startActivity(intent); finish(); } - + public void EditProfile(View view){ + Intent intent = new Intent(getApplicationContext(),HomeOwnerEditProfile.class); + intent.putExtra("username", username); + startActivity(intent); + finish(); + } } diff --git a/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml b/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml index c2c4916..9bd9a8d 100644 --- a/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml +++ b/OlympusServices/app/src/main/res/layout/activity_find_service_provider.xml @@ -108,11 +108,13 @@ android:onClick="Search" android:layout_marginRight="10dp" /> + + android:layout_height="250dp" + android:layout_marginTop="15dp"/> diff --git a/OlympusServices/app/src/main/res/layout/activity_home_owner_edit_profile.xml b/OlympusServices/app/src/main/res/layout/activity_home_owner_edit_profile.xml new file mode 100644 index 0000000..b572235 --- /dev/null +++ b/OlympusServices/app/src/main/res/layout/activity_home_owner_edit_profile.xml @@ -0,0 +1,71 @@ + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + + + //component used from https://github.com/rengwuxian/MaterialEditText + + +