Android Open Source - GroupGoal Sign Up Activity

From Project

Back to project page GroupGoal.


The source code is released under:

GNU General Public License

If you think the Android project GroupGoal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cs121.groupgoal;
  /*  w  w w .  j  a  v  a 2s.  c  o  m*/
  import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
  import com.cs121.groupgoal.R;
import com.parse.ParseACL;
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
   * Activity which displays a sign up screen to the user.
  public class SignUpActivity extends Activity {

    private EditText firstNameEditText;
    private EditText lastNameEditText;
    private EditText usernameEditText;
    private EditText passwordEditText;
    private EditText passwordAgainEditText;
    protected void onCreate(Bundle savedInstanceState) {
      // Sets up the signup form.
      firstNameEditText = (EditText) findViewById(;
      lastNameEditText = (EditText) findViewById(;
      usernameEditText = (EditText) findViewById(;
      passwordEditText = (EditText) findViewById(;
      passwordAgainEditText = (EditText) findViewById(;
      passwordAgainEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          if (actionId == ||
              actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
            return true;
          return false;
      Button mActionButton = (Button) findViewById(;
      mActionButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
    private void signup() {
    String userFirstName = capitalize(firstNameEditText.getText().toString().trim());
    String userLastName = capitalize(lastNameEditText.getText().toString().trim());
    String userfullname = userFirstName + "^" + userLastName;
      String username = usernameEditText.getText().toString().trim();
      String password = passwordEditText.getText().toString().trim();
      String passwordAgain = passwordAgainEditText.getText().toString().trim();
      // Validate the sign up data
      boolean validationError = false;
      StringBuilder validationErrorMessage = new StringBuilder(getString(R.string.error_intro));
      if (username.length() == 0) {
        validationError = true;
      if (userfullname.length() < 2) {
          validationError = true;
      if (password.length() == 0) {
        if (validationError) {
        validationError = true;
      if (!password.equals(passwordAgain)) {
        if (validationError) {
        validationError = true;
      // If there is a validation error, display the error
      if (validationError) {
        Toast.makeText(SignUpActivity.this, validationErrorMessage.toString(), Toast.LENGTH_LONG)
      // Set up a progress dialog
      final ProgressDialog dialog = new ProgressDialog(SignUpActivity.this);
      // Set up a new Parse user
      ParseUser user = new ParseUser(); //creates a new Parse User
      user.put("fullName", userfullname); //save the fullname entered by the user, as well as the username and password
      String message = "Edit Your Personal Message Here";
      user.put("userDescription", message);
      List<String> emptyList = new ArrayList<String>(); 
      user.put("friendsList", emptyList); //stores more user attributes into parse
      user.put("myGoals",  emptyList);
      user.put("createdGoals",  emptyList);
      user.put("invitedGoals", emptyList);
      // Call the Parse signup method
      user.signUpInBackground(new SignUpCallback() {
        public void done(ParseException e) {
          if (e != null) {
            // Show the error message
            Toast.makeText(SignUpActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
          } else {
            // Start an intent for the dispatch activity
            Intent intent = new Intent(SignUpActivity.this, MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  public static String capitalize(String name) {
      name = name.toLowerCase();
      if(name.length() > 1) {
        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
      } else {
        return name.toUpperCase();
    public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == {
        return true;
      return super.onOptionsItemSelected(item);

Java Source Code List