Exemplo n.º 1
1
  // 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;
  }
  /**
   * Attempts to sign in the account specified by the login form. If there are form errors (invalid
   * username, missing fields, etc.), the errors are presented and no actual login attempt is made.
   */
  private void attemptLogin() throws RemoteException {
    // Reset errors.
    mUsernameView.setError(null);

    // Store values at the time of the login attempt.
    String username = mUsernameView.getText().toString().trim();

    // Check for a valid username.
    if (TextUtils.isEmpty(username)) {
      // There was an error; don't attempt login and focus the first
      // form field with an error.
      mUsernameView.setError(getString(R.string.error_field_required));
      mUsernameView.requestFocus();
      return;
    }

    mUsername = username;
    PreferenceStorage.storeUsername(username);
    // perform the user login attempt.
    ArrayList<String> stringArrayList = new ArrayList<String>();
    stringArrayList.add(username);
    // AppSocketListener.getInstance().emit("add user",stringArrayList,null);
    AppSocketListener.getInstance().addOnHandler(SocketEventConstants.login, onLogin);
    AppSocketListener.getInstance().addNewMessageHandler();
    AppSocketListener.getInstance().emit(SocketEventConstants.addUser, username);
  }
Exemplo n.º 3
0
  private boolean canSend() {

    boolean haveContent = !TextUtils.isEmpty(content.getText().toString());
    boolean haveToken = !TextUtils.isEmpty(token);
    boolean contentNumBelow140 = (content.getText().toString().length() < 140);

    if (haveContent && haveToken && contentNumBelow140) {
      return true;
    } else {
      if (!haveContent && !haveToken) {
        Toast.makeText(
                this,
                getString(R.string.content_cant_be_empty_and_dont_have_account),
                Toast.LENGTH_SHORT)
            .show();
      } else if (!haveContent) {
        content.setError(getString(R.string.content_cant_be_empty));
      } else if (!haveToken) {
        Toast.makeText(this, getString(R.string.dont_have_account), Toast.LENGTH_SHORT).show();
      }

      if (!contentNumBelow140) {
        content.setError(getString(R.string.content_words_number_too_many));
      }
    }

    return false;
  }
Exemplo n.º 4
0
  public void actionLogin(View button) {

    final EditText txtpass = (EditText) findViewById(R.id.txtpass);
    if (txtpass.getText().toString().length() < 1) {
      txtpass.setError(getResources().getString(R.string.login_passwd_err));
      return;
    }

    if (firstlogin) {

      final CheckBox chkBoxpass = (CheckBox) findViewById(R.id.chkPass);

      SharedPreferences.Editor editor = preferences.edit();
      editor.putBoolean("firstlogin", false);
      editor.putBoolean("checkpass", chkBoxpass.isChecked());
      editor.putString("dbpassword", StringEncoder.encode(this, txtpass.getText().toString()));
      editor.putString("currency", "€");
      editor.putLong("currency_id", 1);
      editor.commit();

      MyExApp app = (MyExApp) getApplication();
      app.reloadPreferences();
      app.reloadDataManager();
      app.initData();

    } else {

      String password = StringEncoder.decode(this, preferences.getString("dbpassword", ""));
      if (!password.equals(txtpass.getText().toString())) {
        txtpass.setError(getResources().getString(R.string.login_passwd_err2));
        return;
      }
    }
    startMainFragment();
  }
Exemplo n.º 5
0
  private void registByPhone() {
    String phone = phone_edit.getText().toString();
    if (TextUtils.isEmpty(phone)) {
      phone_edit.setError(getString(R.string.nullcontentnotice));
      phone_edit.requestFocus();
      return;
    } else if (!PhoneInfoUtils.isPhoneNum(phone)) {
      phone_edit.setError(getString(R.string.phone_notice_));
      phone_edit.requestFocus();
      return;
    }

    String passwordostr = passWordo.getText().toString();
    String passwordtstr = passWordt.getText().toString();
    if (TextUtils.isEmpty(passwordostr)) {
      passWordo.setError(getString(R.string.nullcontentnotice));
      passWordo.requestFocus();
      return;
    }

    if (!passwordostr.equals(passwordtstr)) {
      passWordt.setError(getString(R.string.password_notice_t));
      passWordt.requestFocus();
      return;
    }

    HealthHttpClient.registerByphone(phone, MD5.MD5jm(passwordtstr), handler);
  }
  private void displayQuestion(Question question) {
    TextView display = (TextView) findViewById(R.id.displayTW);
    TextView answerType = (TextView) findViewById(R.id.answerTypeTW);
    display.setText(question.verb.getPresent());
    answerType.setText(question.answerType.getStringId());

    switch (question.answerType) {
      case PERFECT:
        // Hide/show layout for a perfect question
        findViewById(R.id.perfectLayout).setVisibility(View.VISIBLE);
        findViewById(R.id.preteriteInputTE).setVisibility(View.GONE);
        perfectAuxTE.setText("");
        perfectInputTE.setText("");
        break;
      case PRETERITE:
        // Hide/show layout for a perfect question
        findViewById(R.id.perfectLayout).setVisibility(View.GONE);
        findViewById(R.id.preteriteInputTE).setVisibility(View.VISIBLE);
        preteriteInputTE.setText("");
        break;
    }

    // Hide errors
    perfectAuxTE.setError(null);
    perfectInputTE.setError(null);
    preteriteInputTE.setError(null);
  }
Exemplo n.º 7
0
  /** ** validation *** */
  private boolean setActionValidation() {

    String strName = "" + eTxtAcName.getText().toString().trim();
    String strContent = "" + eTxtAcContent.getText().toString().trim();
    String strSince = "" + eTxtAcSince.getText().toString().trim();

    if (strName.length() == 0) {
      eTxtAcName.setError("Enter Name");
      return false;
    }

    if (strContent.length() == 0) {

      eTxtAcContent.setError("Enter Content");
      return false;
    }

    if (strSince.length() > 0) {

    } else {
      eTxtAcSince.setError("Set Since Date");
      return false;
    }

    return true;
  }
Exemplo n.º 8
0
  @Override
  public boolean okForLogin() {
    if (!DeviceUtil.hasInternet()) {
      ToastUtil.toast(R.string.tip_no_internet);
      return false;
    }
    if (etUserName.length() == 0) {
      etUserName.setError("请输入邮箱/用户名");
      etUserName.requestFocus();
      return false;
    } else if (etUserName.length() < 4) {
      etUserName.setError("用户名长度过短");
      etUserName.requestFocus();
      return false;
    }

    if (etPassword.length() == 0) {
      etPassword.setError("请输入密码");
      etPassword.requestFocus();
      return false;
    } else if (etPassword.length() <= 7) {
      etPassword.setError("密码长度过短");
      etPassword.requestFocus();
      return false;
    }

    return true;
  }
Exemplo n.º 9
0
  void generatePass() {
    url = mURLView.getText().toString();
    if (!url.startsWith("www.") && !url.startsWith("http://")) {
      url = "www." + url;
    }
    if (!url.startsWith("http://")) {
      url = "http://" + url;
    }

    if (!isUrl(url)) {
      mURLView.setError("Please enter a valid URL");
      return;
    }

    if (mPasswordView.getText().length() < 8) {
      mPasswordView.setError("Please use a longer password");
      return;
    }

    saveUrl(url);

    Snackbar.make(mScrollView, "Password generated", Snackbar.LENGTH_LONG)
        .setAction(
            "Copy",
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                GeneratePassActivity.this.copyPassToClipboard();
              }
            })
        .show();
  }
Exemplo n.º 10
0
  /*
   * RULES:
   * Email is valid format ( 6 characters and contains @ and .
   * Password >= 5 characters long
   */
  public void performLogin() {
    final EditText emailText = ((EditText) getView().findViewById(R.id.edit_text_login_email));
    final EditText passwordText =
        ((EditText) getView().findViewById(R.id.edit_text_login_password));
    boolean validLoginCredentials = true;
    String email = emailText.getText().toString();
    String password = passwordText.getText().toString();

    emailText.setError(null);
    passwordText.setError(null);

    if (!email.contains("@") || !(email.contains(".")) || email.length() < MIN_EMAIL_LENGTH) {
      emailText.setError(getString(R.string.signup_error_email_invalid));
      emailText.setText("");
      validLoginCredentials = false;
    }

    if (password.length() < MIN_PASSWORD_LENGTH) {
      passwordText.setError(getString(R.string.login_error_password_invalid_length));
      validLoginCredentials = false;
    }

    if (validLoginCredentials) {
      final ProgressDialog PD = new ProgressDialog(getActivity());
      PD.setTitle("Please Wait..");
      PD.setMessage("Loading...");
      PD.setCancelable(false);
      PD.show();
      doLogin(PD, email, password);
    } else {
      clearEntries();
    }
  }
  /**
   * Attempts to sign in or register the account specified by the login form. If there are form
   * errors (invalid email, missing fields, etc.), the errors are presented and no actual login
   * attempt is made.
   */
  private void attemptLogin() {
    if (mAuthTask != null) {
      return;
    }

    // Reset errors.
    mNameView.setError(null);
    mZipCodeView.setError(null);

    // Store values at the time of the login attempt.
    String name = mNameView.getText().toString();
    String phone = mPhoneView.getText().toString();
    String bloodgroup = adapter.getItem(mBloodGroupsView.getSelectedItemPosition()).toString();
    String zipcode = mZipCodeView.getText().toString();

    boolean cancel = false;
    View focusView = null;

    // Check for a valid password, if the user entered one.
    if (TextUtils.isEmpty(zipcode) || !isZipCodeValid(zipcode)) {
      mZipCodeView.setError("Invalid Zip Code");
      focusView = mZipCodeView;
      cancel = true;
    }

    // Check for a valid email address.
    if (TextUtils.isEmpty(name)) {
      mNameView.setError(getString(R.string.error_field_required));
      focusView = mNameView;
      cancel = true;
    } else if (isEmailValid(name)) {
      mNameView.setError("Invalid Name");
      focusView = mNameView;
      cancel = true;
    }
    if (TextUtils.isEmpty(phone)) {
      mPhoneView.setError("This field is required");
      focusView = mPhoneView;
      cancel = true;
    }

    if (mBloodGroupsView.getSelectedItemPosition() < 1) {
      Snackbar.make(mBloodGroupsView, "Choose your Blood Group", Snackbar.LENGTH_SHORT).show();
      focusView = mBloodGroupsView;
      cancel = true;
    }

    if (cancel) {
      // There was an error; don't attempt login and focus the first
      // form field with an error.
      focusView.requestFocus();
    } else {
      // Show a progress spinner, and kick off a background task to
      // perform the user login attempt.
      showProgress(true);
      mAuthTask = new UserLoginTask(name, phone, bloodgroup, zipcode);
      // showProgress(true);
      mAuthTask.execute((Void) null);
    }
  }
 @Override
 public void onClick(View v) {
   if (v == createButton) {
     boolean create = true;
     if (!checkUserName()) {
       username.setError(getString(R.string.create_account_err_username));
       create = false;
     }
     if (TextUtils.isEmpty(serverEdit.getText())) {
       serverEdit.setError("Choose a server");
       create = false;
     }
     if (!checkPasswords()) {
       password.setError(getString(R.string.create_account_err_passwords));
       confirmPassword.setError(getString(R.string.create_account_err_passwords));
       create = false;
     }
     if (create) {
       String jid = String.format("%s@%s", username.getText(), serverEdit.getText());
       jid = StringUtils.parseBareAddress(jid);
       String pass = password.getText().toString();
       task = new CreateAccountTask();
       task.execute(jid, pass);
     }
   }
 }
 public void afterTextChanged(Editable text) {
   if (text.length() == 0) {
     mNameView.setError(getContext().getText(R.string.errorEmptyName));
   } else {
     mNameView.setError(null);
   }
 }
Exemplo n.º 14
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handles item selection in action bar
    if (item.getItemId() == R.id.action_save_profile) {
      /*
          Performs validation of input data
      */
      boolean isError = false;

      if (name.getText().length() == 0) {
        isError = true;
        name.setError("Name is required");
      }

      if (name.getText().toString().trim().length() > 50) {
        isError = true;
        name.setError("Name can't be longer than 50 characters");
      }

      if (textTimeMinutes.getText().equals("00") && textTimeSeconds.getText().equals("00")) {
        isError = true;
        timeError.setError("Time is required");
      }

      if (repeat.isChecked() && repeatNumber.getText().length() == 0) {
        isError = true;
        repeatNumber.setError("Number of laps is required");
      }

      /*
          Produces an error if:
          - name of profile is taken and adding a new profile
          - changed profile name is taken
      */
      if (dbHandler.profileExists(name.getText().toString().trim())) {
        if (!isEditingProfile || !name.getText().toString().trim().equals(profile.getName())) {
          isError = true;
          name.setError("Name already exists");
        }
      }

      if (!isError) {
        // Either adds or edits the profile depending on what's needed
        if (isEditingProfile) {
          setResult(PROFILE_EDITED);
          updateProfile();
        } else {
          setResult(PROFILE_ADDED);
          addProfile();
        }

        finish();
      }
    }

    return super.onOptionsItemSelected(item);
  }
Exemplo n.º 15
0
 public boolean editTextChecker(EditText editText) {
   String text = editText.getText().toString().trim();
   editText.setError(null);
   if (text.length() == 0) {
     editText.setError(Html.fromHtml("<font color='red'>Cannot Empty "));
     return false;
   }
   return true;
 }
 @Override
 public void onClick(View inButton) {
   boolean isErr = false;
   if (mTitle.getText().toString().length() == 0) {
     mTitle.setError("Required");
     mTitle.setEms(10);
     isErr = true;
   }
   if (mDesc.getText().toString().length() == 0) {
     mDesc.setActivated(true);
     mDesc.setError("Required");
     isErr = true;
   }
   if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE);
   else if (inButton.getId() == mAvail.getId())
     startActivity(new Intent(this, CheckActivity.class));
   else if (inButton.getId() == mBack.getId()) finish();
   else if (inButton.getId() == mSub.getId()) {
     AlertDialog.Builder al = new AlertDialog.Builder(this);
     if (isErr) return;
     else
       al.setTitle("Continue?")
           .setIcon(R.drawable.ornament)
           .setMessage("Your listing is going to be submitted to your chosen category.")
           .setPositiveButton(
               "OK",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {
                   payment = new ArrayList<String>();
                   if (mCard.isChecked()) payment.add("Card");
                   if (mCheck.isChecked()) payment.add("Check");
                   if (mOnline.isChecked()) payment.add("Online");
                   if (mCash.isChecked()) payment.add("Cash");
                   //			Toast.makeText(getApplicationContext(), payment.toString(),
                   // Toast.LENGTH_LONG).show();
                   Intent intent = new Intent(getApplicationContext(), StartActivity.class);
                   intent.putExtra("Payment", payment);
                   intent.putExtra("Category", mChosenCategory);
                   intent.putExtra("Title", mTitle.getText().toString());
                   intent.putExtra("Price", mPrice.getText().toString());
                   intent.putExtra("Description", mDesc.getText().toString());
                   intent.putExtra("Location", mLocation.getText().toString());
                   intent.putExtra("Photo", jpegData);
                   startActivity(intent);
                 }
               })
           .setNegativeButton(
               "Cancel",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {}
               })
           .show();
   } else
     startActivityForResult(
         new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ);
 }
Exemplo n.º 17
0
  private void attemptSignup() {
    if (mAuthTask != null) {
      return;
    }

    // Reset errors.
    mEmailView.setError(null);
    mPassword1View.setError(null);
    mPassword2View.setError(null);

    // Store values at the time of the login attempt.
    String email = mEmailView.getText().toString();
    String username = mUsername.getText().toString();
    String password = mPassword1View.getText().toString();
    String re_password = mPassword2View.getText().toString();

    boolean cancel = false;
    View focusView = null;

    // Check for a valid password, if the user entered one.
    if (!TextUtils.isEmpty(re_password) && !isPasswordMatched(password, re_password)) {
      mPassword2View.setError(getString(R.string.error_incorrect_password));
      focusView = mPassword2View;
      cancel = true;
    }
    if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
      mPassword1View.setError(getString(R.string.error_invalid_password));
      focusView = mPassword1View;
      cancel = true;
    }

    // Check for a valid email address.
    if (!isEmailValid(email)) {
      mEmailView.setError(getString(R.string.error_invalid_email));
      focusView = mEmailView;
      cancel = true;
    } else if (TextUtils.isEmpty(email)) {
      mEmailView.setError(getString(R.string.error_field_required));
      focusView = mEmailView;
      cancel = true;
    }

    if (cancel) {
      // There was an error; don't attempt login and focus the first
      // form field with an error.
      focusView.requestFocus();
    } else {
      // Show a progress spinner, and kick off a background task to
      // perform the user login attempt.
      if (mProgressListener != null) {
        mProgressListener.onShowProgress(true);
      }
      mAuthTask = new UserSignupTask(email, username, password);
      mAuthTask.execute((Void) null);
    }
  }
Exemplo n.º 18
0
 @Override
 public void onTextChanged(CharSequence s, int start, int before, int count) {
   // TODO Auto-generated method stub
   BingLog.i(TAG, "daxiao:" + s.length());
   if (s.length() < 6) {
     passWordo.setError(getString(R.string.password_notice_o));
   } else {
     passWordo.setError(null);
   }
 }
Exemplo n.º 19
0
  private void getUserDetails() {
    CharSequence cs;
    firstname = edit_firstname.getText().toString().trim();
    lastname = edit_lastname.getText().toString().trim();
    username = edit_username.getText().toString().trim();
    email = edit_email.getText().toString().trim();
    dob = text_dob.getText().toString().trim();
    password = edit_password.getText().toString().trim();

    cs = (CharSequence) email;

    if (firstname.length() < 4) {
      edit_firstname.setError("Enter atleast 4 characters");
    }
    if (username.length() < 6) {
      edit_username.setError("Enter atleast 6 characters");
    }
    if (password.length() < 6) {
      edit_password.setError("Enter atleast 6 characters");
    }
    if (!isEmailValid(cs)) {
      edit_email.setError("Enter a valid email");
    }

    if (spinner_gender.getSelectedItemPosition() <= 0) {
      Toast.makeText(RegisterNormal.this, "Please select the gender", Toast.LENGTH_SHORT).show();
    }

    if (dob.length() <= 0) {
      Toast.makeText(RegisterNormal.this, "Please select the DOB", Toast.LENGTH_SHORT).show();
    }

    if (firstname.length() > 4
        && (username.length() >= 6)
        && (password.length() >= 6)
        && (isEmailValid(cs))
        && (spinner_gender.getSelectedItemPosition() > 0)
        && dob.length() > 0) {
      if (terms_check.isChecked()) {
        // call for async for registering the user
        ConnectionDetector conn = new ConnectionDetector(RegisterNormal.this);
        if (conn.isConnectingToInternet()) {
          new Register().execute();
        } else {
          Crouton.makeText(RegisterNormal.this, getString(R.string.crouton_message), Style.ALERT)
              .show();
        }
      } else {
        Toast.makeText(RegisterNormal.this, "Accept the terms and conditions", Toast.LENGTH_SHORT)
            .show();
      }
    } else {
      // Toast.makeText(RegisterNormal.this,"Enter valid details",Toast.LENGTH_LONG).show();
    }
  }
 /**
  * Checks if text of given EditText is not empty. If it is empty an error is set and the EditText
  * gets the focus.
  *
  * @param editText
  * @return true if EditText is not empty
  */
 private boolean isMainEmailValid(EditText editText) {
   if (editText.getText().length() == 0) {
     editText.setError(getString(R.string.create_key_empty));
     editText.requestFocus();
     return false;
   } else if (!checkEmail(editText.getText().toString(), false)) {
     return false;
   }
   editText.setError(null);
   return true;
 }
 /**
  * Checks if the email and password input text is valid and shows an error if not.
  *
  * @return whether the email and password input text is valid (non empty).
  */
 private boolean validEmailPasswordInput() {
   String email = mEmailInput.getText().toString().trim();
   String password = mPasswordInput.getText().toString().trim();
   if (email.isEmpty()) {
     mEmailInput.setError(getString(R.string.simpleauth_error_input_email));
   }
   if (password.isEmpty()) {
     mPasswordInput.setError(getString(R.string.simpleauth_error_input_password));
   }
   return !(email.isEmpty() || password.isEmpty());
 }
 public void Is_Valid_Email(EditText edt) {
   if (edt.getText().toString() == null) {
     edt.setError("Invalid Email Address");
     valid_email = null;
   } else if (isEmailValid(edt.getText().toString()) == false) {
     edt.setError("Invalid Email Address");
     valid_email = null;
   } else {
     valid_email = edt.getText().toString();
   }
 }
Exemplo n.º 23
0
  public void tryToSendMagasin(View v) {

    EditText nomMagasinEdit = (EditText) findViewById(R.id.editTextNomMag);
    EditText adresseMagasinEdit = (EditText) findViewById(R.id.editTextAdrMag);
    EditText codePostalMagasinEdit = (EditText) findViewById(R.id.editTextCPMag);
    EditText villeMagasinEdit = (EditText) findViewById(R.id.editTextVilleMag);
    EditText siteMagasinEdit = (EditText) findViewById(R.id.editTextSiteMag);
    EditText telMagasinEdit = (EditText) findViewById(R.id.editTextTelMag);

    boolean remplit = true;

    // Vérifier si les champs ont bien été rempli
    if (TextUtils.isEmpty(nomMagasinEdit.getText())) {
      nomMagasinEdit.setError("Veuillez entrer le nom du magasin");
      nomMagasinEdit.setFocusable(true);
      remplit = false;
    }
    if (TextUtils.isEmpty(villeMagasinEdit.getText())) {
      villeMagasinEdit.setError("Veuillez entrer la ville du magasin");
      villeMagasinEdit.setFocusable(true);
      remplit = false;
    }
    if (telMagasinEdit.getText().length() < 10) {
      telMagasinEdit.setError("Le numéro de téléphone doit obligatoirement contenir 10 chiffres");
      telMagasinEdit.setFocusable(true);
      remplit = false;
    }
    if (codePostalMagasinEdit.getText().length() < 5) {
      codePostalMagasinEdit.setError("Le code postal doit obligatoirement contenir 5 chiffres");
      codePostalMagasinEdit.setFocusable(true);
      remplit = false;
    }

    if (remplit) {
      if (Utils.getConnectivityStatus(getApplicationContext())) {
        Magasin monMagasin =
            new Magasin(
                2,
                nomMagasinEdit.getText().toString(),
                adresseMagasinEdit.getText().toString(),
                villeMagasinEdit.getText().toString(),
                codePostalMagasinEdit.getText().toString(),
                siteMagasinEdit.getText().toString(),
                telMagasinEdit.getText().toString());
        myDBHelper.ajoutMagasin(monMagasin, this);
        Toast.makeText(this, "Le magasin a bien été crée", Toast.LENGTH_LONG).show();
        this.finish();

      } else
        Toast.makeText(
                this, "Pas de connection internet, veuillez réessayer plus tard", Toast.LENGTH_LONG)
            .show();
    }
  }
 public void Is_Valid_Person_Name(EditText edt) throws NumberFormatException {
   if (edt.getText().toString().length() <= 0) {
     edt.setError("Accept Alphabets Only.");
     valid_name = null;
   } else if (!edt.getText().toString().matches("[a-zA-Z ]+")) {
     edt.setError("Accept Alphabets Only.");
     valid_name = null;
   } else {
     valid_name = edt.getText().toString();
   }
 }
  /** Adds a block-out time to the ArrayList stored by the activity. */
  public void addBlockoutTime(View view) {

    TimeShort newStartTime, newEndTime;

    newStartTime = getTime(startTimePicker);
    newEndTime = getTime(endTimePicker);

    ArrayList<Day> newDayList = getDays();
    if (!(newDayList.size() > 0)) {
      AlertDialog.Builder noDaysErrorDialog = new AlertDialog.Builder(SelectBlockoutTimes.this);
      noDaysErrorDialog.setTitle("Can't block out a time with no days");
      // noDaysErrorDialog.setPositiveButton("OKAY", null);
      noDaysErrorDialog.show();
      return;
    }

    String blockoutTimeName = nameBlockoutTime.getText().toString();
    if (blockoutTimeName.equals("")) {
      nameBlockoutTime.setError("Please give this a name");
      nameBlockoutTime.requestFocus();
      return;
    } else {
      nameBlockoutTime.setError(null);
      nameBlockoutTime.setText("");
    }

    if (workRadioButton.isChecked()) {
      type = BlockType.WORK;
    } else if (commuteRadioButton.isChecked()) {
      type = BlockType.COMMUTE;
    } else if (sleepRadioButton.isChecked()) {
      type = BlockType.SLEEP;
    } else if (studyRadioButton.isChecked()) {
      type = BlockType.STUDY;
    } else if (otherRadioButton.isChecked()) {
      type = BlockType.OTHER;
    }

    Course newBlockoutCourse = new Course("BLOCKOUT", "BLOCKOUT", "BLOCKOUT");
    Section newBlockoutTime =
        new Section(
            Integer.parseInt(type.toString()),
            blockoutTimeName,
            "",
            newStartTime,
            newEndTime,
            newDayList,
            ClassStatus.OPEN,
            newBlockoutCourse);
    newBlockoutCourse.addSection(newBlockoutTime);

    currentBlockoutTimes.add(newBlockoutTime);
    blockoutTimesListAdapter.notifyDataSetChanged();
  }
Exemplo n.º 26
0
 private boolean isPasswordValid(String password, String passwordAgain) {
   if (password.length() < 6) {
     passwordView.setError(getString(R.string.error_invalid_password));
     return false;
   }
   if (!password.equals(passwordAgain)) {
     passwordView.setError(getString(R.string.error_passwords_do_not_match));
     return false;
   }
   return true;
 }
Exemplo n.º 27
0
 /**
  * Check for a valid password
  *
  * @param password Account password
  * @return Valid?
  */
 /* package */ boolean isPasswordValid(String password) {
   if (TextUtils.isEmpty(password)) {
     mPasswordView.setError(getString(R.string.error_field_required));
     return false;
   } else if (password.length() < 4) {
     mPasswordView.setError(getString(R.string.error_invalid_password));
     return false;
   } else {
     return true;
   }
 }
  /**
   * Checks if text of given EditText is not empty. If it is empty an error is set and the EditText
   * gets the focus.
   *
   * @param editText
   * @return true if EditText is not empty
   */
  private boolean isMainEmailValid(EditText editText) {
    boolean output = true;
    if (!checkEmail(editText.getText().toString(), false)) {
      editText.setError(getString(R.string.create_key_empty));
      editText.requestFocus();
      output = false;
    } else {
      editText.setError(null);
    }

    return output;
  }
Exemplo n.º 29
0
  private boolean validateTextArea() {
    txtMessage = (EditText) findViewById(R.id.txtMessage_Post);

    message = txtMessage.getText().toString();
    if (TextUtils.isEmpty(message)) {
      txtMessage.setError("Please enter the title !");
      return false;
    } else {
      txtMessage.setError(null);
      return true;
    }
  }
Exemplo n.º 30
0
  /**
   * Email validation
   *
   * @param editText
   * @return
   */
  public static boolean isEmailValid(EditText editText) {
    String text = editText.getText().toString().trim();
    editText.setError(null);

    // whitespace
    if (hasWhitespace(text)) {
      editText.setError(ERROR_EMAIL_FORMAT);
      return false;
    }

    return isValid(editText, EMAIL_FORMAT_REGEX, ERROR_EMAIL_FORMAT, true);
  }