From 76ce6f52062aa802482497bc79aa05ee3e73244b Mon Sep 17 00:00:00 2001 From: steckbrief Date: Wed, 2 Aug 2017 12:43:47 +0200 Subject: Using a generator approach for generating PresencePackets --- .../conversationsplus/ui/ContactDetailsActivity.java | 19 ++++++------------- .../conversationsplus/ui/XmppActivity.java | 7 +++---- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src/main/java/de/thedevstack/conversationsplus/ui') diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java index 3ca9fce7..6577c9ce 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ContactDetailsActivity.java @@ -33,6 +33,7 @@ import java.security.cert.X509Certificate; import java.util.List; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; +import de.thedevstack.conversationsplus.generator.PresenceGenerator; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; @@ -47,6 +48,7 @@ import de.thedevstack.conversationsplus.services.XmppConnectionService.OnAccount import de.thedevstack.conversationsplus.services.XmppConnectionService.OnRosterUpdate; import de.thedevstack.conversationsplus.utils.CryptoHelper; import de.thedevstack.conversationsplus.utils.UIHelper; +import de.thedevstack.conversationsplus.utils.XmppSendUtil; import de.thedevstack.conversationsplus.xmpp.OnKeyStatusUpdated; import de.thedevstack.conversationsplus.xmpp.OnUpdateBlocklist; import de.thedevstack.conversationsplus.xmpp.XmppConnection; @@ -72,18 +74,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd if (isChecked) { if (contact .getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { - xmppConnectionService.sendPresencePacket(contact - .getAccount(), - xmppConnectionService.getPresenceGenerator() - .sendPresenceUpdatesTo(contact)); + XmppSendUtil.sendPresencePacket(contact.getAccount(), PresenceGenerator.sendPresenceUpdatesTo(contact)); } else { contact.setOption(Contact.Options.PREEMPTIVE_GRANT); } } else { contact.resetOption(Contact.Options.PREEMPTIVE_GRANT); - xmppConnectionService.sendPresencePacket(contact.getAccount(), - xmppConnectionService.getPresenceGenerator() - .stopPresenceUpdatesTo(contact)); + XmppSendUtil.sendPresencePacket(contact.getAccount(), PresenceGenerator.stopPresenceUpdatesTo(contact)); } } }; @@ -93,13 +90,9 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { - xmppConnectionService.sendPresencePacket(contact.getAccount(), - xmppConnectionService.getPresenceGenerator() - .requestPresenceUpdatesFrom(contact)); + XmppSendUtil.sendPresencePacket(contact.getAccount(), PresenceGenerator.requestPresenceUpdatesFrom(contact)); } else { - xmppConnectionService.sendPresencePacket(contact.getAccount(), - xmppConnectionService.getPresenceGenerator() - .stopPresenceUpdatesFrom(contact)); + XmppSendUtil.sendPresencePacket(contact.getAccount(), PresenceGenerator.stopPresenceUpdatesFrom(contact)); } } }; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java index 6785dd31..85bc2af3 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java @@ -72,10 +72,12 @@ import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; import de.thedevstack.conversationsplus.entities.MucOptions; import de.thedevstack.conversationsplus.entities.Presences; +import de.thedevstack.conversationsplus.generator.PresenceGenerator; import de.thedevstack.conversationsplus.services.XmppConnectionService; import de.thedevstack.conversationsplus.services.XmppConnectionService.XmppConnectionBinder; import de.thedevstack.conversationsplus.utils.CryptoHelper; import de.thedevstack.conversationsplus.utils.ExceptionHelper; +import de.thedevstack.conversationsplus.utils.XmppSendUtil; import de.thedevstack.conversationsplus.xmpp.OnKeyStatusUpdated; import de.thedevstack.conversationsplus.xmpp.OnUpdateBlocklist; import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; @@ -562,10 +564,7 @@ public abstract class XmppActivity extends Activity { @Override public void onClick(DialogInterface dialog, int which) { if (xmppConnectionServiceBound) { - xmppConnectionService.sendPresencePacket(contact - .getAccount(), xmppConnectionService - .getPresenceGenerator() - .requestPresenceUpdatesFrom(contact)); + XmppSendUtil.sendPresencePacket(contact.getAccount(), PresenceGenerator.requestPresenceUpdatesFrom(contact)); } } }); -- cgit v1.2.3