@Override
    protected Boolean doInBackground(Void... params) {

      SmartTrailApplication app = (SmartTrailApplication) getApplication();

      try {

        mEmail = mEmailEditText.getText().toString().toLowerCase();
        mPassword = mPasswordEditText.getText().toString();
        String nickname = mNicknameEditText.getText().toString().toLowerCase();

        app.getApi().signup(nickname, mEmail, mPassword);

        app.signin(mEmail, mPassword);

        return true;

      } catch (Exception e) {
        AppLog.d(CLASSTAG, "Caught Exception signing up user.", e);
        mReason = e;

        return false;
      }
    }
  private void setupUi() {
    //		Toast toast = Toast.makeText(this, "We're working out the bugs, so signup is invite
    // only.",Toast.LENGTH_LONG );
    //		toast.setGravity(Gravity.CENTER, 0, 0);
    //		toast.show();
    SmartTrailApplication app = (SmartTrailApplication) getApplication();
    TextView alreadyMember = (TextView) findViewById(R.id.notMember);
    alreadyMember.setText(R.string.alreadyMember);

    Button signInButton = (Button) findViewById(R.id.signUp);
    signInButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(SignupActivity.this, SigninActivity.class));

            SignupActivity.this.finish();
          }
        });
    signInButton.setText(R.string.signInLink);
    signInButton.setTypeface(app.mTf);

    TextView alreadyAMemberTextView = ((TextView) findViewById(R.id.notMember));
    alreadyAMemberTextView.setTypeface(app.mTf);

    mEmailEditText = ((EditText) findViewById(R.id.username));
    mEmailEditText.setTypeface(app.mTf);
    mNicknameEditText = ((EditText) findViewById(R.id.nickname));
    mNicknameEditText.setTypeface(app.mTf);
    mPasswordEditText = ((EditText) findViewById(R.id.password));
    mPasswordEditText.setTypeface(app.mTf);

    CharSequence username = app.getUsername();
    if (username != null) {

      if (username.toString().contains("@")) {
        mEmailEditText.setText(username);
      } else {
        mNicknameEditText.setText(username);
      }
    }

    mPasswordEditText.setText(app.getPassword());
    mPasswordEditText.setHint(R.string.createPasswordHint);
    if (app.getUsername() != null) {
      mPasswordEditText.requestFocus();
    }

    final ImageButton showPassword = (ImageButton) findViewById(R.id.showPassword);
    showPassword.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            mShow = !mShow;
            if (mShow) {
              mPasswordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
              mPasswordEditText.setTransformationMethod(new SingleLineTransformationMethod());

            } else {
              mPasswordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
              mPasswordEditText.setTransformationMethod(new PasswordTransformationMethod());
            }
          }
        });

    final Button signupButton = (Button) findViewById(R.id.signIn);
    signupButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            if (!usernameEditTextFieldIsValid()) {
              Toast.makeText(SignupActivity.this, R.string.invalidEmail, Toast.LENGTH_LONG).show();
            } else if (!passwordEditTextFieldIsValid()) {
              Toast.makeText(SignupActivity.this, R.string.invalidPassword, Toast.LENGTH_LONG)
                  .show();
            } else {
              // close the keyboard
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(mPasswordEditText.getWindowToken(), 0);

              mSignupTask = new SignupTask().execute();
            }
          }
        });
    signupButton.setText(R.string.signUp);
    signupButton.setTypeface(app.mTf);
  }