disable subscription checkboxes when account is offline

This commit is contained in:
iNPUTmice 2014-07-20 13:21:21 +02:00
parent 542cbef53b
commit 3b7f89bbb0
1 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.utils.UIHelper; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -244,6 +259,13 @@ public class ContactDetailsActivity extends XmppActivity {
receive.setChecked(false); 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(), lastseen.setText(UIHelper.lastseen(getApplicationContext(),
contact.lastseen.time)); contact.lastseen.time));
@ -338,6 +360,7 @@ public class ContactDetailsActivity extends XmppActivity {
@Override @Override
public void onBackendConnected() { public void onBackendConnected() {
xmppConnectionService.setOnRosterUpdateListener(this.rosterUpdate); xmppConnectionService.setOnRosterUpdateListener(this.rosterUpdate);
xmppConnectionService.setOnAccountListChangedListener(this.accountUpdate );
if ((accountJid != null) && (contactJid != null)) { if ((accountJid != null) && (contactJid != null)) {
Account account = xmppConnectionService Account account = xmppConnectionService
.findAccountByJid(accountJid); .findAccountByJid(accountJid);
@ -353,6 +376,7 @@ public class ContactDetailsActivity extends XmppActivity {
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
xmppConnectionService.removeOnRosterUpdateListener(); xmppConnectionService.removeOnRosterUpdateListener();
xmppConnectionService.removeOnAccountListChangedListener();
} }
} }