diff --git a/app/build.gradle b/app/build.gradle
index 80b605401..69f9c61be 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -46,7 +46,7 @@ dependencies {
compile 'com.android.support:support-v4:23.0.0'
compile 'com.github.tony19:logback-android-classic:1.1.1-3'
compile 'org.slf4j:slf4j-api:1.7.7'
- compile 'com.github.PhilJay:MPAndroidChart:2.1.0'
+ compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
compile 'com.github.pfichtner:durationformatter:0.1.1'
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivitySleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivitySleepChartFragment.java
index d3a380e40..b60927b46 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivitySleepChartFragment.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ActivitySleepChartFragment.java
@@ -125,8 +125,7 @@ public class ActivitySleepChartFragment extends AbstractChartFragment {
legendLabels.add(akDeepSleep.label);
legendColors.add(akNotWorn.color);
legendLabels.add(akNotWorn.label);
- chart.getLegend().setColors(legendColors);
- chart.getLegend().setLabels(legendLabels);
+ chart.getLegend().setCustom(legendColors, legendLabels);
}
@Override
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomBarChart.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomBarChart.java
deleted file mode 100644
index 34acacf4a..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomBarChart.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package nodomain.freeyourgadget.gadgetbridge.activities.charts;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.github.mikephil.charting.charts.BarChart;
-
-/**
- * A BarChart with some specific customization, like
- *
using a custom legend renderer that always uses fixed labels and colors
- */
-public class CustomBarChart extends BarChart {
-
- public CustomBarChart(Context context) {
- super(context);
- }
-
- public CustomBarChart(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public CustomBarChart(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void init() {
- super.init();
- mLegendRenderer = new CustomLegendRenderer(getViewPortHandler(), getLegend());
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomLegendRenderer.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomLegendRenderer.java
deleted file mode 100644
index b2308cdd4..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/CustomLegendRenderer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package nodomain.freeyourgadget.gadgetbridge.activities.charts;
-
-import android.graphics.Typeface;
-
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.data.ChartData;
-import com.github.mikephil.charting.renderer.LegendRenderer;
-import com.github.mikephil.charting.utils.ViewPortHandler;
-
-/**
- * A legend renderer that does *not* calculate the labels and colors automatically
- * from the data sets or the data entries.
- *
- * Instead, they have to be provided manually, because otherwise the legend will
- * be empty.
- */
-public class CustomLegendRenderer extends LegendRenderer {
- public CustomLegendRenderer(ViewPortHandler viewPortHandler, Legend legend) {
- super(viewPortHandler, legend);
- }
-
- @Override
- public void computeLegend(ChartData> data) {
- if (!mLegend.isEnabled()) {
- return;
- }
-
- // don't call super to avoid computing colors and labels
- // super.computeLegend(data);
-
- Typeface tf = mLegend.getTypeface();
-
- if (tf != null)
- mLegendLabelPaint.setTypeface(tf);
-
- mLegendLabelPaint.setTextSize(mLegend.getTextSize());
- mLegendLabelPaint.setColor(mLegend.getTextColor());
-
- // calculate all dimensions of the mLegend
- mLegend.calculateDimensions(mLegendLabelPaint);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java
index 9c40dc7b4..6da15864b 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java
@@ -16,7 +16,8 @@ import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
-import com.github.mikephil.charting.utils.ValueFormatter;
+import com.github.mikephil.charting.formatter.ValueFormatter;
+import com.github.mikephil.charting.utils.ViewPortHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,7 +72,7 @@ public class SleepChartFragment extends AbstractChartFragment {
PieDataSet set = new PieDataSet(entries, "");
set.setValueFormatter(new ValueFormatter() {
@Override
- public String getFormattedValue(float value) {
+ public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return DateTimeUtils.formatDurationHoursMinutes((long) value, TimeUnit.SECONDS);
}
});
@@ -166,8 +167,7 @@ public class SleepChartFragment extends AbstractChartFragment {
legendLabels.add(akLightSleep.label);
legendColors.add(akDeepSleep.color);
legendLabels.add(akDeepSleep.label);
- chart.getLegend().setColors(legendColors);
- chart.getLegend().setLabels(legendLabels);
+ chart.getLegend().setCustom(legendColors, legendLabels);
chart.getLegend().setTextColor(LEGEND_TEXT_COLOR);
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekStepsChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekStepsChartFragment.java
index 39068828c..4bcd5cb5a 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekStepsChartFragment.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/WeekStepsChartFragment.java
@@ -194,8 +194,7 @@ public class WeekStepsChartFragment extends AbstractChartFragment {
List legendLabels = new ArrayList<>(1);
legendColors.add(akActivity.color);
legendLabels.add(getContext().getString(R.string.chart_steps));
- chart.getLegend().setColors(legendColors);
- chart.getLegend().setLabels(legendLabels);
+ chart.getLegend().setCustom(legendColors, legendLabels);
chart.getLegend().setTextColor(LEGEND_TEXT_COLOR);
}
diff --git a/app/src/main/res/layout-land/fragment_sleepchart.xml b/app/src/main/res/layout-land/fragment_sleepchart.xml
index 0323f2c52..5b4e0b409 100644
--- a/app/src/main/res/layout-land/fragment_sleepchart.xml
+++ b/app/src/main/res/layout-land/fragment_sleepchart.xml
@@ -11,10 +11,10 @@
android:layout_weight="40">
-
diff --git a/app/src/main/res/layout/fragment_charts.xml b/app/src/main/res/layout/fragment_charts.xml
index 9501bcd34..bd8983f8e 100644
--- a/app/src/main/res/layout/fragment_charts.xml
+++ b/app/src/main/res/layout/fragment_charts.xml
@@ -3,7 +3,7 @@
android:layout_height="match_parent"
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity$PlaceholderFragment">
-
-