Commit 80b671f6 authored by chris.crook's avatar chris.crook

> added load on login button

parent a4be48af
......@@ -120,5 +120,70 @@ public class MainActivity extends AppCompatActivity {
}
}
public void testlogin (View view){
file1 = new File(getApplicationContext().getFilesDir(), filename1 + ".txt");
file2 = new File(getApplicationContext().getFilesDir(), filename2 + ".txt");
for (int i = 0; i < sizeoverride; i ++){
magicwords [i] [0] = "END";
}
try{
FileWriter stream = new FileWriter(file1, true);
stream.append(""); //opens and test-loads an append
stream.close();
} catch(Exception e){
Toast.makeText(getApplicationContext(), "write error", Toast.LENGTH_SHORT).show();
}
try{
Scanner reader = new Scanner(file1);
String temp = "";
while (reader.hasNextLine()){
temp = temp + reader.nextLine();
}
} catch(Exception e){
Toast.makeText(getApplicationContext(), "read error", Toast.LENGTH_SHORT).show();
}
tempload = openandload();
if (tempload.equals("&&&")){
// this means that the load failed
}
else{
// load successful
if (tempload.equals("")){
// dont add a '#' to the start
}
else{
tempload += "#";
}
tempload += "adminname&adminuser&adminpassword&ADMIN";
String [] temploadarray = tempload.split("%");
size = temploadarray.length;
for (int i = 0; i < size; i++){
magicwords [i] [0] = temploadarray [i]; // splits by user
}
for (int i = 0; i < size; i++){
String [] sort = temploadarray [i].split("&");
magicwords [i] [1] = sort [0];
magicwords [i] [2] = sort [1];
magicwords [i] [3] = sort [2];
magicwords [i] [4] = sort [3];
}
for (int i = 0; i < sizeoverride; i++){
if (magicwords [i] [0].equals("END")){
// end marker found
tempint = i;
break;
}
System.out.println(size + "");
System.out.println(tempint + "");
}
System.out.println(tempint);
System.out.println("RAW DATA: " + magicwords [0] [0] + " NAME: " + magicwords [0] [1] + " USERNAME: " + magicwords [0] [2] + " PASSWORD: " + magicwords [0] [3] + " ADMIN FLAG: " + magicwords [0] [4]);
}
}
//
}
\ No newline at end of file
......@@ -40,6 +40,7 @@
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="testlogin"
android:text="Log In" />
<Button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment