mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 16:41:43 +01:00
parent
1efdfb757c
commit
9b2f47d10a
@ -1,8 +1,9 @@
|
|||||||
###Changelog
|
###Changelog
|
||||||
|
|
||||||
###Version 0.18.0
|
###Version 0.18.0 (next)
|
||||||
* Added Portuguese pt_PT and pt_BR translations
|
* Added Portuguese pt_PT and pt_BR translations
|
||||||
* Consistently display device specific icons already during discovery
|
* Consistently display device specific icons already during discovery
|
||||||
|
* Add sleep chart diplaying the last week of sleep
|
||||||
|
|
||||||
####Version 0.17.5
|
####Version 0.17.5
|
||||||
* Automatically start the service on boot (can be turned off)
|
* Automatically start the service on boot (can be turned off)
|
||||||
|
@ -19,6 +19,7 @@ import com.github.mikephil.charting.data.BarEntry;
|
|||||||
import com.github.mikephil.charting.data.PieData;
|
import com.github.mikephil.charting.data.PieData;
|
||||||
import com.github.mikephil.charting.data.PieDataSet;
|
import com.github.mikephil.charting.data.PieDataSet;
|
||||||
import com.github.mikephil.charting.data.PieEntry;
|
import com.github.mikephil.charting.data.PieEntry;
|
||||||
|
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||||
import com.github.mikephil.charting.formatter.IValueFormatter;
|
import com.github.mikephil.charting.formatter.IValueFormatter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -93,7 +94,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
|
|
||||||
BarDataSet set = new BarDataSet(entries, "");
|
BarDataSet set = new BarDataSet(entries, "");
|
||||||
set.setColors(getColors());
|
set.setColors(getColors());
|
||||||
set.setValueFormatter(getFormatter());
|
set.setValueFormatter(getBarValueFormatter());
|
||||||
|
|
||||||
BarData barData = new BarData(set);
|
BarData barData = new BarData(set);
|
||||||
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);
|
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);
|
||||||
@ -119,7 +120,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
entries.add(new PieEntry(value));
|
entries.add(new PieEntry(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
set.setValueFormatter(getFormatter());
|
set.setValueFormatter(getPieValueFormatter());
|
||||||
set.setColors(getColors());
|
set.setColors(getColors());
|
||||||
|
|
||||||
if (totalValue < mTargetValue) {
|
if (totalValue < mTargetValue) {
|
||||||
@ -134,8 +135,6 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
return new DayData(data, formatPieValue((int) totalValue));
|
return new DayData(data, formatPieValue((int) totalValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract String formatPieValue(int value);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@ -163,7 +162,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
private void setupTodayPieChart() {
|
private void setupTodayPieChart() {
|
||||||
mTodayPieChart.setBackgroundColor(BACKGROUND_COLOR);
|
mTodayPieChart.setBackgroundColor(BACKGROUND_COLOR);
|
||||||
mTodayPieChart.getDescription().setTextColor(DESCRIPTION_COLOR);
|
mTodayPieChart.getDescription().setTextColor(DESCRIPTION_COLOR);
|
||||||
mTodayPieChart.getDescription().setText(getContext().getString(R.string.weeksteps_today_steps_description, String.valueOf(mTargetValue)));
|
mTodayPieChart.getDescription().setText(getPieDescription(mTargetValue));
|
||||||
// mTodayPieChart.setNoDataTextDescription("");
|
// mTodayPieChart.setNoDataTextDescription("");
|
||||||
mTodayPieChart.setNoDataText("");
|
mTodayPieChart.setNoDataText("");
|
||||||
mTodayPieChart.getLegend().setEnabled(false);
|
mTodayPieChart.getLegend().setEnabled(false);
|
||||||
@ -193,7 +192,7 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
y.setDrawZeroLine(true);
|
y.setDrawZeroLine(true);
|
||||||
y.setSpaceBottom(0);
|
y.setSpaceBottom(0);
|
||||||
y.setAxisMinimum(0);
|
y.setAxisMinimum(0);
|
||||||
|
y.setValueFormatter(getYAxisFormatter());
|
||||||
y.setEnabled(true);
|
y.setEnabled(true);
|
||||||
|
|
||||||
YAxis yAxisRight = mWeekChart.getAxisRight();
|
YAxis yAxisRight = mWeekChart.getAxisRight();
|
||||||
@ -291,7 +290,15 @@ public abstract class AbstractWeekChartFragment extends AbstractChartFragment {
|
|||||||
|
|
||||||
abstract float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts);
|
abstract float[] getTotalsForActivityAmounts(ActivityAmounts activityAmounts);
|
||||||
|
|
||||||
abstract IValueFormatter getFormatter();
|
abstract String formatPieValue(int value);
|
||||||
|
|
||||||
|
abstract IValueFormatter getPieValueFormatter();
|
||||||
|
|
||||||
|
abstract IValueFormatter getBarValueFormatter();
|
||||||
|
|
||||||
|
abstract IAxisValueFormatter getYAxisFormatter();
|
||||||
|
|
||||||
abstract int[] getColors();
|
abstract int[] getColors();
|
||||||
|
|
||||||
|
abstract String getPieDescription(int targetValue);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.components.AxisBase;
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||||
import com.github.mikephil.charting.formatter.IValueFormatter;
|
import com.github.mikephil.charting.formatter.IValueFormatter;
|
||||||
import com.github.mikephil.charting.utils.ViewPortHandler;
|
import com.github.mikephil.charting.utils.ViewPortHandler;
|
||||||
|
|
||||||
@ -18,6 +20,11 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
return getString(R.string.weeksleepchart_sleep_a_week);
|
return getString(R.string.weeksleepchart_sleep_a_week);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getPieDescription(int targetValue) {
|
||||||
|
return getString(R.string.weeksleepchart_today_sleep_description, DateTimeUtils.minutesToHHMM(targetValue));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
int getGoal() {
|
int getGoal() {
|
||||||
return 8 * 60; // FIXME
|
return 8 * 60; // FIXME
|
||||||
@ -43,7 +50,7 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
IValueFormatter getFormatter() {
|
IValueFormatter getPieValueFormatter() {
|
||||||
return new IValueFormatter() {
|
return new IValueFormatter() {
|
||||||
@Override
|
@Override
|
||||||
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
||||||
@ -52,6 +59,26 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
IValueFormatter getBarValueFormatter() {
|
||||||
|
return new IValueFormatter() {
|
||||||
|
@Override
|
||||||
|
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
|
||||||
|
return DateTimeUtils.minutesToHHMM((int) value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
IAxisValueFormatter getYAxisFormatter() {
|
||||||
|
return new IAxisValueFormatter() {
|
||||||
|
@Override
|
||||||
|
public String getFormattedValue(float value, AxisBase axis) {
|
||||||
|
return DateTimeUtils.minutesToHHMM((int) value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
int[] getColors() {
|
int[] getColors() {
|
||||||
return new int[]{akDeepSleep.color, akLightSleep.color};
|
return new int[]{akDeepSleep.color, akLightSleep.color};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
package nodomain.freeyourgadget.gadgetbridge.activities.charts;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||||
import com.github.mikephil.charting.formatter.IValueFormatter;
|
import com.github.mikephil.charting.formatter.IValueFormatter;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
@ -14,6 +15,11 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
return getString(R.string.weekstepschart_steps_a_week);
|
return getString(R.string.weekstepschart_steps_a_week);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getPieDescription(int targetValue) {
|
||||||
|
return getString(R.string.weeksteps_today_steps_description, String.valueOf(targetValue));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
int getGoal() {
|
int getGoal() {
|
||||||
GBDevice device = getChartsHost().getDevice();
|
GBDevice device = getChartsHost().getDevice();
|
||||||
@ -39,7 +45,17 @@ public class WeekStepsChartFragment extends AbstractWeekChartFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
IValueFormatter getFormatter() {
|
IValueFormatter getPieValueFormatter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
IValueFormatter getBarValueFormatter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
IAxisValueFormatter getYAxisFormatter() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,4 +78,8 @@ public class DateTimeUtils {
|
|||||||
public static Calendar getCalendarUTC() {
|
public static Calendar getCalendarUTC() {
|
||||||
return GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
|
return GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String minutesToHHMM(int minutes) {
|
||||||
|
return String.format(Locale.US, "%d:%02d", minutes / 60, minutes % 60); // no I do not want to use durationformatter :P
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,6 +278,7 @@
|
|||||||
<string name="notif_battery_low_bigtext_number_of_charges">Number of charges: %s</string>
|
<string name="notif_battery_low_bigtext_number_of_charges">Number of charges: %s</string>
|
||||||
<string name="sleepchart_your_sleep">Your Sleep</string>
|
<string name="sleepchart_your_sleep">Your Sleep</string>
|
||||||
<string name="weeksleepchart_sleep_a_week">Sleep a week</string>
|
<string name="weeksleepchart_sleep_a_week">Sleep a week</string>
|
||||||
|
<string name="weeksleepchart_today_sleep_description">Sleep today, target: %1$s</string>
|
||||||
<string name="weekstepschart_steps_a_week">Steps a week</string>
|
<string name="weekstepschart_steps_a_week">Steps a week</string>
|
||||||
<string name="activity_sleepchart_activity_and_sleep">Your Activity and Sleep</string>
|
<string name="activity_sleepchart_activity_and_sleep">Your Activity and Sleep</string>
|
||||||
<string name="updating_firmware">Updating Firmware…</string>
|
<string name="updating_firmware">Updating Firmware…</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user