-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSignupActivity.java
More file actions
59 lines (50 loc) · 1.76 KB
/
SignupActivity.java
File metadata and controls
59 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//Henry Garkanian
//CST 338
//2 December 2023
//Project 2 Android Translator
package com.example.androidtranslator;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class SignupActivity extends AppCompatActivity {
Button signUpButton, cancel;
EditText username, password, password2;
boolean allFieldsChecked = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
username = findViewById(R.id.editText);
password = findViewById(R.id.editText2);
password2 = findViewById(R.id.editText3);
cancel = findViewById(R.id.button2);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent returnTo = new Intent(SignupActivity.this, LoginActivity.class);
startActivity(returnTo);
}
});
}
private boolean CheckAllFields() {
if (username.length() == 0) {
username.setError("This field is required");
return false;
}
if (password != password2) {
password.setError("Passwords must match");
password2.setError("Passwords must match");
}
if (password.length() == 0) {
password.setError("Password is required");
return false;
} else if (password.length() < 5) {
password.setError("Password must be minimum 5 characters");
return false;
}
return true; //after all fields are checked
}
}