Package android.widget

Examples of android.widget.EditText


    Log.d(LOG_TAG, "LoginActivity.onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login);

    // Setup the behaviour of the password edit view.
    EditText password = (EditText)findViewById(R.id.login_password);
    password.setOnKeyListener(new View.OnKeyListener() {
      @Override
      public boolean onKey(View v, int keyCode, KeyEvent event) {
        // In the Android 1.1 platform, I used to use a click listener, since
        // pressing the Enter key would generate that event.  However, in
        // Android 1.5 (cupcake) that no longer works.  Therefore I trap the
        // Enter key here with a key listener, and try handling the password
        // when the Enter key is released (action up).  Note that in 1.1 though,
        // if I completely ignore the Enter key action down, I get a popup menu
        // with a paste command.  To get around this, I always return true if
        // the Enter key is pressed or released, but I only try to handle the
        // password on release.  This works for both 1.1 and 1.5.  The Enter
        // does not become part of the password.
        if (KeyEvent.KEYCODE_ENTER == keyCode) {
          if (KeyEvent.ACTION_UP == event.getAction())
            handlePasswordClick((TextView) v);

          return true;
        }

        return false;
      }
    });

    // Further, we need to add ourselves as a TextWatcher of the password edit
    // view. This is because as of Android 1.6, characters are no longer passed
    // to onKey above. However, some keys, including Enter, are still processed
    // by onKey, so the above code is fine and probably needs to stay.
    password.addTextChangedListener(this);
   
    FileUtils.cleanupDataFiles(this);
    Log.d(LOG_TAG, "LoginActivity.onCreate done");
  }
View Full Code Here


    // If there is state information, use it to initialize the activity.
    if (null != state) {
      isEditing = state.getBoolean(STATE_IS_EDITING);
      if (isEditing) {
        EditText description = (EditText) findViewById(R.id.list_description);
        EditText password = (EditText) findViewById(R.id.list_password);
        EditText notes = (EditText) findViewById(R.id.list_notes);

        editingPosition = state.getInt(STATE_EDITING_POSITION);
        description.setText(state.getCharSequence(STATE_EDITING_DESCRIPTION));
        username.setText(state.getCharSequence(STATE_EDITING_USERNAME));
        password.setText(state.getCharSequence(STATE_EDITING_PASSWORD));
        email.setText(state.getCharSequence(STATE_EDITING_EMAIL));
        notes.setText(state.getCharSequence(STATE_EDITING_NOTES));

        getListView().setVisibility(View.GONE);
        edit.setVisibility(View.VISIBLE);
      }
    }
View Full Code Here

      case R.id.list_discard:
        animateFromEditView();
        break;
      case R.id.list_generate_password: {
        String pwd = generatePassword();
        EditText password = (EditText) findViewById(R.id.list_password);
        password.setText(pwd);
        break;
      }
      case R.id.list_backup:
        backupSecrets();
        break;
View Full Code Here

    state.putBoolean(STATE_IS_EDITING, isEditing);

    if (isEditing) {
      saveSecret();

      EditText description = (EditText) findViewById(R.id.list_description);
      EditText username = (EditText) findViewById(R.id.list_username);
      EditText password = (EditText) findViewById(R.id.list_password);
      EditText email = (EditText) findViewById(R.id.list_email);
      EditText notes = (EditText) findViewById(R.id.list_notes);

      state.putInt(STATE_EDITING_POSITION, editingPosition);
      state.putCharSequence(STATE_EDITING_DESCRIPTION, description.getText());
      state.putCharSequence(STATE_EDITING_USERNAME, username.getText());
      state.putCharSequence(STATE_EDITING_PASSWORD, password.getText());
      state.putCharSequence(STATE_EDITING_EMAIL, email.getText());
      state.putCharSequence(STATE_EDITING_NOTES, notes.getText());
    }

    Log.d(LOG_TAG, "SecretsListActivity.onSaveInstanceState");
  }
View Full Code Here

   * @param position Position of secret to edit.
   */
  private void SetEditViews(int position) {
    editingPosition = position;

    EditText description = (EditText) findViewById(R.id.list_description);
    EditText username = (EditText) findViewById(R.id.list_username);
    EditText password = (EditText) findViewById(R.id.list_password);
    EditText email = (EditText) findViewById(R.id.list_email);
    EditText notes = (EditText) findViewById(R.id.list_notes);

    if (AdapterView.INVALID_POSITION == position) {
      description.setText(EMPTY_STRING);
      username.setText(EMPTY_STRING);
      password.setText(EMPTY_STRING);
      email.setText(EMPTY_STRING);
      notes.setText(EMPTY_STRING);

      description.requestFocus();
    } else {
      Secret secret = secretsList.getSecret(position);

      description.setText(secret.getDescription());
      username.setText(secret.getUsername());
      password.setText(secret.getPassword(false));
      email.setText(secret.getEmail());
      notes.setText(secret.getNote());

      password.requestFocus();
    }

    ScrollView scroll = (ScrollView) findViewById(R.id.edit_layout);
View Full Code Here

   * Secrets will be added in alphabetical order by description.
   *
   * All secrets are flushed to persistent storage.
   */
  private void saveSecret() {
    EditText description = (EditText) findViewById(R.id.list_description);
    EditText username = (EditText) findViewById(R.id.list_username);
    EditText password = (EditText) findViewById(R.id.list_password);
    EditText email = (EditText) findViewById(R.id.list_email);
    EditText notes = (EditText) findViewById(R.id.list_notes);

    // If all the text views are blank, then don't do anything if we are
    // supposed to be adding a secret.  Also, if all the views are
    // the same as the current secret, don't do anything either.
    Secret secret;
    String description_text = description.getText().toString();
    String username_text = username.getText().toString();
    String password_text = password.getText().toString();
    String email_text = email.getText().toString();
    String note_text = notes.getText().toString();

    if (AdapterView.INVALID_POSITION == editingPosition) {
      if (0 == description.getText().length() &&
          0 == username.getText().length() &&
          0 == password.getText().length() &&
          0 == email.getText().length() &&
          0 == notes.getText().length())
        return;

      secret = new Secret();
    } else {
      secret = secretsList.getSecret(editingPosition);

      if (description_text.equals(secret.getDescription()) &&
          username_text.equals(secret.getUsername()) &&
          password_text.equals(secret.getPassword(false)) &&
          email_text.equals(secret.getEmail()) &&
          note_text.equals(secret.getNote()))
        return;

      secretsList.remove(editingPosition);
    }

    secret.setDescription(description.getText().toString());
    secret.setUsername(username.getText().toString());
    secret.setPassword(password.getText().toString());
    secret.setEmail(email.getText().toString());
    secret.setNote(notes.getText().toString());

    editingPosition = secretsList.insert(secret);
    secretsList.notifyDataSetChanged();
  }
View Full Code Here

TOP

Related Classes of android.widget.EditText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.