diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2014-03-14 18:56:52 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2014-03-14 18:56:52 +0100 |
commit | 4e20b81bd9a7e91c8570328e7390726d07aecff2 (patch) | |
tree | 5a091100385dc5fdb67eb71dd084dc7d30bed0bb | |
parent | 71cb5548eb453be94ea62e6e2b87d654287c2d29 (diff) |
fixed problem with null messages. added ask again button
-rw-r--r-- | res/layout/activity_contact_details.xml | 14 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/eu/siacs/conversations/entities/Account.java | 1 | ||||
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 2 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ContactDetailsActivity.java | 14 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/ManageAccountActivity.java | 4 | ||||
-rw-r--r-- | src/eu/siacs/conversations/utils/UIHelper.java | 2 | ||||
-rw-r--r-- | src/eu/siacs/conversations/xmpp/XmppConnection.java | 80 |
8 files changed, 78 insertions, 40 deletions
diff --git a/res/layout/activity_contact_details.xml b/res/layout/activity_contact_details.xml index cfa77a4d..ac5f4855 100644 --- a/res/layout/activity_contact_details.xml +++ b/res/layout/activity_contact_details.xml @@ -88,13 +88,25 @@ android:textSize="18sp" android:textColor="#5b5b5b" /> - <CheckBox + <CheckBox android:id="@+id/details_receive_presence" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Receive presence updates" android:textSize="18sp" android:textColor="#5b5b5b" /> + + <TextView + android:id="@+id/ask_again" + android:paddingTop="8dp" + android:paddingLeft="32dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/ask_again" + android:textColor="#33B5E5" + android:textSize="18sp" + android:visibility="gone" + /> <TextView style="@style/sectionHeader" android:layout_width="wrap_content" diff --git a/res/values/strings.xml b/res/values/strings.xml index 937f5570..aa53d081 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,4 +26,5 @@ <string name="account_info">Server Info</string> <string name="register_account">Register new account on server</string> <string name="share_with">Share with</string> + <string name="ask_again"><u>Click to ask again</u></string> </resources> diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java index 5d2e3ccc..d9a3ef03 100644 --- a/src/eu/siacs/conversations/entities/Account.java +++ b/src/eu/siacs/conversations/entities/Account.java @@ -45,6 +45,7 @@ public class Account extends AbstractEntity{ public static final int STATUS_REGISTRATION_FAILED = 7; public static final int STATUS_REGISTRATION_CONFLICT = 8; public static final int STATUS_REGISTRATION_SUCCESSFULL = 9; + public static final int STATUS_REGISTRATION_NOT_SUPPORTED = 10; protected String username; protected String server; diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index bd23c056..6b025d99 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -150,7 +150,7 @@ public class XmppConnectionService extends Service { } else { // Log.d(LOGTAG, "unparsed message " + packet.toString()); } - if (message == null) { + if ((message == null)||(message.getBody() == null)) { return; } if (packet.hasChild("delay")) { diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index 46e5ab32..5dc6eb3b 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -42,6 +42,7 @@ public class ContactDetailsActivity extends XmppActivity { private TextView contactJid; private TextView accountJid; private TextView status; + private TextView askAgain; private CheckBox send; private CheckBox receive; private QuickContactBadge badge; @@ -107,6 +108,7 @@ public class ContactDetailsActivity extends XmppActivity { status = (TextView) findViewById(R.id.details_contactstatus); send = (CheckBox) findViewById(R.id.details_send_presence); receive = (CheckBox) findViewById(R.id.details_receive_presence); + askAgain = (TextView) findViewById(R.id.ask_again); badge = (QuickContactBadge) findViewById(R.id.details_contact_badge); keys = (LinearLayout) findViewById(R.id.details_contact_keys); getActionBar().setHomeButtonEnabled(true); @@ -177,7 +179,17 @@ public class ContactDetailsActivity extends XmppActivity { if (contact.getSubscriptionOption(Contact.Subscription.TO)) { receive.setChecked(true); } else { - receive.setText("Request presence updates"); + receive.setText("Ask for presence updates"); + askAgain.setVisibility(View.VISIBLE); + askAgain.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + Toast.makeText(getApplicationContext(), "Asked for presence updates",Toast.LENGTH_SHORT).show(); + xmppConnectionService.requestPresenceUpdatesFrom(contact); + + } + }); if (contact.getSubscriptionOption(Contact.Subscription.ASKING)) { receive.setChecked(true); } else { diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java index 22f7c78f..7cf39e78 100644 --- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -175,6 +175,10 @@ public class ManageAccountActivity extends XmppActivity { statusView.setText("registration completed"); statusView.setTextColor(0xFF83b600); break; + case Account.STATUS_REGISTRATION_NOT_SUPPORTED: + statusView.setText("server does not support registration"); + statusView.setTextColor(0xFFe92727); + break; default: statusView.setText(""); break; diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java index 544f9429..f66cc734 100644 --- a/src/eu/siacs/conversations/utils/UIHelper.java +++ b/src/eu/siacs/conversations/utils/UIHelper.java @@ -218,7 +218,7 @@ public class UIHelper { mBuilder.setSmallIcon(R.drawable.notification); if (notify) { if (vibrate) { - int dat = 110; + int dat = 70; long[] pattern = {0,3*dat,dat,dat,dat,3*dat,dat,dat}; mBuilder.setVibrate(pattern); } diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 677c0ba6..668391ad 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -441,42 +441,11 @@ public class XmppConnection implements Runnable { && account.isOptionSet(Account.OPTION_USETLS)) { sendStartTLS(); } else if (this.streamFeatures.hasChild("register")&&(account.isOptionSet(Account.OPTION_REGISTER))) { - IqPacket register = new IqPacket(IqPacket.TYPE_GET); - register.query("jabber:iq:register"); - register.setTo(account.getServer()); - sendIqPacket(register, new OnIqPacketReceived() { - - @Override - public void onIqPacketReceived(Account account, IqPacket packet) { - Element instructions = packet.query().findChild("instructions"); - if (packet.query().hasChild("username")&&(packet.query().hasChild("password"))) { - IqPacket register = new IqPacket(IqPacket.TYPE_SET); - Element username = new Element("username").setContent(account.getUsername()); - Element password = new Element("password").setContent(account.getPassword()); - register.query("jabber:iq:register").addChild(username).addChild(password); - sendIqPacket(register, new OnIqPacketReceived() { - - @Override - public void onIqPacketReceived(Account account, IqPacket packet) { - if (packet.getType()==IqPacket.TYPE_RESULT) { - account.setOption(Account.OPTION_REGISTER, false); - changeStatus(Account.STATUS_REGISTRATION_SUCCESSFULL); - Log.d(LOGTAG,"successfull"); - } else if (packet.hasChild("error")&&(packet.findChild("error").hasChild("conflict"))){ - changeStatus(Account.STATUS_REGISTRATION_CONFLICT); - } else { - changeStatus(Account.STATUS_REGISTRATION_FAILED); - Log.d(LOGTAG,packet.toString()); - } - disconnect(true); - } - }); - Log.d(LOGTAG,"registering: "+register.toString()); - } else { - Log.d(LOGTAG,account.getJid()+": could not register. instructions are"+instructions.getContent()); - } - } - }); + sendRegistryRequest(); + } else if (!this.streamFeatures.hasChild("register")&&(account.isOptionSet(Account.OPTION_REGISTER))) { + //Log.d(LOGTAG,"registration not supported. stream features where"+this.streamFeatures.toString()); + changeStatus(Account.STATUS_REGISTRATION_NOT_SUPPORTED); + disconnect(true); } else if (this.streamFeatures.hasChild("mechanisms") && shouldAuthenticate) { sendSaslAuth(); @@ -499,6 +468,45 @@ public class XmppConnection implements Runnable { } } + private void sendRegistryRequest() { + IqPacket register = new IqPacket(IqPacket.TYPE_GET); + register.query("jabber:iq:register"); + register.setTo(account.getServer()); + sendIqPacket(register, new OnIqPacketReceived() { + + @Override + public void onIqPacketReceived(Account account, IqPacket packet) { + Element instructions = packet.query().findChild("instructions"); + if (packet.query().hasChild("username")&&(packet.query().hasChild("password"))) { + IqPacket register = new IqPacket(IqPacket.TYPE_SET); + Element username = new Element("username").setContent(account.getUsername()); + Element password = new Element("password").setContent(account.getPassword()); + register.query("jabber:iq:register").addChild(username).addChild(password); + sendIqPacket(register, new OnIqPacketReceived() { + + @Override + public void onIqPacketReceived(Account account, IqPacket packet) { + if (packet.getType()==IqPacket.TYPE_RESULT) { + account.setOption(Account.OPTION_REGISTER, false); + changeStatus(Account.STATUS_REGISTRATION_SUCCESSFULL); + } else if (packet.hasChild("error")&&(packet.findChild("error").hasChild("conflict"))){ + changeStatus(Account.STATUS_REGISTRATION_CONFLICT); + } else { + changeStatus(Account.STATUS_REGISTRATION_FAILED); + Log.d(LOGTAG,packet.toString()); + } + disconnect(true); + } + }); + } else { + changeStatus(Account.STATUS_REGISTRATION_FAILED); + disconnect(true); + Log.d(LOGTAG,account.getJid()+": could not register. instructions are"+instructions.getContent()); + } + } + }); + } + private void sendInitialPresence() { PresencePacket packet = new PresencePacket(); packet.setAttribute("from", account.getFullJid()); |