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
f2c0c5d0
Commit
f2c0c5d0
authored
May 27, 2023
by
austin.blanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working Login
parent
d45cc8f1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
209 additions
and
5 deletions
+209
-5
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+21
-1
CreateAccountActivity.java
...xample/bookingapp_austinblanke/CreateAccountActivity.java
+33
-0
DatabaseConnector.java
...om/example/bookingapp_austinblanke/DatabaseConnector.java
+76
-0
LoginActivity.java
...va/com/example/bookingapp_austinblanke/LoginActivity.java
+20
-2
MainActivity.java
...ava/com/example/bookingapp_austinblanke/MainActivity.java
+5
-1
createaccount_activity.xml
app/src/main/res/layout/createaccount_activity.xml
+52
-0
login_activity.xml
app/src/main/res/layout/login_activity.xml
+2
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
f2c0c5d0
...
...
@@ -12,14 +12,34 @@
android:theme=
"@style/Theme.BookingAppAustinBlanke"
tools:targetApi=
"31"
>
<activity
android:name=
".
Ma
inActivity"
android:name=
".
Log
inActivity"
android:exported=
"true"
>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".MainActivity"
android:exported=
"false"
>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
</activity>
<activity
android:name=
".CreateAccountActivity"
android:exported=
"false"
>
<meta-data
android:name=
"android.app.lib_name"
android:value=
""
/>
</activity>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/example/bookingapp_austinblanke/CreateAccountActivity.java
0 → 100644
View file @
f2c0c5d0
package
com
.
example
.
bookingapp_austinblanke
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.Toast
;
public
class
CreateAccountActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
createaccount_activity
);
}
public
void
createAccount
(
View
view
)
{
this
.
createAccount
();}
private
void
createAccount
()
{
DatabaseConnector
connector
=
new
DatabaseConnector
(
this
,
null
);
EditText
username
=
findViewById
(
R
.
id
.
Username
);
EditText
password
=
findViewById
(
R
.
id
.
Password
);
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
0 → 100644
View file @
f2c0c5d0
package
com
.
example
.
bookingapp_austinblanke
;
import
android.content.ContentValues
;
import
android.content.Context
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
androidx.annotation.Nullable
;
public
class
DatabaseConnector
extends
SQLiteOpenHelper
{
private
static
final
String
DB_NAME
=
"Registration.db"
;
private
static
final
int
DB_VERSION
=
1
;
private
static
final
String
TABLE_USERS
=
"Users"
;
private
static
final
String
COLUMN_UID
=
"uid"
;
private
static
final
String
COLUMN_USERNAME
=
"username"
;
private
static
final
String
COLUMN_PASSWORD
=
"password"
;
public
DatabaseConnector
(
Context
context
,
SQLiteDatabase
.
CursorFactory
factory
)
{
super
(
context
,
DB_NAME
,
factory
,
DB_VERSION
);
}
@Override
public
void
onCreate
(
SQLiteDatabase
db
)
{
String
CREATE_table
=
"CREATE TABLE "
+
TABLE_USERS
+
"("
+
COLUMN_UID
+
" INTEGER PRIMARY KEY, "
+
COLUMN_USERNAME
+
" TEXT, "
+
COLUMN_PASSWORD
+
" TEXT)"
;
db
.
execSQL
(
CREATE_table
);
}
public
void
addNewUser
(
String
username
,
String
password
)
{
ContentValues
values
=
new
ContentValues
();
values
.
put
(
COLUMN_USERNAME
,
username
);
values
.
put
(
COLUMN_PASSWORD
,
password
);
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
insert
(
TABLE_USERS
,
null
,
values
);
db
.
close
();
}
@Override
public
void
onUpgrade
(
SQLiteDatabase
sqLiteDatabase
,
int
i
,
int
i1
)
{
}
public
boolean
login
(
String
username
,
String
password
)
{
String
query
=
"SELECT * FROM "
+
TABLE_USERS
+
" WHERE "
+
COLUMN_USERNAME
+
" = \""
+
username
+
"\""
;
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
query
,
null
);
boolean
result
=
false
;
if
(
cursor
.
moveToFirst
()){
if
(
cursor
.
getString
(
2
).
equals
(
password
))
result
=
true
;
else
result
=
false
;
}
cursor
.
close
();
db
.
close
();
return
result
;
}
}
app/src/main/java/com/example/bookingapp_austinblanke/LoginActivity.java
View file @
f2c0c5d0
...
...
@@ -15,11 +15,29 @@ public class LoginActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
login_activity
);
}
public
void
login
(
View
view
)
{
Intent
intent
=
new
Intent
(
this
,
Main
Activity
.
class
);
public
void
createAccount
(
View
view
)
{
Intent
intent
=
new
Intent
(
this
,
CreateAccount
Activity
.
class
);
startActivity
(
intent
);
}
public
void
login
(
View
view
)
{
login
();
}
private
void
login
()
{
DatabaseConnector
connector
=
new
DatabaseConnector
(
this
,
null
);
EditText
username
=
findViewById
(
R
.
id
.
Username
);
EditText
password
=
findViewById
(
R
.
id
.
Password
);
boolean
success
=
connector
.
login
(
username
.
getText
().
toString
(),
password
.
getText
().
toString
());
if
(
success
)
{
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
startActivity
(
intent
);
}
else
Toast
.
makeText
(
this
,
"incorrect username or password"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
\ No newline at end of file
app/src/main/java/com/example/bookingapp_austinblanke/MainActivity.java
View file @
f2c0c5d0
...
...
@@ -9,5 +9,9 @@ import android.widget.Toast;
import
androidx.appcompat.app.AppCompatActivity
;
public
class
MainActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
}
}
\ No newline at end of file
app/src/main/res/layout/createaccount_activity.xml
0 → 100644
View file @
f2c0c5d0
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:background=
"#F2F1E8"
tools:context=
".LoginActivity"
>
<EditText
android:id=
"@+id/Password"
android:layout_width=
"228dp"
android:layout_height=
"71dp"
android:ems=
"10"
android:hint=
"Password"
android:inputType=
"textPassword"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.497"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.468"
/>
<EditText
android:id=
"@+id/Username"
android:layout_width=
"218dp"
android:layout_height=
"68dp"
android:ems=
"10"
android:hint=
"Username"
android:inputType=
"textPersonName"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.492"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.345"
/>
<Button
android:id=
"@+id/createAccount"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:onClick=
"createAccount"
android:text=
"Create Account"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.497"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.673"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/login_activity.xml
View file @
f2c0c5d0
...
...
@@ -38,6 +38,7 @@
android:id=
"@+id/CreateAccount"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:onClick=
"createAccount"
android:text=
"Create Account"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
@@ -51,8 +52,8 @@
android:layout_width=
"218dp"
android:layout_height=
"68dp"
android:ems=
"10"
android:hint=
"Username"
android:inputType=
"textPersonName"
android:text=
"Username"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.497"
...
...
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