Example #1
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);
     }
   }
 }
Example #2
0
 /**
  * Helper method to set the tags of each user_account_create field. The tags will be used for
  * validation checks.
  */
 private void setRegistrationTags() {
   EditText text;
   for (int i = 0; i < Constants.USER_ACCOUNT_CREATE_IDS.length; i++) {
     text = (EditText) findViewById(Constants.USER_ACCOUNT_CREATE_IDS[i]);
     text.setTag(Constants.USER_ACCOUNT_CREATE_NAMES[i]);
   }
 }
 void init(int position, ItemPartial currentItem) {
   initListeners();
   qtyEditText.setTag(Integer.valueOf(position));
   tick.setTag(position);
   itemName.setText(currentItem.getItemName());
   subHeading.setText(currentItem.getDescription());
   price.setText("" + currentItem.getMrp());
 }
 @Override
 public void updateEditorText(String newEditorText, @Nullable INote note) {
   // THIS METHOD SHOULD BE CALLED WHEN THE USER EDITS A NOTE
   // THE NOTE ID IS PROVIDED HERE.
   // RETURN THE NOTE ID AS A PARAMETER WITH THE CALLBACK METHOD
   // onSubmitClicked(text, type, noteId) TO NOTIFY APP TO MODIFY
   // EXISTING NOTE.
   // TODO: MICAH delegate method
   awesomeTextViewHandler.setText(note.getNoteText());
   noteText.setTag(note);
 }
  void prepareAddComment(Object data, boolean popKeyboard) {
    Maopao.Comment comment = null;
    EditText content = mEnterLayout.content;
    if (data instanceof Maopao.Comment) {
      comment = (Maopao.Comment) data;
      content.setHint("回复 " + comment.owner.name);
      content.setTag(comment);
    } else if (data instanceof Maopao.MaopaoObject) {
      comment = new Maopao.Comment((Maopao.MaopaoObject) data);
      content.setHint("评论冒泡");
      content.setTag(comment);
    }

    mEnterLayout.restoreLoad(comment);

    if (popKeyboard) {
      content.requestFocus();
      Global.popSoftkeyboard(MaopaoDetailActivity.this, content, true);
    }
  }
  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 #7
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case GET_PERSON_ID:
        person = (Person) data.getSerializableExtra("person");
        person.toString();
        company.set("person", person.get("id"));
        Log.v("TeamLeader", "this company will be linked to person: " + person.get("id"));

        linkPersonEditText.setText(person.getName());
        linkPersonEditText.setTag(person);
        break;
    }
  }
  /**
   * Opens reset password prompt (AlertDialog)
   *
   * @param error String (seeds the error message) TODO: change to strings.xml
   */
  private void resetPassword(String error) {

    final EditText email = new EditText(this);
    email.setTag("email-input");
    email.setHint(getString(R.string.label_email_address));
    email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    if (!error.equals("")) {
      email.setError(error);
    }
    this.emailViewId = email.getId();

    final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setView(email);
    dialogBuilder.setTitle(getString(R.string.label_reset_password));
    dialogBuilder.setMessage(String.format(getString(R.string.dialog_reset_password_email)));
    dialogBuilder.setCancelable(true);
    DialogInterface.OnClickListener onClickListener =
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int whichButton) {
            emailAddress = email.getText().toString();
            email.invalidate();
            dialog.cancel();
            emailDomain = LewaUtils.validateEmail(emailAddress, true);
            Log.d(TAG, "emailAddress: " + emailAddress);
            Message message = Message.obtain();
            if (emailDomain != "" && !emailDomain.equals("")) {
              message.what = USER_INPUT_VALID;
            } else {
              message.what = USER_INPUT_INVALID;
            }
            resetPasswordHandler.sendMessageDelayed(message, 500); // adding
            // delay
            // will
            // hopefully
            // ensure
            // that
            // alertdialog
            // closed
            // and
            // progress
            // dialog
            // shown
          }
        };
    dialogBuilder.setPositiveButton(getString(R.string.label_ok), onClickListener);
    dialogBuilder.show();
  }
Example #9
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 #10
0
 public FormBuilder addTextField(String textLabel, String tag, String value, TextWatcher tw) {
   TextView tv = new TextView(context);
   tv.setTextColor(theme.getTextColor());
   tv.setLayoutParams(new LayoutParams(theme.getLabelWidth(), theme.getLabelHeight()));
   tv.setVisibility(View.VISIBLE);
   tv.setText(textLabel);
   ll.addView(tv);
   EditText te = new EditText(context);
   if (value != null) {
     te.setText(value);
   }
   te.setVisibility(View.VISIBLE);
   te.setTextColor(theme.getTextColor());
   te.setLayoutParams(new LayoutParams(theme.getLabelWidth(), theme.getLabelHeight()));
   te.setTag(tag);
   if (tw != null) te.addTextChangedListener(tw);
   ll.addView(te);
   return this;
 }
  private void prepareConfirmationEmail(final LewaUser user) {

    final EditText email = new EditText(getApplicationContext());
    email.setTag("email-input");
    email.setHint(getString(R.string.label_email_address));
    email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    String newEmailAddress = email.getEditableText().toString().toLowerCase().trim();
    if (newEmailAddress.equals("")) newEmailAddress = user.getEmailAddressNew();
    if (!newEmailAddress.equals("") && !newEmailAddress.equals(user.getEmailAddressNew())) {
      user.setEmailAddress(newEmailAddress);
      user.setEmailAddressNew(newEmailAddress);
    }
    final ProgressDialog resendVerificationProgressDialog =
        ProgressDialog.show(
            LewaLoginActivity.this,
            getString(R.string.label_email_verification),
            String.format(
                "%s: %s",
                getString(R.string.dialog_resend_verification_email), user.getEmailAddress()),
            true,
            true,
            new OnCancelListener() {
              @Override
              public void onCancel(DialogInterface dialog) {
                dialog.dismiss();
              }
            });
    Thread thread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                Looper.prepare();
                lewaAuthService.resendActivationEmail(
                    new SendConfirmEmailHandler(resendVerificationProgressDialog), user);
              }
            });
    thread.start();
  }
  private void resendConfirmationEmail(String error) {

    final LewaUser user = LewaUser.getInstance(getApplicationContext());
    final EditText email = new EditText(getApplicationContext());
    email.setTag("email-input");
    email.setHint(getString(R.string.label_email_address));
    email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    email.setText(user.getEmailAddressNew());
    if (!error.equals("")) {
      email.setError(error);
    }
    this.emailViewId = email.getId();
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(getString(R.string.label_email_verification));
    alert.setMessage(getString(R.string.dialog_resend_verification_email));
    alert.setView(email);
    alert.setCancelable(true);
    alert.setPositiveButton(
        getString(R.string.label_ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            email.invalidate();
            dialog.cancel();
            String emailAddress = email.getEditableText().toString().trim().toLowerCase();
            String emailDomain = LewaUtils.validateEmail(emailAddress, true);
            Message message = Message.obtain();
            if (emailDomain != "") {
              user.setEmailAddress(emailAddress);
              message.what = USER_INPUT_VALID;
            } else {
              message.what = USER_INPUT_INVALID;
            }
            confirmEmailHandler.sendMessageDelayed(message, 1500);
          }
        });
    alert.show();
  }
Example #13
0
  /**
   * Creates a row in signals table to store the signal sources checkboxs. Returns the signal
   * sources checkboxs container.
   *
   * @param signalTypeId
   * @return
   */
  public LinearLayout getSourcesCheckboxsContainer(String signalTypeId) {
    // Is there already a row for this signal type?
    LinearLayout checkboxContainer;
    ArrayList<View> containers =
        AndroidUtil.getViewsByTag(this, signalTypeId + "-checkboxContainer");
    if (containers.size() == 0) { // There is NO row

      TableRow row = new TableRow(this);
      TableRow.LayoutParams lp =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
      row.setLayoutParams(lp);
      row.setTag(signalTypeId + "-row");

      // Signal name.
      TextView signalType = new TextView(this);
      signalType.setText(signalTypeId);
      signalType.setTextColor(Color.BLACK);
      signalType.setBackgroundResource(R.drawable.table_border);
      signalType.setLayoutParams(
          new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, 17f));
      signalType.setGravity(Gravity.CENTER);

      // Signal samples (of each source).
      EditText signalSamples = new EditText(this);
      signalSamples.setInputType(InputType.TYPE_CLASS_NUMBER);
      signalSamples.setBackgroundResource(R.drawable.table_border);
      signalSamples.setTag(signalTypeId + "-samples");
      signalSamples.setLayoutParams(
          new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, 17f));
      signalSamples.setText(
          Preferences.readString(
              this.getClass().getSimpleName(),
              "Signal_" + signalTypeId,
              DEFAULT_SAMPLES_COUNT + ""));
      signalSamples.setTextColor(Color.BLACK);
      signalSamples.setEms(10);

      // Container for sources checkboxs.
      checkboxContainer = new LinearLayout(this);
      checkboxContainer.setOrientation(LinearLayout.HORIZONTAL);
      checkboxContainer.setTag(signalTypeId + "-checkboxContainer");
      // checkboxContainer.setLayoutParams(new TableRow.LayoutParams(0,
      // TableRow.LayoutParams.MATCH_PARENT, 60f));

      LinearLayout left = new LinearLayout(this);
      left.setOrientation(LinearLayout.VERTICAL);
      LinearLayout right = new LinearLayout(this);
      right.setOrientation(LinearLayout.VERTICAL);
      checkboxContainer.addView(left);
      checkboxContainer.addView(right);

      row.addView(signalType);
      row.addView(signalSamples);

      ScrollViewWithMaxHeight scrollView = new ScrollViewWithMaxHeight(this);
      scrollView.setMaxHeight(500);
      // ScrollView scrollView = new ScrollView(this);
      scrollView.setLayoutParams(
          new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, 66f));
      scrollView.addView(checkboxContainer);
      row.addView(scrollView);
      // row.addView(checkboxContainer);

      TableLayout table = (TableLayout) findViewById(R.id.signalsTable);
      table.addView(row);
    } else // There is a row
    {
      checkboxContainer = (LinearLayout) containers.get(0);
    }

    return checkboxContainer;
  }
Example #14
0
  private void initMyGroupView() {
    ll = (LinearLayout) findViewById(R.id.l1);
    DisplayMetrics metric = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metric);
    /**
     * *******************************************************************************************
     */
    mvg = new MyViewGroup(NewSMSActivity.this);
    mvg.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 70));
    //		mvg.setBackgroundColor(Color.GREEN);
    etMess = new EditText(NewSMSActivity.this);
    etMess.setFilters(new InputFilter[] {new InputFilter.LengthFilter(15)});
    etMess.setSelection(etMess.getText().length());
    etMess.setGravity(Gravity.CENTER_VERTICAL);
    etMess.setMinWidth(100);
    etMess.setHeight(60);
    etMess.setTag("edit");
    etMess.getBackground().setAlpha(0);
    etMess.setId(extiTextId);
    etMess.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {

            if (isNum(s.toString())) {
              if (s.length() >= 1) {
                boolean bool = false;
                // length() == 15直接生成按钮
                if (s.length() == 15) {
                  bool = true;
                }
                // 字数没有满足15个验证是否有空格
                if (!bool) {
                  String c = s.toString().substring(start, start + count);
                  for (int i = 0; i < chars.length; i++) {
                    if (chars[i].equals(c)) {
                      bool = true;
                      break;
                    }
                  }
                }
                // bool == true 生成Button
                if (bool) {
                  createView1(s.toString(), s.toString());
                  etMess.setText("");
                }
                // 检测输入框数据是否已经换行
                final View child = mvg.getChildAt(mvg.getChildCount() - 1);
                autoHeight(child);
              }
            } else {
              adapter.getFilter().filter(s);
              queryListView.setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
    mvg.addView(etMess);
    ll.addView(mvg);
    etMess.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              if (isNum(etMess.getText().toString().trim())) {
                createView1(etMess.getText().toString().trim(), etMess.getText().toString().trim());
                etMess.setText("");
              } else {
                etMess.setText("");
                queryListView.setVisibility(View.INVISIBLE);
              }
            }
          }
        });
  }
  public void showOrder(Order order) {
    currentOrder = order;
    valueList = currentOrder.getOrderValues();
    editFields = new ArrayList<EditText>();

    if (mainLayout != null) {

      Button saveButton = (Button) getActivity().findViewById(R.id.saveButton);
      saveButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              saveOrder(currentOrder);
              fragmentListener.saveOrderButtonClicked();
            }
          });

      CheckBox execStateCheckBox = (CheckBox) getActivity().findViewById(R.id.execStateCheckBox);
      execStateCheckBox.setChecked(currentOrder.getExecState());
      execStateCheckBox.setOnCheckedChangeListener(
          new CheckBox.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              currentOrder.setExecState(isChecked);
              valueList.put("execState", isChecked);
            }
          });

      EditText clientNameEdit = (EditText) mainLayout.findViewById(R.id.clientNameEdit);
      clientNameEdit.setOnKeyListener(onTextChanged);
      clientNameEdit.setOnFocusChangeListener(onFocusLost);
      clientNameEdit.setText(currentOrder.getClientName());
      clientNameEdit.setTag("clientName");
      editFields.add(clientNameEdit);

      EditText clientPhoneEdit = (EditText) mainLayout.findViewById(R.id.clientPhoneEdit);
      clientPhoneEdit.setOnKeyListener(onTextChanged);
      clientPhoneEdit.setOnFocusChangeListener(onFocusLost);
      clientPhoneEdit.setText(currentOrder.getClientPhone());
      clientPhoneEdit.setTag("clientPhone");
      editFields.add(clientPhoneEdit);

      EditText carMakerEdit = (EditText) mainLayout.findViewById(R.id.carMakerEdit);
      carMakerEdit.setOnKeyListener(onTextChanged);
      carMakerEdit.setOnFocusChangeListener(onFocusLost);
      carMakerEdit.setText(currentOrder.getCarMaker());
      carMakerEdit.setTag("carMaker");
      editFields.add(carMakerEdit);

      EditText colorCodeEdit = (EditText) mainLayout.findViewById(R.id.colorCodeEdit);
      colorCodeEdit.setOnKeyListener(onTextChanged);
      colorCodeEdit.setOnFocusChangeListener(onFocusLost);
      colorCodeEdit.setText(currentOrder.getColorCode());
      colorCodeEdit.setTag("colorCode");
      editFields.add(colorCodeEdit);

      EditText volumeBaseEdit = (EditText) mainLayout.findViewById(R.id.volumeBaseEdit);
      volumeBaseEdit.setOnKeyListener(onTextChanged);
      volumeBaseEdit.setOnFocusChangeListener(onFocusLost);
      volumeBaseEdit.setFilters(new InputFilter[] {new RealNumberInputFilter()});
      volumeBaseEdit.setText(currentOrder.getVolumeBase().toString());
      volumeBaseEdit.setTag("volumeBase");
      editFields.add(volumeBaseEdit);

      EditText volumeAdditionEdit = (EditText) mainLayout.findViewById(R.id.volumeAdditionEdit);
      volumeAdditionEdit.setOnKeyListener(onTextChanged);
      volumeAdditionEdit.setOnFocusChangeListener(onFocusLost);
      volumeAdditionEdit.setFilters(new InputFilter[] {new RealNumberInputFilter()});
      volumeAdditionEdit.setText(currentOrder.getVolumeAddition().toString());
      volumeAdditionEdit.setTag("volumeAddition");
      editFields.add(volumeAdditionEdit);

      EditText orderDateEdit = (EditText) mainLayout.findViewById(R.id.orderDateEdit);
      orderDateEdit.setOnKeyListener(onTextChanged);
      orderDateEdit.setOnFocusChangeListener(onFocusLost);
      orderDateEdit.setFilters(new InputFilter[] {new DateInputFilter()});
      orderDateEdit.setText(currentOrder.getOrderDate().toString());
      orderDateEdit.setTag("orderDate");
      editFields.add(orderDateEdit);

      EditText execDateEdit = (EditText) mainLayout.findViewById(R.id.execDateEdit);
      execDateEdit.setOnKeyListener(onTextChanged);
      execDateEdit.setOnFocusChangeListener(onFocusLost);
      execDateEdit.setFilters(new InputFilter[] {new DateInputFilter()});
      execDateEdit.setText(currentOrder.getExecDate().toString());
      execDateEdit.setTag("execDate");
      editFields.add(execDateEdit);

      NumberKeyListener realKeyListener =
          new NumberKeyListener() {
            @Override
            protected char[] getAcceptedChars() {
              return new char[] {'.', ',', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
            }

            @Override
            public int getInputType() {
              return TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_DECIMAL;
            }
          };
      volumeBaseEdit.setKeyListener(realKeyListener);
      volumeAdditionEdit.setKeyListener(realKeyListener);
    }
  }