@Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
    // TODO Auto-generated method stub
    try {
      if (s.length() > 0) {
        editUserEmailAddress.setTextColor(Color.BLACK);
        /*
         * Toast.makeText(getApplicationContext(), "OnTextChanged",
         * Toast.LENGTH_SHORT).show();
         */

        // for (int i = 0; i < editTexts.length; i++) {
        // if (editTexts[i].getText().length() > 0) {
        // editTexts[i].setBackgroundResource(R.drawable.edit_text_color);
        //
        // }
        //
        // }
        /*
         * if (editUserEmailAddress.getText().length() > 0) {
         * editUserEmailAddress
         * .setBackgroundResource(R.drawable.edit_text_color);
         * editUserEmailAddress.setTextColor(Color.BLACK); }
         *
         * if (Validate.isEmailAddress(editUserEmailAddress, true)) {
         * editUserEmailAddress
         * .setBackgroundResource(R.drawable.edit_text_color);
         * errorMsg.setVisibility(View.GONE); }
         */

        /*
         * if(editUserPassword.getText().length() < 6 ){
         * editUserPassword
         * .setBackgroundResource(R.drawable.error_border);
         * txtErrorMsg.setText("Password should be 6 chars."); return; }
         */

        if (Validate.matchPassword(editUserPassword, editConfirmPsw)) {
          editUserPassword.setBackgroundResource(R.drawable.edit_text_color);
          editConfirmPsw.setBackgroundResource(R.drawable.edit_text_color);
          errorMsg.setVisibility(View.GONE);
          // txtErrorMsg.setText("");

          txtErrorMsg.setText("");
        }
      }
    } catch (Exception e) {
      Log.e("Error in textWatcher OnTextChanged", e.toString());
    }
    // getUserValidated();

  }
Esempio n. 2
0
  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
    // TODO Auto-generated method stub
    try {
      if (s.length() > 0) {

        if (Validate.isEmailAddress(edtTxtRecoverEmail, true)) {
          edtTxtRecoverEmail.setTextColor(Color.BLACK);
          edtTxtRecoverEmail.setBackgroundResource(R.drawable.edit_text_color);
          errorMsg.setVisibility(View.GONE);
        }
        edtTxtRecoverEmail.setTextColor(Color.BLACK);
      }
    } catch (Exception e) {
      PMWF_Log.fnlog(PMWF_Log.ERROR, "Error in textWatcher OnTextChanged", e.toString());
    }
  }
  protected boolean getUserValidated() {
    boolean userValid = true;
    // String toastMessage = "";
    for (int i = 0; i < editTexts.length; i++) {
      if (Validate.hasText(editTexts[i])) {
        editTexts[i].setBackgroundResource(R.drawable.edit_text_color);
        errorMsg.setVisibility(View.GONE);
      } else {
        editTexts[i].setBackgroundResource(R.drawable.error_border);
        userValid = false;
      }
    }

    if (!userValid) {
      errorMsg.setVisibility(View.VISIBLE);
      txtErrorMsg.setText(
          ApplicationSettings.translationSettings.GetTranslation(
              "and_msg_requiredFieldsNotFilled", "Required fields are not filled"));
      return false;
    }

    // if (!(editUserLastName.getText().length() > 0) ||
    // !(editUserFirstName.getText().length() > 0)
    // || !(editUserEmailAddress.getText().length() > 0) // ||
    // // !(editUserPhoneNumber.getText().length()
    // // > 0)
    // || (!(editUserPassword.getText().length() > 0) ||
    // !(editConfirmPsw.getText().length() > 0))) {
    //
    // errorMsg.setVisibility(View.VISIBLE);
    // txtErrorMsg.setText("");
    // txtErrorMsg.setText(ApplicationSettings.translationSettings.GetTranslation(
    // "and_msg_requiredFieldsNotFilled",
    // "Required fields are not filled"));
    // userValid = false;
    // return false;
    // // txtErrorMsg.setText("");
    // }
    // TODO removed repeated code
    // if (!(editUserFirstName.getText().length() > 0) ||
    // !(editUserEmailAddress.getText().length() > 0) // ||
    // // !(editUserPhoneNumber.getText().length()
    // // >
    // // 0)
    // || (!(editUserPassword.getText().length() > 0) ||
    // !(editConfirmPsw.getText().length() > 0))) {
    //
    // errorMsg.setVisibility(View.VISIBLE);
    // txtErrorMsg.setText("");
    // txtErrorMsg.setText(ApplicationSettings.translationSettings.GetTranslation(
    // "and_msg_requiredFieldsNotFilled",
    // "Required fields are not filled"));
    // userValid = false;
    // return false;
    // // txtErrorMsg.setText("");
    // }
    if (Validate.isEmailAddress(editUserEmailAddress, true)) {
      editUserEmailAddress.setBackgroundResource(R.drawable.edit_text_color);
      errorMsg.setVisibility(View.GONE);
    } else {
      errorMsg.setVisibility(View.VISIBLE);
      txtErrorMsg.setText(
          ApplicationSettings.translationSettings.GetTranslation(
              "and_msg_invalidEmailAddress", "Invalid email address"));
      editUserEmailAddress.setBackgroundResource(R.drawable.error_border);
      // userValid = false;
      return false;
    }

    if (editUserPassword.getText().length() < 6) {
      errorMsg.setVisibility(View.VISIBLE);
      editUserPassword.setBackgroundResource(R.drawable.error_border);
      txtErrorMsg.setText(
          ApplicationSettings.translationSettings.GetTranslation(
              "and_msg_password_length", "Password should be of minimum 6 characters."));
      return false;
    }

    if (editUserPhoneNumber.getText().length() > 15) {
      errorMsg.setVisibility(View.VISIBLE);
      editUserPhoneNumber.setBackgroundResource(R.drawable.error_border);
      txtErrorMsg.setText(
          ApplicationSettings.translationSettings.GetTranslation(
              "and_msg_validation_phoneNumber", "Phone number field exceed the maximum length"));
      editUserPhoneNumber.setFocusable(true);
      return false;
    }
    /*
     * String[] result = editUserPassword.getText().toString().split("");
     * if(result.length!=0){ errorMsg.setVisibility(View.VISIBLE);
     * editUserPassword.setBackgroundResource(R.drawable.error_border);
     * txtErrorMsg.setText("Password shouldnot contain space characters.");
     * return false; }
     */

    if (Validate.matchPassword(editUserPassword, editConfirmPsw)) {
      editUserPassword.setBackgroundResource(R.drawable.edit_text_color);
      editConfirmPsw.setBackgroundResource(R.drawable.edit_text_color);
      errorMsg.setVisibility(View.GONE);
      // txtErrorMsg.setText("");
    } else {
      errorMsg.setVisibility(View.VISIBLE);
      editConfirmPsw.setBackgroundResource(R.drawable.error_border);
      txtErrorMsg.setText(
          ApplicationSettings.translationSettings.GetTranslation(
              "and_msg_passwordDoesntMatch", "Password doesn't match"));

      return false;
    }

    // if (toastMessage != "") {
    // AlertMessage.Alert(toastMessage, UsersInformation.this);
    // }

    // if (userValid) {
    // txtErrorMsg.setText("");
    // } else {
    // errorMsg.setVisibility(View.VISIBLE);
    // txtErrorMsg.setText("Required fields are not filled");
    // }
    return userValid;
  }