From 8b55c9567a8d38ef1726d342271dfd80e7f6c737 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 25 Apr 2019 14:08:36 +0200 Subject: [PATCH] Letter text color --- app/src/main/java/eu/faircode/email/Identicon.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Identicon.java b/app/src/main/java/eu/faircode/email/Identicon.java index a5247567ef..39c72a6620 100644 --- a/app/src/main/java/eu/faircode/email/Identicon.java +++ b/app/src/main/java/eu/faircode/email/Identicon.java @@ -69,12 +69,10 @@ class Identicon { Canvas canvas = new Canvas(bitmap); canvas.drawColor(color); + float y = (299 * Color.red(color) + 587 * Color.green(color) + 114 * Color.blue(color)) / 1000f; + Paint paint = new Paint(); - paint.setColor(Color.argb( - Color.alpha(color), - (~Color.red(color)) & 0xff, - (~Color.green(color)) & 0xff, - (~Color.blue(color)) & 0xff)); + paint.setColor(y < 128 ? Color.WHITE : Color.BLACK); paint.setTextSize(size / 2f); paint.setFakeBoldText(true);