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();
    }
  }
Example #3
0
  // @Override
  public void onCreate(Bundle bundle) {
    Log.i(I, "start Settings");
    super.onCreate(bundle);
    Bundle userdatabundle = getIntent().getExtras();
    chooser = userdatabundle.getInt("chooser");

    // VERY IMPORTANT: checks the settings and if the skeleton is not
    // available let it create by ConfigurationSkeletonMaker
    new AccountSettingsChecker();

    switch (chooser) {
      case 1:
        setContentView(R.layout.settings_incoming);
        incoming_button = (Button) findViewById(R.id.settings_incoming_button_save);
        incoming_button.setOnClickListener(this);
        initFields();
        initIncoming();
        break;
      case 2:
        setContentView(R.layout.settings_outgoing);
        outgoing_button = (Button) findViewById(R.id.settings_outgoing_button_save);
        outgoing_button.setOnClickListener(this);
        initFields();
        initOutgoing();
        break;
      case 3:
        setContentView(R.layout.settings_ftp);
        ftp_button = (Button) findViewById(R.id.settings_ftp_button_save);
        httpUrl = (EditText) findViewById(R.id.settings_ftp_httpurl);
        ftp_button.setOnClickListener(this);
        initFields();
        initftp();
        // continuously update edit-url-field
        host.setOnFocusChangeListener(
            new View.OnFocusChangeListener() {
              @Override
              public void onFocusChange(View arg0, boolean arg1) {
                updateHttpUrlField();
              }
            });
        break;
    }

    // Bundle userdatabundle = getIntent().getExtras();
    // user_data = userdatabundle;

    // Button outgoing_button = (Button)
    // findViewById(R.id.settings_outgoing_button_save);
    // outgoing_button.setOnClickListener(this);
    // Button ftp_button = (Button)
    // findViewById(R.id.settings_ftp_button_save);
    // ftp_button.setOnClickListener(this);
  }