aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/entities/Account.java7
-rw-r--r--src/eu/siacs/conversations/generator/IqGenerator.java16
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java49
-rw-r--r--src/eu/siacs/conversations/ui/EditAccountActivity.java300
-rw-r--r--src/eu/siacs/conversations/ui/EditAccountDialog.java157
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java50
-rw-r--r--src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java11
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java48
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java5
-rw-r--r--src/eu/siacs/conversations/xmpp/pep/Avatar.java1
10 files changed, 400 insertions, 244 deletions
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index b734c6ee..5de2c532 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -45,8 +45,6 @@ public class Account extends AbstractEntity{
public static final int STATUS_UNAUTHORIZED = 3;
public static final int STATUS_SERVER_NOT_FOUND = 5;
- public static final int STATUS_SERVER_REQUIRES_TLS = 6;
-
public static final int STATUS_REGISTRATION_FAILED = 7;
public static final int STATUS_REGISTRATION_CONFLICT = 8;
public static final int STATUS_REGISTRATION_SUCCESSFULL = 9;
@@ -146,6 +144,11 @@ public class Account extends AbstractEntity{
}
}
+ public boolean errorStatus() {
+ int s = getStatus();
+ return (s == STATUS_OFFLINE || s == STATUS_SERVER_NOT_FOUND || s == STATUS_UNAUTHORIZED);
+ }
+
public boolean hasErrorStatus() {
return getStatus() > STATUS_NO_INTERNET && (getXmppConnection().getAttempt() >= 2);
}
diff --git a/src/eu/siacs/conversations/generator/IqGenerator.java b/src/eu/siacs/conversations/generator/IqGenerator.java
index c4d84020..259538c2 100644
--- a/src/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/eu/siacs/conversations/generator/IqGenerator.java
@@ -42,9 +42,11 @@ public class IqGenerator extends AbstractGenerator {
protected IqPacket retrieve(String node, Element item) {
IqPacket packet = new IqPacket(IqPacket.TYPE_GET);
Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub");
- Element items = pubsub.addChild("items");
- items.setAttribute("node", node);
- items.addChild(item);
+ Element items = pubsub.addChild("items");
+ items.setAttribute("node", node);
+ if (item!=null) {
+ items.addChild(item);
+ }
return packet;
}
@@ -76,4 +78,12 @@ public class IqGenerator extends AbstractGenerator {
packet.setTo(avatar.owner);
return packet;
}
+
+ public IqPacket retrieveAvatarMetaData(String to) {
+ IqPacket packet = retrieve("urn:xmpp:avatar:metadata", null);
+ if (to!=null) {
+ packet.setTo(to);
+ }
+ return packet;
+ }
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 1c114f60..01915806 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -112,6 +112,7 @@ public class XmppConnectionService extends Service {
private OnConversationUpdate mOnConversationUpdate = null;
private int convChangedListenerCount = 0;
private OnAccountUpdate mOnAccountUpdate = null;
+ private int accountChangedListenerCount = 0;
private OnRosterUpdate mOnRosterUpdate = null;
public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
@@ -924,10 +925,14 @@ public class XmppConnectionService extends Service {
public void setOnAccountListChangedListener(OnAccountUpdate listener) {
this.mOnAccountUpdate = listener;
+ this.accountChangedListenerCount++;
}
public void removeOnAccountListChangedListener() {
- this.mOnAccountUpdate = null;
+ this.accountChangedListenerCount--;
+ if (this.accountChangedListenerCount == 0) {
+ this.mOnAccountUpdate = null;
+ }
}
public void setOnRosterUpdateListener(OnRosterUpdate listener) {
@@ -1234,7 +1239,11 @@ public class XmppConnectionService extends Service {
}
}
- public void fetchAvatar(Account account, final Avatar avatar) {
+ public void fetchAvatar(Account account, Avatar avatar) {
+ fetchAvatar(account, avatar, null);
+ }
+
+ public void fetchAvatar(Account account, final Avatar avatar, final UiCallback<Avatar> callback) {
Log.d(LOGTAG,account.getJid()+": retrieving avatar for "+avatar.owner);
IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar);
sendIqPacket(account, packet, new OnIqPacketReceived() {
@@ -1250,8 +1259,44 @@ public class XmppConnectionService extends Service {
Contact contact = account.getRoster().getContact(avatar.owner);
contact.setAvatar(avatar.getFilename());
}
+ if (callback!=null) {
+ callback.success(avatar);
+ }
+ return;
+ }
+ }
+ if (callback!=null) {
+ callback.error(0, null);
+ }
+ }
+ });
+ }
+
+ public void checkForAvatar(Account account, final UiCallback<Avatar> callback) {
+ IqPacket packet = this.mIqGenerator.retrieveAvatarMetaData(null);
+ this.sendIqPacket(account, packet, new OnIqPacketReceived() {
+
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE_RESULT) {
+ Element pubsub = packet.findChild("pubsub", "http://jabber.org/protocol/pubsub");
+ if (pubsub!=null) {
+ Element items = pubsub.findChild("items");
+ if (items!=null) {
+ Avatar avatar = Avatar.parseMetadata(items);
+ if (avatar!=null) {
+ avatar.owner = account.getJid();
+ if (fileBackend.isAvatarCached(avatar)) {
+ callback.success(avatar);
+ } else {
+ fetchAvatar(account, avatar,callback);
+ }
+ return;
+ }
+ }
}
}
+ callback.error(0, null);
}
});
}
diff --git a/src/eu/siacs/conversations/ui/EditAccountActivity.java b/src/eu/siacs/conversations/ui/EditAccountActivity.java
new file mode 100644
index 00000000..681be439
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -0,0 +1,300 @@
+package eu.siacs.conversations.ui;
+
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
+import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
+import eu.siacs.conversations.utils.Validator;
+import eu.siacs.conversations.xmpp.pep.Avatar;
+
+public class EditAccountActivity extends XmppActivity {
+
+ private AutoCompleteTextView mAccountJid;
+ private EditText mPassword;
+ private EditText mPasswordConfirm;
+ private CheckBox mRegisterNew;
+ private Button mCancelButton;
+ private Button mSaveButton;
+
+ private String jidToEdit;
+ private Account mAccount;
+ private Avatar mAvatar = null;
+
+ private boolean mUserInputIsValid = false;
+ private boolean mFetchingAvatar = false;
+ private boolean mFinishedInitialSetup = false;
+
+ private OnClickListener mSaveButtonClickListener = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (mAccount != null && mFinishedInitialSetup) {
+ Intent intent;
+ if (mAvatar!=null) {
+ intent = new Intent(getApplicationContext(), StartConversationActivity.class);
+ } else {
+ intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
+ intent.putExtra("account", mAccount.getJid());
+ }
+ startActivity(intent);
+ finish();
+ return;
+ } else if (mAccount != null && mAccount.errorStatus()
+ && !mUserInputIsValid) {
+ xmppConnectionService.reconnectAccount(mAccount, true);
+ return;
+ }
+ boolean registerNewAccount = mRegisterNew.isChecked();
+ String[] jidParts = mAccountJid.getText().toString().split("@");
+ String username = jidParts[0];
+ String server;
+ if (jidParts.length >= 2) {
+ server = jidParts[1];
+ } else {
+ server = "";
+ }
+ String password = mPassword.getText().toString();
+ String passwordConfirm = mPasswordConfirm.getText().toString();
+ if (registerNewAccount) {
+ if (!password.equals(passwordConfirm)) {
+ mPasswordConfirm
+ .setError(getString(R.string.passwords_do_not_match));
+ return;
+ }
+ }
+ if (mAccount != null) {
+ mAccount.setPassword(password);
+ mAccount.setUsername(username);
+ mAccount.setServer(server);
+ mAccount.setOption(Account.OPTION_REGISTER, mRegisterNew.isChecked());
+ xmppConnectionService.updateAccount(mAccount);
+ } else {
+ if (xmppConnectionService.findAccountByJid(mAccountJid.getText().toString())!=null) {
+ mAccountJid.setError(getString(R.string.account_already_exists));
+ return;
+ }
+ mAccount = new Account(username, server, password);
+ mAccount.setOption(Account.OPTION_USETLS, true);
+ mAccount.setOption(Account.OPTION_USECOMPRESSION, true);
+ if (registerNewAccount) {
+ mAccount.setOption(Account.OPTION_REGISTER, true);
+ }
+ xmppConnectionService.createAccount(mAccount);
+ }
+ if (jidToEdit != null) {
+ finish();
+ } else {
+ mUserInputIsValid = false;
+ updateSaveButton();
+ updateAccountInformation();
+ }
+
+ }
+ };
+ private OnClickListener mCancelButtonClickListener = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ };
+ private TextWatcher mTextWatcher = new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before,
+ int count) {
+ if (Validator.isValidJid(mAccountJid.getText().toString())) {
+ mUserInputIsValid = inputDataDiffersFromAccount();
+ } else {
+ mUserInputIsValid = false;
+ }
+ updateSaveButton();
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ };
+ private OnAccountUpdate mOnAccountUpdateListener = new OnAccountUpdate() {
+
+ @Override
+ public void onAccountUpdate() {
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ if (jidToEdit==null && mAccount!=null && mAccount.getStatus() == Account.STATUS_ONLINE) {
+ if (!mFetchingAvatar) {
+ mFetchingAvatar = true;
+ xmppConnectionService.checkForAvatar(mAccount, mAvatarFetchCallback);
+ }
+ } else {
+ updateSaveButton();
+ }
+ }
+ });
+ }
+ };
+ private UiCallback<Avatar> mAvatarFetchCallback = new UiCallback<Avatar>() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi, Avatar avatar) {
+ finishInitialSetup(avatar);
+ }
+
+ @Override
+ public void success(Avatar avatar) {
+ finishInitialSetup(avatar);
+ }
+
+ @Override
+ public void error(int errorCode, Avatar avatar) {
+ finishInitialSetup(avatar);
+ }
+ };
+
+ protected void finishInitialSetup(Avatar avatar) {
+ this.mFinishedInitialSetup = true;
+ this.mAvatar = avatar;
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ updateSaveButton();
+ }
+ });
+ }
+
+ protected boolean inputDataDiffersFromAccount() {
+ if (mAccount == null) {
+ return true;
+ } else {
+ return (!mAccount.getJid().equals(mAccountJid.getText().toString()))
+ || (!mAccount.getPassword().equals(
+ mPassword.getText().toString()) || mAccount
+ .isOptionSet(Account.OPTION_REGISTER) != mRegisterNew
+ .isChecked());
+ }
+ }
+
+ protected void updateSaveButton() {
+ if (mAccount != null && mFinishedInitialSetup) {
+ this.mSaveButton.setEnabled(true);
+ this.mSaveButton.setTextColor(getPrimaryTextColor());
+ this.mSaveButton.setText(R.string.next);
+ } else if (mAccount != null
+ && mAccount.getStatus() == Account.STATUS_CONNECTING
+ && !mUserInputIsValid) {
+ this.mSaveButton.setEnabled(false);
+ this.mSaveButton.setTextColor(getSecondaryTextColor());
+ this.mSaveButton.setText(R.string.account_status_connecting);
+ } else if (mAccount != null && mAccount.errorStatus()
+ && !mUserInputIsValid) {
+ this.mSaveButton.setEnabled(true);
+ this.mSaveButton.setTextColor(getPrimaryTextColor());
+ this.mSaveButton.setText(R.string.connect);
+ } else if (mUserInputIsValid) {
+ this.mSaveButton.setEnabled(true);
+ this.mSaveButton.setTextColor(getPrimaryTextColor());
+ } else {
+ this.mSaveButton.setEnabled(false);
+ this.mSaveButton.setTextColor(getSecondaryTextColor());
+ this.mSaveButton.setText(R.string.save);
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_account);
+ this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
+ this.mPassword = (EditText) findViewById(R.id.account_password);
+ this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
+ this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
+ this.mSaveButton = (Button) findViewById(R.id.save_button);
+ this.mCancelButton = (Button) findViewById(R.id.cancel_button);
+ this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener);
+ this.mCancelButton.setOnClickListener(this.mCancelButtonClickListener);
+ this.mRegisterNew
+ .setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView,
+ boolean isChecked) {
+ if (isChecked) {
+ mPasswordConfirm.setVisibility(View.VISIBLE);
+ } else {
+ mPasswordConfirm.setVisibility(View.GONE);
+ }
+ mUserInputIsValid = inputDataDiffersFromAccount();
+ updateSaveButton();
+ }
+ });
+ this.mAccountJid.addTextChangedListener(this.mTextWatcher);
+ this.mPassword.addTextChangedListener(this.mTextWatcher);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (getIntent() != null) {
+ this.jidToEdit = getIntent().getStringExtra("jid");
+ if (this.jidToEdit != null) {
+ this.mRegisterNew.setVisibility(View.GONE);
+ getActionBar().setTitle(R.string.mgmt_account_edit);
+ } else {
+ getActionBar().setTitle(R.string.action_add_account);
+ }
+ }
+ }
+
+ @Override
+ protected void onBackendConnected() {
+ this.xmppConnectionService
+ .setOnAccountListChangedListener(this.mOnAccountUpdateListener);
+ this.mAccountJid.setAdapter(null);
+ if (this.jidToEdit != null) {
+ this.mAccount = xmppConnectionService.findAccountByJid(jidToEdit);
+ updateAccountInformation();
+ } else if (this.xmppConnectionService.getAccounts().size() == 0) {
+ getActionBar().setDisplayHomeAsUpEnabled(false);
+ getActionBar().setDisplayShowHomeEnabled(false);
+ this.mCancelButton.setEnabled(false);
+ }
+ this.mAccountJid.setAdapter(new KnownHostsAdapter(this,
+ android.R.layout.simple_list_item_1, xmppConnectionService
+ .getKnownHosts()));
+ updateSaveButton();
+ }
+
+ private void updateAccountInformation() {
+ this.mAccountJid.setText(this.mAccount.getJid());
+ this.mPassword.setText(this.mAccount.getPassword());
+ if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
+ this.mRegisterNew.setVisibility(View.VISIBLE);
+ this.mRegisterNew.setChecked(true);
+ this.mPasswordConfirm.setText(this.mAccount.getPassword());
+ } else {
+ this.mRegisterNew.setVisibility(View.GONE);
+ this.mRegisterNew.setChecked(false);
+ }
+ }
+}
diff --git a/src/eu/siacs/conversations/ui/EditAccountDialog.java b/src/eu/siacs/conversations/ui/EditAccountDialog.java
deleted file mode 100644
index 7c135fc1..00000000
--- a/src/eu/siacs/conversations/ui/EditAccountDialog.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package eu.siacs.conversations.ui;
-
-import java.util.List;
-
-import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
-import eu.siacs.conversations.utils.Validator;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.EditText;
-import android.widget.TextView;
-
-public class EditAccountDialog extends DialogFragment {
-
- protected Account account;
-
- protected AutoCompleteTextView mAccountJid;
-
- public void setAccount(Account account) {
- this.account = account;
- }
-
- public interface EditAccountListener {
- public void onAccountEdited(Account account);
- }
-
- protected EditAccountListener listener = null;
-
- private KnownHostsAdapter mKnownHostsAdapter;
-
- public void setEditAccountListener(EditAccountListener listener) {
- this.listener = listener;
- }
-
- public void setKnownHosts(List<String> hosts, Context context) {
- this.mKnownHostsAdapter = new KnownHostsAdapter(context, android.R.layout.simple_list_item_1, hosts);
- if (this.mAccountJid != null) {
- this.mAccountJid.setAdapter(this.mKnownHostsAdapter);
- }
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.edit_account_dialog, null);
- mAccountJid = (AutoCompleteTextView) view.findViewById(R.id.account_jid);
- if (this.mKnownHostsAdapter!=null) {
- mAccountJid.setAdapter(this.mKnownHostsAdapter);
- }
- final TextView confirmPwDesc = (TextView) view
- .findViewById(R.id.account_confirm_password_desc);
-
- final EditText password = (EditText) view
- .findViewById(R.id.account_password);
- final EditText passwordConfirm = (EditText) view
- .findViewById(R.id.account_password_confirm2);
- final CheckBox registerAccount = (CheckBox) view
- .findViewById(R.id.edit_account_register_new);
-
- if (account != null) {
- mAccountJid.setText(account.getJid());
- password.setText(account.getPassword());
- if (account.isOptionSet(Account.OPTION_REGISTER)) {
- registerAccount.setChecked(true);
- passwordConfirm.setVisibility(View.VISIBLE);
- passwordConfirm.setText(account.getPassword());
- } else {
- registerAccount.setVisibility(View.GONE);
- }
- }
- builder.setTitle(R.string.account_settings);
-
-
- registerAccount
- .setOnCheckedChangeListener(new OnCheckedChangeListener() {
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView,
- boolean isChecked) {
- if (isChecked) {
- passwordConfirm.setVisibility(View.VISIBLE);
- confirmPwDesc.setVisibility(View.VISIBLE);
- } else {
- passwordConfirm.setVisibility(View.GONE);
- confirmPwDesc.setVisibility(View.GONE);
- }
- }
- });
-
- builder.setView(view);
- builder.setNeutralButton(getString(R.string.cancel), null);
- builder.setPositiveButton(getString(R.string.save), null);
- return builder.create();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- final AlertDialog d = (AlertDialog) getDialog();
- Button positiveButton = (Button) d.getButton(Dialog.BUTTON_POSITIVE);
- positiveButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- EditText jidEdit = (EditText) d.findViewById(R.id.account_jid);
- String jid = jidEdit.getText().toString();
- EditText passwordEdit = (EditText) d
- .findViewById(R.id.account_password);
- EditText passwordConfirmEdit = (EditText) d.findViewById(R.id.account_password_confirm2);
- String password = passwordEdit.getText().toString();
- String passwordConfirm = passwordConfirmEdit.getText().toString();
- CheckBox register = (CheckBox) d.findViewById(R.id.edit_account_register_new);
- String username;
- String server;
- if (Validator.isValidJid(jid)) {
- String[] parts = jid.split("@");
- username = parts[0];
- server = parts[1];
- } else {
- jidEdit.setError(getString(R.string.invalid_jid));
- return;
- }
- if (register.isChecked()) {
- if (!passwordConfirm.equals(password)) {
- passwordConfirmEdit.setError(getString(R.string.passwords_do_not_match));
- return;
- }
- }
- if (account != null) {
- account.setPassword(password);
- account.setUsername(username);
- account.setServer(server);
- } else {
- account = new Account(username, server, password);
- account.setOption(Account.OPTION_USETLS, true);
- account.setOption(Account.OPTION_USECOMPRESSION, true);
- }
- account.setOption(Account.OPTION_REGISTER, register.isChecked());
- if (listener != null) {
- listener.onAccountEdited(account);
- d.dismiss();
- }
- }
- });
- }
-}
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 19c9552a..d522a733 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -6,7 +6,6 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
-import eu.siacs.conversations.ui.EditAccountDialog.EditAccountListener;
import eu.siacs.conversations.ui.adapter.AccountAdapter;
import eu.siacs.conversations.xmpp.XmppConnection;
import android.app.Activity;
@@ -236,17 +235,7 @@ public class ManageAccountActivity extends XmppActivity {
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
if (!isActionMode) {
- Account account = accountList.get(position);
- if (account.getStatus() == Account.STATUS_OFFLINE) {
- activity.xmppConnectionService.reconnectAccount(
- accountList.get(position), true);
- } else if (account.getStatus() == Account.STATUS_ONLINE) {
- activity.startActivity(new Intent(activity
- .getApplicationContext(),
- StartConversationActivity.class));
- } else if (account.getStatus() != Account.STATUS_DISABLED) {
- editAccount(account);
- }
+ editAccount(accountList.get(position));
} else {
selectedAccountForActionMode = accountList.get(position);
actionMode.invalidate();
@@ -292,7 +281,6 @@ public class ManageAccountActivity extends XmppActivity {
if ((this.accountList.size() == 0) && (this.firstrun)) {
getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setHomeButtonEnabled(false);
- addAccount();
this.firstrun = false;
}
}
@@ -307,7 +295,7 @@ public class ManageAccountActivity extends XmppActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_account:
- addAccount();
+ startActivity(new Intent(getApplicationContext(), EditAccountActivity.class));
break;
default:
break;
@@ -337,37 +325,9 @@ public class ManageAccountActivity extends XmppActivity {
}
private void editAccount(Account account) {
- EditAccountDialog dialog = new EditAccountDialog();
- dialog.setAccount(account);
- dialog.setEditAccountListener(new EditAccountListener() {
-
- @Override
- public void onAccountEdited(Account account) {
- xmppConnectionService.updateAccount(account);
- if (actionMode != null) {
- actionMode.finish();
- }
- }
- });
- dialog.show(getFragmentManager(), "edit_account");
- dialog.setKnownHosts(xmppConnectionService.getKnownHosts(), this);
-
- }
-
- protected void addAccount() {
- final Activity activity = this;
- EditAccountDialog dialog = new EditAccountDialog();
- dialog.setEditAccountListener(new EditAccountListener() {
-
- @Override
- public void onAccountEdited(Account account) {
- xmppConnectionService.createAccount(account);
- activity.getActionBar().setDisplayHomeAsUpEnabled(true);
- activity.getActionBar().setHomeButtonEnabled(true);
- }
- });
- dialog.show(getFragmentManager(), "add_account");
- dialog.setKnownHosts(xmppConnectionService.getKnownHosts(), this);
+ Intent intent = new Intent(this, EditAccountActivity.class);
+ intent.putExtra("jid", account.getJid());
+ startActivity(intent);
}
@Override
diff --git a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
index 434d1d4d..3b6ca13d 100644
--- a/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
+++ b/src/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
@@ -134,17 +134,6 @@ public class PublishProfilePictureActivity extends XmppActivity {
}
@Override
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- super.onOptionsItemSelected(menuItem);
- switch (menuItem.getItemId()) {
- case android.R.id.home:
- finish();
- break;
- }
- return true;
- }
-
- @Override
protected void onBackendConnected() {
if (getIntent() != null) {
String jid = getIntent().getStringExtra("account");
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 32750b98..44043a79 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -39,16 +39,16 @@ public abstract class XmppActivity extends Activity {
public XmppConnectionService xmppConnectionService;
public boolean xmppConnectionServiceBound = false;
protected boolean handledViewIntent = false;
-
+
protected int mPrimaryTextColor;
protected int mSecondaryTextColor;
protected int mWarningTextColor;
protected int mPrimaryColor;
-
+
protected interface OnValueEdited {
public void onValueEdited(String value);
}
-
+
public interface OnPresenceSelected {
public void onPresenceSelected();
}
@@ -154,6 +154,9 @@ public abstract class XmppActivity extends Activity {
case R.id.action_accounts:
startActivity(new Intent(this, ManageAccountActivity.class));
break;
+ case android.R.id.home:
+ finish();
+ break;
}
return super.onOptionsItemSelected(item);
}
@@ -203,11 +206,12 @@ public abstract class XmppActivity extends Activity {
}
protected void inviteToConversation(Conversation conversation) {
- Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
- intent.putExtra("conversation",conversation.getUuid());
+ Intent intent = new Intent(getApplicationContext(),
+ ChooseContactActivity.class);
+ intent.putExtra("conversation", conversation.getUuid());
startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
}
-
+
protected void announcePgp(Account account, final Conversation conversation) {
xmppConnectionService.getPgpEngine().generateSignature(account,
"online", new UiCallback<Account>() {
@@ -218,7 +222,8 @@ public abstract class XmppActivity extends Activity {
try {
startIntentSenderForResult(pi.getIntentSender(),
REQUEST_ANNOUNCE_PGP, null, 0, 0, 0);
- } catch (SendIntentException e) {}
+ } catch (SendIntentException e) {
+ }
}
@Override
@@ -279,15 +284,17 @@ public abstract class XmppActivity extends Activity {
builder.create().show();
}
- protected void quickEdit(final String previousValue, final OnValueEdited callback) {
+ protected void quickEdit(final String previousValue,
+ final OnValueEdited callback) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- View view = (View) getLayoutInflater().inflate(R.layout.quickedit, null);
+ View view = (View) getLayoutInflater()
+ .inflate(R.layout.quickedit, null);
final EditText editor = (EditText) view.findViewById(R.id.editor);
editor.setText(previousValue);
builder.setView(view);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.edit, new OnClickListener() {
-
+
@Override
public void onClick(DialogInterface dialog, int which) {
String value = editor.getText().toString();
@@ -298,7 +305,7 @@ public abstract class XmppActivity extends Activity {
});
builder.create().show();
}
-
+
public void selectPresence(final Conversation conversation,
final OnPresenceSelected listener) {
Contact contact = conversation.getContact();
@@ -350,33 +357,36 @@ public abstract class XmppActivity extends Activity {
}
}
}
-
+
protected void onActivityResult(int requestCode, int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_INVITE_TO_CONVERSATION && resultCode == RESULT_OK) {
+ if (requestCode == REQUEST_INVITE_TO_CONVERSATION
+ && resultCode == RESULT_OK) {
String contactJid = data.getStringExtra("contact");
String conversationUuid = data.getStringExtra("conversation");
- Conversation conversation = xmppConnectionService.findConversationByUuid(conversationUuid);
+ Conversation conversation = xmppConnectionService
+ .findConversationByUuid(conversationUuid);
if (conversation.getMode() == Conversation.MODE_MULTI) {
xmppConnectionService.invite(conversation, contactJid);
}
- Log.d("xmppService","inviting "+contactJid+" to "+conversation.getName(true));
+ Log.d("xmppService", "inviting " + contactJid + " to "
+ + conversation.getName(true));
}
}
-
+
public int getSecondaryTextColor() {
return this.mSecondaryTextColor;
}
-
+
public int getPrimaryTextColor() {
return this.mPrimaryTextColor;
}
-
+
public int getWarningTextColor() {
return this.mWarningTextColor;
}
-
+
public int getPrimaryColor() {
return this.mPrimaryColor;
}
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index c83f39a8..8e93a91d 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -221,11 +221,6 @@ public class XmppConnection implements Runnable {
processStreamError(nextTag);
} else if (nextTag.isStart("features")) {
processStreamFeatures(nextTag);
- if ((streamFeatures.getChildren().size() == 1)
- && (streamFeatures.hasChild("starttls"))
- && (!account.isOptionSet(Account.OPTION_USETLS))) {
- changeStatus(Account.STATUS_SERVER_REQUIRES_TLS);
- }
} else if (nextTag.isStart("proceed")) {
switchOverToTls(nextTag);
} else if (nextTag.isStart("compressed")) {
diff --git a/src/eu/siacs/conversations/xmpp/pep/Avatar.java b/src/eu/siacs/conversations/xmpp/pep/Avatar.java
index b99a2fe3..6d5c1431 100644
--- a/src/eu/siacs/conversations/xmpp/pep/Avatar.java
+++ b/src/eu/siacs/conversations/xmpp/pep/Avatar.java
@@ -25,6 +25,7 @@ public class Avatar {
return sha1sum;
}
}
+
public static Avatar parseMetadata(Element items) {
Element item = items.findChild("item");
if (item==null) {