Skip to content
Snippets Groups Projects
Commit c7387ee3 authored by str4d's avatar str4d
Browse files

Modify IdenticonBase to use a dark background for light identicons

parent dfb9222c
No related branches found
No related tags found
No related merge requests found
...@@ -51,13 +51,14 @@ public abstract class IdenticonBase { ...@@ -51,13 +51,14 @@ public abstract class IdenticonBase {
protected void setupColors() { protected void setupColors() {
mColors = new int[mRowCount][mColumnCount]; mColors = new int[mRowCount][mColumnCount];
int colorVisible = getIconColor(); int colorVisible = getIconColor();
int colorInvisible = getBackgroundColor();
for (int r = 0; r < mRowCount; r++) { for (int r = 0; r < mRowCount; r++) {
for (int c = 0; c < mColumnCount; c++) { for (int c = 0; c < mColumnCount; c++) {
if (isCellVisible(r, c)) { if (isCellVisible(r, c)) {
mColors[r][c] = colorVisible; mColors[r][c] = colorVisible;
} else { } else {
mColors[r][c] = Color.TRANSPARENT; mColors[r][c] = colorInvisible;
} }
} }
} }
...@@ -94,6 +95,15 @@ public abstract class IdenticonBase { ...@@ -94,6 +95,15 @@ public abstract class IdenticonBase {
abstract protected int getIconColor(); 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) { public void updateSize(int w, int h) {
mCellWidth = w / mColumnCount; mCellWidth = w / mColumnCount;
mCellHeight = h / mRowCount; mCellHeight = h / mRowCount;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment