aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-01-26 15:08:24 +0100
committerChristian Schneppe <christian@pix-art.de>2019-01-26 15:08:24 +0100
commit28c12f9fa868dd5273a80c305c69ae0106329c37 (patch)
tree8b90d085ca1f97e0ef3d7a75eec7f1140cc5c378 /src/main/java
parentf2d502518ea3de673c7f0ebf425f53295f620f2f (diff)
always show number of connected accounts in foreground notification
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/Config.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java81
2 files changed, 38 insertions, 45 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index 5ad1f873c..6bbf2b1d0 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -63,8 +63,6 @@ public final class Config {
public static final boolean HIDE_MESSAGE_TEXT_IN_NOTIFICATION = false;
- public static final boolean SHOW_CONNECTED_ACCOUNTS = false; //show number of connected accounts in foreground notification
-
public static final boolean ALWAYS_NOTIFY_BY_DEFAULT = false;
public static final boolean SUPPRESS_ERROR_NOTIFICATION = false;
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index c3f97a7fe..7b2dc2122 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -910,57 +910,52 @@ public class NotificationService {
Notification createForegroundNotification() {
final Notification.Builder mBuilder = new Notification.Builder(mXmppConnectionService);
mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
- if (Compatibility.runsAndTargetsTwentySix(mXmppConnectionService) || Config.SHOW_CONNECTED_ACCOUNTS) {
- List<Account> accounts = mXmppConnectionService.getAccounts();
- int enabled = 0;
- int connected = 0;
- String status;
- Account mAccount = null;
- if (accounts != null) {
- for (Account account : accounts) {
- if (account.isOnlineAndConnected()) {
- connected++;
- enabled++;
- } else if (account.isEnabled()) {
- enabled++;
- }
- }
- if (accounts.size() == 1) {
- mAccount = accounts.get(0);
- if (mAccount.getStatus() == Account.State.ONLINE) {
- status = "(" + mXmppConnectionService.getString(R.string.account_status_online) + ")";
- status = " " + status;
- Log.d(Config.LOGTAG, "Status: " + status);
- mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
- } else if (mAccount.getStatus() == Account.State.CONNECTING) {
- status = "(" + mXmppConnectionService.getString(R.string.account_status_connecting) + ")";
- status = " " + status;
- Log.d(Config.LOGTAG, "Status: " + status);
- mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
- } else {
- status = "(" + mXmppConnectionService.getString(R.string.account_status_offline) + ")";
- status = " " + status;
- Log.d(Config.LOGTAG, "Status: " + status);
- mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
- }
- } else if (accounts.size() > 1) {
- mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
- } else {
- status = "(" + mXmppConnectionService.getString(R.string.account_status_offline) + ")";
- status = " " + status;
- Log.d(Config.LOGTAG, "Status: " + status);
- mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
+ Account mAccount = null;
+ String status;
+ final List<Account> accounts = mXmppConnectionService.getAccounts();
+ int enabled = 0;
+ int connected = 0;
+ if (accounts != null) {
+ for (Account account : accounts) {
+ if (account.isOnlineAndConnected()) {
+ connected++;
+ enabled++;
+ } else if (account.isEnabled()) {
+ enabled++;
}
+ }
+ }
+ if (accounts.size() == 1) {
+ mAccount = accounts.get(0);
+ if (mAccount.getStatus() == Account.State.ONLINE) {
+ status = "(" + mXmppConnectionService.getString(R.string.account_status_online) + ")";
+ status = " " + status;
+ Log.d(Config.LOGTAG, "Status: " + status);
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
+ } else if (mAccount.getStatus() == Account.State.CONNECTING) {
+ status = "(" + mXmppConnectionService.getString(R.string.account_status_connecting) + ")";
+ status = " " + status;
+ Log.d(Config.LOGTAG, "Status: " + status);
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
} else {
- mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
+ status = "(" + mXmppConnectionService.getString(R.string.account_status_offline) + ")";
+ status = " " + status;
+ Log.d(Config.LOGTAG, "Status: " + status);
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
}
+ } else if (accounts.size() > 1) {
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
} else {
- mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
+ status = "(" + mXmppConnectionService.getString(R.string.account_status_offline) + ")";
+ status = " " + status;
+ Log.d(Config.LOGTAG, "Status: " + status);
+ mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service) + status);
}
+ mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
mBuilder.setContentIntent(createOpenConversationsIntent());
mBuilder.setWhen(0);
mBuilder.setPriority(Notification.PRIORITY_MIN);
- mBuilder.setSmallIcon(R.drawable.ic_link_white_24dp);
+ mBuilder.setSmallIcon(connected > 0 ? R.drawable.ic_link_white_24dp : R.drawable.ic_link_off_white_24dp);
if (Compatibility.runsTwentySix()) {
mBuilder.setChannelId(FOREGROUND_CHANNEL_ID);
}