mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-24 16:21:16 +02:00
Edit Changelog
Do not count days with 0 steps into average/goal. Add sleep to the 0 days not calculation. Do not count days with 0 steps into average/goal.
This commit is contained in:
parent
89017ac58f
commit
630c58c8f4
@ -1,5 +1,8 @@
|
||||
### Changelog
|
||||
|
||||
#### Version 0.43.2
|
||||
* Fossil Q Hybrid: Allow choosing and cropping image to be set as watch background
|
||||
* Steps/Sleep averages: skip days with zero data
|
||||
|
||||
#### Version 0.43.1
|
||||
* Initial support for Amazfit Bip S (incomplete, needs the official app once to obtain the pairing key)
|
||||
|
@ -59,6 +59,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.LimitedQueue;
|
||||
public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(AbstractWeekChartFragment.class);
|
||||
protected final int TOTAL_DAYS = getRangeDays();
|
||||
protected int TOTAL_DAYS_FOR_AVERAGE = 0;
|
||||
|
||||
private Locale mLocale;
|
||||
private int mTargetValue = 0;
|
||||
@ -124,10 +125,17 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
ArrayList<String> labels = new ArrayList<String>();
|
||||
|
||||
long balance = 0;
|
||||
long daily_balance=0;
|
||||
|
||||
|
||||
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
||||
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
||||
daily_balance=calculateBalance(amounts);
|
||||
if (daily_balance>0){
|
||||
TOTAL_DAYS_FOR_AVERAGE++;
|
||||
}
|
||||
|
||||
balance += calculateBalance(amounts);
|
||||
balance += daily_balance;
|
||||
entries.add(new BarEntry(counter, getTotalsForActivityAmounts(amounts)));
|
||||
labels.add(getWeeksChartsLabel(day));
|
||||
day.add(Calendar.DATE, 1);
|
||||
@ -146,8 +154,8 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||
barChart.getAxisLeft().addLimitLine(target);
|
||||
|
||||
float average = 0;
|
||||
if (TOTAL_DAYS > 0) {
|
||||
average = Math.abs(balance / TOTAL_DAYS);
|
||||
if (TOTAL_DAYS_FOR_AVERAGE > 0) {
|
||||
average = Math.abs(balance / TOTAL_DAYS_FOR_AVERAGE);
|
||||
}
|
||||
LimitLine average_line = new LimitLine(average);
|
||||
average_line.setLabel(getString(R.string.average, getAverage(average)));
|
||||
|
@ -76,7 +76,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||
@Override
|
||||
protected String getBalanceMessage(long balance, int targetValue) {
|
||||
if (balance > 0) {
|
||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS);
|
||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS_FOR_AVERAGE);
|
||||
if (totalBalance > 0)
|
||||
return getString(R.string.overslept, getHM(totalBalance));
|
||||
else
|
||||
|
@ -109,7 +109,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||
@Override
|
||||
protected String getBalanceMessage(long balance, int targetValue) {
|
||||
if (balance > 0) {
|
||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS);
|
||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS_FOR_AVERAGE);
|
||||
if (totalBalance > 0)
|
||||
return getString(R.string.overstep, Math.abs(totalBalance));
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user