Compare commits
64 commits
master
...
deliverabl
Author | SHA1 | Date | |
---|---|---|---|
|
33611b8983 | ||
|
ea0e8bd7d1 | ||
|
8ac71c9cac | ||
|
6f49545aba | ||
|
695ab61b15 | ||
|
674ed9352f | ||
|
39ba11d11b | ||
|
23293089cb | ||
|
8b2532d27e | ||
|
073885ebeb | ||
|
3491212fbc | ||
|
7790edac33 | ||
|
60c0da3558 | ||
|
6c270be5ce | ||
|
7646deb05b | ||
|
97148737de | ||
|
d29b03972e | ||
|
319428eebb | ||
|
2da777b576 | ||
|
22cfef6b7b | ||
|
1f822b8181 | ||
|
4fe5b70d6e | ||
|
c91d38cf18 | ||
|
04362b99c0 | ||
|
8c35832b28 | ||
|
f12d7aa693 | ||
|
3288d51cf7 | ||
|
4a725dd6d6 | ||
|
a1d92aa423 | ||
|
d740cf72d3 | ||
|
8be4ccbbd7 | ||
|
fc2f8bba29 | ||
|
7edfe3a185 | ||
|
114c698b61 | ||
|
173f6097fd | ||
|
f1c28f1a4c | ||
|
9cd04e06da | ||
|
5599bd9179 | ||
|
9bb3534191 | ||
|
6f9590413f | ||
|
ab84abd042 | ||
|
0d9cf73143 | ||
|
7cde8be55a | ||
|
296aaf05e3 | ||
|
1014a78de8 | ||
|
555932b877 | ||
|
a80c6d37dc | ||
|
5a382baab4 | ||
|
8ecd089fe3 | ||
|
bba1c248a1 | ||
|
b22a32b4a2 | ||
|
aa102421ef | ||
|
e1b947ef43 | ||
|
0499d81093 | ||
|
0b36bb32e3 | ||
|
f299770923 | ||
|
6b1ff038c8 | ||
|
bcfa204f44 | ||
|
ac7e8aec0a | ||
|
a9746fb215 | ||
|
65bc8b2109 | ||
|
9cd853df11 | ||
|
50b0fc49c1 | ||
|
0aed26f071 |
BIN
Deliverable1.zip
Normal file
14
OlympusServices/.idea/assetWizardSettings.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="WizardSettings">
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="vectorWizard">
|
||||||
|
<value>
|
||||||
|
<PersistentState />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -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_7" 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 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -16,6 +16,11 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
testOptions {
|
||||||
|
unitTests {
|
||||||
|
includeAndroidResources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -24,10 +29,15 @@ dependencies {
|
||||||
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'
|
||||||
|
implementation 'com.android.support:recyclerview-v7:28.0.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,14 @@
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher_round"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
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:screenOrientation="portrait">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -29,13 +28,20 @@
|
||||||
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
|
||||||
<meta-data
|
android:name=".SignUp"
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:screenOrientation="portrait" />
|
||||||
android:value=".Main" />
|
<activity
|
||||||
</activity>
|
android:name=".LogIn"
|
||||||
<activity android:name=".LogIn" />
|
android:screenOrientation="portrait" />
|
||||||
<activity android:name=".Welcome"/>
|
<activity
|
||||||
|
android:name=".Welcome"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
<activity
|
||||||
|
android:name=".AdminWelcome"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
|
<activity android:name=".UsersList" />
|
||||||
|
<activity android:name=".ServicesList"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
BIN
OlympusServices/app/src/main/ic_launcher-web.png
Normal file
After Width: | Height: | Size: 37 KiB |
|
@ -0,0 +1,10 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
public class Admin extends UserType {
|
||||||
|
|
||||||
|
Admin(){
|
||||||
|
super("admin", "admin", "Admin", "Admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "Admin"; }
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
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,385 @@
|
||||||
|
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 = 2;
|
||||||
|
//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";
|
||||||
|
|
||||||
|
//name of table containing services and rates
|
||||||
|
private static final String TABLE_SERVICES = "services";
|
||||||
|
//columns of TABLE_LOGIN
|
||||||
|
private static final String COLUMN_SERVICE = "service";
|
||||||
|
private static final String COLUMN_RATE = "rate";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
//since these methods take a while we will call them once and store the returned dbs
|
||||||
|
readDB = this.getReadableDatabase();
|
||||||
|
writeDB = this.getWritableDatabase();
|
||||||
|
//pre-add the admin user
|
||||||
|
addUser(new Admin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db){
|
||||||
|
|
||||||
|
//making the table containing user login information
|
||||||
|
String CREATE_LOGIN_TABLE = "CREATE TABLE "+ TABLE_LOGIN + "("
|
||||||
|
+ COLUMN_USERNAME + " TEXT UNIQUE NOT NULL PRIMARY KEY ON CONFLICT ROLLBACK,"
|
||||||
|
+ COLUMN_PASSWORD + " TEXT NOT NULL,"
|
||||||
|
+ COLUMN_FIRSTNAME + " TEXT DEFAULT 'FirstName',"
|
||||||
|
+ COLUMN_LASTNAME + " TEXT DEFAULT 'LastName',"
|
||||||
|
+ COLUMN_USERTYPE + " TEXT NOT NULL" + ")";
|
||||||
|
db.execSQL(CREATE_LOGIN_TABLE);
|
||||||
|
|
||||||
|
//making the table containing services and their rates
|
||||||
|
String CREATE_SERVICES_TABLE = "CREATE TABLE "+ TABLE_SERVICES + "("
|
||||||
|
+ COLUMN_SERVICE + " TEXT UNIQUE NOT NULL PRIMARY KEY ON CONFLICT ROLLBACK,"
|
||||||
|
+ COLUMN_RATE + " REAL DEFAULT 0.0" + ")";
|
||||||
|
db.execSQL(CREATE_SERVICES_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
|
||||||
|
switch(oldVersion){
|
||||||
|
case 1: //going from db version 1 to 2
|
||||||
|
//change usertype of Users to Homeowner
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_USERTYPE, "HomeOwner");
|
||||||
|
db.update(TABLE_LOGIN, values, COLUMN_USERTYPE + " = ?", new String[]{"User"});
|
||||||
|
|
||||||
|
//if services table is not created, create it
|
||||||
|
db.execSQL("CREATE TABLE IF NOT EXISTS "+ TABLE_SERVICES + "("
|
||||||
|
+ COLUMN_SERVICE + " TEXT UNIQUE NOT NULL PRIMARY KEY ON CONFLICT ROLLBACK,"
|
||||||
|
+ COLUMN_RATE + " REAL DEFAULT 0.0" + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
onUpgrade(db, oldVersion, newVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//methods for table of users
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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){
|
||||||
|
cursor.close();
|
||||||
|
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 HomeOwner(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(){
|
||||||
|
return getAll("SELECT " + COLUMN_USERNAME + ", "
|
||||||
|
+ COLUMN_FIRSTNAME + ", "
|
||||||
|
+ COLUMN_LASTNAME + ", "
|
||||||
|
+ COLUMN_USERTYPE
|
||||||
|
+ " FROM "+TABLE_LOGIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
//methods for table of services
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a service to the database. Returns false if service already
|
||||||
|
* exists in the database.
|
||||||
|
* Returns true if successful in adding service to database.
|
||||||
|
*
|
||||||
|
* @param service service to be added
|
||||||
|
* @return whether adding service was successful
|
||||||
|
*/
|
||||||
|
public boolean addService(Service service){
|
||||||
|
//Check for duplicate username by querying login table
|
||||||
|
Cursor cursor = writeDB.query(TABLE_SERVICES,
|
||||||
|
new String[] {COLUMN_SERVICE},
|
||||||
|
COLUMN_SERVICE + " = ?",
|
||||||
|
new String[]{service.getName()},
|
||||||
|
null, null, null,
|
||||||
|
"1");
|
||||||
|
//If cursor has 1+ elements in it, username already exists in table
|
||||||
|
if (cursor != null && cursor.getCount() > 0){
|
||||||
|
cursor.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_SERVICE, service.getName());
|
||||||
|
values.put(COLUMN_RATE, service.getRate());
|
||||||
|
writeDB.insert(TABLE_SERVICES, null, values);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks in database for service with specified, and returns an
|
||||||
|
* object of Service if found.
|
||||||
|
* Returns null if no such service found.
|
||||||
|
*
|
||||||
|
* @param serviceName service to look up
|
||||||
|
* @return object representing service found
|
||||||
|
*/
|
||||||
|
public Service findService(String serviceName){
|
||||||
|
Service service;
|
||||||
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_SERVICES
|
||||||
|
+ " WHERE " + COLUMN_SERVICE + " = ?",
|
||||||
|
new String[]{serviceName});
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()){
|
||||||
|
String servName = cursor.getString(0);
|
||||||
|
double rate = cursor.getDouble(1);
|
||||||
|
service = new Service(servName, rate);
|
||||||
|
} else {
|
||||||
|
service = null;
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates service rate using a Service object.
|
||||||
|
* Returns true if a service was found and entry updated.
|
||||||
|
* Returns false if no service was found.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param service service object containing updated values
|
||||||
|
*
|
||||||
|
* @return whether updating service information was successful
|
||||||
|
*/
|
||||||
|
public boolean updateService(Service service){
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_RATE, service.getRate());
|
||||||
|
|
||||||
|
return writeDB.update(TABLE_SERVICES, values, COLUMN_SERVICE+" = ?",
|
||||||
|
new String[]{service.getName()}) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates service rate using input of service name and rate.
|
||||||
|
* Returns true if a service was found and entry updated.
|
||||||
|
* Returns false if no service was found.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param name name of service
|
||||||
|
* @param rate rate of service
|
||||||
|
*
|
||||||
|
* @return whether updating service information was successful
|
||||||
|
*/
|
||||||
|
public boolean updateService(String name, double rate){
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
if (rate > 0)
|
||||||
|
values.put(COLUMN_RATE, rate);
|
||||||
|
|
||||||
|
return writeDB.update(TABLE_SERVICES, values, COLUMN_SERVICE+" = ?",
|
||||||
|
new String[]{name}) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks in database for a service, and deletes the corresponding
|
||||||
|
* entry. Returns true if a user was deleted, false otherwise.
|
||||||
|
*
|
||||||
|
* @param service service of entry to delete
|
||||||
|
* @return whether the service was deleted
|
||||||
|
*/
|
||||||
|
public boolean deleteService(String service) {
|
||||||
|
return writeDB.delete(TABLE_SERVICES, COLUMN_SERVICE+" = ?",
|
||||||
|
new String[]{service}) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of String arrays containing the service categories,
|
||||||
|
* names and hourly rates.
|
||||||
|
*
|
||||||
|
* @return list of arrays of [service, rate]
|
||||||
|
*/
|
||||||
|
public List<String[]> getAllServices(){
|
||||||
|
return getAll("SELECT * FROM " + TABLE_SERVICES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints all entries of table. One row is printed per line. Columns are
|
||||||
|
* separated by spaces.
|
||||||
|
*
|
||||||
|
* @param tableName name of table to print
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<String[]> getAll(String rawQuery){
|
||||||
|
List<String[]> list = new LinkedList<>();
|
||||||
|
String[] infoArray;
|
||||||
|
Cursor cursor = readDB.rawQuery(rawQuery,null);
|
||||||
|
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
for (int i = 0; i < cursor.getCount(); i++) {
|
||||||
|
infoArray = new String[cursor.getColumnNames().length];
|
||||||
|
for (int j = 0; j < cursor.getColumnNames().length; j++) {
|
||||||
|
infoArray[j] = cursor.getString(j);
|
||||||
|
}
|
||||||
|
list.add(infoArray);
|
||||||
|
cursor.moveToNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
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
|
||||||
|
args.putString("name", (String)getArguments().get("name"));
|
||||||
|
args.putDouble("rate", 2.5);
|
||||||
|
//
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
|
||||||
|
public class HomeOwner extends UserType {
|
||||||
|
|
||||||
|
HomeOwner(String username, String password, String firstname, String lastname){
|
||||||
|
super(username, password, firstname, lastname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "HomeOwner"; }
|
||||||
|
|
||||||
|
}
|
|
@ -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,54 @@ 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);
|
||||||
|
if(username.matches("[a-zA-Z0-9]*")&&password.matches("[a-zA-Z0-9]*")
|
||||||
|
&& password.length()>0 && username.length()>0) {
|
||||||
|
if (dbHelper.findUserByUsername(username) != null) {
|
||||||
|
UserType user = dbHelper.findUserByUsername(username);
|
||||||
|
if (user.getUsername().equals(username) &&
|
||||||
|
user.getPassword().equals(password)) {
|
||||||
|
if(user.getRole()=="Admin"){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),AdminWelcome.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Intent intent = new Intent(getApplicationContext(),Welcome.class);
|
||||||
|
intent.putExtra("username", username);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Wrong Password", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Account does not exist", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(username.length()==0 || password.length()==0){
|
||||||
|
Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Toast.makeText(this, "Fields may only contain alphanumeric values", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onBackPressed(){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,24 @@ 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);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickLogIn(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),LogIn.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
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;
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@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_new, null))
|
||||||
|
// Add action buttons
|
||||||
|
.setPositiveButton(R.string.add, 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
|
||||||
|
args.putString("name", "test2");
|
||||||
|
args.putDouble("rate", 2.5);
|
||||||
|
///
|
||||||
|
NewServiceDialogFragment.this.setArguments(args);
|
||||||
|
mListener.onDialogNew(NewServiceDialogFragment.this);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
NewServiceDialogFragment.this.getDialog().cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Service {
|
||||||
|
private String name;
|
||||||
|
private double rate;
|
||||||
|
private List<ServiceProvider> serviceProviders;
|
||||||
|
|
||||||
|
Service(String name, double rate) {
|
||||||
|
this.name = name;
|
||||||
|
this.rate = rate;
|
||||||
|
serviceProviders = new ArrayList<ServiceProvider>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRate() {
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRate(double rate) {
|
||||||
|
this.rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addServiceProvider(ServiceProvider user){
|
||||||
|
for (ServiceProvider listUser : serviceProviders){
|
||||||
|
if (user.getUsername().equals(listUser.getUsername())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serviceProviders.add(user);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ServiceProvider> getServiceProviders(){
|
||||||
|
return serviceProviders;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ServiceProvider extends UserType {
|
||||||
|
|
||||||
|
private List<Service> services;
|
||||||
|
|
||||||
|
ServiceProvider(String username, String password, String firstname, String lastname){
|
||||||
|
super(username, password, firstname, lastname);
|
||||||
|
services = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "ServiceProvider"; }
|
||||||
|
|
||||||
|
public boolean addService(Service service){
|
||||||
|
for (Service listService : services){
|
||||||
|
if (service.getName().equals(listService.getName())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
services.add(service);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Service> getServices(){
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.GridView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ServicesList extends AppCompatActivity implements NewServiceDialogFragment.NoticeDialogListener, EditServiceDialogFragment.NoticeDialogListener{
|
||||||
|
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
private RecyclerView.Adapter mAdapter;
|
||||||
|
private RecyclerView.LayoutManager mLayoutManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_services_list);
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
List<String[]> serviceslist = dbHelper.getAllServices();
|
||||||
|
Service[] services = new Service[(serviceslist.size())];
|
||||||
|
Iterator iter = serviceslist.iterator();
|
||||||
|
for (int i=0; i<serviceslist.size();i++){
|
||||||
|
String[] current = (String[])iter.next();
|
||||||
|
services[i] = new Service(current[0], Double.parseDouble(current[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
mRecyclerView = (RecyclerView) findViewById(R.id.Services);
|
||||||
|
|
||||||
|
|
||||||
|
mLayoutManager = new LinearLayoutManager(this);
|
||||||
|
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
|
||||||
|
mAdapter = new MyAdapter(services, this);
|
||||||
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void addService(View view) {
|
||||||
|
DialogFragment newFragment = new NewServiceDialogFragment();
|
||||||
|
newFragment.show(getSupportFragmentManager(), "addService");
|
||||||
|
}
|
||||||
|
public void editService(View view, String name) {
|
||||||
|
DialogFragment newFragment = new EditServiceDialogFragment();
|
||||||
|
newFragment.show(getSupportFragmentManager(), "editService");
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("name", name);
|
||||||
|
newFragment.setArguments(args);
|
||||||
|
}
|
||||||
|
//add new service
|
||||||
|
@Override
|
||||||
|
public void onDialogNew(DialogFragment dialog) {
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
String name = (String)dialog.getArguments().get("name");
|
||||||
|
Double rate = (Double)dialog.getArguments().get("rate");
|
||||||
|
dbHelper.addService(new Service(name,rate));
|
||||||
|
dialog.dismiss();
|
||||||
|
this.recreate();
|
||||||
|
}
|
||||||
|
//user clicked cancel
|
||||||
|
@Override
|
||||||
|
public void onDialogNevermind(DialogFragment dialog) {
|
||||||
|
|
||||||
|
}
|
||||||
|
//edits service with info from dialog
|
||||||
|
@Override
|
||||||
|
public void onDialogEdit(DialogFragment dialog) {
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
String name = (String)dialog.getArguments().get("name");
|
||||||
|
Double rate = (Double)dialog.getArguments().get("rate");
|
||||||
|
dbHelper.updateService(new Service(name,rate));
|
||||||
|
dialog.dismiss();
|
||||||
|
this.recreate();
|
||||||
|
}
|
||||||
|
//deletes service with info from dialog
|
||||||
|
@Override
|
||||||
|
public void onDialogDelete(DialogFragment dialog) {
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
String name = (String)dialog.getArguments().get("name");
|
||||||
|
dbHelper.deleteService(name);
|
||||||
|
dialog.dismiss();
|
||||||
|
this.recreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ServicesHolder> {
|
||||||
|
|
||||||
|
private Service[] services;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
// Provide a reference to the views for each data item
|
||||||
|
// Complex data items may need more than one view per item, and
|
||||||
|
// you provide access to all the views for a data item in a view holder
|
||||||
|
|
||||||
|
// Provide a suitable constructor (depends on the kind of dataset)
|
||||||
|
public MyAdapter(Service[] services, Context context) {
|
||||||
|
this.services = services;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new views (invoked by the layout manager)
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ServicesHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.list_item, parent, false);
|
||||||
|
ServicesHolder vh = new ServicesHolder(v);
|
||||||
|
return vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace the contents of a view (invoked by the layout manager)
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ServicesHolder holder, int position) {
|
||||||
|
Service service = services[position];
|
||||||
|
holder.name.setText(service.getName());
|
||||||
|
holder.rate.setText(""+service.getRate());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the size of your dataset (invoked by the layout manager)
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return services.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ServicesHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
||||||
|
|
||||||
|
TextView name;
|
||||||
|
TextView rate;
|
||||||
|
|
||||||
|
public ServicesHolder(View row){
|
||||||
|
super(row);
|
||||||
|
name = row.findViewById(R.id.Name);
|
||||||
|
rate = row.findViewById(R.id.Rate);
|
||||||
|
row.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
TextView nameview = (TextView)view.findViewById(R.id.Name);
|
||||||
|
String name = nameview.getText().toString();
|
||||||
|
editService(view, name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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,15 +15,65 @@ 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("Home Owner", "Service Provider");
|
||||||
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) {
|
||||||
Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(view, "Clicked " + item, Snackbar.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
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
|
||||||
|
if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
|
||||||
|
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
|
||||||
|
switch(spinner.getText().toString()){
|
||||||
|
case "Home Owner":
|
||||||
|
newUser = new HomeOwner(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
case "Service Provider":
|
||||||
|
newUser = new ServiceProvider(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newUser = new HomeOwner(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)){
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}else{
|
||||||
|
Toast.makeText(this,"Username is taken",Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(firstname.length()==0 || lastname.length()==0 || username.length()==0 || password.length()==0){
|
||||||
|
Toast.makeText(this, "Fields cannot be empty", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
else if (username.length()<=5 || password.length()<=5 ){
|
||||||
|
Toast.makeText(this, "Password and username must be longer than 4 characters", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Toast.makeText(this, "Fields may only contain alphanumeric values", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onBackPressed(){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.GridView;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UsersList extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_users_list);
|
||||||
|
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
List<String[]> users = dbHelper.getAllUsers();
|
||||||
|
String[] usernames = new String[(users.size()+1)*2];
|
||||||
|
usernames[0] = "Username";
|
||||||
|
usernames[1] = "User Type";
|
||||||
|
Iterator iter = users.iterator();
|
||||||
|
for (int i=0; i<users.size();i++){
|
||||||
|
String[] current = (String[])iter.next();
|
||||||
|
usernames[(i+1)*2] = current[0];
|
||||||
|
usernames[(i+1)*2+1] = current[3];
|
||||||
|
}
|
||||||
|
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.simple_list_item_1_customized, usernames);
|
||||||
|
GridView gridView = findViewById(R.id.Users);
|
||||||
|
gridView.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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,26 @@ 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 = findViewById(R.id.Role);
|
||||||
|
TextView name = findViewById(R.id.name);
|
||||||
|
role.setText(user.getRole());
|
||||||
|
name.setText(user.getFirstname());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void onBackPressed(){
|
||||||
|
}
|
||||||
|
public void LogOut(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(), Main.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
BIN
OlympusServices/app/src/main/res/drawable/logo.JPG
Normal file
After Width: | Height: | Size: 18 KiB |
|
@ -0,0 +1,54 @@
|
||||||
|
<?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=".Welcome">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Welcome"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Welcome Admin"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Users"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:onClick="goToUsers"
|
||||||
|
android:text="List of Users"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Services"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:onClick="goToServices"
|
||||||
|
android:text="List of Services"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/LogOut"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:onClick="LogOut"
|
||||||
|
android:text="Logout"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
</LinearLayout>
|
|
@ -13,4 +13,62 @@
|
||||||
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" />
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/UsernameInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:background="@color/colorWhite"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:hint="@string/username"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
|
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:textSize="15sp"
|
||||||
|
android:hint="@string/password"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
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/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>
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?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=".ServicesList">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Welcome"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="List of Services"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Title1"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Name"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Title2"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Hourly Rate"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/Services"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="250dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/newService"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="Add New Service"
|
||||||
|
android:onClick="addService"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -16,78 +16,93 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/Title"
|
android:id="@+id/Title"
|
||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginBottom="40dp"
|
android:layout_marginBottom="10dp"
|
||||||
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"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="36sp"
|
android:textSize="15sp"
|
||||||
app:fontFamily="@font/julius_sans_one" />
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
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="15sp" />
|
||||||
|
|
||||||
|
// component used from https://github.com/jaredrummler/MaterialSpinner
|
||||||
<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="45dp"
|
||||||
android:layout_marginBottom="15dp" />
|
android:layout_marginBottom="10dp" />
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
<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="80dp"
|
||||||
android:hint="Username"
|
|
||||||
android:textSize="20sp"
|
|
||||||
app:met_baseColor="@android:color/white"
|
|
||||||
android:background="@color/colorWhite"
|
android:background="@color/colorWhite"
|
||||||
|
android:hint="Username"
|
||||||
|
android:textSize="15sp"
|
||||||
|
app:met_baseColor="@android:color/white"
|
||||||
app:met_floatingLabel="highlight"
|
app:met_floatingLabel="highlight"
|
||||||
app:met_primaryColor="?colorAccent"
|
app:met_primaryColor="@color/colorWhite"
|
||||||
app:met_singleLineEllipsis="true"/>
|
app:met_singleLineEllipsis="true"
|
||||||
|
android:textCursorDrawable="@color/colorWhite"/>
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
<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="80dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
android:textSize="20sp"
|
android:textSize="15sp"
|
||||||
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="@color/colorWhite"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true"
|
||||||
android:background="@drawable/customborder"/>
|
android:inputType="textPassword"
|
||||||
|
android:textCursorDrawable="@color/colorWhite"/>
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
<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="80dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="First Name"
|
android:hint="First Name"
|
||||||
android:textSize="20sp"
|
android:textSize="15sp"
|
||||||
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="@color/colorWhite"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true"
|
||||||
android:background="@drawable/customborder"/>
|
android:textCursorDrawable="@color/colorWhite"/>
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
<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="80dp"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
android:hint="Last Name"
|
android:hint="Last Name"
|
||||||
android:textSize="20sp"
|
android:textSize="15sp"
|
||||||
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="@color/colorWhite"
|
||||||
app:met_singleLineEllipsis="true"
|
app:met_singleLineEllipsis="true"
|
||||||
android:background="@drawable/customborder"/>
|
android:textCursorDrawable="@color/colorWhite"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/SignUp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:onClick="onClickSignUp"
|
||||||
|
android:text="@string/signup"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?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=".Welcome">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Welcome"
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="List of Users"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<GridView
|
||||||
|
android:id="@+id/Users"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:numColumns="2"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -13,4 +13,63 @@
|
||||||
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="30sp"
|
||||||
|
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="20sp"
|
||||||
|
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 a"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="18sp"
|
||||||
|
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="Role Here"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
|
android:textSize="20sp"
|
||||||
|
app:fontFamily="@font/julius_sans_one" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/LogOut"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:onClick="LogOut"
|
||||||
|
android:text="Logout"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?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"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/RateInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:hint="@string/servicerate"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
|
android:textSize="15sp"
|
||||||
|
app:met_baseColor="@android:color/black"
|
||||||
|
app:met_floatingLabel="highlight"
|
||||||
|
app:met_primaryColor="@color/colorBlack"
|
||||||
|
app:met_singleLineEllipsis="true"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?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"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/NameInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:hint="@string/servicename"
|
||||||
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
|
android:textSize="15sp"
|
||||||
|
app:met_baseColor="@android:color/black"
|
||||||
|
app:met_floatingLabel="highlight"
|
||||||
|
app:met_primaryColor="@color/colorBlack"
|
||||||
|
app:met_singleLineEllipsis="true"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"/>
|
||||||
|
|
||||||
|
//component used from https://github.com/rengwuxian/MaterialEditText
|
||||||
|
<com.rengwuxian.materialedittext.MaterialEditText
|
||||||
|
android:id="@+id/RateInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:hint="@string/servicerate"
|
||||||
|
android:inputType="numberDecimal"
|
||||||
|
android:textCursorDrawable="@color/colorWhite"
|
||||||
|
android:textSize="15sp"
|
||||||
|
app:met_baseColor="@android:color/black"
|
||||||
|
app:met_floatingLabel="highlight"
|
||||||
|
app:met_primaryColor="@color/colorBlack"
|
||||||
|
app:met_singleLineEllipsis="true"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
31
OlympusServices/app/src/main/res/layout/list_item.xml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="45dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="@drawable/customborder"
|
||||||
|
android:layout_marginBottom="5dp">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:id="@+id/Name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text=""
|
||||||
|
android:textColor="@color/colorWhite"
|
||||||
|
android:textSize="15sp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/Rate"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text=""
|
||||||
|
android:textColor="@color/colorWhite"
|
||||||
|
android:textSize="15sp"/>
|
||||||
|
</LinearLayout>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@android:id/text1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||||
|
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||||
|
android:textColor="@android:color/white">
|
||||||
|
|
||||||
|
</TextView>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@drawable/ic_launcher_background" />
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@drawable/ic_launcher_background" />
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 9 KiB After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -2,7 +2,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#303F9F</color>
|
||||||
<color name="colorWhite">#FFFFFF</color>
|
<color name="colorWhite">#FFFFFF</color>
|
||||||
<color name="colorBlack">#000000</color>
|
<color name="colorBlack">#000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#FFFFFF</color>
|
||||||
|
</resources>
|
|
@ -19,6 +19,15 @@
|
||||||
<string name="login">Log In</string>
|
<string name="login">Log In</string>
|
||||||
<string name="newusername">Enter Username</string>
|
<string name="newusername">Enter Username</string>
|
||||||
<string name="newpassword">Enter Password</string>
|
<string name="newpassword">Enter Password</string>
|
||||||
|
<string name="password">Password</string>
|
||||||
|
<string name="username">Username</string>
|
||||||
|
<string name="servicename">Service Name</string>
|
||||||
|
<string name="servicerate">Service Rate</string>
|
||||||
|
<string name="save">Save</string>
|
||||||
|
<string name="cancel">Cancel</string>
|
||||||
|
<string name="update">Update</string>
|
||||||
|
<string name="delete">Delete</string>
|
||||||
|
<string name="add">Add</string>
|
||||||
<string-array name="roles">
|
<string-array name="roles">
|
||||||
<item>Admin</item>
|
<item>Admin</item>
|
||||||
<item>User</item>
|
<item>User</item>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
|
<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
|
|
@ -0,0 +1,214 @@
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
@Config(packageName = "com.uottawa.olympus.olympusservices")
|
||||||
|
public class DBIntegrationTest {
|
||||||
|
private DBHelper dbHelper = new DBHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
|
//testing user login table
|
||||||
|
@Test
|
||||||
|
public void testAdminExists(){
|
||||||
|
UserType dbUser = dbHelper.findUserByUsername("admin");
|
||||||
|
assertEquals("Admin", dbUser.getClass().getSimpleName());
|
||||||
|
assertEquals("admin", dbUser.getUsername());
|
||||||
|
assertEquals("admin", dbUser.getPassword());
|
||||||
|
assertEquals("Admin", dbUser.getFirstname());
|
||||||
|
assertEquals("Admin", dbUser.getLastname());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddAndDeleteUser(){
|
||||||
|
UserType originalUser, dbUser;
|
||||||
|
boolean deleted, addedOne, addedTwo;
|
||||||
|
|
||||||
|
|
||||||
|
originalUser = new HomeOwner("mgarzon", "soccer", "Miguel", "Garzon");
|
||||||
|
addedOne = dbHelper.addUser(originalUser);
|
||||||
|
dbUser = dbHelper.findUserByUsername("mgarzon");
|
||||||
|
|
||||||
|
assertEquals("HomeOwner", 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 HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
|
assertTrue(added);
|
||||||
|
added = dbHelper.addUser(new HomeOwner("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 HomeOwner("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");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllUsers(){
|
||||||
|
dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
|
|
||||||
|
List<String[]> allUsers = dbHelper.getAllUsers();
|
||||||
|
|
||||||
|
for (String[] user : allUsers){
|
||||||
|
/* for (String s : user){
|
||||||
|
System.out.print(s + " ");
|
||||||
|
}
|
||||||
|
System.out.println();*/
|
||||||
|
UserType usertype = dbHelper.findUserByUsername(user[0]);
|
||||||
|
assertEquals(usertype.getFirstname(), user[1]);
|
||||||
|
assertEquals(usertype.getLastname(), user[2]);
|
||||||
|
assertEquals(usertype.getClass().getSimpleName(), user[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbHelper.deleteUser("jbO4aBF4dC");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Testing services table
|
||||||
|
@Test
|
||||||
|
public void testAddAndDeleteServices(){
|
||||||
|
Service originalService, dbService;
|
||||||
|
boolean deleted, addedOne, addedTwo;
|
||||||
|
|
||||||
|
|
||||||
|
originalService = new Service("Exterminating flatworms", 20.00);
|
||||||
|
addedOne = dbHelper.addService(originalService);
|
||||||
|
dbService = dbHelper.findService("Exterminating flatworms");
|
||||||
|
|
||||||
|
assertEquals("Exterminating flatworms", dbService.getName());
|
||||||
|
assertEquals(20.00, dbService.getRate(), 0.001);
|
||||||
|
|
||||||
|
|
||||||
|
originalService = new Service("Cleaning fishtanks", 15.00);
|
||||||
|
addedTwo = dbHelper.addService(originalService);
|
||||||
|
dbService = dbHelper.findService("Cleaning fishtanks");
|
||||||
|
|
||||||
|
assertEquals("Cleaning fishtanks", dbService.getName());
|
||||||
|
assertEquals(15.00, dbService.getRate(), 0.001);
|
||||||
|
|
||||||
|
if (addedOne) {
|
||||||
|
deleted = dbHelper.deleteService("Exterminating flatworms");
|
||||||
|
assertTrue(deleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addedTwo) {
|
||||||
|
deleted = dbHelper.deleteService("Cleaning fishtanks");
|
||||||
|
assertTrue(deleted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddDuplicateService(){
|
||||||
|
boolean added;
|
||||||
|
|
||||||
|
added = dbHelper.addService(new Service("Exterminating flatworms", 20.00));
|
||||||
|
assertTrue(added);
|
||||||
|
added = dbHelper.addService(new Service("Exterminating flatworms", 25.00));
|
||||||
|
assertTrue(!added);
|
||||||
|
|
||||||
|
dbHelper.deleteService("Exterminating flatworms");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateService(){
|
||||||
|
boolean updated;
|
||||||
|
Service service;
|
||||||
|
|
||||||
|
dbHelper.addService(new Service("Exterminating flatworms", 20.00));
|
||||||
|
updated = dbHelper.updateService("Exterminating flatworms", 25.00);
|
||||||
|
assertTrue(updated);
|
||||||
|
|
||||||
|
service = dbHelper.findService("Exterminating flatworms");
|
||||||
|
|
||||||
|
assertEquals("Exterminating flatworms", service.getName());
|
||||||
|
assertEquals(25.00, service.getRate(), 0.001);
|
||||||
|
|
||||||
|
dbHelper.deleteService("Exterminating flatworms");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllServices(){
|
||||||
|
dbHelper.addService(new Service("Exterminating flatworms", 20.00));
|
||||||
|
|
||||||
|
List<String[]> allServices = dbHelper.getAllServices();
|
||||||
|
|
||||||
|
for (String[] service : allServices){
|
||||||
|
/* for (String s : user){
|
||||||
|
System.out.print(s + " ");
|
||||||
|
}
|
||||||
|
System.out.println();*/
|
||||||
|
Service dbService = dbHelper.findService(service[0]);
|
||||||
|
assertEquals(dbService.getRate(), Double.parseDouble(service[1]), 0.001);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbHelper.deleteService("Exterminating flatworms");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
# SEG2105-Olympus
|
# SEG2105-Olympus
|
||||||
SEG2105 final project, Ivana Erlich, Anshu Sharma, Batuhan Basoglu, Mary Tran
|
SEG2105 final project, Ivana Erlich, Anshu Sharma, Batuhan Basoglu, Mary Tran
|
||||||
|
https://github.com/ebivibe/SEG2105-Olympus
|
||||||
|
|