always show number of connected accounts in foreground notification. fixes #3352

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/Config.java                       |  1 
src/main/java/eu/siacs/conversations/services/NotificationService.java | 28 
src/main/res/drawable-hdpi/ic_link_off_white_24dp.png                  |  0 
src/main/res/drawable-mdpi/ic_link_off_white_24dp.png                  |  0 
src/main/res/drawable-xhdpi/ic_link_off_white_24dp.png                 |  0 
src/main/res/drawable-xxhdpi/ic_link_off_white_24dp.png                |  0 
src/main/res/drawable-xxxhdpi/ic_link_off_white_24dp.png               |  0 
src/main/res/values/strings.xml                                        |  1 
src/quicksy/res/values/strings.xml                                     |  3 
9 files changed, 13 insertions(+), 20 deletions(-)

Detailed changes

src/main/java/eu/siacs/conversations/Config.java 🔗

@@ -51,7 +51,6 @@ public final class Config {
 
 	//Notification settings
 	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;
 

src/main/java/eu/siacs/conversations/services/NotificationService.java 🔗

@@ -901,28 +901,24 @@ public class NotificationService {
     Notification createForegroundNotification() {
         final Notification.Builder mBuilder = new Notification.Builder(mXmppConnectionService);
         mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.app_name));
-        if (Compatibility.runsAndTargetsTwentySix(mXmppConnectionService) || Config.SHOW_CONNECTED_ACCOUNTS) {
-            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++;
-                    }
+        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++;
                 }
             }
-            mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
-        } else {
-            mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
         }
+        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");

src/main/res/values/strings.xml 🔗

@@ -400,7 +400,6 @@
     <string name="pdf_document">PDF document</string>
     <string name="apk">Android App</string>
     <string name="vcard">Contact</string>
-    <string name="touch_to_open_conversations">Touch to open Conversations</string>
     <string name="avatar_has_been_published">Avatar has been published!</string>
     <string name="sending_x_file">Sending %s</string>
     <string name="offering_x_file">Offering %s</string>

src/quicksy/res/values/strings.xml 🔗

@@ -7,7 +7,6 @@
     <string name="contacts_have_no_pgp_keys">Quicksy is unable to encrypt your messages because your contacts are not announcing their public key.\n\n<small>Please ask your contacts to setup OpenPGP.</small></string>
     <string name="pref_notification_grace_period_summary">The length of time Quicksy keeps quiet after seeing activity on another device</string>
     <string name="pref_never_send_crash_summary">By sending in stack traces you are helping the ongoing development of Quicksy</string>
-    <string name="touch_to_open_conversations">Touch to open Quicksy</string>
     <string name="no_storage_permission">Quicksy needs access to external storage</string>
     <string name="no_camera_permission">Quicksy needs access to the camera</string>
     <string name="battery_optimizations_enabled_explained">Your device is doing some heavy battery optimizations on Quicksy that might lead to delayed notifications or even message loss.\nIt is recommended to disable those.</string>
@@ -20,4 +19,4 @@
     <string name="no_microphone_permission">Quicksy needs access to the microphone</string>
     <string name="foreground_service_channel_description">This notification category is used to display a permanent notification indicating that Quicksy is running.</string>
     <string name="set_profile_picture">Quicksy profile picture</string>
-</resources>
+</resources>