This commit is contained in:
Batuhan Berk Başoğlu 2018-11-18 16:35:06 -05:00
commit 213845f5f3
10 changed files with 183 additions and 16 deletions

View file

@ -57,7 +57,7 @@
android:label="Welcome"
android:screenOrientation="portrait" />
<activity
android:name=".EditProfile"
android:name=".ServiceProviderEditProfile"
android:label="Edit Profile"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden" />
@ -73,7 +73,8 @@
<activity android:name=".ServiceProviderBookings" />
<activity android:name=".HomeOwnerBookings" />
<activity android:name=".FindServiceProvider" />
<activity android:name=".MakeBooking"></activity>
<activity android:name=".MakeBooking" />
<activity android:name=".HomeOwnerEditProfile"></activity>
</application>
</manifest>

View file

@ -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();
}
}
}

View file

@ -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();
}
}

View file

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

View file

@ -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();
}
}

View file

@ -108,11 +108,13 @@
android:onClick="Search"
android:layout_marginRight="10dp"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/ServiceProviders"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="250dp"/>
android:layout_height="250dp"
android:layout_marginTop="15dp"/>

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".HomeOwnerEditProfile">
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/FirstNameInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="First Name"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:textCursorDrawable="@color/colorWhite"
android:layout_marginTop="20dp"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/LastNameInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="Last Name"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:textCursorDrawable="@color/colorWhite"/>
//component used from https://github.com/rengwuxian/MaterialEditText
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/PasswordInput"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/customborder"
android:hint="Password"
android:textSize="15sp"
app:met_baseColor="@android:color/white"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorWhite"
app:met_singleLineEllipsis="true"
android:inputType="textPassword"
android:textCursorDrawable="@color/colorWhite"/>
<Button
android:id="@+id/Save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"
android:onClick="Save"
android:theme="@style/AppTheme.Button" />
</LinearLayout>

View file

@ -25,11 +25,13 @@
android:text="Home Owner:"
android:paddingRight="5dp"
android:paddingLeft="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textSize="15sp"
android:layout_gravity="start"/>
<TextView
android:background="@color/colorWhite"
@ -39,10 +41,12 @@
android:text="Service Provider:"
android:paddingRight="5dp"
android:paddingLeft="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:layout_marginBottom="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textSize="15sp"
android:layout_gravity="start"/>
<TextView
android:background="@color/colorWhite"
@ -53,10 +57,11 @@
android:layout_marginBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textSize="15sp"
android:layout_gravity="start"/>
</LinearLayout>
@ -103,7 +108,7 @@
<Button
android:id="@+id/Book"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_height="55dp"
android:text="Book"
android:theme="@style/AppTheme.Button"
android:onClick="Book"
@ -112,7 +117,7 @@
<Button
android:id="@+id/Cancel"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_height="55dp"
android:text="Cancel"
android:theme="@style/AppTheme.Button"
android:onClick="Cancel"/>

View file

@ -11,7 +11,7 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/background"
tools:context=".EditProfile">
tools:context=".ServiceProviderEditProfile">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -136,7 +136,7 @@
android:textCursorDrawable="@color/colorWhite"/>
<Button
android:id="@+id/SignUp"
android:id="@+id/Save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"

View file

@ -32,6 +32,7 @@
android:layout_height="60dp"
android:layout_marginTop="10dp"
android:text="Profile"
android:onClick="EditProfile"
android:theme="@style/AppTheme.Button" />
<Button
android:id="@+id/Find"