Fix colors in BarChart and HistoryChard

pull/630/head
Alinson S. Xavier 5 years ago
parent 61f32449dd
commit 8a895b2d20

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@ -181,6 +181,8 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
int color = PaletteUtils.getColor(getContext(), habit.getColor());
historyChart.setColor(color);
historyChart.setCheckmarks(checkmarks);
historyChart.setNumerical(habit.isNumerical());
historyChart.setTarget(habit.getTargetValue() / habit.getFrequency().getDenominator());
}
}
}

@ -77,8 +77,6 @@ public class BarChart extends ScrollableChart
@Nullable
private List<Checkmark> checkmarks;
private int primaryColor;
private int bucketSize = 7;
private int backgroundColor;
@ -99,6 +97,10 @@ public class BarChart extends ScrollableChart
private double target;
private int primaryColor;
private int darkerPrimaryColor;
public BarChart(Context context)
{
super(context);
@ -148,7 +150,10 @@ public class BarChart extends ScrollableChart
public void setColor(int primaryColor)
{
StyledResources res = new StyledResources(getContext());
int backgroundColor = res.getColor(R.attr.cardBgColor);
this.primaryColor = primaryColor;
this.darkerPrimaryColor = ColorUtils.mixColors(primaryColor, backgroundColor, 0.6f);
postInvalidate();
}
@ -271,7 +276,7 @@ public class BarChart extends ScrollableChart
float margin = baseSize * 0.225f;
float round = dpToPixels(getContext(), 2);
int color = textColor;
int color = darkerPrimaryColor;
if (value / 1000 >= target) color = primaryColor;
rect.inset(-margin, 0);
@ -364,7 +369,7 @@ public class BarChart extends ScrollableChart
{
if (value == 0) return;
int activeColor = textColor;
int activeColor = darkerPrimaryColor;
if (value / 1000 >= target)
activeColor = primaryColor;

@ -44,7 +44,7 @@ public class HistoryChart extends ScrollableChart
{
private int[] checkmarks;
private int target;
private double target;
private Paint pSquareBg, pSquareFg, pTextHeader;
@ -202,6 +202,7 @@ public class HistoryChart extends ScrollableChart
public void setNumerical(boolean numerical)
{
isNumerical = numerical;
postInvalidate();
}
public void setIsBackgroundTransparent(boolean isBackgroundTransparent)
@ -215,7 +216,7 @@ public class HistoryChart extends ScrollableChart
this.isEditable = isEditable;
}
public void setTarget(int target)
public void setTarget(double target)
{
this.target = target;
postInvalidate();
@ -385,14 +386,14 @@ public class HistoryChart extends ScrollableChart
pSquareBg.setColor(colors[0]);
pSquareFg.setColor(textColors[1]);
}
else if ((isNumerical && checkmark < target) || checkmark != YES_MANUAL)
else if ((isNumerical && (checkmark / 1000f >= target) || (!isNumerical && checkmark == YES_MANUAL)))
{
pSquareBg.setColor(colors[1]);
pSquareBg.setColor(colors[2]);
pSquareFg.setColor(textColors[2]);
}
else
{
pSquareBg.setColor(colors[2]);
pSquareBg.setColor(colors[1]);
pSquareFg.setColor(textColors[2]);
}
}

@ -79,7 +79,7 @@ class HabitCardListView(
cardView.dataOffset = dataOffset
cardView.score = score
cardView.unit = habit.unit
cardView.threshold = habit.targetValue
cardView.threshold = habit.targetValue / habit.frequency.denominator
val detector = GestureDetector(context, CardViewGestureDetector(holder))
cardView.setOnTouchListener { _, ev ->

@ -149,7 +149,7 @@ public class BarCard extends HabitCard
if (habit.isNumerical())
{
boolSpinner.setVisibility(GONE);
chart.setTarget(habit.getTargetValue() * bucketSize);
chart.setTarget(habit.getTargetValue() / habit.getFrequency().getDenominator() * bucketSize);
}
else
{

@ -132,8 +132,8 @@ public class HistoryCard extends HabitCard
chart.setColor(color);
if(habit.isNumerical())
{
chart.setTarget((int) (habit.getTargetValue() * 1000));
chart.setNumerical(true);
chart.setTarget(habit.getTargetValue() / habit.getFrequency().getDenominator());
}
}
}

@ -46,6 +46,8 @@ class HistoryWidget(
setFirstWeekday(firstWeekday)
setColor(PaletteUtils.getColor(context, habit.color))
setCheckmarks(habit.checkmarks.allValues)
setNumerical(habit.isNumerical)
setTarget(habit.targetValue / habit.frequency.denominator)
}
}

Loading…
Cancel
Save