updates needed
This commit is contained in:
parent
3bdd8b5ad6
commit
abc98d59f2
5 changed files with 380 additions and 4 deletions
Binary file not shown.
|
@ -72,7 +72,8 @@
|
||||||
<activity android:name=".SignUpPart2" />
|
<activity android:name=".SignUpPart2" />
|
||||||
<activity android:name=".ServiceProviderBookings" />
|
<activity android:name=".ServiceProviderBookings" />
|
||||||
<activity android:name=".HomeOwnerBookings" />
|
<activity android:name=".HomeOwnerBookings" />
|
||||||
<activity android:name=".FindServiceProvider"></activity>
|
<activity android:name=".FindServiceProvider" />
|
||||||
|
<activity android:name=".MakeBooking"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -8,6 +8,7 @@ import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -29,6 +30,13 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
String username;
|
String username;
|
||||||
DBHelper dbHelper;
|
DBHelper dbHelper;
|
||||||
|
|
||||||
|
//field for RecyclerView
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
//field for adapter of Recycler view
|
||||||
|
private RecyclerView.Adapter mAdapter;
|
||||||
|
//field for layout manager of Recyler view.
|
||||||
|
private RecyclerView.LayoutManager mLayoutManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -37,7 +45,7 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
username = bundle.getString("username");
|
username = bundle.getString("username");
|
||||||
|
|
||||||
MaterialSpinner spinner = findViewById(R.id.RatingInput);
|
MaterialSpinner spinner = findViewById(R.id.RatingInput);
|
||||||
spinner.setItems(1, 2, 3, 4, 5);
|
spinner.setItems("",1, 2, 3, 4, 5);
|
||||||
|
|
||||||
dbHelper = new DBHelper(this);
|
dbHelper = new DBHelper(this);
|
||||||
MaterialSpinner spinner2 = findViewById(R.id.ServicesInput);
|
MaterialSpinner spinner2 = findViewById(R.id.ServicesInput);
|
||||||
|
@ -51,6 +59,21 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
spinner2.setItems(services);
|
spinner2.setItems(services);
|
||||||
|
|
||||||
|
|
||||||
|
//iffy code
|
||||||
|
ServiceProvider provider = (ServiceProvider)dbHelper.findUserByUsername("testing");
|
||||||
|
ServiceProvider[] providerslist = {provider};
|
||||||
|
|
||||||
|
mRecyclerView = (RecyclerView) findViewById(R.id.ServiceProviders);
|
||||||
|
|
||||||
|
|
||||||
|
mLayoutManager = new LinearLayoutManager(this);
|
||||||
|
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
|
||||||
|
mAdapter = new MyAdapter(providerslist, this);
|
||||||
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
//
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,6 +84,54 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
public void Search(View view){
|
public void Search(View view){
|
||||||
|
MaterialSpinner spinner = findViewById(R.id.ServicesInput);
|
||||||
|
Button button = findViewById(R.id.Start);
|
||||||
|
Button button2 = findViewById(R.id.End);
|
||||||
|
Button button3 = findViewById(R.id.Date);
|
||||||
|
MaterialSpinner spinner2 = findViewById(R.id.RatingInput);
|
||||||
|
|
||||||
|
String service = spinner.getText().toString();
|
||||||
|
int start;
|
||||||
|
int end;
|
||||||
|
String date;
|
||||||
|
if(button.getText().toString()!="Start" && button.getText().toString()!="End"
|
||||||
|
&& button3.getText().toString()!="Date"){
|
||||||
|
start = Integer.parseInt(button.getText().toString());
|
||||||
|
end = Integer.parseInt(button2.getText().toString());
|
||||||
|
date = button3.getText().toString();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//figure out with dbhelper
|
||||||
|
}
|
||||||
|
|
||||||
|
int rating;
|
||||||
|
if(spinner2.getText().toString()!=""){
|
||||||
|
rating = Integer.parseInt(spinner2.getText().toString());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//figure out with dbhelper
|
||||||
|
}
|
||||||
|
//do search here
|
||||||
|
//update recylcler view
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void makeBooking(String serviceprovider){
|
||||||
|
MaterialSpinner spinner = findViewById(R.id.ServicesInput);
|
||||||
|
String service = spinner.getText().toString();
|
||||||
|
Intent intent = new Intent(getApplicationContext(),MakeBooking.class);
|
||||||
|
intent.putExtra("homeowner", username);
|
||||||
|
intent.putExtra("serviceprovider", serviceprovider);
|
||||||
|
intent.putExtra("service", service);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +147,21 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
public void onDateSet(DatePicker view, int year, int month, int day) {
|
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||||
Calendar newDate = Calendar.getInstance();
|
Calendar newDate = Calendar.getInstance();
|
||||||
newDate.set(year, month, day);
|
newDate.set(year, month, day);
|
||||||
button.setText(month + " / " + (day) + " / "
|
String daystring;
|
||||||
|
String monthstring;
|
||||||
|
if((""+day).length()==1){
|
||||||
|
daystring = "0"+day;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
daystring = day+"";
|
||||||
|
}
|
||||||
|
if((""+month).length()==1){
|
||||||
|
monthstring = "0"+month;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
monthstring = ""+month;
|
||||||
|
}
|
||||||
|
button.setText(monthstring + " / " + daystring + " / "
|
||||||
+ year);
|
+ year);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +275,8 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
public void onBindViewHolder(ProviderHolder holder, int position) {
|
public void onBindViewHolder(ProviderHolder holder, int position) {
|
||||||
ServiceProvider serviceprovider = serviceProviders[position];
|
ServiceProvider serviceprovider = serviceProviders[position];
|
||||||
holder.name.setText(serviceprovider.getFirstname()+" "+serviceprovider.getLastname());
|
holder.name.setText(serviceprovider.getFirstname()+" "+serviceprovider.getLastname());
|
||||||
holder.rate.setText(String.format("$%,.2f", serviceprovider.getRating()));
|
holder.rate.setText("5");
|
||||||
|
//serviceprovider.getRating()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,6 +303,7 @@ public class FindServiceProvider extends AppCompatActivity {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
TextView nameview = (TextView)view.findViewById(R.id.Name);
|
TextView nameview = (TextView)view.findViewById(R.id.Name);
|
||||||
String name = nameview.getText().toString();
|
String name = nameview.getText().toString();
|
||||||
|
makeBooking(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.app.TimePickerDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
public class MakeBooking extends AppCompatActivity {
|
||||||
|
String homeowner;
|
||||||
|
String serviceprovider;
|
||||||
|
String service;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_make_booking);
|
||||||
|
Bundle bundle = getIntent().getExtras();
|
||||||
|
homeowner = bundle.getString("homeowner");
|
||||||
|
serviceprovider = bundle.getString("serviceprovider");
|
||||||
|
service = bundle.getString("service");
|
||||||
|
|
||||||
|
TextView homeo = findViewById(R.id.HomeOwner);
|
||||||
|
TextView servicep = findViewById(R.id.ServiceProvider);
|
||||||
|
TextView serv = findViewById(R.id.Service);
|
||||||
|
|
||||||
|
homeo.setText("Home Owner: \n"+homeowner);
|
||||||
|
servicep.setText("ServiceProvider: \n"+serviceprovider);
|
||||||
|
serv.setText("Service: \n"+service);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed(){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),Welcome.class);
|
||||||
|
intent.putExtra("username", homeowner);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
public void Cancel(View view){
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Book(View view){
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickDate(View view){
|
||||||
|
|
||||||
|
final Button button = (Button)view;
|
||||||
|
final Calendar c = Calendar.getInstance();
|
||||||
|
|
||||||
|
DatePickerDialog datePickerDialog = new DatePickerDialog(this,
|
||||||
|
new DatePickerDialog.OnDateSetListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||||
|
Calendar newDate = Calendar.getInstance();
|
||||||
|
newDate.set(year, month, day);
|
||||||
|
String daystring;
|
||||||
|
String monthstring;
|
||||||
|
if((""+day).length()==1){
|
||||||
|
daystring = "0"+day;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
daystring = day+"";
|
||||||
|
}
|
||||||
|
if((""+month).length()==1){
|
||||||
|
monthstring = "0"+month;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
monthstring = ""+month;
|
||||||
|
}
|
||||||
|
button.setText(monthstring + " / " + daystring + " / "
|
||||||
|
+ year);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH));
|
||||||
|
datePickerDialog.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onClickTime(View view){
|
||||||
|
final Calendar c = Calendar.getInstance();
|
||||||
|
int hour = c.get(Calendar.HOUR_OF_DAY);
|
||||||
|
int minute = c.get(Calendar.MINUTE);
|
||||||
|
final Button button = (Button)view;
|
||||||
|
|
||||||
|
// Launch Time Picker Dialog
|
||||||
|
TimePickerDialog timePickerDialog = new TimePickerDialog(this,
|
||||||
|
new TimePickerDialog.OnTimeSetListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTimeSet(TimePicker view, int hourOfDay,
|
||||||
|
int minute) {
|
||||||
|
String time = "";
|
||||||
|
|
||||||
|
button.setText(formatTime(hourOfDay,minute));
|
||||||
|
//set availibility for service provider and check start time is less than finish
|
||||||
|
}
|
||||||
|
|
||||||
|
}, hour, minute, false);
|
||||||
|
timePickerDialog.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatTime(int hours, int minutes){
|
||||||
|
String time = "";
|
||||||
|
if(hours<10){
|
||||||
|
time = time+"0"+hours+":";
|
||||||
|
}else{
|
||||||
|
time = time+hours+":";
|
||||||
|
}
|
||||||
|
if (minutes<10){
|
||||||
|
time = time+"0"+minutes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
time = time+minutes;
|
||||||
|
}
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] parseTime(String startTime, String endTime){
|
||||||
|
int[] times = new int[4];
|
||||||
|
if(startTime.equals("START")){
|
||||||
|
times[0]=0;
|
||||||
|
times[1]=0;
|
||||||
|
}else{
|
||||||
|
times[0] = Integer.parseInt(startTime.substring(0,2));
|
||||||
|
times[1] = Integer.parseInt(startTime.substring(3));
|
||||||
|
}
|
||||||
|
if(endTime.equals("END")){
|
||||||
|
times[2]=0;
|
||||||
|
times[3]=0;
|
||||||
|
}else{
|
||||||
|
times[2] = Integer.parseInt(endTime.substring(0,2));
|
||||||
|
times[3] = Integer.parseInt(endTime.substring(3));
|
||||||
|
}
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateTime(int[] time){
|
||||||
|
if(time[0]==0&&time[1]==0&&time[2]==0&&time[3]==0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(time[2]>time[0]){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
if(time[2]==time[0]&&time[3]>time[1]){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
<?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=".MakeBooking">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
<TextView
|
||||||
|
android:background="@color/colorWhite"
|
||||||
|
android:id="@+id/HomeOwner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Home Owner:"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_gravity="start"/>
|
||||||
|
<TextView
|
||||||
|
android:background="@color/colorWhite"
|
||||||
|
android:id="@+id/ServiceProvider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Service Provider:"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_gravity="start"/>
|
||||||
|
<TextView
|
||||||
|
android:background="@color/colorWhite"
|
||||||
|
android:id="@+id/Service"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Service:"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_gravity="start"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Start"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Start"
|
||||||
|
android:theme="@style/AppTheme.Button"
|
||||||
|
android:onClick="onClickTime"
|
||||||
|
android:layout_marginRight="5dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/End"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="End"
|
||||||
|
android:theme="@style/AppTheme.Button"
|
||||||
|
android:onClick="onClickTime"
|
||||||
|
android:layout_marginRight="5dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Date"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Date"
|
||||||
|
android:theme="@style/AppTheme.Button"
|
||||||
|
android:onClick="onClickDate"
|
||||||
|
android:layout_gravity="end"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="30dp">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Book"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Book"
|
||||||
|
android:theme="@style/AppTheme.Button"
|
||||||
|
android:onClick="Book"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginLeft="20dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Cancel"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Cancel"
|
||||||
|
android:theme="@style/AppTheme.Button"
|
||||||
|
android:onClick="Cancel"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in a new issue