private void performSubmitClick() {
    if (noteText.getTag() != null) {
      sanitizer.testForScriptures(bible, noteText.getText().toString());
      mCallbacks.onSubmitClicked(
          noteText.getText().toString(), getNoteType(), (INote) noteText.getTag());
    } else {
      sanitizer.testForScriptures(bible, noteText.getText().toString());
      mCallbacks.onSubmitClicked(noteText.getText().toString(), getNoteType(), null);
    }

    noteText.setText("");
    noteText.setTag(null);
  }
Example #2
0
 @Override
 public void onClick(View v) {
   final SharedPreferences settings = MyApplication.getInstance().getSettings();
   final String securityQuestion = MyApplication.PrefKey.SECURITY_QUESTION.getString("");
   EditText input = (EditText) dialog.findViewById(R.id.password);
   TextView error = (TextView) dialog.findViewById(R.id.passwordInvalid);
   if (v == dialog.getButton(AlertDialog.BUTTON_NEGATIVE)) {
     if ((Boolean) input.getTag()) {
       input.setTag(Boolean.valueOf(false));
       ((Button) v).setText(R.string.password_lost);
       dialog.setTitle(R.string.password_prompt);
     } else {
       input.setTag(Boolean.valueOf(true));
       dialog.setTitle(securityQuestion);
       ((Button) v).setText(android.R.string.cancel);
     }
   } else {
     String value = input.getText().toString();
     boolean isInSecurityQuestion = (Boolean) input.getTag();
     if (Utils.md5(value)
         .equals(
             (isInSecurityQuestion
                     ? MyApplication.PrefKey.SECURITY_ANSWER
                     : MyApplication.PrefKey.SET_PASSWORD)
                 .getString(""))) {
       input.setText("");
       error.setText("");
       MyApplication.getInstance().setLocked(false);
       ctx.findViewById(android.R.id.content).setVisibility(View.VISIBLE);
       if (ctx instanceof ActionBarActivity) {
         ((ActionBarActivity) ctx).getSupportActionBar().show();
       }
       if (isInSecurityQuestion) {
         MyApplication.PrefKey.PERFORM_PROTECTION.putBoolean(false);
         Toast.makeText(
                 ctx.getBaseContext(), R.string.password_disabled_reenable, Toast.LENGTH_LONG)
             .show();
         dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setText(R.string.password_lost);
         dialog.setTitle(R.string.password_prompt);
         input.setTag(Boolean.valueOf(false));
       }
       dialog.dismiss();
     } else {
       input.setText("");
       error.setText(
           isInSecurityQuestion
               ? R.string.password_security_answer_not_valid
               : R.string.password_not_valid);
     }
   }
 }
        @Override
        public void onClick(View v) {
          if (mMaopaoObject == null) {
            showButtomToast(R.string.maopao_load_fail_comment);
            return;
          }

          EditText content = mEnterLayout.content;
          String input = content.getText().toString();

          if (EmojiFilter.containsEmptyEmoji(v.getContext(), input)) {
            return;
          }

          Maopao.Comment comment = (Maopao.Comment) content.getTag();
          String uri = String.format(ADD_COMMENT, comment.tweet_id);

          RequestParams params = new RequestParams();

          String contentString;
          if (comment.id == 0) {
            contentString = Global.encodeInput("", input);
          } else {
            contentString = Global.encodeInput(comment.owner.name, input);
          }
          params.put("content", contentString);
          postNetwork(uri, params, ADD_COMMENT, 0, comment);

          showProgressBar(R.string.sending_comment);
        }
Example #4
0
 @Override
 public void afterTextChanged(Editable s) {
   if (!mReady) {
     return;
   }
   EntryHolder holder = (EntryHolder) mHost.getTag();
   String text = s.toString();
   if (mHost.getId() == R.id.field_name) {
     holder.mEntryItem.mName = text;
   } else {
     holder.mEntryItem.mValue = text;
   }
   boolean savable = false;
   if (!text.isEmpty()) {
     savable = true;
     for (EntryHolder eh : mEntries) {
       if (eh.mEntryItem.mName.isEmpty() || eh.mEntryItem.mValue.isEmpty()) {
         savable = false;
         break;
       }
     }
   }
   mSavable = savable;
   changeSaveStatus();
 }
 public void onFocusChange(View view, boolean hasFocus) {
   EditText currentEditField = (EditText) view;
   if (!hasFocus) {
     if (currentEditField.getText() != null) {
       valueList.put(
           currentEditField.getTag().toString(), currentEditField.getText().toString());
     }
   }
 }
 private void saveOrder(Order orderToSave) {
   valueList.put("_id", currentOrder.getOrderId());
   for (EditText fieldToSave : editFields) {
     if (fieldToSave.getText() != null) {
       valueList.put(fieldToSave.getTag().toString(), fieldToSave.getText().toString());
     }
   }
   orderToSave.setOrderValues(valueList);
   if (orderToSave.save()) {
     Toast toast =
         Toast.makeText(
             MainActivity.appContext,
             "Order " + orderToSave.getOrderId() + " saved",
             Toast.LENGTH_LONG);
     toast.show();
   }
 }
        @Override
        public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
          EditText currentField = (EditText) view;
          View nextField = mainLayout.findViewById(view.getNextFocusDownId());
          String currentFieldTag = (String) currentField.getTag();
          if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) {
            if (currentField.getText() != null) {
              valueList.put(currentFieldTag, currentField.getText().toString());
            }
            if (nextField != null) {
              nextField.requestFocus();
            }
            return true;
          }

          return false;
        }
Example #8
0
 @Override
 public void onFocusChange(View v, boolean hasFocus) {
   EditText textView = (EditText) v;
   InputMethodManager imm =
       (InputMethodManager)
           textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
   String hint;
   if (hasFocus) {
     hint = textView.getHint().toString();
     textView.setTag(hint);
     textView.setHint("");
     imm.showSoftInput(textView, InputMethodManager.SHOW_FORCED);
   } else {
     hint = textView.getTag().toString();
     textView.setHint(hint);
   }
 }
Example #9
0
  @Override
  public EnterCompany handleResponse(HttpResponse response)
      throws ClientProtocolException, IOException {
    // No need to do anything here... Other than display a success dialog which may be more of a
    // hindrance.
    // what's returned is an id for the Company added.  I'm not going to store this since we have to
    // query to get
    // that id later anyway.  Might as well let the api do the work.
    //		Toast.makeText(this, "Add Company Completed", Toast.LENGTH_LONG).show();
    HttpEntity httpEntity = response.getEntity();
    InputStream inputStream = httpEntity.getContent();
    LineNumberReader lnr = new LineNumberReader(new InputStreamReader(inputStream));
    String currentString;
    while ((currentString = lnr.readLine()) != null) {
      Log.v("TeamLeader", "httpResponse:" + currentString);

      if (!currentString.equals("\"OK\""))
        try {
          int id = Integer.parseInt(currentString);
          company.setId(id);

        } catch (NumberFormatException nfe) {
          nfe.printStackTrace();
        }
    }

    // if the Person was set, link them
    person = (Person) linkPersonEditText.getTag();
    if (person != null && !personLinked) {
      RESTfulAPI restAPI2 = new RESTfulAPI(this, null, progressDialog);
      restAPI2.linkCompanyToPerson(company, person);
      personLinked = true;
      finish();
    } else finish();
    return null;
  }
 /**
  * Adds a validator that updates every time a user modifies an EditText view and indicates if the
  * field meets certain criteria
  *
  * @param t EditText object to listen to
  */
 public static void onTextChangedValidator(final EditText t) {
   Validator val;
   // --- Use input type to determine how to validate
   switch (t.getInputType()) {
     case (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD):
       // Implement the interface to pass function as parameter
       val =
           new Validator() {
             public Errors validate(String s) {
               return Validate.validatePasswordField(s);
             }
           };
       // Create onTextChangedValidator
       addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS):
       // Implement the interface to pass function as parameter
       val =
           new Validator() {
             public Errors validate(String s) {
               return Validate.validateEmailField(s);
             }
           };
       // Create onTextChangedValidator
       addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME):
       // Implement the interface to pass function as parameter
       if (t.getTag().toString().equalsIgnoreCase(Constants.VIEW_HINT_FIRST_NAME)) {
         val =
             new Validator() {
               public Errors validate(String s) {
                 return Validate.validateFirstNameField(s);
               }
             };
       } else if (t.getTag().toString().equalsIgnoreCase(Constants.VIEW_HINT_STATE)) {
         val =
             new Validator() {
               public Errors validate(String s) {
                 return Validate.validateStateField(s);
               }
             };
       } else if (t.getTag().toString().equalsIgnoreCase(Constants.VIEW_HINT_CITY)) {
         val =
             new Validator() {
               public Errors validate(String s) {
                 return Validate.validateCityField(s);
               }
             };
       } else {
         val =
             new Validator() {
               public Errors validate(String s) {
                 return Validate.validateLastNameField(s);
               }
             };
       }
       // Create onTextChangedValidator
       addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS):
       // Implement the interface to pass function as parameter
       val =
           new Validator() {
             public Errors validate(String s) {
               return Validate.validateAddressField(s);
             }
           };
       // Create onTextChangedValidator
       addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL):
       // Implement the interface to pass function as parameter
       if (t.getTag().toString().equalsIgnoreCase(Constants.VIEW_HINT_ZIPCODE)) {
         val =
             new Validator() {
               public Errors validate(String s) {
                 return Validate.validateZipcodeField(s);
               }
             };
       }
       // Create onTextChangedValidator
       // addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL):
       // Implement the interface to pass function as parameter
       // val = new Validator() {	public Errors validate(String s) {return
       // Validate.validateTextField(s);}};
       // Create onTextChangedValidator
       // addOnTextChangedValidator(t, val);
       break;
     case (InputType.TYPE_CLASS_PHONE):
       // Implement the interface to pass function as parameter
       val =
           new Validator() {
             public Errors validate(String s) {
               return Validate.validateSSNField(s);
             }
           };
       // Create onTextChangedValidator
       addOnTextChangedValidator(t, val);
       break;
     default:
       // If inputType doesn't match, then don't validate
       break;
   }
 }