Modify IdenticonBase to use a dark background for light identicons

This commit is contained in:
str4d
2016-01-26 02:44:23 +00:00
parent dfb9222ccd
commit c7387ee37c

View File

@@ -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;