Logic
This commit is contained in:
parent
1014a78de8
commit
8be4ccbbd7
17 changed files with 146 additions and 43 deletions
Binary file not shown.
|
@ -5,31 +5,27 @@
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
<option name="myNullables">
|
<option name="myNullables">
|
||||||
<value>
|
<value>
|
||||||
<list size="7">
|
<list size="5">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
|
||||||
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="6">
|
<list size="4">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
|
||||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" 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 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -14,7 +14,6 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".Main"
|
android:name=".Main"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
|
@ -29,7 +28,9 @@
|
||||||
android:name="preloaded_fonts"
|
android:name="preloaded_fonts"
|
||||||
android:resource="@array/preloaded_fonts" />
|
android:resource="@array/preloaded_fonts" />
|
||||||
|
|
||||||
<activity android:name=".SignUp" android:parentActivityName=".Main">
|
<activity
|
||||||
|
android:name=".SignUp"
|
||||||
|
android:parentActivityName=".Main">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".Main" />
|
android:value=".Main" />
|
||||||
|
|
|
@ -5,4 +5,6 @@ public class Admin extends UserType {
|
||||||
Admin(){
|
Admin(){
|
||||||
super("admin", "admin", "Admin", "Admin");
|
super("admin", "admin", "Admin", "Admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "Admin"; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@ package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class LogIn extends AppCompatActivity {
|
public class LogIn extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -10,4 +14,29 @@ public class LogIn extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_log_in);
|
setContentView(R.layout.activity_log_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickLogIn(View view){
|
||||||
|
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString();
|
||||||
|
String password = ((EditText) findViewById(R.id.PasswordInput)).getText().toString();
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
Intent intent = new Intent(getApplicationContext(),Welcome.class);
|
||||||
|
if(dbHelper.findUserByUsername(username).getUsername().equals(username)&&
|
||||||
|
dbHelper.findUserByUsername(username).getPassword().equals(password)){
|
||||||
|
//TODO send the welcome message the user information
|
||||||
|
intent.putExtra("username",username);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//TODO program incorrect username or password message
|
||||||
|
Toast.makeText(this,"error",Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,22 @@ public class Main extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
UserType admin = new Admin();
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
dbHelper.addUser(admin);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickSignUp(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),SignUp.class);
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickLogIn(View view){
|
||||||
|
Intent intent = new Intent(getApplicationContext(),LogIn.class);
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,4 +6,7 @@ public class ServiceProvider extends UserType {
|
||||||
super(username, password, firstname, lastname);
|
super(username, password, firstname, lastname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "ServiceProvider"; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,10 @@ import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.jaredrummler.materialspinner.MaterialSpinner;
|
import com.jaredrummler.materialspinner.MaterialSpinner;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class SignUp extends AppCompatActivity {
|
public class SignUp extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +15,7 @@ public class SignUp extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_sign_up);
|
setContentView(R.layout.activity_sign_up);
|
||||||
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||||
spinner.setItems("Ice Cream Sandwich", "Jelly Bean", "KitKat", "Lollipop", "Marshmallow");
|
spinner.setItems("User", "ServiceProvider");
|
||||||
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
||||||
|
|
||||||
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
||||||
|
@ -19,7 +23,39 @@ public class SignUp extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void main(String[] args){
|
|
||||||
|
public void onClickSignUp(View view){
|
||||||
|
UserType newUser;
|
||||||
|
String username = ((EditText) findViewById(R.id.UsernameInput)).getText().toString();
|
||||||
|
String password = ((EditText) findViewById(R.id.PasswordInput)).getText().toString();
|
||||||
|
String firstname = ((EditText) findViewById(R.id.FirstNameInput)).getText().toString();
|
||||||
|
String lastname = ((EditText) findViewById(R.id.LastNameInput)).getText().toString();
|
||||||
|
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||||
|
//TODO add message conditional to check if every EditText is filled up to standards
|
||||||
|
switch(spinner.getText().toString()){
|
||||||
|
case "User":
|
||||||
|
newUser = new User(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
case "ServiceProvider":
|
||||||
|
newUser = new ServiceProvider(username,password,firstname,lastname);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newUser = new User(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
Intent intent = new Intent(getApplicationContext(),LogIn.class); //TODO check if signup should take to the login page or automatically login
|
||||||
|
if(dbHelper.addUser(newUser)){
|
||||||
|
startActivityForResult(intent,0);
|
||||||
|
}else{
|
||||||
|
Toast.makeText(this,"error",Toast.LENGTH_LONG).show();
|
||||||
|
//TODO add reaction is username is already taken
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ public class User extends UserType {
|
||||||
super(username, password, firstname, lastname);
|
super(username, password, firstname, lastname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "User"; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package com.uottawa.olympus.olympusservices;
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
public abstract class UserType {
|
public abstract class UserType {
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
String password;
|
String password;
|
||||||
String firstname;
|
String firstname;
|
||||||
String lastname;
|
String lastname;
|
||||||
|
|
||||||
|
|
||||||
UserType(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
UserType(String username, String password, String firstname, String lastname){
|
UserType(String username, String password, String firstname, String lastname){
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
@ -19,6 +20,8 @@ public abstract class UserType {
|
||||||
this.lastname = lastname;
|
this.lastname = lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract String getRole();
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
@ -64,4 +67,15 @@ public abstract class UserType {
|
||||||
//so cannot be initialized in this class
|
//so cannot be initialized in this class
|
||||||
this.lastname = lastname;
|
this.lastname = lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean equals(UserType other){
|
||||||
|
if(this.username.equals(other.username)&&this.password.equals(other.password)&&
|
||||||
|
this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
public class Welcome extends AppCompatActivity {
|
public class Welcome extends AppCompatActivity {
|
||||||
|
|
||||||
|
@ -9,5 +12,18 @@ public class Welcome extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_welcome);
|
||||||
|
Bundle bundle = getIntent().getExtras();
|
||||||
|
String username = bundle.getString("username");
|
||||||
|
DBHelper dbHelper = new DBHelper(this);
|
||||||
|
UserType user;
|
||||||
|
user = dbHelper.findUserByUsername(username);
|
||||||
|
TextView role = (TextView) findViewById(R.id.Role);
|
||||||
|
TextView name = (TextView) findViewById(R.id.name);
|
||||||
|
role.setText(user.getRole());
|
||||||
|
name.setText(user.getFirstname());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,15 +52,14 @@
|
||||||
app:met_singleLineEllipsis="true" />
|
app:met_singleLineEllipsis="true" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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:layout_marginTop="40dp"
|
android:layout_marginTop="40dp"
|
||||||
/>
|
android:onClick="onClickLogIn"
|
||||||
|
android:text="@string/login"
|
||||||
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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>
|
|
@ -88,12 +88,13 @@
|
||||||
app:met_singleLineEllipsis="true" />
|
app:met_singleLineEllipsis="true" />
|
||||||
|
|
||||||
<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_marginTop="20dp"
|
||||||
|
android:onClick="onClickSignUp"
|
||||||
android:text="@string/signup"
|
android:text="@string/signup"
|
||||||
android:layout_marginTop="20dp"/>
|
android:theme="@style/AppTheme.Button" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,9 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
<<<<<<< HEAD
|
|
||||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
|
||||||
=======
|
|
||||||
<<<<<<< HEAD
|
|
||||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
|
||||||
=======
|
|
||||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||||
|
|
||||||
>>>>>>> 0e3ca9a99ca712d5307384360c5dd5be9aeac57a
|
|
||||||
>>>>>>> refs/remotes/origin/master
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
Loading…
Reference in a new issue