mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 22:12:55 +00:00
Generate TextDrawable based on issuer and use account name as fallback
This commit is contained in:
parent
4a4ab1a82c
commit
3aba0f3f47
3 changed files with 28 additions and 22 deletions
|
@ -8,13 +8,16 @@ public class TextDrawableHelper {
|
|||
|
||||
}
|
||||
|
||||
public static TextDrawable generate(String s) {
|
||||
if (s == null || s.length() <= 1) {
|
||||
return null;
|
||||
public static TextDrawable generate(String text, String fallback) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
if (fallback == null || fallback.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
text = fallback;
|
||||
}
|
||||
|
||||
ColorGenerator generator = ColorGenerator.MATERIAL;
|
||||
int color = generator.getColor(s);
|
||||
return TextDrawable.builder().buildRound(s.substring(0, 1).toUpperCase(), color);
|
||||
int color = generator.getColor(text);
|
||||
return TextDrawable.builder().buildRound(text.substring(0, 1).toUpperCase(), color);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue