Fixed user storage
This commit is contained in:
parent
4b78cb5f37
commit
a3aa30c6d7
|
|
@ -12,6 +12,6 @@
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</runningDeviceTargetSelectedWithDropDown>
|
</runningDeviceTargetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-03-18T14:41:30.662193Z" />
|
<timeTargetWasSelectedWithDropDown value="2023-03-18T17:23:33.549301Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -3,8 +3,6 @@ package xyz.r0r5chach.cpsAssist.login;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
import xyz.r0r5chach.cpsAssist.R;
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
|
|
||||||
|
|
@ -14,6 +12,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
findViewById(R.id.loginButton).setOnClickListener(new OnClickListener(findViewById(R.id.userNameField), findViewById(R.id.passwordField)));
|
findViewById(R.id.loginButton).setOnClickListener(new OnClickListener(findViewById(R.id.userNameField), findViewById(R.id.passwordField), getString(R.string.users)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,19 +2,12 @@ package xyz.r0r5chach.cpsAssist.login;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import xyz.r0r5chach.cpsAssist.ArrayTools;
|
import xyz.r0r5chach.cpsAssist.ArrayTools;
|
||||||
import xyz.r0r5chach.cpsAssist.home.HomeActivity;
|
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
||||||
/**
|
/**
|
||||||
* This Class defines the definition of the OnCLickListener for the LoginActivity
|
* This Class defines the definition of the OnCLickListener for the LoginActivity
|
||||||
* @author r0r5chach
|
* @author r0r5chach
|
||||||
|
|
@ -32,10 +25,6 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
* This attribute stores the View for the password field of the UI
|
* This attribute stores the View for the password field of the UI
|
||||||
*/
|
*/
|
||||||
private final EditText passwordField;
|
private final EditText passwordField;
|
||||||
/**
|
|
||||||
* This attribute stores the properties for the activity
|
|
||||||
*/
|
|
||||||
private Properties props;
|
|
||||||
/**
|
/**
|
||||||
* This attribute stores a list of users' usernames and password
|
* This attribute stores a list of users' usernames and password
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,9 +34,8 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
* @param usernameField the View for the username field of the UI
|
* @param usernameField the View for the username field of the UI
|
||||||
* @param passwordField the View for the password field of the UI
|
* @param passwordField the View for the password field of the UI
|
||||||
*/
|
*/
|
||||||
public OnClickListener(EditText usernameField, EditText passwordField) {
|
public OnClickListener(EditText usernameField, EditText passwordField, String users) {
|
||||||
loadProperties();
|
initUsers(users);
|
||||||
initUsers();
|
|
||||||
this.currentAttempts = 0;
|
this.currentAttempts = 0;
|
||||||
this.usernameField = usernameField;
|
this.usernameField = usernameField;
|
||||||
this.passwordField = passwordField;
|
this.passwordField = passwordField;
|
||||||
|
|
@ -65,7 +53,7 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUser(inputs)) {
|
if (isUser(inputs)) {
|
||||||
Intent home = new Intent(view.getContext(), HomeActivity.class);
|
Intent home = new Intent(view.getContext(), NotesActivity.class);
|
||||||
home.putExtra("username", inputs[0]);
|
home.putExtra("username", inputs[0]);
|
||||||
view.getContext().startActivity(home);
|
view.getContext().startActivity(home);
|
||||||
((Activity)view.getContext()).finish();
|
((Activity)view.getContext()).finish();
|
||||||
|
|
@ -75,25 +63,11 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
Toast.makeText(view.getContext(), "Incorrect Username/Password!", Toast.LENGTH_LONG).show();
|
Toast.makeText(view.getContext(), "Incorrect Username/Password!", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This method loads the properties for the activity from resources
|
|
||||||
*/
|
|
||||||
private void loadProperties() {
|
|
||||||
props = new Properties();
|
|
||||||
try {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
props.loadFromXML(Files.newInputStream(Paths.get(Objects.requireNonNull(LoginActivity.class.getResource("values/properties_login.xml")).getPath())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* This method initializes the users array from the activity properties
|
* This method initializes the users array from the activity properties
|
||||||
*/
|
*/
|
||||||
private void initUsers() {
|
private void initUsers(String usersString) {
|
||||||
String[] users = props.getProperty("users").split("%");
|
String[] users = usersString.split("%");
|
||||||
this.users = new String[users.length][2];
|
this.users = new String[users.length][2];
|
||||||
for (int i = 0; i < users.length; i++) {
|
for (int i = 0; i < users.length; i++) {
|
||||||
String[] details = users[i].split("#");
|
String[] details = users[i].split("#");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
|
||||||
<properties>
|
|
||||||
<entry key="users">josh#pass%kofi#pass%jaiwin#pass</entry>
|
|
||||||
</properties>
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
<string name="usernameFieldHint">Username</string>
|
<string name="usernameFieldHint">Username</string>
|
||||||
<string name="passwordFieldHint">Password</string>
|
<string name="passwordFieldHint">Password</string>
|
||||||
<string name="loginButtonText">Login</string>
|
<string name="loginButtonText">Login</string>
|
||||||
|
<string name="users">josh#pass%kofi#pass%jaiwin#pass</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue