From e7a0040ec5423c92128f394d0655cbfa5889082e Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 11 Jul 2014 13:52:27 +0200 Subject: [PATCH] fixed #255 and made some other improvements to the subscription mgmt --- res/layout/activity_contact_details.xml | 12 ---- .../siacs/conversations/entities/Contact.java | 2 + .../conversations/parser/PresenceParser.java | 2 - .../services/XmppConnectionService.java | 62 ++++++++++++------- .../ui/ContactDetailsActivity.java | 24 +++---- 5 files changed, 49 insertions(+), 53 deletions(-) diff --git a/res/layout/activity_contact_details.xml b/res/layout/activity_contact_details.xml index d55dcc9c3..8f0b42c14 100644 --- a/res/layout/activity_contact_details.xml +++ b/res/layout/activity_contact_details.xml @@ -105,18 +105,6 @@ android:text="@string/receive_presence_updates" android:textSize="14sp" android:textColor="@color/primarytext" /> - - getKnownHosts() { List hosts = new ArrayList(); - for(Account account : getAccounts()) { + for (Account account : getAccounts()) { if (!hosts.contains(account.getServer())) { hosts.add(account.getServer()); } - for(Contact contact : account.getRoster().getContacts()) { + for (Contact contact : account.getRoster().getContacts()) { if (contact.showInRoster()) { String server = contact.getServer(); - if (server!=null && !hosts.contains(server)) { + if (server != null && !hosts.contains(server)) { hosts.add(server); } } diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index bee937130..06b5a8099 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -47,7 +47,6 @@ public class ContactDetailsActivity extends XmppActivity { private TextView contactJidTv; private TextView accountJidTv; private TextView status; - private TextView askAgain; private TextView lastseen; private CheckBox send; private CheckBox receive; @@ -115,7 +114,6 @@ public class ContactDetailsActivity extends XmppActivity { lastseen = (TextView) findViewById(R.id.details_lastseen); 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); @@ -174,6 +172,8 @@ public class ContactDetailsActivity extends XmppActivity { setTitle(contact.getDisplayName()); if (contact.getOption(Contact.Options.FROM)) { send.setChecked(true); + } else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)){ + send.setChecked(false); } else { send.setText(R.string.preemptively_grant); if (contact @@ -187,17 +187,6 @@ public class ContactDetailsActivity extends XmppActivity { receive.setChecked(true); } else { receive.setText(R.string.ask_for_presence_updates); - askAgain.setVisibility(View.VISIBLE); - askAgain.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - Toast.makeText(getApplicationContext(), getString(R.string.asked_for_presence_updates), - Toast.LENGTH_SHORT).show(); - xmppConnectionService.requestPresenceUpdatesFrom(contact); - - } - }); if (contact.getOption(Contact.Options.ASKING)) { receive.setChecked(true); } else { @@ -317,8 +306,7 @@ public class ContactDetailsActivity extends XmppActivity { updated = true; } } else { - if (contact - .getOption(Contact.Options.PREEMPTIVE_GRANT)) { + if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) { if (!send.isChecked()) { if (online) { contact.resetOption(Contact.Options.PREEMPTIVE_GRANT); @@ -328,7 +316,11 @@ public class ContactDetailsActivity extends XmppActivity { } else { if (send.isChecked()) { if (online) { - contact.setOption(Contact.Options.PREEMPTIVE_GRANT); + if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { + xmppConnectionService.sendPresenceUpdatesTo(contact); + } else { + contact.setOption(Contact.Options.PREEMPTIVE_GRANT); + } } updated = true; }