Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Simmitive_Chris_Crook
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
chris.crook
Simmitive_Chris_Crook
Commits
30b6f87e
Commit
30b6f87e
authored
Apr 09, 2021
by
chris.crook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
> added more admin functionality
parent
7db571c8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
306 additions
and
15 deletions
+306
-15
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
AdminMenu.java
...ain/java/com/example/summative_chris_crook/AdminMenu.java
+36
-8
AdminRegister.java
...java/com/example/summative_chris_crook/AdminRegister.java
+153
-0
MainActivity.java
.../java/com/example/summative_chris_crook/MainActivity.java
+5
-4
register_page.java
...java/com/example/summative_chris_crook/register_page.java
+1
-1
activity_admin_menu.xml
app/src/main/res/layout/activity_admin_menu.xml
+8
-1
activity_admin_register.xml
app/src/main/res/layout/activity_admin_register.xml
+94
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+7
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
30b6f87e
...
...
@@ -9,7 +9,8 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.Summative_Chris_Crook"
>
<activity
android:name=
".AdminMenu"
></activity>
<activity
android:name=
".AdminRegister"
></activity>
<activity
android:name=
".AdminMenu"
/>
<activity
android:name=
".UserMenu"
/>
<activity
android:name=
".register_page"
/>
<activity
android:name=
".MainActivity"
>
...
...
app/src/main/java/com/example/summative_chris_crook/AdminMenu.java
View file @
30b6f87e
...
...
@@ -26,6 +26,11 @@ public class AdminMenu extends AppCompatActivity {
startActivity
(
intent
);
}
public
void
register2electricboogaloo
(
View
view
){
Intent
intent
=
new
Intent
(
this
,
AdminRegister
.
class
);
startActivity
(
intent
);
}
public
void
ohhshiiiiii
(
View
view
){
// wipe the user login folder and reset it
File
file1
;
...
...
@@ -55,15 +60,20 @@ public class AdminMenu extends AppCompatActivity {
}
if
(
temp
.
equals
(
""
)){
// dont add a '%' to the start
temp
+=
"adminname&adminuser&
adminpassword
&ADMIN"
;
temp
+=
"%examplename&exampleuser&
examplepassword
&USER"
;
temp
+=
"adminname&adminuser&
"
+
"adminpassword"
.
hashCode
()
+
"
&ADMIN"
;
temp
+=
"%examplename&exampleuser&
"
+
"examplepassword"
.
hashCode
()
+
"
&USER"
;
}
else
{
temp
+=
"%"
;
temp
+=
"adminname&adminuser&adminpassword&ADMIN"
;
temp
+=
"%examplename&exampleuser&examplepassword&USER"
;
}
Toast
.
makeText
(
getApplicationContext
(),
temp
,
Toast
.
LENGTH_SHORT
).
show
();
temp
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN"
;
temp
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER"
;
}
//Toast.makeText(getApplicationContext(), temp, Toast.LENGTH_SHORT).show();
AlertDialog
.
Builder
dataall
=
new
AlertDialog
.
Builder
(
AdminMenu
.
this
);
dataall
.
setMessage
(
temp
);
dataall
.
setTitle
(
"User Data: "
);
dataall
.
setNegativeButton
(
"OK"
,
null
);
dataall
.
create
().
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
...
...
@@ -120,11 +130,29 @@ public class AdminMenu extends AppCompatActivity {
msgbox
.
setNegativeButton
(
"Cancel"
,
null
);
msgbox
.
setNeutralButton
(
"Display all
login related
data"
,
new
DialogInterface
.
OnClickListener
()
{
msgbox
.
setNeutralButton
(
"Display all
wipe-able
data"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
// display all data
disall
();
// display all data in an alert box
File
file1
;
// all this does is read the file and display it all
String
filename1
=
"magicwords"
;
String
temp
=
""
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
try
{
Scanner
reader
=
new
Scanner
(
file1
);
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
}
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
//disall();
AlertDialog
.
Builder
dataall
=
new
AlertDialog
.
Builder
(
AdminMenu
.
this
);
dataall
.
setMessage
(
temp
);
dataall
.
setTitle
(
"User Data: "
);
dataall
.
setNegativeButton
(
"OK"
,
null
);
dataall
.
create
().
show
();
}
});
...
...
app/src/main/java/com/example/summative_chris_crook/AdminRegister.java
0 → 100644
View file @
30b6f87e
package
com
.
example
.
summative_chris_crook
;
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
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.util.Scanner
;
public
class
AdminRegister
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_admin_register
);
}
public
void
goback
(
View
view
){
Intent
intent
=
new
Intent
(
this
,
AdminMenu
.
class
);
startActivity
(
intent
);
}
public
void
createuser
(
View
view
){
//
String
name
=
((
EditText
)
findViewById
(
R
.
id
.
Name_input
)).
getText
().
toString
();
String
user
=
((
EditText
)
findViewById
(
R
.
id
.
Username_input
)).
getText
().
toString
();
String
pass
=
((
EditText
)
findViewById
(
R
.
id
.
Password_input
)).
getText
().
toString
();
String
conf
=
((
EditText
)
findViewById
(
R
.
id
.
Password_confirm
)).
getText
().
toString
();
if
(
name
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Name"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
user
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Username"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
pass
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
conf
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password (confirmation)"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
pass
.
equals
(
conf
)){
// put all stuff together for saving to magicwords.txt
File
file1
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER"
;
//System.out.println(reassembly);
String
temp
=
""
;
try
{
Scanner
reader
=
new
Scanner
(
file1
);
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
}
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"File Error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
String
write
;
if
(
temp
.
equals
(
""
)){
write
=
reassembly
;
}
else
{
write
=
"%"
+
reassembly
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
true
);
stream
.
append
(
write
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"User Account Created"
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"The passwords do not match"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
public
void
createadmin
(
View
view
){
//
String
name
=
((
EditText
)
findViewById
(
R
.
id
.
Name_input
)).
getText
().
toString
();
String
user
=
((
EditText
)
findViewById
(
R
.
id
.
Username_input
)).
getText
().
toString
();
String
pass
=
((
EditText
)
findViewById
(
R
.
id
.
Password_input
)).
getText
().
toString
();
String
conf
=
((
EditText
)
findViewById
(
R
.
id
.
Password_confirm
)).
getText
().
toString
();
if
(
name
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Name"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
user
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Username"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
pass
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
conf
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password (confirmation)"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
pass
.
equals
(
conf
)){
// put all stuff together for saving to magicwords.txt
File
file1
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&ADMIN"
;
//System.out.println(reassembly);
String
temp
=
""
;
try
{
Scanner
reader
=
new
Scanner
(
file1
);
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
}
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"File Error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
String
write
;
if
(
temp
.
equals
(
""
)){
write
=
reassembly
;
}
else
{
write
=
"%"
+
reassembly
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
true
);
stream
.
append
(
write
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"Admin Account Created"
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
else
{
Toast
.
makeText
(
getApplicationContext
(),
"The passwords do not match"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
}
\ No newline at end of file
app/src/main/java/com/example/summative_chris_crook/MainActivity.java
View file @
30b6f87e
...
...
@@ -167,13 +167,13 @@ public class MainActivity extends AppCompatActivity {
// load successful
if
(
tempload
.
equals
(
""
)){
// dont add a '%' to the start
tempload
+=
"adminname&adminuser&
adminpassword
&ADMIN"
;
tempload
+=
"%examplename&exampleuser&
examplepassword
&USER"
;
tempload
+=
"adminname&adminuser&
"
+
"adminpassword"
.
hashCode
()
+
"
&ADMIN"
;
tempload
+=
"%examplename&exampleuser&
"
+
"examplepassword"
.
hashCode
()
+
"
&USER"
;
}
else
{
tempload
+=
"%"
;
tempload
+=
"adminname&adminuser&
adminpassword
&ADMIN"
;
tempload
+=
"%examplename&exampleuser&
examplepassword
&USER"
;
tempload
+=
"adminname&adminuser&
"
+
"adminpassword"
.
hashCode
()
+
"
&ADMIN"
;
tempload
+=
"%examplename&exampleuser&
"
+
"examplepassword"
.
hashCode
()
+
"
&USER"
;
}
String
[]
temploadarray
=
tempload
.
split
(
"%"
);
size
=
temploadarray
.
length
;
...
...
@@ -211,6 +211,7 @@ public class MainActivity extends AppCompatActivity {
Toast
.
makeText
(
getApplicationContext
(),
"Enter a valid Password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
epass
=
epass
.
hashCode
()
+
""
;
boolean
wasthereausername
=
false
;
for
(
int
i
=
0
;
i
<
sizeoverride
;
i
++){
if
(
euser
.
equals
(
magicwords
[
i
]
[
2
])){
...
...
app/src/main/java/com/example/summative_chris_crook/register_page.java
View file @
30b6f87e
...
...
@@ -69,7 +69,7 @@ public class register_page extends AppCompatActivity {
File
file1
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
+
"&USER"
;
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER"
;
//System.out.println(reassembly);
String
temp
=
""
;
try
{
...
...
app/src/main/res/layout/activity_admin_menu.xml
View file @
30b6f87e
...
...
@@ -36,6 +36,13 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"displaythemagicwords"
android:text=
"Display magicwords.txt"
/>
android:text=
"Display all avaliable logins"
/>
<Button
android:id=
"@+id/button13"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"register2electricboogaloo"
android:text=
"Register page (admin)"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_admin_register.xml
0 → 100644
View file @
30b6f87e
<?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"
tools:context=
".AdminRegister"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/textView9"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Register user"
/>
<Button
android:id=
"@+id/button8"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"goback"
android:text=
"Back to Admin menu"
/>
<TextView
android:id=
"@+id/textView10"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Enter Name:"
/>
<EditText
android:id=
"@+id/name_input"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:inputType=
"textPersonName"
/>
<TextView
android:id=
"@+id/textView11"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Enter Username:"
/>
<EditText
android:id=
"@+id/username_input2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:inputType=
"textPersonName"
/>
<TextView
android:id=
"@+id/textView12"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Enter Password:"
/>
<EditText
android:id=
"@+id/password_input2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:inputType=
"textPassword"
/>
<TextView
android:id=
"@+id/textView13"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"Confirm Password:"
/>
<EditText
android:id=
"@+id/password_confirm"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:ems=
"10"
android:inputType=
"textPassword"
/>
<Button
android:id=
"@+id/button11"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"createuser"
android:text=
"Create User Account"
/>
<Button
android:id=
"@+id/button12"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"createadmin"
android:text=
"Create Admin Account"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
30b6f87e
...
...
@@ -50,6 +50,13 @@
android:onClick=
"navigate"
android:text=
"register"
/>
<Button
android:id=
"@+id/button10"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"ohhshiiiiii"
android:text=
"Button"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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