mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-27 23:40:31 +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
|
### 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
|
#### Version 0.43.1
|
||||||
* Initial support for Amazfit Bip S (incomplete, needs the official app once to obtain the pairing key)
|
* 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 {
|
public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||||
protected static final Logger LOG = LoggerFactory.getLogger(AbstractWeekChartFragment.class);
|
protected static final Logger LOG = LoggerFactory.getLogger(AbstractWeekChartFragment.class);
|
||||||
protected final int TOTAL_DAYS = getRangeDays();
|
protected final int TOTAL_DAYS = getRangeDays();
|
||||||
|
protected int TOTAL_DAYS_FOR_AVERAGE = 0;
|
||||||
|
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private int mTargetValue = 0;
|
private int mTargetValue = 0;
|
||||||
|
@ -124,10 +125,17 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||||
ArrayList<String> labels = new ArrayList<String>();
|
ArrayList<String> labels = new ArrayList<String>();
|
||||||
|
|
||||||
long balance = 0;
|
long balance = 0;
|
||||||
|
long daily_balance=0;
|
||||||
|
|
||||||
|
|
||||||
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
for (int counter = 0; counter < TOTAL_DAYS; counter++) {
|
||||||
ActivityAmounts amounts = getActivityAmountsForDay(db, day, device);
|
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)));
|
entries.add(new BarEntry(counter, getTotalsForActivityAmounts(amounts)));
|
||||||
labels.add(getWeeksChartsLabel(day));
|
labels.add(getWeeksChartsLabel(day));
|
||||||
day.add(Calendar.DATE, 1);
|
day.add(Calendar.DATE, 1);
|
||||||
|
@ -146,8 +154,8 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
||||||
barChart.getAxisLeft().addLimitLine(target);
|
barChart.getAxisLeft().addLimitLine(target);
|
||||||
|
|
||||||
float average = 0;
|
float average = 0;
|
||||||
if (TOTAL_DAYS > 0) {
|
if (TOTAL_DAYS_FOR_AVERAGE > 0) {
|
||||||
average = Math.abs(balance / TOTAL_DAYS);
|
average = Math.abs(balance / TOTAL_DAYS_FOR_AVERAGE);
|
||||||
}
|
}
|
||||||
LimitLine average_line = new LimitLine(average);
|
LimitLine average_line = new LimitLine(average);
|
||||||
average_line.setLabel(getString(R.string.average, getAverage(average)));
|
average_line.setLabel(getString(R.string.average, getAverage(average)));
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
||||||
@Override
|
@Override
|
||||||
protected String getBalanceMessage(long balance, int targetValue) {
|
protected String getBalanceMessage(long balance, int targetValue) {
|
||||||
if (balance > 0) {
|
if (balance > 0) {
|
||||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS);
|
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS_FOR_AVERAGE);
|
||||||
if (totalBalance > 0)
|
if (totalBalance > 0)
|
||||||
return getString(R.string.overslept, getHM(totalBalance));
|
return getString(R.string.overslept, getHM(totalBalance));
|
||||||
else
|
else
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
||||||
@Override
|
@Override
|
||||||
protected String getBalanceMessage(long balance, int targetValue) {
|
protected String getBalanceMessage(long balance, int targetValue) {
|
||||||
if (balance > 0) {
|
if (balance > 0) {
|
||||||
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS);
|
final long totalBalance = balance - ((long)targetValue * TOTAL_DAYS_FOR_AVERAGE);
|
||||||
if (totalBalance > 0)
|
if (totalBalance > 0)
|
||||||
return getString(R.string.overstep, Math.abs(totalBalance));
|
return getString(R.string.overstep, Math.abs(totalBalance));
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user