public class LoginActivity extends RedirectableAppCompatActivity
Modifier and Type | Field and Description |
---|---|
(package private) android.widget.EditText |
confirmPassword
Reference to the text field for password confirmation
|
(package private) android.widget.EditText |
firstNameText
Reference to the text field for the user's first name
|
(package private) android.widget.EditText |
lastNameText
Reference to the text field for the user's last name
|
(package private) android.widget.TextView |
needAccountText
Text field the user can click to toggle between creating an account and signing in
|
(package private) android.widget.EditText |
passwordText
Reference to the text field for the user's password
|
private RequestQueue |
queue
Queue for asynchronous tasks
|
private boolean |
signInToggle
Whether the user is signing in or creating an account (
true if signing in) |
(package private) android.widget.EditText |
usernameText
Reference to the text field for the user's username
|
Constructor and Description |
---|
LoginActivity() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isLoggedIn(android.content.SharedPreferences settings)
Check whether any user is currently signed in
|
private void |
login(RequestQueue queue,
java.lang.String email,
java.lang.String password)
Helper method that logs the user in using the provided credentials
|
protected void |
onCreate(android.os.Bundle savedInstanceState)
Create the user interface from
R.layout#activity_login . |
static void |
setLoggedIn(android.content.SharedPreferences settings,
long userID,
java.lang.String email)
Largely for testing, this public method can be used to set which user is currently logged in
This is useful for PickOnboardingStatusActivity because different login states correspond
to different users.
|
static void |
setLoggedOut(android.content.SharedPreferences settings)
Logout the currently logged-out user.
|
onDestroy
private boolean signInToggle
true
if signing in)android.widget.EditText firstNameText
android.widget.EditText lastNameText
android.widget.EditText confirmPassword
android.widget.EditText passwordText
android.widget.EditText usernameText
android.widget.TextView needAccountText
private RequestQueue queue
public static void setLoggedIn(android.content.SharedPreferences settings, long userID, java.lang.String email)
settings
- The SharedPreferences storing user login stateuserID
- ID of the user to make logged-inpublic static boolean isLoggedIn(android.content.SharedPreferences settings)
settings
- The app's shared settings, which store user preferencestrue
if a user is signed in, false
otherwisepublic static void setLoggedOut(android.content.SharedPreferences settings)
settings
- The app's shared settings, which store user preferencesprivate void login(RequestQueue queue, java.lang.String email, java.lang.String password)
queue
- Queue to which the asynchronous task will be addedemail
- User's account email addresspassword
- User's passwordprotected void onCreate(android.os.Bundle savedInstanceState)
R.layout#activity_login
. Also setup buttons to perform
the associated actions, including log-ins with
API.Get#loginWithCred(RequestQueue, String, String, SharedPreferences,
Response.Listener)
and account creation with
API.Post#user(RequestQueue, User, String, String, Response.Listener)
. Also sets up
the animations to convert between signing in and creating an account.savedInstanceState
-