Commit 6fe99650 authored by chris.crook's avatar chris.crook

> smaller boi

parent 19f077f9
......@@ -14,6 +14,8 @@ import java.util.Scanner;
public class AdminRegister extends AppCompatActivity {
int sizeoverride = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -25,8 +27,64 @@ public class AdminRegister extends AppCompatActivity {
startActivity(intent);
}
public String openandload(){
File file1;
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_LONG).show();
return temp;
} catch(Exception e){
Toast.makeText(getApplicationContext(), "read error", Toast.LENGTH_LONG).show();
return "&&&";
}
}
public void createuser (View view){
//
String [] [] magicwords = new String [sizeoverride] [7];
File file1;
String filename1 = "magicwords";
String tempload = openandload();
if (tempload.equals("&&&")){
// this means that the load failed
}
else {
// load successful
if (tempload.equals("")) {
// dont add a '%' to the start
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
} else {
tempload += "%";
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
}
String[] temploadarray = tempload.split("%");
int 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]; // name of user
magicwords[i][2] = sort[1]; // username
magicwords[i][3] = sort[2]; // password
magicwords[i][4] = sort[3]; // admin flag
magicwords[i][5] = sort[4]; // currency mode
magicwords[i][6] = sort[5]; // language
}
}
String name = ((EditText) findViewById(R.id.name_input2)).getText().toString();
String user = ((EditText) findViewById(R.id.username_input2)).getText().toString();
String pass = ((EditText) findViewById(R.id.password_input2)).getText().toString();
......@@ -47,10 +105,16 @@ public class AdminRegister extends AppCompatActivity {
Toast.makeText(getApplicationContext(), "Enter a Password (confirmation)", Toast.LENGTH_SHORT).show();
return;
}
for (int q = 0; q<sizeoverride; q++){
if(user.equals(magicwords[q] [2])){
Toast.makeText(getApplicationContext(), "Username already exists", Toast.LENGTH_SHORT).show();
return;
}
}
String curr = ((EditText) findViewById(R.id.CurrencyStore)).getText().toString();
String lang = ((EditText) findViewById(R.id.LangStore)).getText().toString();
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&£&ENG";
//System.out.println(reassembly);
......@@ -90,6 +154,42 @@ public class AdminRegister extends AppCompatActivity {
public void createadmin (View view){
//
String [] [] magicwords = new String [sizeoverride] [7];
File file1;
String filename1 = "magicwords";
String tempload = openandload();
if (tempload.equals("&&&")){
// this means that the load failed
}
else {
// load successful
if (tempload.equals("")) {
// dont add a '%' to the start
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
} else {
tempload += "%";
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
}
String[] temploadarray = tempload.split("%");
int 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]; // name of user
magicwords[i][2] = sort[1]; // username
magicwords[i][3] = sort[2]; // password
magicwords[i][4] = sort[3]; // admin flag
magicwords[i][5] = sort[4]; // currency mode
magicwords[i][6] = sort[5]; // language
}
}
String name = ((EditText) findViewById(R.id.name_input2)).getText().toString();
String user = ((EditText) findViewById(R.id.username_input2)).getText().toString();
String pass = ((EditText) findViewById(R.id.password_input2)).getText().toString();
......@@ -110,10 +210,16 @@ public class AdminRegister extends AppCompatActivity {
Toast.makeText(getApplicationContext(), "Enter a Password (confirmation)", Toast.LENGTH_SHORT).show();
return;
}
for (int q = 0; q<sizeoverride; q++){
if(user.equals(magicwords[q] [2])){
Toast.makeText(getApplicationContext(), "Username already exists", Toast.LENGTH_SHORT).show();
return;
}
}
String curr = ((EditText) findViewById(R.id.CurrencyStore)).getText().toString();
String lang = ((EditText) findViewById(R.id.LangStore)).getText().toString();
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&£&ENG";
//System.out.println(reassembly);
......@@ -150,4 +256,36 @@ public class AdminRegister extends AppCompatActivity {
return;
}
}
public void seteng (View view){
((EditText)findViewById(R.id.WOAH)).setText("ENG");
}
public void setfr (View view){
((EditText)findViewById(R.id.WOAH)).setText("FRA");
}
public void setesp (View view){
((EditText)findViewById(R.id.WOAH)).setText("ESP");
}
public void setde (View view){
((EditText)findViewById(R.id.WOAH)).setText("DEU");
}
public void setGBP (View view){
((EditText)findViewById(R.id.currencyStore)).setText("£");
}
public void setEUR(View view){
((EditText)findViewById(R.id.currencyStore)).setText("€");
}
public void setUSD (View view){
((EditText)findViewById(R.id.currencyStore)).setText("US$");
}
public void setHKD (View view){
((EditText)findViewById(R.id.currencyStore)).setText("HK$");
}
}
\ No newline at end of file
......@@ -14,6 +14,8 @@ import java.util.Scanner;
public class register_page extends AppCompatActivity {
int sizeoverride = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -42,8 +44,66 @@ public class register_page extends AppCompatActivity {
// }
// }
public String openandload(){
File file1;
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_LONG).show();
return temp;
} catch(Exception e){
Toast.makeText(getApplicationContext(), "read error", Toast.LENGTH_LONG).show();
return "&&&";
}
}
public void createuser (View view){
//
String [] [] magicwords = new String [sizeoverride] [7];
File file1;
String filename1 = "magicwords";
file1 = new File(getApplicationContext().getFilesDir(), filename1 + ".txt");
String tempload = openandload();
if (tempload.equals("&&&")){
// this means that the load failed
}
else {
// load successful
if (tempload.equals("")) {
// dont add a '%' to the start
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
} else {
tempload += "%";
tempload += "adminname&adminuser&" + "adminpassword".hashCode() + "&ADMIN&£&ENG";
tempload += "%examplename&exampleuser&" + "examplepassword".hashCode() + "&USER&£&ENG";
tempload += "%frenchperson&france&" + "pass".hashCode() + "&USER&€&FRA";
}
String[] temploadarray = tempload.split("%");
int 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]; // name of user
magicwords[i][2] = sort[1]; // username
magicwords[i][3] = sort[2]; // password
magicwords[i][4] = sort[3]; // admin flag
magicwords[i][5] = sort[4]; // currency mode
magicwords[i][6] = sort[5]; // language
}
}
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();
......@@ -64,12 +124,18 @@ public class register_page extends AppCompatActivity {
Toast.makeText(getApplicationContext(), "Enter a Password (confirmation)", Toast.LENGTH_SHORT).show();
return;
}
for (int q = 0; q<sizeoverride; q++){
if(user.equals(magicwords[q] [2])){
Toast.makeText(getApplicationContext(), "Username already exists", Toast.LENGTH_SHORT).show();
return;
}
}
String curr = ((EditText) findViewById(R.id.CurrencyStore)).getText().toString();
String lang = ((EditText) findViewById(R.id.LangStore)).getText().toString();
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&£&ENG";
String reassembly = name + "&" + user + "&" + pass.hashCode() + "&USER&" + curr + "&" + lang;
//System.out.println(reassembly);
String temp = "";
try{
......@@ -104,4 +170,38 @@ public class register_page extends AppCompatActivity {
return;
}
}
public void seteng (View view){
((EditText)findViewById(R.id.LangStore)).setText("ENG");
}
public void setfr (View view){
((EditText)findViewById(R.id.LangStore)).setText("FRA");
}
public void setesp (View view){
((EditText)findViewById(R.id.LangStore)).setText("ESP");
}
public void setde (View view){
((EditText)findViewById(R.id.LangStore)).setText("DEU");
}
public void setGBP (View view){
((EditText)findViewById(R.id.CurrencyStore)).setText("£");
}
public void setEUR(View view){
((EditText)findViewById(R.id.CurrencyStore)).setText("€");
}
public void setUSD (View view){
((EditText)findViewById(R.id.CurrencyStore)).setText("US$");
}
public void setHKD (View view){
((EditText)findViewById(R.id.CurrencyStore)).setText("HK$");
}
}
\ No newline at end of file
......@@ -76,6 +76,111 @@
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView27"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Default Language" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button73"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="seteng"
android:text="ENG" />
<Button
android:id="@+id/button74"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setfr"
android:text="FR" />
<Button
android:id="@+id/button75"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setesp"
android:text="ESP" />
<Button
android:id="@+id/button76"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setde"
android:text="DE" />
</LinearLayout>
<TextView
android:id="@+id/textView28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Default Currency" />
<EditText
android:id="@+id/WOAH"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="ENG" />
<EditText
android:id="@+id/currencyStore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="£" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="222dp"
android:orientation="horizontal">
<Button
android:id="@+id/button77"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setGBP"
android:text="GBP (£)" />
<Button
android:id="@+id/button78"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setEUR"
android:text="Euro (€)" />
<Button
android:id="@+id/button79"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setUSD"
android:text="USD ($)" />
<Button
android:id="@+id/button80"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setHKD"
android:text="HKD ($)" />
</LinearLayout>
<Button
android:id="@+id/button11"
android:layout_width="match_parent"
......
......@@ -76,6 +76,110 @@
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textView25"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Default account language" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button65"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="seteng"
android:text="ENG" />
<Button
android:id="@+id/button66"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setfr"
android:text="FR" />
<Button
android:id="@+id/button67"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setesp"
android:text="ESP" />
<Button
android:id="@+id/button68"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setde"
android:text="DE" />
</LinearLayout>
<TextView
android:id="@+id/textView26"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Default Currency" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/button69"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setGBP"
android:text="GBP (£)" />
<Button
android:id="@+id/button70"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setEUR"
android:text="Euro (€)" />
<Button
android:id="@+id/button71"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setUSD"
android:text="USD ($)" />
<Button
android:id="@+id/button72"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="setHKD"
android:text="HKD ($)" />
</LinearLayout>
<EditText
android:id="@+id/LangStore"
android:layout_width="match_parent"
android:layout_height="0px"
android:ems="10"
android:inputType="textPersonName"
android:text="ENG" />
<EditText
android:id="@+id/CurrencyStore"
android:layout_width="match_parent"
android:layout_height="0px"
android:ems="10"
android:inputType="textPersonName"
android:text="£" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
......
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