コード例 #1
1
ファイル: LoginActivity.java プロジェクト: pkaneri/Tagistry
  // checks if fields match required rules
  public boolean validate() {
    boolean valid = true;

    String email = _emailText.getText().toString();
    String password = _passwordText.getText().toString();

    if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
      _emailText.setError("enter a valid email address");
      valid = false;
    } else {
      _emailText.setError(null);
    }

    if (password.isEmpty()
        || password.length() < 8
        || password.length() > 100
        || password.equals(password.toLowerCase())
        || !password.matches(".*\\d+.*")) {
      _passwordText.setError(
          "Password must be at least 8 characters and contain at least 1 uppercase, 1 lowercase, and 1 number");
      valid = false;
    } else {
      _passwordText.setError(null);
    }

    return valid;
  }
コード例 #2
1
ファイル: SettingsFragment.java プロジェクト: kogeva/Reactr
 private boolean isValidEmail(CharSequence target) {
   if (target == null) {
     return false;
   } else {
     return android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
   }
 }
コード例 #3
1
ファイル: SignUpActivity.java プロジェクト: martineq/tp7552
 public static final boolean isValidEmail(CharSequence target) {
   if (TextUtils.isEmpty(target)) {
     return false;
   } else {
     return android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
   }
 }
コード例 #4
0
 public static boolean isValidEmail(String target) {
   if (TextUtils.isEmpty(target)) {
     return false;
   }
   // android Regex to check the email address Validation
   return android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
 }
コード例 #5
0
  public boolean validate() {
    boolean valid = true;

    String name = _nameText.getText().toString();
    String email = _emailText.getText().toString();
    String password = _passwordText.getText().toString();

    if (name.isEmpty() || name.length() < 3) {
      _nameText.setError("at least 3 characters");
      valid = false;
    } else {
      _nameText.setError(null);
    }

    if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
      _emailText.setError("enter a valid email address");
      valid = false;
    } else {
      _emailText.setError(null);
    }

    if (password.isEmpty() || password.length() < 4 || password.length() > 10) {
      _passwordText.setError("between 4 and 10 alphanumeric characters");
      valid = false;
    } else {
      _passwordText.setError(null);
    }

    return valid;
  }
 private void a() {
   String str = b.getText().toString().trim();
   if (StringUtils.d(str)) {
     AppData.a(EventIri.UpdatePrimaryEmail, "is_email_changed", Boolean.valueOf(false));
     as.a(AppData.b().getString(2131165845), 1);
   }
   do {
     return;
     if (!Patterns.EMAIL_ADDRESS.matcher(str).matches()) {
       AppData.a(EventIri.UpdatePrimaryEmail, "is_email_changed", Boolean.valueOf(false));
       as.a(AppData.b().getString(2131165836), 1);
       return;
     }
     if (str.equalsIgnoreCase(a.i())) {
       AppData.a(EventIri.UpdatePrimaryEmail, "is_email_changed", Boolean.valueOf(false));
       setResult(0);
       finish();
       return;
     }
     if ((c != null) && (c.u()) && (!str.equalsIgnoreCase(c.b()))) {
       c.a(true);
     }
   } while ((c != null) && (c.u()));
   c = new ex(str, d);
   c.f(new Void[0]);
   showLoadingDialog(c);
   AppData.a(EventIri.UpdatePrimaryEmail, "is_email_changed", Boolean.valueOf(true));
 }
コード例 #7
0
ファイル: validador.java プロジェクト: jessicaoliveiira/lotus
 public static final boolean validateEmail(String txtEmail) {
   if (TextUtils.isEmpty(txtEmail)) {
     return false;
   } else {
     return android.util.Patterns.EMAIL_ADDRESS.matcher(txtEmail).matches();
   }
 }
コード例 #8
0
  private boolean validRegisterForm(
      String emailAddress,
      String name,
      String surname,
      String userName,
      String pass1,
      String pass2) {
    if (name.equals("")) {
      Toast.makeText(this, "Name required!", Toast.LENGTH_SHORT).show();
      return false;
    }
    if (surname.equals("")) {
      Toast.makeText(this, "Surname required!", Toast.LENGTH_SHORT).show();
      return false;
    }

    if (!android.util.Patterns.EMAIL_ADDRESS.matcher(emailAddress).matches()) {
      Toast.makeText(this, "Not valid email address!", Toast.LENGTH_SHORT).show();
      return false;
    }
    if (userName.equals("")) {
      Toast.makeText(this, "UserName required!", Toast.LENGTH_SHORT).show();
      return false;
    }
    if (pass1.length() == 0) {
      Toast.makeText(this, "Empty passwords not allowed!", Toast.LENGTH_SHORT).show();
      return false;
    }
    if (!pass1.equals(pass2.toString())) {
      Toast.makeText(this, "Passwords are not equal", Toast.LENGTH_SHORT).show();
      return false;
    }
    return true;
  }
コード例 #9
0
  private boolean IsValid() {
    boolean ret = true;
    if (firstName.getText().toString().matches("")) {
      firstName.setError(null);
      firstName.setError("Please enter your first name");
      firstName.requestFocus();
      ret = false;
    } else if (lastName.getText().toString().matches("")) {
      lastName.setError(null);
      lastName.setError("Please enter your last name");
      lastName.requestFocus();
      ret = false;
    } else if (email.getText().toString().matches("")) {
      email.setError(null);
      email.setError("Please enter email");
      email.requestFocus();
      ret = false;
    }

    // finally lets validate the email we already checked for null
    if (ret == true) {
      ret = android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText()).matches();
      if (ret != true) {
        email.setError(null);
        email.setError("Please enter valid email");
        email.requestFocus();
      }
    }

    return ret;
  }
コード例 #10
0
ファイル: CommonUtils.java プロジェクト: khalid64927/iPark
 /* Email must be in correct email pattern */
 public static boolean validateEmail(String emailString) {
   if (TextUtils.isEmpty(emailString)
       || !android.util.Patterns.EMAIL_ADDRESS.matcher(emailString).matches()) {
     return false;
   } else {
     return true;
   }
 }
コード例 #11
0
  @OnClick(R.id.txt_next)
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.txt_next:
        // Hide keyboard
        InputMethodManager inputMethodManager =
            (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);

        // Make sure email is lower case
        editEmail.setText(editEmail.getText().toString().trim().toLowerCase());

        // Validate data before requesting an access token
        boolean valid = true;

        // Validate email address
        if (editEmail.getText().toString().isEmpty()) {
          setError(txtEmailError, getString(R.string.error_field_required));
          valid = false;
        } else if (!Patterns.EMAIL_ADDRESS.matcher(editEmail.getText().toString()).matches()) {
          setError(txtEmailError, getString(R.string.error_invalid_email));
          valid = false;
        } else if (AccountUtils.accountExists(
            getActivity(), blogUrl, editEmail.getText().toString())) {
          setError(txtEmailError, getString(R.string.error_email_exists));
          valid = false;
        } else {
          setError(txtEmailError, null);
        }

        // Validate password
        if (editPassword.getText().toString().trim().isEmpty()) {
          setError(txtPasswordError, getString(R.string.error_field_required));
          valid = false;
        } else {
          setError(txtPasswordError, null);
        }

        // If valid request access token
        if (valid) {
          // Disable button to avoid multiple clicks, show progress bar
          txtNext.setEnabled(false);
          progressBar.setVisibility(View.VISIBLE);

          // Get credentials for later
          email = editEmail.getText().toString();
          password = editPassword.getText().toString();

          // Request access token
          Authentication authentication = ghostClient.createAuthentication();
          authentication.getAccessToken(
              ApiConstants.GRANT_TYPE_PASSWORD, ApiConstants.CLIENT_ID, email, password, this);
        }
        break;
    }
  }
コード例 #12
0
ファイル: Common.java プロジェクト: joseffilzmaier/sw14_xp_06
 private List<String> getEmailList() {
   List<String> lst = new ArrayList<String>();
   Account[] accounts = AccountManager.get(this).getAccounts();
   for (Account account : accounts) {
     if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
       lst.add(account.name);
     }
   }
   return lst;
 }
コード例 #13
0
ファイル: MainActivity.java プロジェクト: chsergey/sdk
 /*
  * Validate email
  */
 private String getEmailError() {
   String value = loginText.getText().toString();
   if (value.length() == 0) {
     return getString(R.string.error_enter_email);
   }
   if (!android.util.Patterns.EMAIL_ADDRESS.matcher(value).matches()) {
     return getString(R.string.error_invalid_email);
   }
   return null;
 }
コード例 #14
0
  protected boolean shouldButtonBeEnabled() {
    final String email = emailEdit.getText().toString();
    final String password = passwordEdit.getText().toString();

    boolean enabled =
        (email.length() > 0)
            && Patterns.EMAIL_ADDRESS.matcher(email).matches()
            && (password.length() >= minimumPasswordLength);
    return enabled;
  }
コード例 #15
0
ファイル: ContactHelper.java プロジェクト: BenEdridge/apg
  public static List<String> getPossibleUserEmails(Context context) {
    Set<String> accountMails = getAccountEmails(context);
    accountMails.addAll(getMainProfileContactEmails(context));

    // remove items that are not an email
    Iterator<String> it = accountMails.iterator();
    while (it.hasNext()) {
      String email = it.next();
      Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
      if (!emailMatcher.matches()) {
        it.remove();
      }
    }

    // now return the Set (without duplicates) as a List
    return new ArrayList<>(accountMails);
  }
コード例 #16
0
ファイル: ContactHelper.java プロジェクト: BenEdridge/apg
  public static List<String> getPossibleUserNames(Context context) {
    Set<String> accountMails = getAccountEmails(context);
    Set<String> names = getContactNamesFromEmails(context, accountMails);
    names.addAll(getMainProfileContactName(context));

    // remove items that are an email
    Iterator<String> it = names.iterator();
    while (it.hasNext()) {
      String email = it.next();
      Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
      if (emailMatcher.matches()) {
        it.remove();
      }
    }

    return new ArrayList<>(names);
  }
コード例 #17
0
 @Override
 public void afterTextChanged(Editable editable) {
   String email = editable.toString();
   if (email.length() > 0) {
     Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
     if (emailMatcher.matches()) {
       EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(
           0, 0, R.drawable.ic_stat_retyped_ok, 0);
     } else {
       EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(
           0, 0, R.drawable.ic_stat_retyped_bad, 0);
     }
   } else {
     // remove drawable if email is empty
     EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
   }
 }
コード例 #18
0
  /** This updates UI, so needs to be done on the foreground thread. */
  protected void populateEmailAddressAutocomplete(Account[] accounts) {
    // First a set, since we don't want repeats.
    final Set<String> emails = new HashSet<String>();
    for (Account account : accounts) {
      if (!Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
        continue;
      }
      emails.add(account.name);
    }

    // And then sorted in alphabetical order.
    final String[] sortedEmails = emails.toArray(new String[emails.size()]);
    Arrays.sort(sortedEmails);

    final ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, sortedEmails);
    emailEdit.setAdapter(adapter);
  }
コード例 #19
0
ファイル: Setting.java プロジェクト: ems123/freeminder
  /** ** validation *** */
  private boolean setValidation() {

    String strName = "" + eTxtName.getText().toString().trim();
    String strEmailID = "" + eTxtEmailId.getText().toString().trim();
    String strPassword = "" + eTxtPassword.getText().toString().trim();
    String strService = "" + spinnerGlobalService.getSelectedItem().toString().trim();
    String strNumber = "" + eTxtNumber.getText().toString().trim();
    if (strName.length() == 0) {
      eTxtName.setError("Enter Name");
      return false;
    }

    if (strEmailID.length() > 0) {
      if (android.util.Patterns.EMAIL_ADDRESS.matcher(strEmailID).matches()) {

      } else {
        eTxtEmailId.setError("Enter valid EmailID");
        return false;
      }
    } else {
      eTxtEmailId.setError("Enter EmailID");
      return false;
    }

    if (strPassword.length() == 0) {
      eTxtPassword.setError("Enter Password");
      return false;
    }
    if (strNumber.length() == 0) {
      eTxtNumber.setError("Please Enter Number");
      return false;
    } else if (strNumber.length() > 10
        || strNumber.length() < 10
        || !strNumber.matches("\\d{10}")) {
      eTxtNumber.setError("Please Enter Valid Number");
      return false;
    }

    if (strService.length() == 0) {
      spinnerGlobalService.setPrompt("Select the Service");
    }

    return true;
  }
コード例 #20
0
ファイル: LoginInfo.java プロジェクト: rutulkotak/MvvmDemo
 public boolean validate(Resources res) {
   if (!loginExecuted) {
     return true;
   }
   int emailErrorRes = 0;
   int passwordErrorRes = 0;
   if (email.get().isEmpty()) {
     emailErrorRes = R.string.mandatory_field;
   } else {
     if (!Patterns.EMAIL_ADDRESS.matcher(email.get()).matches()) {
       emailErrorRes = R.string.invalid_email;
     }
   }
   if (existingUser.get() && password.get().isEmpty()) {
     passwordErrorRes = R.string.mandatory_field;
   }
   emailError.set(emailErrorRes != 0 ? res.getString(emailErrorRes) : null);
   passwordError.set(passwordErrorRes != 0 ? res.getString(passwordErrorRes) : null);
   return emailErrorRes == 0 && passwordErrorRes == 0;
 }
コード例 #21
0
  public boolean validateFields() {
    boolean valid = true;

    if (email.getText().toString().trim().length() == 0) {
      email.setError("Please enter your email");
      valid = false;
    } else if (!Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) {
      email.setError("Please enter a valid email");
      valid = false;
    } else {
      email.setError(null);
    }

    if (password.getText().toString().trim().length() == 0) {
      password.setError("Please enter your password");
      valid = false;
    } else {
      password.setError(null);
    }

    return valid;
  }
コード例 #22
0
  /**
   * Retrieves the user profile information in a manner supported by Gingerbread devices.
   *
   * @param context the context from which to retrieve the user's email address and name
   * @return a list of the possible user's email address and name
   */
  private static UserProfile getUserProfileOnGingerbreadDevice(Context context) {
    // Other that using Patterns (API level 8) this works on devices down to
    // API level 5
    final Matcher valid_email_address = Patterns.EMAIL_ADDRESS.matcher("");
    final Account[] accounts =
        AccountManager.get(context).getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    UserProfile user_profile = new UserProfile();
    // As far as I can tell, there is no way to get the real name or phone
    // number from the Google account
    for (Account account : accounts) {
      if (valid_email_address.reset(account.name).matches())
        user_profile.addPossibleEmail(account.name);
    }
    // Gets the phone number of the device is the device has one
    if (context.getPackageManager().hasSystemFeature(Context.TELEPHONY_SERVICE)) {
      final TelephonyManager telephony =
          (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
      user_profile.addPossiblePhoneNumber(telephony.getLine1Number());
    }

    return user_profile;
  }
コード例 #23
0
ファイル: LoginActivity.java プロジェクト: kamalkishit/cws
  public boolean validate() {
    boolean valid = true;

    String emailStr = email.getText().toString();
    String passwordStr = password.getText().toString();

    if (emailStr.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(emailStr).matches()) {
      email.setError("enter a valid email address");
      valid = false;
    } else {
      email.setError(null);
    }

    if (passwordStr.isEmpty() || passwordStr.length() < 4 || password.length() > 10) {
      password.setError("between 4 and 10 characters");
      valid = false;
    } else {
      password.setError(null);
    }

    return valid;
  }
コード例 #24
0
  /** This initialise the email autocomplete with all emails accounts in the devise. */
  private void emailInitialisation() {
    final Set<String> emails = new HashSet<>();
    Account[] accounts = AccountManager.get(this).getAccounts();
    for (Account account : accounts) {
      if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
        emails.add(account.name);
      }
    }
    // Create the adapter and set it to the loginEmail
    ArrayAdapter<String> adapter =
        new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<>(emails));
    emailLogin.setAdapter(adapter);
    final String selectedEmail = ActivityManager.getSharedStringValue(this, SELECTED_EMAIL, null);
    if (null != selectedEmail) {
      emailLogin.setText(selectedEmail);
    } else if (!emails.isEmpty()) {
      emailLogin.setText(emails.iterator().next());
    }

    emailLogin.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
              if (event.getRawX()
                  >= (emailLogin.getRight()
                      - emailLogin.getCompoundDrawables()[2].getBounds().width())) {
                emailLogin.setText(null);
                return true;
              }
            }
            emailLogin.getBackground().clearColorFilter();
            emailLoginError.setVisibility(View.GONE);
            return false;
          }
        });
  }
コード例 #25
0
ファイル: BaseActivity.java プロジェクト: Wolf00Bomber/Hcue
 /**
  * This method validates the given email is in valid format or not?
  *
  * @param email : Email id in String format
  */
 public boolean isValidEmail(String email) {
   if (email == null || email.isEmpty()) return false;
   return Patterns.EMAIL_ADDRESS.matcher(email).matches();
 }
コード例 #26
0
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnContinue:
        String name = edtName.getText().toString().trim();
        String password = edtPassword.getText().toString().trim();
        String emailId = edtEmail.getText().toString().trim();
        String contactNo = edtContact.getText().toString().trim();
        String confirmPassword = edtConPassword.getText().toString().trim();

        if (TextUtils.isEmpty(name)) {
          FireToast.makeToast(mContext, "Please enter name.");
          return;
        }
        if (TextUtils.isEmpty(emailId)) {
          FireToast.makeToast(mContext, "Please enter email id.");
          return;
        }
        if (!android.util.Patterns.EMAIL_ADDRESS.matcher(emailId).matches()) {
          FireToast.makeToast(this, "Please enter valid email id.");
          return;
        }
        if (TextUtils.isEmpty(password)) {
          FireToast.makeToast(mContext, "Please enter password.");
          return;
        }
        if (TextUtils.isEmpty(confirmPassword)) {
          FireToast.makeToast(mContext, "Please enter confirm password.");
          return;
        }
        if (!password.equals(confirmPassword)) {
          FireToast.makeToast(getApplicationContext(), "Password not match.");
          return;
        }
        if (TextUtils.isEmpty(contactNo)) {
          FireToast.makeToast(mContext, "Please enter contact no.");
          return;
        }
        if (!isValidMobile(contactNo)) {
          FireToast.makeToast(mContext, "Please enter a 10 digit contact no.");
          return;
        }

        // {"Id":0,"Name":"Vinod","Password":"******","EmailId":"*****@*****.**","ContactNumber":null,"Addresses":[{"Title":"Home","Address":"Address Line","HouseType":0,"Id":0,"Area":{"AreaId":1,"AreaName":"Pimple Saudagar","City":0},"Society":{"SocietyId":1,"SocietyName":"Ginger","AreaId":0}}]}

        JSONObject object = new JSONObject();
        try {

          object.put("Name", edtName.getText().toString().trim());
          object.put("password", edtPassword.getText().toString().trim());
          object.put("EmailId", edtEmail.getText().toString().trim());
          object.put("ContactNumber", edtContact.getText().toString().trim());
          object.put("ReferralCode", edtRefCode.getText().toString());
          /* startActivity(new Intent(this, RegisterAddressActivity.class)
          .putExtra("customer", object.toString()));*/
          startActivityForResult(
              new Intent(this, RegisterAddressActivity.class)
                  .putExtra("customer", object.toString()),
              Register_code);

          // .putExtra("customer", object.toString()));

          // finish();
        } catch (JSONException e) {
          e.printStackTrace();
          FireToast.makeToast(mContext, "Fail to create customer object");
        }

        break;
    }
  }
コード例 #27
0
 private static boolean isValidEmail(String email) {
   return !TextUtils.isEmpty(email)
       && android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
 }
コード例 #28
0
  /**
   * * Taken from here: http://stackoverflow.com/questions/9355899/android-email-edittext-validation
   *
   * @param target
   * @return
   */
  public static final boolean isValidEmail(CharSequence target) {
    if (target == null) return false;

    return android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
  }
コード例 #29
0
 /**
  * Elides any emails in the specified {@link String} with {@link #EMAIL_ELISION}.
  *
  * @param original String potentially containing emails.
  * @return String with elided emails.
  */
 @VisibleForTesting
 protected static String elideEmail(String original) {
   return Patterns.EMAIL_ADDRESS.matcher(original).replaceAll(EMAIL_ELISION);
 }
コード例 #30
0
 protected boolean validateEmail(String email) {
   boolean valid = false;
   if (!TextUtils.isEmpty(email) && Patterns.EMAIL_ADDRESS.matcher(email).matches()) valid = true;
   return valid;
 }