Compare commits
26 commits
Author | SHA1 | Date | |
---|---|---|---|
|
7bebb316ef | ||
|
72bf00563c | ||
|
5eae198bbf | ||
|
ef6446f05b | ||
|
d4f1433f91 | ||
|
8be4ccbbd7 | ||
|
1014a78de8 | ||
|
555932b877 | ||
|
a80c6d37dc | ||
|
5a382baab4 | ||
|
8ecd089fe3 | ||
|
bba1c248a1 | ||
|
b22a32b4a2 | ||
|
aa102421ef | ||
|
e1b947ef43 | ||
|
0499d81093 | ||
|
0b36bb32e3 | ||
|
f299770923 | ||
|
6b1ff038c8 | ||
|
bcfa204f44 | ||
|
ac7e8aec0a | ||
|
a9746fb215 | ||
|
65bc8b2109 | ||
|
9cd853df11 | ||
|
50b0fc49c1 | ||
|
0aed26f071 |
28 changed files with 931 additions and 41 deletions
Binary file not shown.
|
@ -25,7 +25,7 @@
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -16,18 +16,27 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
testOptions {
|
||||||
|
unitTests {
|
||||||
|
includeAndroidResources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||||
implementation 'com.android.support:design:28.0.0'
|
implementation 'com.android.support:design:28.0.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
testImplementation 'org.robolectric:robolectric:4.0-alpha-3-SNAPSHOT'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
implementation 'com.jaredrummler:material-spinner:1.2.5'
|
implementation 'com.jaredrummler:material-spinner:1.2.5'
|
||||||
implementation 'com.android.support:design:28.0.0-alpha3'
|
implementation 'com.android.support:design:28.0.0-alpha3'
|
||||||
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
|
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Main"
|
android:name=".Main"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
@ -29,13 +28,15 @@
|
||||||
android:name="preloaded_fonts"
|
android:name="preloaded_fonts"
|
||||||
android:resource="@array/preloaded_fonts" />
|
android:resource="@array/preloaded_fonts" />
|
||||||
|
|
||||||
<activity android:name=".SignUp" android:parentActivityName=".Main">
|
<activity
|
||||||
|
android:name=".SignUp"
|
||||||
|
android:parentActivityName=".Main">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".Main" />
|
android:value=".Main" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".LogIn" />
|
<activity android:name=".LogIn" />
|
||||||
<activity android:name=".Welcome"/>
|
<activity android:name=".Welcome" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class allows the app to create admin object which is a child of the UserType class.
|
||||||
|
* The admin object has administrator control over the app. A user logging in with
|
||||||
|
* admin can delete and edit user profiles and delete and edit services.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Admin extends UserType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an admin object such that the admin
|
||||||
|
* has a constant username and password of admin and admin.
|
||||||
|
* And the admin has a constant first name and last name of Admin.
|
||||||
|
* there should only be one admin object.
|
||||||
|
*/
|
||||||
|
Admin(){
|
||||||
|
super("admin", "admin", "Admin", "Admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is a method gets the string object describing the
|
||||||
|
* role of the object.
|
||||||
|
*
|
||||||
|
* @return String "admin"
|
||||||
|
*/
|
||||||
|
public String getRole(){ return "Admin"; }
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class AdminWelcome extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_admin_welcome);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onBackPressed(){
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogOut(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
public void goToUsers(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), UsersList.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
public void goToServices(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), ServicesList.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
public class Appointment {
|
||||||
|
Service service;
|
||||||
|
ServiceProvider provider;
|
||||||
|
}
|
|
@ -0,0 +1,234 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class DBHelper allows the Android application to access and perform
|
||||||
|
* CRUD (Create, Read, Update, Delete) operations on the tables of the SQLite database.
|
||||||
|
* There is currently one table of all users' login information and names.
|
||||||
|
* Table of service providers and services to come soon.
|
||||||
|
*
|
||||||
|
* To use, create an object of this class with the current activity as context.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
//version of db used for update method
|
||||||
|
private static final int DB_VERSION = 1;
|
||||||
|
//name of db in app data
|
||||||
|
private static final String DB_NAME = "UsersDB.db";
|
||||||
|
|
||||||
|
//SQLiteDatabase for reading
|
||||||
|
private static SQLiteDatabase readDB;
|
||||||
|
|
||||||
|
//SQLiteDatabase for writing
|
||||||
|
private static SQLiteDatabase writeDB;
|
||||||
|
|
||||||
|
//name of table containing user login information and names
|
||||||
|
private static final String TABLE_LOGIN = "userInfo";
|
||||||
|
//columns of TABLE_LOGIN
|
||||||
|
private static final String COLUMN_USERNAME = "username";
|
||||||
|
private static final String COLUMN_PASSWORD = "password";
|
||||||
|
private static final String COLUMN_FIRSTNAME = "firstName";
|
||||||
|
private static final String COLUMN_LASTNAME = "lastName";
|
||||||
|
private static final String COLUMN_USERTYPE = "userType";
|
||||||
|
|
||||||
|
// private static final String TABLE_SERVICEPROVIDERS = "serviceProviders";
|
||||||
|
|
||||||
|
|
||||||
|
// private static final String TABLE_SERVICES = "services";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of DBHelper to allow activities to access and
|
||||||
|
* perform CRUD operations on the database via DBHelper's methods
|
||||||
|
*
|
||||||
|
* @param context current activity calling DBHelper
|
||||||
|
*/
|
||||||
|
public DBHelper(Context context){
|
||||||
|
super(context, DB_NAME, null, DB_VERSION);
|
||||||
|
readDB = this.getReadableDatabase();
|
||||||
|
writeDB = this.getWritableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db){
|
||||||
|
|
||||||
|
String CREATE_LOGIN_TABLE = "CREATE TABLE "+ TABLE_LOGIN + "("
|
||||||
|
+ COLUMN_USERNAME + " STRING UNIQUE NOT NULL PRIMARY KEY ON CONFLICT ROLLBACK,"
|
||||||
|
+ COLUMN_PASSWORD + " STRING NOT NULL,"
|
||||||
|
+ COLUMN_FIRSTNAME + " STRING DEFAULT 'FirstName',"
|
||||||
|
+ COLUMN_LASTNAME + " STRING DEFAULT 'LastName',"
|
||||||
|
+ COLUMN_USERTYPE + " STRING NOT NULL" + ")";
|
||||||
|
|
||||||
|
db.execSQL(CREATE_LOGIN_TABLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
onUpgrade(db, oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a user to the database. Returns false if there is a user already
|
||||||
|
* existing in the database with the same username. Returns true if
|
||||||
|
* successful in adding user to database.
|
||||||
|
*
|
||||||
|
* @param userType user to be added
|
||||||
|
* @return whether adding user was successful
|
||||||
|
*/
|
||||||
|
public boolean addUser(UserType userType){
|
||||||
|
//Check for duplicate username by querying login table
|
||||||
|
Cursor cursor = writeDB.query(TABLE_LOGIN,
|
||||||
|
new String[] {COLUMN_USERNAME},
|
||||||
|
COLUMN_USERNAME + " = ?",
|
||||||
|
new String[]{userType.getUsername()},
|
||||||
|
null, null, null,
|
||||||
|
"1");
|
||||||
|
//If cursor has 1+ elements in it, username already exists in table
|
||||||
|
if (cursor != null && cursor.getCount() > 0)
|
||||||
|
return false;
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_USERNAME, userType.getUsername());
|
||||||
|
values.put(COLUMN_PASSWORD, userType.getPassword());
|
||||||
|
values.put(COLUMN_FIRSTNAME, userType.getFirstname());
|
||||||
|
values.put(COLUMN_LASTNAME, userType.getLastname());
|
||||||
|
values.put(COLUMN_USERTYPE, userType.getClass().getSimpleName());
|
||||||
|
writeDB.insert(TABLE_LOGIN, null, values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks in database for user with requested username, and returns an
|
||||||
|
* object of UserType corresponding to said user's role.
|
||||||
|
* Returns null if no such user found.
|
||||||
|
*
|
||||||
|
* @param username username to look up
|
||||||
|
* @return object representing user found
|
||||||
|
*/
|
||||||
|
public UserType findUserByUsername(String username){
|
||||||
|
UserType usertype;
|
||||||
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_LOGIN
|
||||||
|
+ " WHERE " + COLUMN_USERNAME + " = ?",
|
||||||
|
new String[]{username});
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()){
|
||||||
|
String password = cursor.getString(1);
|
||||||
|
String firstname = cursor.getString(2);
|
||||||
|
String lastname = cursor.getString(3);
|
||||||
|
if (cursor.getString(4)
|
||||||
|
.equals("Admin")){
|
||||||
|
usertype = new Admin();
|
||||||
|
} else if (cursor.getString(4)
|
||||||
|
.equals("ServiceProvider")){
|
||||||
|
usertype = new ServiceProvider(username, password, firstname, lastname);
|
||||||
|
} else {
|
||||||
|
usertype = new User(username, password, firstname, lastname);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usertype = null;
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return usertype;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates user login information and name for user with requested username.
|
||||||
|
* Returns true if a user of said username was found and entry updated.
|
||||||
|
* Returns false if no user was found of said username.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param username username of entry to update
|
||||||
|
* @param password new password
|
||||||
|
* @param firstname new first name
|
||||||
|
* @param lastname new last name
|
||||||
|
*
|
||||||
|
* @return whether updating user information was successful
|
||||||
|
*/
|
||||||
|
public boolean updateUserInfo(String username, String password, String firstname, String lastname){
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_PASSWORD, password);
|
||||||
|
values.put(COLUMN_FIRSTNAME, firstname);
|
||||||
|
values.put(COLUMN_LASTNAME, lastname);
|
||||||
|
|
||||||
|
return writeDB.update(TABLE_LOGIN, values, COLUMN_USERNAME+" = ?",
|
||||||
|
new String[]{username}) > 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks in database for user with requested username, and deletes the corresponding
|
||||||
|
* entry. Returns true if a user was deleted, false otherwise.
|
||||||
|
*
|
||||||
|
* @param username username of entry to delete
|
||||||
|
* @return whether a user was deleted
|
||||||
|
*/
|
||||||
|
public boolean deleteUser(String username) {
|
||||||
|
return writeDB.delete(TABLE_LOGIN, COLUMN_USERNAME+" = ?",
|
||||||
|
new String[]{username}) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints all entries of table. One row is printed per line. Columns are
|
||||||
|
* separated by spaces.
|
||||||
|
*
|
||||||
|
* @param tableName name of table to print
|
||||||
|
*/
|
||||||
|
public void printTable(String tableName){
|
||||||
|
Cursor cursor = readDB.rawQuery("SELECT * FROM "+tableName, null);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
for (int i = 0; i<cursor.getCount(); i++){
|
||||||
|
String[] columns = cursor.getColumnNames();
|
||||||
|
for (String name: columns) {
|
||||||
|
System.out.print(cursor.getString(cursor.getColumnIndex(name))+" ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
cursor.moveToNext();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of String arrays containing the username, first name,
|
||||||
|
* last name, and user type of every user in TABLE_LOGIN.
|
||||||
|
*
|
||||||
|
* @return list of arrays of [username, first name, last name, user type]
|
||||||
|
*/
|
||||||
|
public List<String[]> getAllUsers(){
|
||||||
|
List<String[]> listOfUsers = new LinkedList<>();
|
||||||
|
String[] user;
|
||||||
|
Cursor cursor = readDB.rawQuery("SELECT ? , ?, ?, ? FROM "+TABLE_LOGIN,
|
||||||
|
new String[]{COLUMN_USERNAME, COLUMN_FIRSTNAME,
|
||||||
|
COLUMN_LASTNAME, COLUMN_USERTYPE});
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
|
user = new String[4];
|
||||||
|
for (int j = 0; j < cursor.getColumnNames().length; j++) {
|
||||||
|
user[j] = cursor.getString(j);
|
||||||
|
}
|
||||||
|
listOfUsers.add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return listOfUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
public class EditServiceDialogFragment extends DialogFragment{
|
||||||
|
|
||||||
|
public interface NoticeDialogListener {
|
||||||
|
public void onDialogEdit(DialogFragment dialog);
|
||||||
|
public void onDialogDelete(DialogFragment dialog);
|
||||||
|
}
|
||||||
|
EditServiceDialogFragment.NoticeDialogListener mListener;
|
||||||
|
|
||||||
|
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
// Verify that the host activity implements the callback interface
|
||||||
|
try {
|
||||||
|
// Instantiate the NoticeDialogListener so we can send events to the host
|
||||||
|
mListener = (EditServiceDialogFragment.NoticeDialogListener) context;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
// The activity doesn't implement the interface, throw exception
|
||||||
|
throw new ClassCastException(this.toString()
|
||||||
|
+ " must implement NoticeDialogListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
// Get the layout inflater
|
||||||
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
|
||||||
|
// Inflate and set the layout for the dialog
|
||||||
|
// Pass null as the parent view because its going in the dialog layout
|
||||||
|
builder.setView(inflater.inflate(R.layout.dialog_service_edit, null))
|
||||||
|
// Add action buttons
|
||||||
|
.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
//@anshu: get the name and rate to come from the dialog_service_new dialog
|
||||||
|
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
||||||
|
double rate = Double.parseDouble(rateInput.getText().toString());
|
||||||
|
args.putDouble("rate", rate);
|
||||||
|
//EditServiceDialogFragment.this.setArguments(args);
|
||||||
|
mListener.onDialogEdit(EditServiceDialogFragment.this);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
//@anshu: get the name and rate to come from the dialog_service_new dialog
|
||||||
|
args.putString("name", (String)getArguments().get("name"));
|
||||||
|
//
|
||||||
|
EditServiceDialogFragment.this.setArguments(args);
|
||||||
|
mListener.onDialogDelete(EditServiceDialogFragment.this);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTitle((String)getArguments().get("name"));
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,10 @@ package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class LogIn extends AppCompatActivity {
|
public class LogIn extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -10,4 +14,29 @@ public class LogIn extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_log_in);
|
setContentView(R.layout.activity_log_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickLogIn(View view){
|
||||||
|
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString();
|
||||||
|
String password = ((EditText) findViewById(R.id.PasswordInput)).getText().toString();
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
Intent intent = new Intent(getApplicationContext(),Welcome.class);
|
||||||
|
if(dbHelper.findUserByUsername(username).getUsername().equals(username)&&
|
||||||
|
dbHelper.findUserByUsername(username).getPassword().equals(password)){
|
||||||
|
//TODO send the welcome message the user information
|
||||||
|
intent.putExtra("username",username);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//TODO program incorrect username or password message
|
||||||
|
Toast.makeText(this,"error",Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,22 @@ public class Main extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
UserType admin = new Admin();
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
dbHelper.addUser(admin);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickSignUp(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),SignUp.class);
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickLogIn(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),LogIn.class);
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.rengwuxian.materialedittext.MaterialEditText;
|
||||||
|
|
||||||
|
public class NewServiceDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
|
||||||
|
public interface NoticeDialogListener {
|
||||||
|
public void onDialogNew(DialogFragment dialog);
|
||||||
|
public void onDialogNevermind(DialogFragment dialog);
|
||||||
|
}
|
||||||
|
NoticeDialogListener mListener;
|
||||||
|
|
||||||
|
// Override the Fragment.onAttach() method to instantiate the NoticeDialogListener
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
// Verify that the host activity implements the callback interface
|
||||||
|
try {
|
||||||
|
// Instantiate the NoticeDialogListener so we can send events to the host
|
||||||
|
mListener = (NoticeDialogListener) context;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
// The activity doesn't implement the interface, throw exception
|
||||||
|
throw new ClassCastException(this.toString()
|
||||||
|
+ " must implement NoticeDialogListener");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//String name = ((EditText) view.findViewById(R.id.NameInput)).getText().toString();
|
||||||
|
//int rate = Integer.parseInt(((EditText) view.findViewById(R.id.RateInput)).getText().toString())
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
// Get the layout inflater
|
||||||
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
View view = inflater.inflate(R.layout.dialog_service_new, null);
|
||||||
|
builder.setView(view);
|
||||||
|
|
||||||
|
|
||||||
|
// Inflate and set the layout for the dialog
|
||||||
|
// Pass null as the parent view because its going in the dialog layout
|
||||||
|
builder.setView(view)
|
||||||
|
// Add action buttons
|
||||||
|
.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput);
|
||||||
|
EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput);
|
||||||
|
String name = nameInput.getText().toString();
|
||||||
|
double rate = Double.parseDouble(rateInput.getText().toString());
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("name", name);
|
||||||
|
args.putDouble("rate", rate);
|
||||||
|
NewServiceDialogFragment.this.setArguments(args);
|
||||||
|
mListener.onDialogNew(NewServiceDialogFragment.this);
|
||||||
|
//@anshu: get the name and rate to come from the dialog_service_new dialog
|
||||||
|
dostuff();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
NewServiceDialogFragment.this.getDialog().cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dostuff(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
public class Service {
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
public class ServiceProvider extends UserType {
|
||||||
|
|
||||||
|
ServiceProvider(String username, String password, String firstname, String lastname){
|
||||||
|
super(username, password, firstname, lastname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "ServiceProvider"; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,10 @@ import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.jaredrummler.materialspinner.MaterialSpinner;
|
import com.jaredrummler.materialspinner.MaterialSpinner;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class SignUp extends AppCompatActivity {
|
public class SignUp extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +15,7 @@ public class SignUp extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_sign_up);
|
setContentView(R.layout.activity_sign_up);
|
||||||
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||||
spinner.setItems("Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow");
|
spinner.setItems("User", "ServiceProvider");
|
||||||
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
||||||
|
|
||||||
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
||||||
|
@ -19,7 +23,39 @@ public class SignUp extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void main(String[] args){
|
|
||||||
|
public void onClickSignUp(View view){
|
||||||
|
UserType newUser;
|
||||||
|
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString();
|
||||||
|
String password = ((EditText) findViewById(R.id.PasswordInput)).getText().toString();
|
||||||
|
String firstname = ((EditText) findViewById(R.id.FirstNameInput)).getText().toString();
|
||||||
|
String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString();
|
||||||
|
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||||
|
//TODO add message conditional to check if every EditText is filled up to standards
|
||||||
|
switch(spinner.getText().toString()){
|
||||||
|
case "User":
|
||||||
|
newUser = new User(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
case "ServiceProvider":
|
||||||
|
newUser = new ServiceProvider(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newUser = new User(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
Intent intent = new Intent(getApplicationContext(),LogIn.class); //TODO check if signup should take to the login page or automatically login
|
||||||
|
if(dbHelper.addUser(newUser)){
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
}else{
|
||||||
|
Toast.makeText(this,"error",Toast.LENGTH_LONG).show();
|
||||||
|
//TODO add reaction is username is already taken
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
public class User extends UserType {
|
||||||
|
|
||||||
|
User(String username, String password, String firstname, String lastname){
|
||||||
|
super(username, password, firstname, lastname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "User"; }
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public abstract class UserType {
|
||||||
|
|
||||||
|
String username;
|
||||||
|
String password;
|
||||||
|
String firstname;
|
||||||
|
String lastname;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UserType(String username, String password, String firstname, String lastname){
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.firstname = firstname;
|
||||||
|
this.lastname = lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getRole();
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstname() {
|
||||||
|
return firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastname() {
|
||||||
|
return lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
//remember to call updateUser(String username, String password, String firstname, String lastname)
|
||||||
|
//in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized
|
||||||
|
//so cannot be initialized in this class
|
||||||
|
this.username = username;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
//remember to call updateUser(String username, String password, String firstname, String lastname)
|
||||||
|
//in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized
|
||||||
|
//so cannot be initialized in this class
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstname(String firstname) {
|
||||||
|
//remember to call updateUser(String username, String password, String firstname, String lastname)
|
||||||
|
//in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized
|
||||||
|
//so cannot be initialized in this class
|
||||||
|
this.firstname = firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastname(String lastname) {
|
||||||
|
//remember to call updateUser(String username, String password, String firstname, String lastname)
|
||||||
|
//in activity whenever a setter is called. DBHelper requires a Context (Activity) to be initialized
|
||||||
|
//so cannot be initialized in this class
|
||||||
|
this.lastname = lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean equals(UserType other){
|
||||||
|
if(this.username.equals(other.username)&&this.password.equals(other.password)&&
|
||||||
|
this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,9 @@ package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
public class Welcome extends AppCompatActivity {
|
public class Welcome extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -9,5 +12,18 @@ public class Welcome extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_welcome);
|
||||||
|
Bundle bundle = getIntent().getExtras();
|
||||||
|
String username = bundle.getString("username");
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
UserType user;
|
||||||
|
user = dbHelper.findUserByUsername(username);
|
||||||
|
TextView role = (TextView) findViewById(R.id.Role);
|
||||||
|
TextView name = (TextView) findViewById(R.id.name);
|
||||||
|
role.setText(user.getRole());
|
||||||
|
name.setText(user.getFirstname());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,57 @@
|
||||||
android:background="@drawable/background"
|
android:background="@drawable/background"
|
||||||
tools:context=".LogIn">
|
tools:context=".LogIn">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Title"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/login"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="36sp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/UsernameInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="70dp"
|
||||||
|
android:background="@color/colorWhite"
|
||||||
|
android:hint="Username"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
app:met_baseColor="@android:color/white"
|
||||||
|
app:met_floatingLabel="highlight"
|
||||||
|
app:met_primaryColor="?colorAccent"
|
||||||
|
app:met_singleLineEllipsis="true" />
|
||||||
|
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/PasswordInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="70dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
|
android:hint="Password"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
app:met_baseColor="@android:color/white"
|
||||||
|
app:met_floatingLabel="highlight"
|
||||||
|
app:met_primaryColor="?colorAccent"
|
||||||
|
app:met_singleLineEllipsis="true" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/LogIn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
android:onClick="onClickLogIn"
|
||||||
|
android:text="@string/login"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -26,18 +26,20 @@
|
||||||
app:fontFamily="@font/julius_sans_one" />
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:theme="@style/AppTheme.Button"
|
|
||||||
android:id="@+id/SignUp"
|
android:id="@+id/SignUp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="50dp"
|
android:layout_marginBottom="50dp"
|
||||||
android:text="@string/signup" />
|
android:onClick="onClickSignUp"
|
||||||
|
android:text="@string/signup"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:theme="@style/AppTheme.Button"
|
|
||||||
android:id="@+id/LogIn"
|
android:id="@+id/LogIn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/login" />
|
android:onClick="onClickLogIn"
|
||||||
|
android:text="@string/login"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -17,7 +17,7 @@
|
||||||
android:id="@+id/Title"
|
android:id="@+id/Title"
|
||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:layout_marginBottom="40dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/signup"
|
android:text="@string/signup"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
@ -29,62 +29,73 @@
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="20sp"
|
android:text="Role"
|
||||||
android:text="Role" />
|
android:textColor="#6d81a5"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<com.jaredrummler.materialspinner.MaterialSpinner
|
<com.jaredrummler.materialspinner.MaterialSpinner
|
||||||
android:id="@+id/RoleInput"
|
android:id="@+id/RoleInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="50dp"
|
||||||
android:layout_marginBottom="15dp" />
|
android:layout_marginBottom="10dp" />
|
||||||
|
|
||||||
<com.rengwuxian.materialedittext.MaterialEditText
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
android:id="@+id/UsernameInput"
|
android:id="@+id/UsernameInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
|
android:background="@color/colorWhite"
|
||||||
android:hint="Username"
|
android:hint="Username"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:met_baseColor="@android:color/white"
|
app:met_baseColor="@android:color/white"
|
||||||
android:background="@color/colorWhite"
|
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="?colorAccent"
|
app:met_primaryColor="?colorAccent"
|
||||||
app:met_singleLineEllipsis="true"/>
|
app:met_singleLineEllipsis="true" />
|
||||||
|
|
||||||
<com.rengwuxian.materialedittext.MaterialEditText
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
android:id="@+id/PasswordInput"
|
android:id="@+id/PasswordInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:met_baseColor="@android:color/white"
|
app:met_baseColor="@android:color/white"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="?colorAccent"
|
app:met_primaryColor="?colorAccent"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true" />
|
||||||
android:background="@drawable/customborder"/>
|
|
||||||
|
|
||||||
<com.rengwuxian.materialedittext.MaterialEditText
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
android:id="@+id/FirstNameInput"
|
android:id="@+id/FirstNameInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="First Name"
|
android:hint="First Name"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:met_baseColor="@android:color/white"
|
app:met_baseColor="@android:color/white"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="?colorAccent"
|
app:met_primaryColor="?colorAccent"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true" />
|
||||||
android:background="@drawable/customborder"/>
|
|
||||||
|
|
||||||
<com.rengwuxian.materialedittext.MaterialEditText
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
android:id="@+id/LastNameInput"
|
android:id="@+id/LastNameInput"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="70dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="Last Name"
|
android:hint="Last Name"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:met_baseColor="@android:color/white"
|
app:met_baseColor="@android:color/white"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="?colorAccent"
|
app:met_primaryColor="?colorAccent"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true" />
|
||||||
android:background="@drawable/customborder"/>
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/SignUp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:onClick="onClickSignUp"
|
||||||
|
android:text="@string/signup"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,55 @@
|
||||||
android:background="@drawable/background"
|
android:background="@drawable/background"
|
||||||
tools:context=".Welcome">
|
tools:context=".Welcome">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Welcome"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Welcome"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="FirstNameHere"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Roleis"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="You are logged in as"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="36sp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Role"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="RoleHere"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
|
android:textSize="36sp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
//import android.content.Context;
|
||||||
|
//import android.database.DatabaseUtils;
|
||||||
|
//import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(packageName = "com.uottawa.olympus.olympusservices")
|
||||||
|
public class DBUnitTest {
|
||||||
|
private DBHelper dbHelper = new DBHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddAndDeleteUser(){
|
||||||
|
UserType originalUser, dbUser;
|
||||||
|
boolean deleted, addedOne, addedTwo;
|
||||||
|
|
||||||
|
|
||||||
|
originalUser = new User("mgarzon", "soccer", "Miguel", "Garzon");
|
||||||
|
addedOne = dbHelper.addUser(originalUser);
|
||||||
|
dbUser = dbHelper.findUserByUsername("mgarzon");
|
||||||
|
|
||||||
|
assertEquals("User", dbUser.getClass().getSimpleName());
|
||||||
|
assertEquals("mgarzon", dbUser.getUsername());
|
||||||
|
assertEquals("soccer", dbUser.getPassword());
|
||||||
|
assertEquals("Miguel", dbUser.getFirstname());
|
||||||
|
assertEquals("Garzon", dbUser.getLastname());
|
||||||
|
|
||||||
|
|
||||||
|
originalUser = new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman");
|
||||||
|
addedTwo = dbHelper.addUser(originalUser);
|
||||||
|
dbUser = dbHelper.findUserByUsername("jbO4aBF4dC");
|
||||||
|
|
||||||
|
assertEquals("ServiceProvider", dbUser.getClass().getSimpleName());
|
||||||
|
assertEquals("jbO4aBF4dC", dbUser.getUsername());
|
||||||
|
assertEquals("seg2105", dbUser.getPassword());
|
||||||
|
assertEquals("Juan", dbUser.getFirstname());
|
||||||
|
assertEquals("Guzman", dbUser.getLastname());
|
||||||
|
|
||||||
|
if (addedOne) {
|
||||||
|
deleted = dbHelper.deleteUser("mgarzon");
|
||||||
|
assertTrue(deleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addedTwo) {
|
||||||
|
deleted = dbHelper.deleteUser("jbO4aBF4dC");
|
||||||
|
assertTrue(deleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddDuplicateUsers(){
|
||||||
|
boolean added;
|
||||||
|
|
||||||
|
added = dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
|
assertTrue(added);
|
||||||
|
added = dbHelper.addUser(new User("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
|
||||||
|
assertTrue(!added);
|
||||||
|
added = dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman"));
|
||||||
|
assertTrue(!added);
|
||||||
|
|
||||||
|
dbHelper.deleteUser("jbO4aBF4dC");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateUserLogin(){
|
||||||
|
boolean updated;
|
||||||
|
UserType dbUser;
|
||||||
|
|
||||||
|
dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
|
updated = dbHelper.updateUserInfo("jbO4aBF4dC", "soccer", "Juan", "Guzman");
|
||||||
|
assertTrue(updated);
|
||||||
|
|
||||||
|
dbUser = dbHelper.findUserByUsername("jbO4aBF4dC");
|
||||||
|
|
||||||
|
assertEquals("jbO4aBF4dC", dbUser.getUsername());
|
||||||
|
assertEquals("soccer", dbUser.getPassword());
|
||||||
|
assertEquals("Juan", dbUser.getFirstname());
|
||||||
|
assertEquals("Guzman", dbUser.getLastname());
|
||||||
|
|
||||||
|
//changed on character of username. Everything is case sensitive!
|
||||||
|
updated = dbHelper.updateUserInfo("JbO4aBF4dC", "seg2105", "Juan", "Guzman");
|
||||||
|
assertTrue(!updated);
|
||||||
|
|
||||||
|
dbHelper.deleteUser("jbO4aBF4dC");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ buildscript {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#Fri Sep 28 14:59:51 EDT 2018
|
<<<<<<< HEAD
|
||||||
|
#Fri Oct 05 11:36:36 EDT 2018
|
||||||
|
=======
|
||||||
|
#Fri Oct 05 10:21:14 EDT 2018
|
||||||
|
>>>>>>> refs/remotes/origin/master
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||||
|
|
BIN
UML Class Diagram.docx
Normal file
BIN
UML Class Diagram.docx
Normal file
Binary file not shown.
BIN
~$L Class Diagram.docx
Normal file
BIN
~$L Class Diagram.docx
Normal file
Binary file not shown.
Loading…
Reference in a new issue