1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-27 01:57:32 +01:00

Modify charts range based on settings. More/Less labels density.

This commit is contained in:
vanous 2019-08-12 23:18:20 +02:00 committed by Andreas Shimokawa
parent 80bd31d894
commit a263059317

View File

@ -59,7 +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 = 7; protected final int TOTAL_DAYS = getRangeDays();
private Locale mLocale; private Locale mLocale;
private int mTargetValue = 0; private int mTargetValue = 0;
@ -103,6 +103,17 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
// mBalanceView.setText(getBalanceMessage(balance)); // mBalanceView.setText(getBalanceMessage(balance));
} }
private String getWeeksChartsLabel(Calendar day){
if (GBApplication.getPrefs().getBoolean("charts_range", true)) {
//month, show day date
return String.valueOf(day.get(Calendar.DAY_OF_MONTH));
}
else{
//week, show short day name
return day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale);
}
}
private WeekChartsData<BarData> refreshWeekBeforeData(DBHandler db, BarChart barChart, Calendar day, GBDevice device) { private WeekChartsData<BarData> refreshWeekBeforeData(DBHandler db, BarChart barChart, Calendar day, GBDevice device) {
day = (Calendar) day.clone(); // do not modify the caller's argument day = (Calendar) day.clone(); // do not modify the caller's argument
day.add(Calendar.DATE, -TOTAL_DAYS); day.add(Calendar.DATE, -TOTAL_DAYS);
@ -115,7 +126,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
balance += calculateBalance(amounts); balance += calculateBalance(amounts);
entries.add(new BarEntry(counter, getTotalsForActivityAmounts(amounts))); entries.add(new BarEntry(counter, getTotalsForActivityAmounts(amounts)));
labels.add(day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale)); labels.add(getWeeksChartsLabel(day));
day.add(Calendar.DATE, 1); day.add(Calendar.DATE, 1);
} }
@ -337,6 +348,14 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
return amounts; return amounts;
} }
private int getRangeDays(){
if (GBApplication.getPrefs().getBoolean("charts_range", true)) {
return 30;}
else{
return 7;
}
}
abstract String getAverage(float value); abstract String getAverage(float value);
abstract int getGoal(); abstract int getGoal();