Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Disable badge for persistent notification (fixes #1305) #1307

Merged
merged 1 commit into from
Apr 20, 2019

Conversation

GermanCoding
Copy link
Contributor

@GermanCoding GermanCoding commented Apr 20, 2019

Purpose:

As mentioned in #1305, some users don't like the "dot" (badge) displayed when there is not really new info available.

Changes:

The current behavior is that the dot is always shown when syncthing has a notification open - usually the persistent Syncthing is running message used for the background service.

This PR changes this behavior and disables the dot/badge when only the Syncthing is running notification is displayed. This does not affect the operation of the notification or the service.

Please note that this only affects the Syncthing is running notification. The Syncthing is disabled message or other info notifications will still get a badge. This is intentional, because I think these notifications deserve attention from the user.

Tests:

I verified this briefly on Android Emulators running Android 8.1, 7.0 and 4.4. On API level >= 26 (Oreo) this works as intended, on lower Androids this has no effect because this feature does not exist.

Compatibility note:
NotificationChannel.setShowBadge() was added in API level 26. The buildscript currently targets/compiles this API level, therefore I concluded that usage of this method is unproblematic. The method call is guarded by a version comparison, to avoid calling this on anything lower than Oreo.

Copy link
Contributor

@capi capi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The version check is required, since our Min-SDK is below 26.

@capi capi merged commit 6a36c2d into syncthing:master Apr 20, 2019
@GermanCoding GermanCoding deleted the issue-1305 branch April 20, 2019 23:27
@Catfriend1
Copy link
Contributor

Hi,

I've tested this von AVD 8.0 (API level 26) and the badge still appears. I've also tried a different commit for the other channels, setting two of them to false and setting three of them to false - no luck.
Catfriend1/syncthing-android@dd05263

Can anyone please confirm this is working?

@GermanCoding
Copy link
Contributor Author

I'm repeating myself, but it worked in my tests on 8.1. I just performed an additional test with Android 8.0/API level 26 and it works there too. Screenshot below.

It's possible that you have uncleared notifications which prevent the badge from disappearing. Have you tried a clean install?

Android_8_Test

@Catfriend1
Copy link
Contributor

I'll try a fresh install later and post the screenshot from the emulator if the issue persists.

@capi
Copy link
Contributor

capi commented Apr 21, 2019

It seems to work on my Android 9, that's why I approved it. The thing is, that the handling of the notification dot can vary a lot between the ROMs and also can be forced and prohibited by users via the notification settings. That's how I got rid of the dot for this notification until now.

I think that the change is small and doesn't hurt, even if it might not fix it for everyone. I'm quite sure that it shouldn't cause problems for anyone.

@capi
Copy link
Contributor

capi commented Apr 21, 2019

Also, changes to the notification channel do not affect existing notifications, only newly created ones. And if you modified any of the settings for the channel at any time, it's possible that Android does not pick up the new settings (intentionally). That all could come into play here.

@Catfriend1
Copy link
Contributor

Thanks for the details on it, good work! Sure, it couldn't break anything so it's good :).

@syncthing syncthing locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants