mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-11 11:45:01 -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() {
|
public void toggleForegroundService() {
|
||||||
if (keepForegroundService()) {
|
if (keepForegroundService() && hasEnabledAccounts()) {
|
||||||
startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification());
|
startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification());
|
||||||
} else {
|
} else {
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
@ -1825,6 +1825,7 @@ public class XmppConnectionService extends Service {
|
|||||||
this.accounts.add(account);
|
this.accounts.add(account);
|
||||||
this.reconnectAccountInBackground(account);
|
this.reconnectAccountInBackground(account);
|
||||||
updateAccountUi();
|
updateAccountUi();
|
||||||
|
toggleForegroundService();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAccountFromKey(final String alias, final OnAccountCreated callback) {
|
public void createAccountFromKey(final String alias, final OnAccountCreated callback) {
|
||||||
@ -1894,6 +1895,7 @@ public class XmppConnectionService extends Service {
|
|||||||
reconnectAccountInBackground(account);
|
reconnectAccountInBackground(account);
|
||||||
updateAccountUi();
|
updateAccountUi();
|
||||||
getNotificationService().updateErrorNotification();
|
getNotificationService().updateErrorNotification();
|
||||||
|
toggleForegroundService();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -2199,7 +2201,7 @@ public class XmppConnectionService extends Service {
|
|||||||
XmppConnection connection = account.getXmppConnection();
|
XmppConnection connection = account.getXmppConnection();
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
if (broadcastLastActivity) {
|
if (broadcastLastActivity) {
|
||||||
sendPresence(account, broadcastLastActivity);
|
sendPresence(account, true);
|
||||||
}
|
}
|
||||||
if (connection.getFeatures().csi()) {
|
if (connection.getFeatures().csi()) {
|
||||||
connection.sendInactive();
|
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) {
|
public void renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) {
|
||||||
final MucOptions options = conversation.getMucOptions();
|
final MucOptions options = conversation.getMucOptions();
|
||||||
final Jid joinJid = options.createJoinJid(nick);
|
final Jid joinJid = options.createJoinJid(nick);
|
||||||
|
Loading…
Reference in New Issue
Block a user