Example #1
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();
    }
  }
Example #2
0
  private void saveFTPSettings(View v) {
    Configuration conf = userAccount.getConfiguration();
    AttributeList<FileTransferConnection> conList = conf.getFileTransferConncetions();
    FileTransferConnection con = conList.get(0);

    con.setHost(new SingleAttribute<String>("host", host.getText().toString()));
    con.setPort(new SingleAttribute<String>("port", port.getText().toString()));
    con.setUsername(new SingleAttribute<String>("username", username.getText().toString()));
    con.setPassword(new SingleAttribute<String>("password", password.getText().toString()));
    con.setHttpUrl(new SingleAttribute<String>("httpurl", httpUrl.getText().toString()));

    if (ftp.isChecked()) {
      FileTransferProtocol ftp = FileTransferProtocol.FTP;
      con.setProtocol(ftp);
    }
    if (sftp.isChecked()) {
      FileTransferProtocol sftp = FileTransferProtocol.SFTP;
      con.setProtocol(sftp);
    }
    ArrayList<FileTransferConnection> attributes = new ArrayList<FileTransferConnection>();
    attributes.add(con);
    conList.setAttributes(attributes);
    conf.setFileTransferConnections(conList);
    userAccount.setConfiguration(conf);

    try {
      AccountManager am = new AccountManager();
      am.encryptAndSaveAccount(
          userAccount, HelloWorldBasic.getUsername(), HelloWorldBasic.getPassword(), null);
      SettingsChooser.setSuccessMessage("FTP");
      goBackToSettingsChooser();
    } catch (Exception e) {
      Toast.makeText(this, "Sorry, settings couldn't be saved", Toast.LENGTH_LONG).show();
    }
  }