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