mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Remove target from HistoryChart and BarChart
This commit is contained in:
@@ -191,7 +191,6 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
|
|||||||
historyChart.setColor(color);
|
historyChart.setColor(color);
|
||||||
historyChart.setEntries(checkmarks);
|
historyChart.setEntries(checkmarks);
|
||||||
historyChart.setNumerical(habit.isNumerical());
|
historyChart.setNumerical(habit.isNumerical());
|
||||||
historyChart.setTarget(habit.getTargetValue() / habit.getFrequency().getDenominator());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,12 +94,8 @@ public class BarChart extends ScrollableChart
|
|||||||
|
|
||||||
private double maxValue;
|
private double maxValue;
|
||||||
|
|
||||||
private double target;
|
|
||||||
|
|
||||||
private int primaryColor;
|
private int primaryColor;
|
||||||
|
|
||||||
private int darkerPrimaryColor;
|
|
||||||
|
|
||||||
public BarChart(Context context)
|
public BarChart(Context context)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context);
|
||||||
@@ -126,7 +122,6 @@ public class BarChart extends ScrollableChart
|
|||||||
}
|
}
|
||||||
|
|
||||||
setEntries(entries);
|
setEntries(entries);
|
||||||
setTarget(0.5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBucketSize(int bucketSize)
|
public void setBucketSize(int bucketSize)
|
||||||
@@ -150,9 +145,7 @@ public class BarChart extends ScrollableChart
|
|||||||
public void setColor(int primaryColor)
|
public void setColor(int primaryColor)
|
||||||
{
|
{
|
||||||
StyledResources res = new StyledResources(getContext());
|
StyledResources res = new StyledResources(getContext());
|
||||||
int backgroundColor = res.getColor(R.attr.cardBgColor);
|
|
||||||
this.primaryColor = primaryColor;
|
this.primaryColor = primaryColor;
|
||||||
this.darkerPrimaryColor = ColorUtils.mixColors(primaryColor, backgroundColor, 0.6f);
|
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,12 +155,6 @@ public class BarChart extends ScrollableChart
|
|||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(double target)
|
|
||||||
{
|
|
||||||
this.target = target;
|
|
||||||
postInvalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas)
|
protected void onDraw(Canvas canvas)
|
||||||
{
|
{
|
||||||
@@ -275,8 +262,7 @@ public class BarChart extends ScrollableChart
|
|||||||
float margin = baseSize * 0.225f;
|
float margin = baseSize * 0.225f;
|
||||||
float round = dpToPixels(getContext(), 2);
|
float round = dpToPixels(getContext(), 2);
|
||||||
|
|
||||||
int color = darkerPrimaryColor;
|
int color = primaryColor;
|
||||||
if (value / 1000 >= target) color = primaryColor;
|
|
||||||
|
|
||||||
rect.inset(-margin, 0);
|
rect.inset(-margin, 0);
|
||||||
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
||||||
@@ -367,10 +353,7 @@ public class BarChart extends ScrollableChart
|
|||||||
private void drawValue(Canvas canvas, RectF rect, double value)
|
private void drawValue(Canvas canvas, RectF rect, double value)
|
||||||
{
|
{
|
||||||
if (value == 0) return;
|
if (value == 0) return;
|
||||||
|
int activeColor = primaryColor;
|
||||||
int activeColor = darkerPrimaryColor;
|
|
||||||
if (value / 1000 >= target)
|
|
||||||
activeColor = primaryColor;
|
|
||||||
|
|
||||||
String label = NumberButtonViewKt.toShortString(value / 1000);
|
String label = NumberButtonViewKt.toShortString(value / 1000);
|
||||||
Rect rText = new Rect();
|
Rect rText = new Rect();
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ public class HistoryChart extends ScrollableChart
|
|||||||
{
|
{
|
||||||
private int[] checkmarks;
|
private int[] checkmarks;
|
||||||
|
|
||||||
private double target;
|
|
||||||
|
|
||||||
private Paint pSquareBg, pSquareFg, pTextHeader;
|
private Paint pSquareBg, pSquareFg, pTextHeader;
|
||||||
|
|
||||||
private float squareSpacing;
|
private float squareSpacing;
|
||||||
@@ -227,12 +225,6 @@ public class HistoryChart extends ScrollableChart
|
|||||||
this.isEditable = isEditable;
|
this.isEditable = isEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(double target)
|
|
||||||
{
|
|
||||||
this.target = target;
|
|
||||||
postInvalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFirstWeekday(int firstWeekday)
|
public void setFirstWeekday(int firstWeekday)
|
||||||
{
|
{
|
||||||
this.firstWeekday = firstWeekday;
|
this.firstWeekday = firstWeekday;
|
||||||
@@ -397,7 +389,7 @@ public class HistoryChart extends ScrollableChart
|
|||||||
pSquareBg.setColor(colors[0]);
|
pSquareBg.setColor(colors[0]);
|
||||||
pSquareFg.setColor(textColors[1]);
|
pSquareFg.setColor(textColors[1]);
|
||||||
}
|
}
|
||||||
else if ((isNumerical && (checkmark / 1000f >= target) || (!isNumerical && checkmark == YES_MANUAL)))
|
else if (isNumerical || checkmark == YES_MANUAL)
|
||||||
{
|
{
|
||||||
pSquareBg.setColor(colors[2]);
|
pSquareBg.setColor(colors[2]);
|
||||||
pSquareFg.setColor(textColors[2]);
|
pSquareFg.setColor(textColors[2]);
|
||||||
@@ -458,7 +450,6 @@ public class HistoryChart extends ScrollableChart
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
target = 2;
|
|
||||||
|
|
||||||
initColors();
|
initColors();
|
||||||
initPaints();
|
initPaints();
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ data class BarCardViewModel(
|
|||||||
val bucketSize: Int,
|
val bucketSize: Int,
|
||||||
val color: PaletteColor,
|
val color: PaletteColor,
|
||||||
val isNumerical: Boolean,
|
val isNumerical: Boolean,
|
||||||
val target: Double,
|
|
||||||
val numericalSpinnerPosition: Int,
|
val numericalSpinnerPosition: Int,
|
||||||
val boolSpinnerPosition: Int,
|
val boolSpinnerPosition: Int,
|
||||||
)
|
)
|
||||||
@@ -52,10 +51,8 @@ class BarCard(context: Context, attrs: AttributeSet) : LinearLayout(context, att
|
|||||||
binding.barChart.setColor(androidColor)
|
binding.barChart.setColor(androidColor)
|
||||||
if (data.isNumerical) {
|
if (data.isNumerical) {
|
||||||
binding.boolSpinner.visibility = GONE
|
binding.boolSpinner.visibility = GONE
|
||||||
binding.barChart.setTarget(data.target)
|
|
||||||
} else {
|
} else {
|
||||||
binding.numericalSpinner.visibility = GONE
|
binding.numericalSpinner.visibility = GONE
|
||||||
binding.barChart.setTarget(0.0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.numericalSpinner.onItemSelectedListener = null
|
binding.numericalSpinner.onItemSelectedListener = null
|
||||||
@@ -115,7 +112,6 @@ class BarCardPresenter(
|
|||||||
bucketSize = bucketSize,
|
bucketSize = bucketSize,
|
||||||
color = habit.color,
|
color = habit.color,
|
||||||
isNumerical = habit.isNumerical,
|
isNumerical = habit.isNumerical,
|
||||||
target = (habit.targetValue / habit.frequency.denominator * bucketSize),
|
|
||||||
numericalSpinnerPosition = numericalSpinnerPosition,
|
numericalSpinnerPosition = numericalSpinnerPosition,
|
||||||
boolSpinnerPosition = boolSpinnerPosition,
|
boolSpinnerPosition = boolSpinnerPosition,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ data class HistoryCardViewModel(
|
|||||||
val firstWeekday: Int,
|
val firstWeekday: Int,
|
||||||
val isNumerical: Boolean,
|
val isNumerical: Boolean,
|
||||||
val isSkipEnabled: Boolean,
|
val isSkipEnabled: Boolean,
|
||||||
val target: Double,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class HistoryCard(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
|
class HistoryCard(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
|
||||||
@@ -54,7 +53,6 @@ class HistoryCard(context: Context, attrs: AttributeSet) : LinearLayout(context,
|
|||||||
binding.historyChart.setColor(androidColor)
|
binding.historyChart.setColor(androidColor)
|
||||||
if (data.isNumerical) {
|
if (data.isNumerical) {
|
||||||
binding.historyChart.setNumerical(true)
|
binding.historyChart.setNumerical(true)
|
||||||
binding.historyChart.setTarget(data.target)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,6 +69,5 @@ class HistoryCardPresenter(
|
|||||||
firstWeekday = firstWeekday,
|
firstWeekday = firstWeekday,
|
||||||
isNumerical = habit.isNumerical,
|
isNumerical = habit.isNumerical,
|
||||||
isSkipEnabled = isSkipEnabled,
|
isSkipEnabled = isSkipEnabled,
|
||||||
target = habit.targetValue / habit.frequency.denominator,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,6 @@ class HistoryWidget(
|
|||||||
setColor(habit.color.toThemedAndroidColor(context))
|
setColor(habit.color.toThemedAndroidColor(context))
|
||||||
setEntries(habit.computedEntries.getAllValues())
|
setEntries(habit.computedEntries.getAllValues())
|
||||||
setNumerical(habit.isNumerical)
|
setNumerical(habit.isNumerical)
|
||||||
setTarget(habit.targetValue / habit.frequency.denominator)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user