Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Booking App COM5007
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
austin.blanke
Booking App COM5007
Commits
e689cc5e
Commit
e689cc5e
authored
May 27, 2023
by
austin.blanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completed Login
parent
f2c0c5d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
CreateAccountActivity.java
...xample/bookingapp_austinblanke/CreateAccountActivity.java
+17
-4
DatabaseConnector.java
...om/example/bookingapp_austinblanke/DatabaseConnector.java
+18
-0
No files found.
app/src/main/java/com/example/bookingapp_austinblanke/CreateAccountActivity.java
View file @
e689cc5e
...
@@ -2,6 +2,8 @@ package com.example.bookingapp_austinblanke;
...
@@ -2,6 +2,8 @@ package com.example.bookingapp_austinblanke;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.EditText
;
...
@@ -24,10 +26,21 @@ public class CreateAccountActivity extends AppCompatActivity {
...
@@ -24,10 +26,21 @@ public class CreateAccountActivity extends AppCompatActivity {
EditText
username
=
findViewById
(
R
.
id
.
Username
);
EditText
username
=
findViewById
(
R
.
id
.
Username
);
EditText
password
=
findViewById
(
R
.
id
.
Password
);
EditText
password
=
findViewById
(
R
.
id
.
Password
);
connector
.
addNewUser
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
());
if
(
username
.
length
()
==
0
||
password
.
length
()
==
0
){
Toast
.
makeText
(
this
,
"username or password not provided"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
intent
=
new
Intent
(
this
,
LoginActivity
.
class
);
}
startActivity
(
intent
);
else
{
if
(
connector
.
usernameRepeat
(
username
.
getText
().
toString
())){
Toast
.
makeText
(
this
,
"username already taken"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
connector
.
addNewUser
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
());
Intent
intent
=
new
Intent
(
this
,
LoginActivity
.
class
);
startActivity
(
intent
);
}
}
}
}
}
}
app/src/main/java/com/example/bookingapp_austinblanke/DatabaseConnector.java
View file @
e689cc5e
...
@@ -54,6 +54,24 @@ public class DatabaseConnector extends SQLiteOpenHelper {
...
@@ -54,6 +54,24 @@ public class DatabaseConnector extends SQLiteOpenHelper {
}
}
public
boolean
usernameRepeat
(
String
username
){
boolean
result
=
false
;
String
query
=
"SELECT * FROM "
+
TABLE_USERS
+
" WHERE "
+
COLUMN_USERNAME
+
" = \""
+
username
+
"\""
;
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
query
,
null
);
if
(
cursor
.
getCount
()
==
0
){
result
=
false
;
}
else
result
=
true
;
cursor
.
close
();
db
.
close
();
return
result
;
}
public
boolean
login
(
String
username
,
String
password
)
{
public
boolean
login
(
String
username
,
String
password
)
{
String
query
=
"SELECT * FROM "
+
TABLE_USERS
+
" WHERE "
+
COLUMN_USERNAME
+
" = \""
+
username
+
"\""
;
String
query
=
"SELECT * FROM "
+
TABLE_USERS
+
" WHERE "
+
COLUMN_USERNAME
+
" = \""
+
username
+
"\""
;
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment