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
f0bd4ef9
Commit
f0bd4ef9
authored
Apr 09, 2021
by
chris.crook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
> pass user preferences
parent
c2ac6dc3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
45 deletions
+68
-45
AdminMenu.java
...ain/java/com/example/summative_chris_crook/AdminMenu.java
+7
-4
AdminRegister.java
...java/com/example/summative_chris_crook/AdminRegister.java
+2
-2
MainActivity.java
.../java/com/example/summative_chris_crook/MainActivity.java
+41
-21
register_page.java
...java/com/example/summative_chris_crook/register_page.java
+17
-17
activity_admin_menu.xml
app/src/main/res/layout/activity_admin_menu.xml
+1
-1
No files found.
app/src/main/java/com/example/summative_chris_crook/AdminMenu.java
View file @
f0bd4ef9
...
@@ -60,13 +60,13 @@ public class AdminMenu extends AppCompatActivity {
...
@@ -60,13 +60,13 @@ public class AdminMenu extends AppCompatActivity {
}
}
if
(
temp
.
equals
(
""
)){
if
(
temp
.
equals
(
""
)){
// dont add a '%' to the start
// dont add a '%' to the start
temp
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN"
;
temp
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN
&£&ENG
"
;
temp
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER"
;
temp
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER
&£&ENG
"
;
}
}
else
{
else
{
temp
+=
"%"
;
temp
+=
"%"
;
temp
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN"
;
temp
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN
&£&ENG
"
;
temp
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER"
;
temp
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER
&£&ENG
"
;
}
}
//Toast.makeText(getApplicationContext(), temp, Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(), temp, Toast.LENGTH_SHORT).show();
AlertDialog
.
Builder
dataall
=
new
AlertDialog
.
Builder
(
AdminMenu
.
this
);
AlertDialog
.
Builder
dataall
=
new
AlertDialog
.
Builder
(
AdminMenu
.
this
);
...
@@ -144,6 +144,9 @@ public class AdminMenu extends AppCompatActivity {
...
@@ -144,6 +144,9 @@ public class AdminMenu extends AppCompatActivity {
while
(
reader
.
hasNextLine
()){
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
temp
=
temp
+
reader
.
nextLine
();
}
}
if
(
temp
.
equals
(
""
)){
temp
=
"No user data"
;
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
...
app/src/main/java/com/example/summative_chris_crook/AdminRegister.java
View file @
f0bd4ef9
...
@@ -52,7 +52,7 @@ public class AdminRegister extends AppCompatActivity {
...
@@ -52,7 +52,7 @@ public class AdminRegister extends AppCompatActivity {
File
file1
;
File
file1
;
String
filename1
=
"magicwords"
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER"
;
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER
&£&ENG
"
;
//System.out.println(reassembly);
//System.out.println(reassembly);
String
temp
=
""
;
String
temp
=
""
;
try
{
try
{
...
@@ -115,7 +115,7 @@ public class AdminRegister extends AppCompatActivity {
...
@@ -115,7 +115,7 @@ public class AdminRegister extends AppCompatActivity {
File
file1
;
File
file1
;
String
filename1
=
"magicwords"
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&ADMIN"
;
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&ADMIN
&£&ENG
"
;
//System.out.println(reassembly);
//System.out.println(reassembly);
String
temp
=
""
;
String
temp
=
""
;
try
{
try
{
...
...
app/src/main/java/com/example/summative_chris_crook/MainActivity.java
View file @
f0bd4ef9
...
@@ -22,7 +22,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -22,7 +22,7 @@ public class MainActivity extends AppCompatActivity {
// generic variables and stuff
// generic variables and stuff
int
sizeoverride
=
1000
;
int
sizeoverride
=
1000
;
String
tempload
=
""
;
String
tempload
=
""
;
String
[]
[]
magicwords
=
new
String
[
sizeoverride
]
[
5
];
// storage of the login info
String
[]
[]
magicwords
=
new
String
[
sizeoverride
]
[
7
];
// storage of the login info
int
size
=
0
;
int
size
=
0
;
boolean
tempbool
=
true
;
boolean
tempbool
=
true
;
int
tempint
=
0
;
int
tempint
=
0
;
...
@@ -116,16 +116,16 @@ public class MainActivity extends AppCompatActivity {
...
@@ -116,16 +116,16 @@ public class MainActivity extends AppCompatActivity {
startActivity
(
intent
);
startActivity
(
intent
);
}
}
public
void
saveandclose
(){
//
public void saveandclose(){
try
{
//
try{
FileWriter
stream
=
new
FileWriter
(
file1
,
false
);
//
FileWriter stream = new FileWriter(file1, false);
stream
.
write
(
" "
);
//
stream.write(" ");
stream
.
close
();
//
stream.close();
//
}
catch
(
Exception
e
){
//
} catch(Exception e){
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_LONG
).
show
();
//
Toast.makeText(getApplicationContext(), "write error", Toast.LENGTH_LONG).show();
}
//
}
}
//
}
/*public void openpage(View view,String destination){
/*public void openpage(View view,String destination){
destination += ".class";
destination += ".class";
...
@@ -167,13 +167,13 @@ public class MainActivity extends AppCompatActivity {
...
@@ -167,13 +167,13 @@ public class MainActivity extends AppCompatActivity {
// load successful
// load successful
if
(
tempload
.
equals
(
""
)){
if
(
tempload
.
equals
(
""
)){
// dont add a '%' to the start
// dont add a '%' to the start
tempload
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN"
;
tempload
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN
&£&ENG
"
;
tempload
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER"
;
tempload
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER
&£&ENG
"
;
}
}
else
{
else
{
tempload
+=
"%"
;
tempload
+=
"%"
;
tempload
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN"
;
tempload
+=
"adminname&adminuser&"
+
"adminpassword"
.
hashCode
()
+
"&ADMIN
&£&ENG
"
;
tempload
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER"
;
tempload
+=
"%examplename&exampleuser&"
+
"examplepassword"
.
hashCode
()
+
"&USER
&£&ENG
"
;
}
}
String
[]
temploadarray
=
tempload
.
split
(
"%"
);
String
[]
temploadarray
=
tempload
.
split
(
"%"
);
size
=
temploadarray
.
length
;
size
=
temploadarray
.
length
;
...
@@ -182,10 +182,12 @@ public class MainActivity extends AppCompatActivity {
...
@@ -182,10 +182,12 @@ public class MainActivity extends AppCompatActivity {
}
}
for
(
int
i
=
0
;
i
<
size
;
i
++){
for
(
int
i
=
0
;
i
<
size
;
i
++){
String
[]
sort
=
temploadarray
[
i
].
split
(
"&"
);
String
[]
sort
=
temploadarray
[
i
].
split
(
"&"
);
magicwords
[
i
]
[
1
]
=
sort
[
0
];
magicwords
[
i
]
[
1
]
=
sort
[
0
];
// name of user
magicwords
[
i
]
[
2
]
=
sort
[
1
];
magicwords
[
i
]
[
2
]
=
sort
[
1
];
// username
magicwords
[
i
]
[
3
]
=
sort
[
2
];
magicwords
[
i
]
[
3
]
=
sort
[
2
];
// password
magicwords
[
i
]
[
4
]
=
sort
[
3
];
magicwords
[
i
]
[
4
]
=
sort
[
3
];
// admin flag
magicwords
[
i
]
[
5
]
=
sort
[
4
];
// currency mode
magicwords
[
i
]
[
6
]
=
sort
[
5
];
// language
}
}
for
(
int
i
=
0
;
i
<
sizeoverride
;
i
++){
for
(
int
i
=
0
;
i
<
sizeoverride
;
i
++){
if
(
magicwords
[
i
]
[
0
].
equals
(
"END"
)){
if
(
magicwords
[
i
]
[
0
].
equals
(
"END"
)){
...
@@ -220,13 +222,31 @@ public class MainActivity extends AppCompatActivity {
...
@@ -220,13 +222,31 @@ public class MainActivity extends AppCompatActivity {
// login is verified
// login is verified
if
(
magicwords
[
i
]
[
4
].
equals
(
"ADMIN"
)){
if
(
magicwords
[
i
]
[
4
].
equals
(
"ADMIN"
)){
// user is an admin
// user is an admin
Toast
.
makeText
(
getApplicationContext
(),
"Signed in as admin"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Signed in as "
+
magicwords
[
i
]
[
1
]
+
" (admin)"
,
Toast
.
LENGTH_SHORT
).
show
();
String
writetotemp
=
magicwords
[
i
]
[
1
]
+
"&"
+
magicwords
[
i
]
[
4
]
+
"&"
+
magicwords
[
i
]
[
5
];
Toast
.
makeText
(
getApplicationContext
(),
"Admin preferences loaded: "
+
writetotemp
,
Toast
.
LENGTH_SHORT
).
show
();
try
{
FileWriter
stream
=
new
FileWriter
(
file2
,
false
);
stream
.
append
(
writetotemp
);
stream
.
close
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
Intent
intent
=
new
Intent
(
this
,
AdminMenu
.
class
);
Intent
intent
=
new
Intent
(
this
,
AdminMenu
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
return
;
return
;
}
}
else
{
else
{
Toast
.
makeText
(
getApplicationContext
(),
"Signed in as user"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"Signed in as "
+
magicwords
[
i
]
[
1
],
Toast
.
LENGTH_SHORT
).
show
();
String
writetotemp
=
magicwords
[
i
]
[
1
]
+
"&"
+
magicwords
[
i
]
[
4
]
+
"&"
+
magicwords
[
i
]
[
5
];
Toast
.
makeText
(
getApplicationContext
(),
"User preferences loaded: "
+
writetotemp
,
Toast
.
LENGTH_SHORT
).
show
();
try
{
FileWriter
stream
=
new
FileWriter
(
file2
,
false
);
stream
.
append
(
writetotemp
);
stream
.
close
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"Internal File Error"
,
Toast
.
LENGTH_LONG
).
show
();
}
Intent
intent
=
new
Intent
(
this
,
UserMenu
.
class
);
Intent
intent
=
new
Intent
(
this
,
UserMenu
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
return
;
return
;
...
...
app/src/main/java/com/example/summative_chris_crook/register_page.java
View file @
f0bd4ef9
...
@@ -25,22 +25,22 @@ public class register_page extends AppCompatActivity {
...
@@ -25,22 +25,22 @@ public class register_page extends AppCompatActivity {
startActivity
(
intent
);
startActivity
(
intent
);
}
}
public
void
createadmin
(
View
view
){
//
public void createadmin (View view){
//
//
//
String
name
=
((
EditText
)
findViewById
(
R
.
id
.
Name_input
)).
getText
().
toString
();
//
String name = ((EditText) findViewById(R.id.Name_input)).getText().toString();
String
user
=
((
EditText
)
findViewById
(
R
.
id
.
Username_input
)).
getText
().
toString
();
//
String user = ((EditText) findViewById(R.id.Username_input)).getText().toString();
String
pass
=
((
EditText
)
findViewById
(
R
.
id
.
Password_input
)).
getText
().
toString
();
//
String pass = ((EditText) findViewById(R.id.Password_input)).getText().toString();
String
conf
=
((
EditText
)
findViewById
(
R
.
id
.
Password_confirm
)).
getText
().
toString
();
//
String conf = ((EditText) findViewById(R.id.Password_confirm)).getText().toString();
if
(
pass
.
equals
(
conf
)){
//
if (pass.equals(conf)){
//
//
//
String
reassembly
=
"#"
+
name
+
"%"
+
user
+
"%"
+
pass
+
"%USER"
;
//
String reassembly = "#" + name + "%" + user + "%" + pass + "%USER";
System
.
out
.
println
(
reassembly
);
//
System.out.println(reassembly);
}
//
}
else
{
//
else{
Toast
.
makeText
(
getApplicationContext
(),
"The passwords do not match"
,
Toast
.
LENGTH_SHORT
).
show
();
//
Toast.makeText(getApplicationContext(), "The passwords do not match", Toast.LENGTH_SHORT).show();
return
;
//
return;
}
//
}
}
//
}
public
void
createuser
(
View
view
){
public
void
createuser
(
View
view
){
//
//
...
@@ -69,7 +69,7 @@ public class register_page extends AppCompatActivity {
...
@@ -69,7 +69,7 @@ public class register_page extends AppCompatActivity {
File
file1
;
File
file1
;
String
filename1
=
"magicwords"
;
String
filename1
=
"magicwords"
;
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER"
;
String
reassembly
=
name
+
"&"
+
user
+
"&"
+
pass
.
hashCode
()
+
"&USER
&£&ENG
"
;
//System.out.println(reassembly);
//System.out.println(reassembly);
String
temp
=
""
;
String
temp
=
""
;
try
{
try
{
...
...
app/src/main/res/layout/activity_admin_menu.xml
View file @
f0bd4ef9
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:onClick=
"wipealldialogboxopen"
android:onClick=
"wipealldialogboxopen"
android:text=
"
Wipe user login file
"
/>
android:text=
"
Reset App
"
/>
<Button
<Button
android:id=
"@+id/button9"
android:id=
"@+id/button9"
...
...
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