예제 #1
0
  private void initOutgoing() {

    smtps.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            Log.i(I, "clicked on SMTPS");
            port.setText(SendMailProtocol.SMTPS.standardPort() + "");
          }
        });

    smtp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            Log.i(I, "clicked on SMTP");
            port.setText(SendMailProtocol.SMTP.standardPort() + "");
          }
        });

    SendMailConnection conn = userAccount.getConfiguration().getSendMailConncetions().get(0);

    String value = "";

    value = conn.getSenderAddress().getValue();
    if (value != "") {
      adress.setText(value);
      value = "";
    }
    value = conn.getHost().getValue();
    if (value != "") {
      host.setText(value);
      value = "";
    }
    value = conn.getPassword().getValue();
    if (value != "") {
      password.setText(value);
      value = "";
    }
    value = conn.getUsername().getValue();
    if (value != "") {
      username.setText(value);
      value = "";
    }
    value = conn.getPort().getValue();
    if (value != "") {
      port.setText(value);
    }
    value = conn.getProtocol().lowerCaseName();
    if (value != "") {
      String name = conn.getProtocol().lowerCaseName();
      if (name == "smtp") {
        smtp.setChecked(true);
        name = "";
      }
      name = conn.getProtocol().lowerCaseName();
      if (name == "smtps") {
        smtps.setChecked(true);
      }
    }
  }
예제 #2
0
  private void saveSendMailSettings(View v) {
    Configuration conf = userAccount.getConfiguration();
    AttributeList<SendMailConnection> conList = conf.getSendMailConncetions();
    SendMailConnection con = conList.get(0);

    con.setHost(new SingleAttribute<String>("host", host.getText().toString()));
    con.setPort(new SingleAttribute<String>("port", port.getText().toString()));
    Log.i(I, "adress test: ** " + adress.getText().toString());
    con.setSenderAddress(new SingleAttribute<String>("senderAddress", adress.getText().toString()));
    con.setUsername(new SingleAttribute<String>("username", username.getText().toString()));
    con.setPassword(new SingleAttribute<String>("password", password.getText().toString()));

    if (smtp.isChecked()) {
      SendMailProtocol smtp = SendMailProtocol.SMTP;
      con.setProtocol(smtp);
    }
    if (smtps.isChecked()) {
      SendMailProtocol smtps = SendMailProtocol.SMTPS;
      con.setProtocol(smtps);
    }
    ArrayList<SendMailConnection> attributes = new ArrayList<SendMailConnection>();
    attributes.add(con);
    conList.setAttributes(attributes);
    conf.setSendMailConnections(conList);
    userAccount.setConfiguration(conf);
    try {
      AccountManager am = new AccountManager();
      am.encryptAndSaveAccount(
          userAccount, HelloWorldBasic.getUsername(), HelloWorldBasic.getPassword(), null);
      SettingsChooser.setSuccessMessage("Outgoing Mail");
      goBackToSettingsChooser();
    } catch (Exception e) {
      Toast.makeText(this, "Sorry, settings couldn't be saved", Toast.LENGTH_LONG).show();
    }
  }