Ejemplo n.º 1
0
  private void initIncoming() {

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

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

    FetchMailConnection conn = userAccount.getConfiguration().getFetchMailConncetions().get(0);

    String 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 == "pop3") {
        pop3.setChecked(true);
        name = "";
      }
      name = conn.getProtocol().lowerCaseName();
      if (name == "pop3s") {
        pop3s.setChecked(true);
      }
    }
  }
Ejemplo n.º 2
0
  private void saveFetchMailSettings(View v) {
    Log.i(
        I,
        "saved SenderAdress: "
            + userAccount
                .getConfiguration()
                .getFetchMailConncetions()
                .get(0)
                .getSenderAddress()
                .getValue());
    Configuration conf = userAccount.getConfiguration();
    AttributeList<FetchMailConnection> conList = conf.getFetchMailConncetions();
    FetchMailConnection fetchCon = conList.get(0);

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

    if (pop3.isChecked()) {
      FetchMailProtocol pop3 = FetchMailProtocol.POP3;
      fetchCon.setProtocol(pop3);
    }
    if (pop3s.isChecked()) {
      FetchMailProtocol pop3s = FetchMailProtocol.POP3S;
      fetchCon.setProtocol(pop3s);
    }
    ArrayList<FetchMailConnection> attributes = new ArrayList<FetchMailConnection>();
    attributes.add(fetchCon);
    conList.setAttributes(attributes);
    conf.setFetchMailConnections(conList);
    userAccount.setConfiguration(conf);
    try {
      AccountManager am = new AccountManager();
      am.encryptAndSaveAccount(
          userAccount, HelloWorldBasic.getUsername(), HelloWorldBasic.getPassword(), null);

      Log.i(
          I,
          "saved SenderAdress: "
              + userAccount
                  .getConfiguration()
                  .getFetchMailConncetions()
                  .get(0)
                  .getSenderAddress()
                  .getValue());

      SettingsChooser.setSuccessMessage("Incoming Mail");
      goBackToSettingsChooser();

    } catch (Exception e) {
      Toast.makeText(this, "Sorry, settings couldn't be saved", Toast.LENGTH_LONG).show();
    }
  }