diff --git a/android_app/app/app.iml b/android_app/app/app.iml index 0c1a36d5..39a0faea 100644 --- a/android_app/app/app.iml +++ b/android_app/app/app.iml @@ -85,6 +85,7 @@ + diff --git a/android_app/app/build.gradle b/android_app/app/build.gradle index b138d104..53ddeb7e 100644 --- a/android_app/app/build.gradle +++ b/android_app/app/build.gradle @@ -22,4 +22,5 @@ dependencies { compile 'com.android.support:support-v4:21.0.3' compile 'com.android.support:appcompat-v7:21.0.0' compile files('libs/hellocharts-library-1.2.jar') + compile files('libs/hellocharts-library-1.5.5.jar') } diff --git a/android_app/app/libs/hellocharts-library-1.2.jar b/android_app/app/libs/hellocharts-library-1.2.jar deleted file mode 100644 index f73a0c99..00000000 Binary files a/android_app/app/libs/hellocharts-library-1.2.jar and /dev/null differ diff --git a/android_app/app/libs/hellocharts-library-1.5.5.jar b/android_app/app/libs/hellocharts-library-1.5.5.jar new file mode 100644 index 00000000..14231670 Binary files /dev/null and b/android_app/app/libs/hellocharts-library-1.5.5.jar differ diff --git a/android_app/app/src/main/java/com/health/openscale/gui/GraphFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/GraphFragment.java index b69712a7..244b26c5 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/GraphFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/GraphFragment.java @@ -40,19 +40,21 @@ import java.util.Calendar; import java.util.List; import java.util.Locale; +import lecho.lib.hellocharts.formatter.SimpleLineChartValueFormatter; import lecho.lib.hellocharts.gesture.ZoomType; +import lecho.lib.hellocharts.listener.ColumnChartOnValueSelectListener; +import lecho.lib.hellocharts.listener.LineChartOnValueSelectListener; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Column; import lecho.lib.hellocharts.model.ColumnChartData; -import lecho.lib.hellocharts.model.ColumnValue; import lecho.lib.hellocharts.model.Line; import lecho.lib.hellocharts.model.LineChartData; import lecho.lib.hellocharts.model.PointValue; import lecho.lib.hellocharts.model.SelectedValue; -import lecho.lib.hellocharts.model.SimpleValueFormatter; +import lecho.lib.hellocharts.model.SubcolumnValue; import lecho.lib.hellocharts.model.Viewport; -import lecho.lib.hellocharts.util.Utils; +import lecho.lib.hellocharts.util.ChartUtils; import lecho.lib.hellocharts.view.ColumnChartView; import lecho.lib.hellocharts.view.LineChartView; @@ -162,21 +164,21 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { Line lineWeight = new Line(valuesWeight). - setColor(Utils.COLOR_VIOLET). + setColor(ChartUtils.COLOR_VIOLET). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineFat = new Line(valuesFat). - setColor(Utils.COLOR_ORANGE). + setColor(ChartUtils.COLOR_ORANGE). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineWater = new Line(valuesWater). - setColor(Utils.COLOR_BLUE). + setColor(ChartUtils.COLOR_BLUE). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineMuscle = new Line(valuesMuscle). - setColor(Utils.COLOR_GREEN). + setColor(ChartUtils.COLOR_GREEN). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); activeLines = new ArrayList(); @@ -225,7 +227,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { Viewport v = new Viewport(0, (int)maxValue, maxDays-1, 0); chartTop.setMaximumViewport(v); - chartTop.setCurrentViewport(v, true); + chartTop.setCurrentViewport(v); chartTop.setZoomType(ZoomType.HORIZONTAL); } @@ -246,8 +248,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { String month_name = month_date.format(calMonths.getTime()); axisValues.add(new AxisValue(i, month_name.toCharArray())); - List values = new ArrayList(); - values.add(new ColumnValue(numOfMonth[i], Utils.COLORS[i % Utils.COLORS.length])); + List values = new ArrayList(); + values.add(new SubcolumnValue(numOfMonth[i], ChartUtils.COLORS[i % ChartUtils.COLORS.length])); columns.add(new Column(values).setHasLabelsOnlyForSelected(true)); @@ -261,15 +263,15 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { chartBottom.setColumnChartData(columnData); chartBottom.setValueSelectionEnabled(true); chartBottom.setZoomEnabled(false); - chartBottom.selectValue(new SelectedValue(calLastSelected.get(Calendar.MONTH), 0, 0)); + chartBottom.selectValue(new SelectedValue(calLastSelected.get(Calendar.MONTH), 0, SelectedValue.SelectedValueType.COLUMN)); generateLineData(calLastSelected); } - private class ChartBottomValueTouchListener implements ColumnChartView.ColumnChartOnValueTouchListener { + private class ChartBottomValueTouchListener implements ColumnChartOnValueSelectListener { @Override - public void onValueTouched(int selectedLine, int selectedValue, ColumnValue value) { + public void onValueSelected(int selectedLine, int selectedValue, SubcolumnValue value) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.add(Calendar.MONTH, selectedLine); @@ -280,14 +282,14 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { } @Override - public void onNothingTouched() { + public void onValueDeselected() { } } - private class ChartTopValueTouchListener implements LineChartView.LineChartOnValueTouchListener { + private class ChartTopValueTouchListener implements LineChartOnValueSelectListener { @Override - public void onValueTouched(int lineIndex, int pointIndex, PointValue pointValue) { + public void onValueSelected(int lineIndex, int pointIndex, PointValue pointValue) { ScaleData scaleData = scaleDataList.get(pointIndex); lines selectedLine = activeLines.get(lineIndex); @@ -296,7 +298,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { switch (selectedLine) { case WEIGHT: Toast.makeText(getActivity(), getResources().getString(R.string.info_your_weight) + " " + scaleData.weight + ScaleUser.UNIT_STRING[OpenScale.getInstance(graphView.getContext()).getSelectedScaleUser().scale_unit] + " " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show(); - break; + break; case FAT: Toast.makeText(getActivity(), getResources().getString(R.string.info_your_fat) + " " + scaleData.fat + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show(); break; @@ -310,7 +312,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { } @Override - public void onNothingTouched() { + public void onValueDeselected() { } } diff --git a/android_app/app/src/main/java/com/health/openscale/gui/OverviewFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/OverviewFragment.java index a5daf032..189fa596 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/OverviewFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/OverviewFragment.java @@ -42,15 +42,16 @@ import java.util.Calendar; import java.util.List; import java.util.concurrent.TimeUnit; -import lecho.lib.hellocharts.model.ArcValue; +import lecho.lib.hellocharts.formatter.SimpleLineChartValueFormatter; +import lecho.lib.hellocharts.listener.PieChartOnValueSelectListener; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Line; import lecho.lib.hellocharts.model.LineChartData; import lecho.lib.hellocharts.model.PieChartData; import lecho.lib.hellocharts.model.PointValue; -import lecho.lib.hellocharts.model.SimpleValueFormatter; -import lecho.lib.hellocharts.util.Utils; +import lecho.lib.hellocharts.model.SliceValue; +import lecho.lib.hellocharts.util.ChartUtils; import lecho.lib.hellocharts.view.LineChartView; import lecho.lib.hellocharts.view.PieChartView; @@ -348,21 +349,21 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener } Line lineWeight = new Line(valuesWeight). - setColor(Utils.COLOR_VIOLET). + setColor(ChartUtils.COLOR_VIOLET). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineFat = new Line(valuesFat). - setColor(Utils.COLOR_ORANGE). + setColor(ChartUtils.COLOR_ORANGE). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineWater = new Line(valuesWater). - setColor(Utils.COLOR_BLUE). + setColor(ChartUtils.COLOR_BLUE). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); Line lineMuscle = new Line(valuesMuscle). - setColor(Utils.COLOR_GREEN). + setColor(ChartUtils.COLOR_GREEN). setHasLabels(prefs.getBoolean("labelsEnable", true)). - setFormatter(new SimpleValueFormatter(1, false, null, null)); + setFormatter(new SimpleLineChartValueFormatter(1)); if(prefs.getBoolean("weightEnable", true)) { lines.add(lineWeight); @@ -402,15 +403,14 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener private void updateLastPieChart() { - List arcValuesLast = new ArrayList(); + List arcValuesLast = new ArrayList(); - arcValuesLast.add(new ArcValue(lastScaleData.fat, Utils.COLOR_ORANGE)); - arcValuesLast.add(new ArcValue(lastScaleData.water, Utils.COLOR_BLUE)); - arcValuesLast.add(new ArcValue(lastScaleData.muscle, Utils.COLOR_GREEN)); + arcValuesLast.add(new SliceValue(lastScaleData.fat, ChartUtils.COLOR_ORANGE)); + arcValuesLast.add(new SliceValue(lastScaleData.water, ChartUtils.COLOR_BLUE)); + arcValuesLast.add(new SliceValue(lastScaleData.muscle, ChartUtils.COLOR_GREEN)); PieChartData pieChartData = new PieChartData(arcValuesLast); pieChartData.setHasLabels(false); - pieChartData.setFormatter(new SimpleValueFormatter(1, false, null, " %".toCharArray())); pieChartData.setHasCenterCircle(true); pieChartData.setCenterText1(Float.toString(lastScaleData.weight) + " " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit]); pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy").format(lastScaleData.date_time)); @@ -442,11 +442,10 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener startActivityForResult(intent, 1); } - private class PieChartLastTouchListener implements PieChartView.PieChartOnValueTouchListener + private class PieChartLastTouchListener implements PieChartOnValueSelectListener { @Override - public void onValueTouched(int i, ArcValue arcValue) - { + public void onValueSelected(int i, SliceValue arcValue) { if (lastScaleData == null) { return; } @@ -468,8 +467,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener } @Override - public void onNothingTouched() - { + public void onValueDeselected() { } }