|
|
@ -218,14 +218,7 @@ public class HabitStreakView extends View implements HabitDataView
|
|
|
|
float gap = (width - barWidth) / 2;
|
|
|
|
float gap = (width - barWidth) / 2;
|
|
|
|
float paddingTopBottom = baseSize * 0.05f;
|
|
|
|
float paddingTopBottom = baseSize * 0.05f;
|
|
|
|
|
|
|
|
|
|
|
|
float croppedPercentage;
|
|
|
|
paint.setColor(percentageToColor(percentage));
|
|
|
|
if (maxLength == minLength)
|
|
|
|
|
|
|
|
croppedPercentage = 1.0f;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
croppedPercentage = (float) (streak.length - minLength) / (maxLength - minLength);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int c = (int) (croppedPercentage * 3);
|
|
|
|
|
|
|
|
paint.setColor(colors[(c)]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvas.drawRect(rect.left + gap, rect.top + paddingTopBottom, rect.right - gap,
|
|
|
|
canvas.drawRect(rect.left + gap, rect.top + paddingTopBottom, rect.right - gap,
|
|
|
|
rect.bottom - paddingTopBottom, paint);
|
|
|
|
rect.bottom - paddingTopBottom, paint);
|
|
|
@ -250,6 +243,14 @@ public class HabitStreakView extends View implements HabitDataView
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int percentageToColor(float percentage)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(percentage >= 1.0f) return colors[3];
|
|
|
|
|
|
|
|
if(percentage >= 0.8f) return colors[2];
|
|
|
|
|
|
|
|
if(percentage >= 0.5f) return colors[1];
|
|
|
|
|
|
|
|
return colors[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setIsBackgroundTransparent(boolean isBackgroundTransparent)
|
|
|
|
public void setIsBackgroundTransparent(boolean isBackgroundTransparent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.isBackgroundTransparent = isBackgroundTransparent;
|
|
|
|
this.isBackgroundTransparent = isBackgroundTransparent;
|
|
|
|