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
7db571c8
Commit
7db571c8
authored
Apr 08, 2021
by
chris.crook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
> login system pretty much complete
parent
445bae67
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
9 deletions
+106
-9
AdminMenu.java
...ain/java/com/example/summative_chris_crook/AdminMenu.java
+92
-0
register_page.java
...java/com/example/summative_chris_crook/register_page.java
+6
-2
activity_admin_menu.xml
app/src/main/res/layout/activity_admin_menu.xml
+8
-1
activity_main.xml
app/src/main/res/layout/activity_main.xml
+0
-6
No files found.
app/src/main/java/com/example/summative_chris_crook/AdminMenu.java
View file @
7db571c8
package
com
.
example
.
summative_chris_crook
;
package
com
.
example
.
summative_chris_crook
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
...
@@ -9,6 +11,7 @@ import android.widget.Toast;
...
@@ -9,6 +11,7 @@ import android.widget.Toast;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.FileWriter
;
import
java.util.Scanner
;
public
class
AdminMenu
extends
AppCompatActivity
{
public
class
AdminMenu
extends
AppCompatActivity
{
...
@@ -38,4 +41,93 @@ public class AdminMenu extends AppCompatActivity {
...
@@ -38,4 +41,93 @@ public class AdminMenu extends AppCompatActivity {
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
}
public
void
displaythemagicwords
(
View
view
){
File
file1
;
// all this does is read the file and display it all
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
try
{
Scanner
reader
=
new
Scanner
(
file1
);
String
temp
=
""
;
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
}
if
(
temp
.
equals
(
""
)){
// dont add a '%' to the start
temp
+=
"adminname&adminuser&adminpassword&ADMIN"
;
temp
+=
"%examplename&exampleuser&examplepassword&USER"
;
}
else
{
temp
+=
"%"
;
temp
+=
"adminname&adminuser&adminpassword&ADMIN"
;
temp
+=
"%examplename&exampleuser&examplepassword&USER"
;
}
Toast
.
makeText
(
getApplicationContext
(),
temp
,
Toast
.
LENGTH_SHORT
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
public
void
displaylogins
(
View
view
){
//
}
public
void
delall
(){
// wipe the user login folder and reset it
File
file1
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
false
);
stream
.
append
(
""
);
stream
.
close
();
Toast
.
makeText
(
getApplicationContext
(),
"User Accounts Wiped, Admin and Default accounts only"
,
Toast
.
LENGTH_SHORT
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
public
void
disall
(){
File
file1
;
// all this does is read the file and display it all
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
try
{
Scanner
reader
=
new
Scanner
(
file1
);
String
temp
=
""
;
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
}
Toast
.
makeText
(
getApplicationContext
(),
temp
,
Toast
.
LENGTH_SHORT
).
show
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
public
void
wipealldialogboxopen
(
View
view
){
AlertDialog
.
Builder
msgbox
=
new
AlertDialog
.
Builder
(
this
);
msgbox
.
setMessage
(
"This action is not reversible"
);
msgbox
.
setTitle
(
"Are you sure"
);
msgbox
.
setPositiveButton
(
"Continue"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
// delete all the data
delall
();
}
});
msgbox
.
setNegativeButton
(
"Cancel"
,
null
);
msgbox
.
setNeutralButton
(
"Display all login related data"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
// display all data
disall
();
}
});
msgbox
.
create
().
show
();
}
}
}
\ No newline at end of file
app/src/main/java/com/example/summative_chris_crook/register_page.java
View file @
7db571c8
...
@@ -50,15 +50,19 @@ public class register_page extends AppCompatActivity {
...
@@ -50,15 +50,19 @@ public class register_page extends AppCompatActivity {
String
conf
=
((
EditText
)
findViewById
(
R
.
id
.
Password_confirm
)).
getText
().
toString
();
String
conf
=
((
EditText
)
findViewById
(
R
.
id
.
Password_confirm
)).
getText
().
toString
();
if
(
name
.
equals
(
""
)){
if
(
name
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Name"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Name"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
if
(
user
.
equals
(
""
)){
if
(
user
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Username"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Username"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
if
(
pass
.
equals
(
""
)){
if
(
pass
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
if
(
conf
.
equals
(
""
)){
if
(
conf
.
equals
(
""
)){
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password (confirmation)"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Enter a Password (confirmation)"
,
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
}
if
(
pass
.
equals
(
conf
)){
if
(
pass
.
equals
(
conf
)){
// put all stuff together for saving to magicwords.txt
// put all stuff together for saving to magicwords.txt
...
@@ -79,10 +83,10 @@ public class register_page extends AppCompatActivity {
...
@@ -79,10 +83,10 @@ public class register_page extends AppCompatActivity {
}
}
String
write
;
String
write
;
if
(
temp
.
equals
(
""
)){
if
(
temp
.
equals
(
""
)){
write
=
"%"
+
reassembly
;
write
=
reassembly
;
}
}
else
{
else
{
write
=
reassembly
;
write
=
"%"
+
reassembly
;
}
}
try
{
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
true
);
FileWriter
stream
=
new
FileWriter
(
file1
,
true
);
...
...
app/src/main/res/layout/activity_admin_menu.xml
View file @
7db571c8
...
@@ -28,7 +28,14 @@
...
@@ -28,7 +28,14 @@
android:id=
"@+id/button6"
android:id=
"@+id/button6"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:onClick=
"
ohhshiiiiii
"
android:onClick=
"
wipealldialogboxopen
"
android:text=
"Wipe user login file"
/>
android:text=
"Wipe user login file"
/>
<Button
android:id=
"@+id/button9"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"displaythemagicwords"
android:text=
"Display magicwords.txt"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_main.xml
View file @
7db571c8
...
@@ -50,12 +50,6 @@
...
@@ -50,12 +50,6 @@
android:onClick=
"navigate"
android:onClick=
"navigate"
android:text=
"register"
/>
android:text=
"register"
/>
<Button
android:id=
"@+id/button8"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:onClick=
"ohhshiiiiii"
android:text=
"testing"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</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