create colored name avatars when no avatar picture is set

Bug #1550670 reported by swizzle on 2016-02-27
This bug affects 3 people
Affects Status Importance Assigned to Milestone

Bug Description

just what the title says. We've seen this in Android an iOS, it looks and works pretty well. Daniel Foré would be DF

description: updated
Daniel Fore (danrabbit) on 2016-03-03
Changed in pantheon-mail:
importance: Undecided → Wishlist
Daniel Fore (danrabbit) wrote :

We'll probably want to create this functionality inside granite.widgets.avatar itself

I think we would want the colors to be consistent across apps, so we'll have to figure out some scheme for generating colors consistently. For example we could convert the name to hex (even 3 characters give us 6 characters in hex) and use the first 6 characters or something.

Changed in pantheon-mail:
status: New → Confirmed
Daniel Fore (danrabbit) wrote :

Alright so it sounds like this is what we need to do. Granite.Widgets.Avatar needs to be able to accept either a string or an image, but one of these should be mandatory. No more mystery man. Given a string, it should...

Get letters to display:

* Take the first two letters of the first two words. So if you give it "Gordon Ramsey", it takes "GR". If you give it "<email address hidden>" it takes "D".

Get a color to use:

* Take the first 3 characters of the string and convert that to hex.
* convert the hex to a HSL color.
* Maximize the saturation.

Getting the color with this formula instead of randomly means that given the same string you'll get the same filler-avatar across apps. So Gordon Ramsey is blue in Mail, Calendar, the session menu, the users plug, etc.

Sam Hewitt (snwh) on 2016-03-04
Changed in granite:
status: New → Confirmed

Sounds awesome! Back then you said replacing the shutdown icon by an avatar picture wouldn't look good because it is so small. What about a text avatar "DF" as a replacement for the shutdown icon?

PS: You're saying If you give it "<email address hidden>" it takes "D". I don't know if it is possible but maybe you could get the full name from the header or through the API instead of the email itself.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Related blueprints