1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-14 04:34:18 +02:00

update hellochart library to version 1.5.5

This commit is contained in:
OliE
2015-06-27 10:45:40 +02:00
parent d1c651440f
commit b8f2c1e673
6 changed files with 45 additions and 43 deletions

View File

@@ -85,6 +85,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="hellocharts-library-1.5.5" level="project" />
<orderEntry type="library" exported="" name="hellocharts-library-1.2" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.0" level="project" />
</component>

View File

@@ -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')
}

Binary file not shown.

View File

@@ -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<lines>();
@@ -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<ColumnValue> values = new ArrayList<ColumnValue>();
values.add(new ColumnValue(numOfMonth[i], Utils.COLORS[i % Utils.COLORS.length]));
List<SubcolumnValue> values = new ArrayList<SubcolumnValue>();
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() {
}
}

View File

@@ -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<ArcValue> arcValuesLast = new ArrayList<ArcValue>();
List<SliceValue> arcValuesLast = new ArrayList<SliceValue>();
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() {
}
}