From 3b7f89bbb0ba96b00f97ff23ea713bd2915c7c74 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sun, 20 Jul 2014 13:21:21 +0200 Subject: disable subscription checkboxes when account is offline --- .../conversations/ui/ContactDetailsActivity.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/eu/siacs') diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index 71ff4ca8..2ec6459b 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -31,6 +31,7 @@ import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Presences; +import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.utils.UIHelper; @@ -144,6 +145,20 @@ public class ContactDetailsActivity extends XmppActivity { } }; + private OnAccountUpdate accountUpdate = new OnAccountUpdate() { + + @Override + public void onAccountUpdate() { + runOnUiThread(new Runnable() { + + @Override + public void run() { + populateView(); + } + }); + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -244,6 +259,13 @@ public class ContactDetailsActivity extends XmppActivity { receive.setChecked(false); } } + if (contact.getAccount().getStatus() == Account.STATUS_ONLINE) { + receive.setEnabled(true); + send.setEnabled(true); + } else { + receive.setEnabled(false); + send.setEnabled(false); + } lastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.lastseen.time)); @@ -338,6 +360,7 @@ public class ContactDetailsActivity extends XmppActivity { @Override public void onBackendConnected() { xmppConnectionService.setOnRosterUpdateListener(this.rosterUpdate); + xmppConnectionService.setOnAccountListChangedListener(this.accountUpdate ); if ((accountJid != null) && (contactJid != null)) { Account account = xmppConnectionService .findAccountByJid(accountJid); @@ -353,6 +376,7 @@ public class ContactDetailsActivity extends XmppActivity { protected void onStop() { super.onStop(); xmppConnectionService.removeOnRosterUpdateListener(); + xmppConnectionService.removeOnAccountListChangedListener(); } } -- cgit v1.2.3