aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java2
-rw-r--r--src/eu/siacs/conversations/ui/EditAccountActivity.java50
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java20
3 files changed, 67 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index e09dd0c5..18752659 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -73,7 +73,7 @@ public class MessageParser extends AbstractParser implements
updateLastseen(packet, account, true);
String body = packet.getBody();
if (body.matches("^\\?OTRv\\d*\\?")) {
- conversation.resetOtrSession();
+ conversation.endOtrIfNeeded();
}
if (!conversation.hasValidOtrSession()) {
if (properlyAddressed) {
diff --git a/src/eu/siacs/conversations/ui/EditAccountActivity.java b/src/eu/siacs/conversations/ui/EditAccountActivity.java
index 9aa8a9b4..0ec38547 100644
--- a/src/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -5,6 +5,8 @@ import android.content.ClipData;
import android.content.ClipboardManager;
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;
@@ -53,6 +55,12 @@ public class EditAccountActivity extends XmppActivity {
@Override
public void onClick(View v) {
+ if (mAccount != null
+ && mAccount.getStatus() == Account.STATUS_DISABLED) {
+ mAccount.setOption(Account.OPTION_DISABLED, false);
+ xmppConnectionService.updateAccount(mAccount);
+ return;
+ }
if (!Validator.isValidJid(mAccountJid.getText().toString())) {
mAccountJid.setError(getString(R.string.invalid_jid));
mAccountJid.requestFocus();
@@ -162,6 +170,25 @@ public class EditAccountActivity extends XmppActivity {
}
};
private KnownHostsAdapter mKnownHostsAdapter;
+ private TextWatcher mTextWatcher = new TextWatcher() {
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before,
+ int count) {
+ updateSaveButton();
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count,
+ int after) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ };
protected void finishInitialSetup(final Avatar avatar) {
runOnUiThread(new Runnable() {
@@ -202,6 +229,11 @@ public class EditAccountActivity extends XmppActivity {
this.mSaveButton.setEnabled(false);
this.mSaveButton.setTextColor(getSecondaryTextColor());
this.mSaveButton.setText(R.string.account_status_connecting);
+ } else if (mAccount != null
+ && mAccount.getStatus() == Account.STATUS_DISABLED) {
+ this.mSaveButton.setEnabled(true);
+ this.mSaveButton.setTextColor(getPrimaryTextColor());
+ this.mSaveButton.setText(R.string.enable);
} else {
this.mSaveButton.setEnabled(true);
this.mSaveButton.setTextColor(getPrimaryTextColor());
@@ -209,6 +241,10 @@ public class EditAccountActivity extends XmppActivity {
if (mAccount != null
&& mAccount.getStatus() == Account.STATUS_ONLINE) {
this.mSaveButton.setText(R.string.save);
+ if (!accountInfoEdited()) {
+ this.mSaveButton.setEnabled(false);
+ this.mSaveButton.setTextColor(getSecondaryTextColor());
+ }
} else {
this.mSaveButton.setText(R.string.connect);
}
@@ -218,12 +254,21 @@ public class EditAccountActivity extends XmppActivity {
}
}
+ protected boolean accountInfoEdited() {
+ return (!this.mAccount.getJid().equals(
+ this.mAccountJid.getText().toString()))
+ || (!this.mAccount.getPassword().equals(
+ this.mPassword.getText().toString()));
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_account);
this.mAccountJid = (AutoCompleteTextView) findViewById(R.id.account_jid);
+ this.mAccountJid.addTextChangedListener(this.mTextWatcher);
this.mPassword = (EditText) findViewById(R.id.account_password);
+ this.mPassword.addTextChangedListener(this.mTextWatcher);
this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm);
this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new);
this.mStats = (LinearLayout) findViewById(R.id.stats);
@@ -261,7 +306,7 @@ public class EditAccountActivity extends XmppActivity {
this.jidToEdit = getIntent().getStringExtra("jid");
if (this.jidToEdit != null) {
this.mRegisterNew.setVisibility(View.GONE);
- getActionBar().setTitle(R.string.mgmt_account_edit);
+ getActionBar().setTitle(jidToEdit);
} else {
getActionBar().setTitle(R.string.action_add_account);
}
@@ -336,7 +381,8 @@ public class EditAccountActivity extends XmppActivity {
this.mOtrFingerprintHeadline.setVisibility(View.VISIBLE);
this.mOtrFingerprint.setVisibility(View.VISIBLE);
this.mOtrFingerprint.setText(fingerprint);
- this.mOtrFingerprintToClipboardButton.setVisibility(View.VISIBLE);
+ this.mOtrFingerprintToClipboardButton
+ .setVisibility(View.VISIBLE);
this.mOtrFingerprintToClipboardButton
.setOnClickListener(new View.OnClickListener() {
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 76cfa603..07cd2b45 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -311,7 +311,8 @@ public class XmppConnection implements Runnable {
} catch (NumberFormatException e) {
}
- changeStatus(Account.STATUS_ONLINE);
+ sendInitialPing();
+
} else if (nextTag.isStart("r")) {
tagReader.readElement(nextTag);
AckPacket ack = new AckPacket(this.stanzasReceived, smVersion);
@@ -351,6 +352,21 @@ public class XmppConnection implements Runnable {
}
}
}
+
+ private void sendInitialPing() {
+ Log.d(Config.LOGTAG,account.getJid()+": sending intial ping");
+ IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
+ iq.setFrom(account.getFullJid());
+ iq.addChild("ping", "urn:xmpp:ping");
+ this.sendIqPacket(iq, new OnIqPacketReceived() {
+
+ @Override
+ public void onIqPacketReceived(Account account, IqPacket packet) {
+ Log.d(Config.LOGTAG,account.getJid()+": online with resource "+account.getResource());
+ changeStatus(Account.STATUS_ONLINE);
+ }
+ });
+ }
private Element processPacket(Tag currentTag, int packetType)
throws XmlPullParserException, IOException {
@@ -681,7 +697,7 @@ public class XmppConnection implements Runnable {
if (bindListener != null) {
bindListener.onBind(account);
}
- changeStatus(Account.STATUS_ONLINE);
+ sendInitialPing();
} else {
disconnect(true);
}