-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Use application icon for notifications on Android #5667
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
base: develop
Are you sure you want to change the base?
Use application icon for notifications on Android #5667
Conversation
This code works... if your icon is white. Android design specifications require an all-white small icon for notifications (more or less, additional reading), because they use that to create small silhouettes. If you pass in an icon with a color, you just get a box (or circle) and android refuses to render it. Here's an example of what an app looks like with an all-white icon: And here's when I try the default Fyne icon: So I think we either need to support a Would love to hear any other ideas and contribute what I can to this. |
I think the same style of icon is required to make the "adaptive icons" (matching system theme) work for Android as well. Might be good to auto-generate by default (strip out background and make the rest white?) but provide the option for something in the metadata perhaps "silhouette icon" or "outline icon" that we can use in these cases? |
Stripping out the background and making the rest white will be a complicated task. If it is true that greyscale icons work (can check), then I'd say we should just make the icon greyscale by default, and yes supporting a different icon type for this in the metadata would be worth including as part of this I think |
Greyscale icons do not work on my device |
It shouldn't be too tough to convert all pixels that are BG (the top left or most common of all 4 corners colour) to transparent. After that all visible pixels go white. |
My launcher icon background is a white circle, which is a pretty common pattern. If the white circle is identified as the background and made transparent, and the rest made white, that would work really well in my case, and a few other examples I can see on my phone. So in the tools repo, I suspect one of the packaging steps would be to generate this icon and add it to the android manifest somehow so that we can reference it in this part of the code? Then allow for an override to what that reference points to. |
Sounds good. |
RIght, we shouldn't assume a circle, it's just a common pattern, so whatever we do shouldn't break with a circle. Adaptive icons are cool! I wasn't aware of this. |
What is the rest of the icon outline if the background is only a circle shape? |
jobject appInfo = (*env)->CallObjectMethod(env, (jobject)ctx, getApplicationInfoMethod); | ||
jclass applicationInfoClass = find_class(env, "android/content/pm/ApplicationInfo"); | ||
jfieldID iconFieldID = (*env)->GetFieldID(env, applicationInfoClass, "icon", "I"); | ||
jint iconID = (*env)->GetIntField(env, appInfo, iconFieldID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very glad you tracked this down. Feels like the hard part is already done :). Now we just need to get the API right for the icon types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope it's useful! I got familiar with the JNI stuff doing the battery optimization calls, so I'm happy to dive into more JNI where it's needed.
Not 100% sure I understand the question, but I think the answer is transparency. I have a square transparent PNG, containing a white circle, with my logo in it |
Thanks, that is what I was asking. In that case (icons not matching the recommended square non-transparent) then maybe we see transparent pixel and do no transformation and allow the app to override. At least they the silhouette will be right which may in cases be all that was wanted. |
Description:
This is a work in progress to get android notifications to use a good icon. Experimentation reveals we have some choices to make about how icons are defined in Fyne, discussion below.
Fixes #936
Checklist: