LoginActivity

public class LoginActivity extends RedirectableAppCompatActivity

Login screen that lets a user either sign in with email and password or create a new account

Fields

confirmPassword

EditText confirmPassword

Reference to the text field for password confirmation

firstNameText

EditText firstNameText

Reference to the text field for the user’s first name

lastNameText

EditText lastNameText

Reference to the text field for the user’s last name

needAccountText

TextView needAccountText

Text field the user can click to toggle between creating an account and signing in

passwordText

EditText passwordText

Reference to the text field for the user’s password

usernameText

EditText usernameText

Reference to the text field for the user’s username

Methods

isLoggedIn

public static boolean isLoggedIn(SharedPreferences settings)

Check whether any user is currently signed in

Parameters:
  • settings – The app’s shared settings, which store user preferences
Returns:

true if a user is signed in, false otherwise

onCreate

protected void onCreate(Bundle savedInstanceState)

Create the user interface from 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.

Parameters:

setLoggedIn

public static void setLoggedIn(SharedPreferences settings, long userID, 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. No logged-in user is signalled by a missing SharedPreferences entry.

Parameters:
  • settings – The SharedPreferences storing user login state
  • userID – ID of the user to make logged-in

setLoggedOut

public static void setLoggedOut(SharedPreferences settings)

Logout the currently logged-out user. If no user is logged in, nothing happens

Parameters:
  • settings – The app’s shared settings, which store user preferences