New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom notification light color on Android 8+ #5544
Comments
This comment has been minimized.
This comment has been minimized.
The options for LED notification and vibrate pattern now appear in the account settings. However, they are greyed-out, so they cannot be used. Tested on Huawei Mediapad and Ulefone (both Android 8). |
You have to enable vibration and "blink light" for the "Messages" notification category first. |
Either your device has no notification light or you'll have to enable it in Android settings. |
Same problem on Honor 8X. All three Devices work fine with K9 5.6 (out of the box). |
I wonder why those options have to be grayed out anyway. In version 5.6 they were accessible all the time and the feature just worked great. |
If you want to learn more about how the notification API on Android works, I suggest starting here: https://developer.android.com/training/notify-user/channels |
Thanks. I'll go back to version 5.6 until the bug is fixed. |
Looks like you just have to call enableLights and setLightColor... |
By default global use of the notification light is disabled on newer Android versions. Your screenshot doesn't show a "blink light" option, so for you it's most likely disabled in Android settings. On one of my test devices with a notification LED (Android 8) the setting can be found under Android settings > Apps & notifications > Notifications > Blink light. It's probably best to use the search function to search for "blink light". Afterwards a "Blink light" option will appear in the "Messages" notification category screen. After enabling it there, you'll be able to select a notification light color in K-9 Mail. |
There is a global setting, yes. It is enabled (other apps can blink the LED- including K9 5.6). By the way, my Honor 8X has Android 10. The other two devices have Android 8. Unfortunately I don't own more devices, so my testing abilities are limited. But on all 3 (of 3) devices, this problem exists. All have notification LEDs which worked fine in K9 5.6. |
Could you publish a debugging version of K9 which simply ignores the value returned by shouldShowLights (and assumes "true")? |
The setting in K-9 Mail will only configure the light color, not enable the "blink light" feature. That's typically done using Android's UI to change the settings of the notification category. Allowing the user to pick a color when the feature is not enabled won't do anything. Since you feel confident enough to suggest code changes, you should have no trouble building the app yourself. It's basically installing Android Studio, cloning the repository, and opening the project in Android Studio. See https://github.com/k9mail/k-9/wiki/BuildingK9 (somewhat outdated, but still mostly correct) You could try removing the code to disable the notification light preference and then explicitly enable the notification light in |
https://github.com/k9mail/k-9/search?q=shouldshowlights I can confirm that replacing both occurrences of shouldShowLights() by "true" resolves the issue. |
Thanks for testing this 👍 It looks like some vendors were really lazy when building their Android version and only allow the user to change very few properties of a notification. To allow users of such devices to configure the notification category, we'll have to basically offer the settings that should be available in the system UI. I guess we can do this in one of two ways:
Neither of these options sounds very appealing. I'll have to think about this for a bit. @kriegste: Out of curiosity; does the "notification management" screen allow you to change the "ringtone" or can you only turn it on and off? |
On my Honor 8X (Android 10) I can change the sound per app. I will have a look into the other devices later. Please don't complicate the issue. Edit: Edit2: |
Android 8 has introduced notification channels where an app can only provide an initial configuration. After creation a notification channel can only be configured by the user via Android's notification settings. Unfortunately their settings screen doesn't allow setting a color for the notification light.
It seems like our only option is to use our own UI to allow users to select a color for the notification light. Then we'll have to delete the existing notification channel and create a new one (copying the configuration of the old notification channel).
We will also have to use a different ID for the new notification channel. So we have to dynamically create that ID and keep track of it instead of being able to use a static identifier.
See also #5543
The text was updated successfully, but these errors were encountered: