From c7387ee37c5d2f362bd8b471c2e59997e4ceefec Mon Sep 17 00:00:00 2001
From: str4d <str4d@mail.i2p>
Date: Tue, 26 Jan 2016 02:44:23 +0000
Subject: [PATCH] Modify IdenticonBase to use a dark background for light
 identicons

---
 .../im/delight/android/identicons/IdenticonBase.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/briar-android/src/im/delight/android/identicons/IdenticonBase.java b/briar-android/src/im/delight/android/identicons/IdenticonBase.java
index 8a7153ed99..f5ccc90e44 100644
--- a/briar-android/src/im/delight/android/identicons/IdenticonBase.java
+++ b/briar-android/src/im/delight/android/identicons/IdenticonBase.java
@@ -51,13 +51,14 @@ public abstract class IdenticonBase {
     protected void setupColors() {
         mColors = new int[mRowCount][mColumnCount];
         int colorVisible = getIconColor();
+        int colorInvisible = getBackgroundColor();
 
         for (int r = 0; r < mRowCount; r++) {
             for (int c = 0; c < mColumnCount; c++) {
                 if (isCellVisible(r, c)) {
                     mColors[r][c] = colorVisible;
                 } else {
-                    mColors[r][c] = Color.TRANSPARENT;
+                    mColors[r][c] = colorInvisible;
                 }
             }
         }
@@ -94,6 +95,15 @@ public abstract class IdenticonBase {
 
     abstract protected int getIconColor();
 
+    protected int getBackgroundColor() {
+        float[] hsv = new float[3];
+        Color.colorToHSV(getIconColor(), hsv);
+        if (hsv[2] < 0.5)
+            return Color.parseColor("#ffeeeeee"); // @color/background_material_light
+        else
+            return Color.parseColor("#ff303030"); // @color/background_material_dark
+    }
+
     public void updateSize(int w, int h) {
         mCellWidth = w / mColumnCount;
         mCellHeight = h / mRowCount;
-- 
GitLab