mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
disable foreground service if all accounts are disabled
This commit is contained in:
parent
edb28ccb31
commit
ecc0ef45c5
@ -1085,7 +1085,7 @@ public class XmppConnectionService extends Service {
|
||||
}
|
||||
|
||||
public void toggleForegroundService() {
|
||||
if (keepForegroundService()) {
|
||||
if (keepForegroundService() && hasEnabledAccounts()) {
|
||||
startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification());
|
||||
} else {
|
||||
stopForeground(true);
|
||||
@ -1825,6 +1825,7 @@ public class XmppConnectionService extends Service {
|
||||
this.accounts.add(account);
|
||||
this.reconnectAccountInBackground(account);
|
||||
updateAccountUi();
|
||||
toggleForegroundService();
|
||||
}
|
||||
|
||||
public void createAccountFromKey(final String alias, final OnAccountCreated callback) {
|
||||
@ -1894,6 +1895,7 @@ public class XmppConnectionService extends Service {
|
||||
reconnectAccountInBackground(account);
|
||||
updateAccountUi();
|
||||
getNotificationService().updateErrorNotification();
|
||||
toggleForegroundService();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -2199,7 +2201,7 @@ public class XmppConnectionService extends Service {
|
||||
XmppConnection connection = account.getXmppConnection();
|
||||
if (connection != null) {
|
||||
if (broadcastLastActivity) {
|
||||
sendPresence(account, broadcastLastActivity);
|
||||
sendPresence(account, true);
|
||||
}
|
||||
if (connection.getFeatures().csi()) {
|
||||
connection.sendInactive();
|
||||
@ -2380,6 +2382,15 @@ public class XmppConnectionService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasEnabledAccounts() {
|
||||
for(Account account : this.accounts) {
|
||||
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) {
|
||||
final MucOptions options = conversation.getMucOptions();
|
||||
final Jid joinJid = options.createJoinJid(nick);
|
||||
|
Loading…
Reference in New Issue
Block a user