1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-30 19:49:59 +02:00

add dynamically the floating buttons for the graph fragment

This commit is contained in:
OliE
2018-02-17 15:13:02 +01:00
parent 85c451ec14
commit 5c4c8096ab
15 changed files with 180 additions and 278 deletions

View File

@@ -35,6 +35,7 @@ import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupMenu; import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.health.openscale.R; import com.health.openscale.R;
@@ -42,6 +43,18 @@ import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleMeasurement; import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.utils.PolynomialFitter; import com.health.openscale.core.utils.PolynomialFitter;
import com.health.openscale.gui.activities.DataEntryActivity; import com.health.openscale.gui.activities.DataEntryActivity;
import com.health.openscale.gui.views.BMIMeasurementView;
import com.health.openscale.gui.views.BoneMeasurementView;
import com.health.openscale.gui.views.FatMeasurementView;
import com.health.openscale.gui.views.FloatMeasurementView;
import com.health.openscale.gui.views.HipMeasurementView;
import com.health.openscale.gui.views.LBWMeasurementView;
import com.health.openscale.gui.views.MuscleMeasurementView;
import com.health.openscale.gui.views.WHRMeasurementView;
import com.health.openscale.gui.views.WHtRMeasurementView;
import com.health.openscale.gui.views.WaistMeasurementView;
import com.health.openscale.gui.views.WaterMeasurementView;
import com.health.openscale.gui.views.WeightMeasurementView;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@@ -75,18 +88,13 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
private TextView txtYear; private TextView txtYear;
private Button btnLeftYear; private Button btnLeftYear;
private Button btnRightYear; private Button btnRightYear;
private FloatingActionButton diagramWeight; private LinearLayout floatingActionBar;
private FloatingActionButton diagramFat;
private FloatingActionButton diagramWater;
private FloatingActionButton diagramMuscle;
private FloatingActionButton diagramLBW;
private FloatingActionButton diagramWaist;
private FloatingActionButton diagramHip;
private FloatingActionButton diagramBone;
private ImageView optionMenu; private ImageView optionMenu;
private PopupMenu popup; private PopupMenu popup;
private SharedPreferences prefs; private SharedPreferences prefs;
private ArrayList<FloatMeasurementView> measurementViews;
private int textColor; private int textColor;
private OpenScale openScale; private OpenScale openScale;
@@ -136,25 +144,23 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
txtYear = (TextView) graphView.findViewById(R.id.txtYear); txtYear = (TextView) graphView.findViewById(R.id.txtYear);
txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR))); txtYear.setText(Integer.toString(calYears.get(Calendar.YEAR)));
diagramWeight = (FloatingActionButton) graphView.findViewById(R.id.diagramWeight); floatingActionBar = (LinearLayout) graphView.findViewById(R.id.floatingActionBar);
diagramFat = (FloatingActionButton) graphView.findViewById(R.id.diagramFat);
diagramWater = (FloatingActionButton) graphView.findViewById(R.id.diagramWater); measurementViews = new ArrayList<>();
diagramMuscle = (FloatingActionButton) graphView.findViewById(R.id.diagramMuscle);
diagramLBW = (FloatingActionButton) graphView.findViewById(R.id.diagramLBW); measurementViews.add(new WeightMeasurementView(getContext()));
diagramWaist = (FloatingActionButton) graphView.findViewById(R.id.diagramWaist); measurementViews.add(new BMIMeasurementView(getContext()));
diagramHip = (FloatingActionButton) graphView.findViewById(R.id.diagramHip); measurementViews.add(new WaterMeasurementView(getContext()));
diagramBone = (FloatingActionButton) graphView.findViewById(R.id.diagramBone); measurementViews.add(new MuscleMeasurementView(getContext()));
measurementViews.add(new LBWMeasurementView(getContext()));
measurementViews.add(new FatMeasurementView(getContext()));
measurementViews.add(new BoneMeasurementView(getContext()));
measurementViews.add(new WaistMeasurementView(getContext()));
measurementViews.add(new WHtRMeasurementView(getContext()));
measurementViews.add(new HipMeasurementView(getContext()));
measurementViews.add(new WHRMeasurementView(getContext()));
optionMenu = (ImageView) graphView.findViewById(R.id.optionMenu); optionMenu = (ImageView) graphView.findViewById(R.id.optionMenu);
diagramWeight.setOnClickListener(new onClickListenerDiagramLines());
diagramFat.setOnClickListener(new onClickListenerDiagramLines());
diagramWater.setOnClickListener(new onClickListenerDiagramLines());
diagramMuscle.setOnClickListener(new onClickListenerDiagramLines());
diagramLBW.setOnClickListener(new onClickListenerDiagramLines());
diagramWaist.setOnClickListener(new onClickListenerDiagramLines());
diagramHip.setOnClickListener(new onClickListenerDiagramLines());
diagramBone.setOnClickListener(new onClickListenerDiagramLines());
optionMenu.setOnClickListener(new View.OnClickListener() { optionMenu.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -162,40 +168,6 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
} }
}); });
prefs = PreferenceManager.getDefaultSharedPreferences(graphView.getContext());
if (!prefs.getBoolean("weightEnable", true)) {
diagramWeight.setVisibility(View.GONE);
}
if (!prefs.getBoolean("fatEnable", true)) {
diagramFat.setVisibility(View.GONE);
}
if (!prefs.getBoolean("waterEnable", true)) {
diagramWater.setVisibility(View.GONE);
}
if (!prefs.getBoolean("muscleEnable", true)) {
diagramMuscle.setVisibility(View.GONE);
}
if (!prefs.getBoolean("lbwEnable", false)) {
diagramLBW.setVisibility(View.GONE);
}
if (!prefs.getBoolean("boneEnable", false)) {
diagramBone.setVisibility(View.GONE);
}
if (!prefs.getBoolean("waistEnable", false)) {
diagramWaist.setVisibility(View.GONE);
}
if (!prefs.getBoolean("hipEnable", false)) {
diagramHip.setVisibility(View.GONE);
}
btnLeftYear = graphView.findViewById(R.id.btnLeftYear); btnLeftYear = graphView.findViewById(R.id.btnLeftYear);
btnLeftYear.setOnClickListener(new View.OnClickListener() { btnLeftYear.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
@@ -251,6 +223,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
}); });
popup.getMenuInflater().inflate(R.menu.graph_menu, popup.getMenu()); popup.getMenuInflater().inflate(R.menu.graph_menu, popup.getMenu());
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
MenuItem enableMonth = popup.getMenu().findItem(R.id.enableMonth); MenuItem enableMonth = popup.getMenu().findItem(R.id.enableMonth);
enableMonth.setChecked(prefs.getBoolean("showMonth", true)); enableMonth.setChecked(prefs.getBoolean("showMonth", true));
@@ -273,6 +247,27 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
generateGraphs(); generateGraphs();
} }
private void addFloatingActionButton(FloatMeasurementView measurementView) {
FloatingActionButton actionButton = new FloatingActionButton(getContext());
actionButton.setTag("actionButton" + measurementView.getName());
actionButton.setImageDrawable(measurementView.getIcon());
actionButton.setClickable(true);
actionButton.setSize(android.support.design.widget.FloatingActionButton.SIZE_MINI);
RelativeLayout.LayoutParams lay = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lay.setMargins(0,5,20,10);
actionButton.setLayoutParams(lay);
actionButton.setOnClickListener(new onClickListenerDiagramLines());
if (prefs.getBoolean(String.valueOf("actionButton" + measurementView.getName()), true)) {
actionButton.setBackgroundTintList(ColorStateList.valueOf(measurementView.getColor()));
} else {
actionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
floatingActionBar.addView(actionButton);
}
/** /**
* Add a point to a point value stack. * Add a point to a point value stack.
* *
@@ -326,135 +321,44 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
calDays.add(field, 1); calDays.add(field, 1);
} }
Stack<PointValue> valuesWeight = new Stack<PointValue>(); List<Line> diagramLineList = new ArrayList<Line>();
Stack<PointValue> valuesFat = new Stack<PointValue>();
Stack<PointValue> valuesWater = new Stack<PointValue>();
Stack<PointValue> valuesMuscle = new Stack<PointValue>();
Stack<PointValue> valuesLBW = new Stack<PointValue>();
Stack<PointValue> valuesWaist = new Stack<PointValue>();
Stack<PointValue> valuesHip = new Stack<PointValue>();
Stack<PointValue> valuesBone = new Stack<>();
List<Line> lines = new ArrayList<Line>();
Calendar calDB = Calendar.getInstance(); Calendar calDB = Calendar.getInstance();
pointIndexScaleMeasurementList = new ArrayList<>(); pointIndexScaleMeasurementList = new ArrayList<>();
for (ScaleMeasurement scaleEntry: scaleMeasurementList) { floatingActionBar.removeAllViews();
calDB.setTime(scaleEntry.getDateTime());
if (addPointValue(valuesWeight, calDB.get(field), scaleEntry.getConvertedWeight(openScale.getSelectedScaleUser().getScaleUnit()))) { for (FloatMeasurementView measurementView : measurementViews) {
pointIndexScaleMeasurementList.add(scaleEntry); // if new point was added, add this point to pointIndexScaleDataList to get the correct point index after selecting an point measurementView.updatePreferences(prefs);
Stack<PointValue> valuesStack = new Stack<PointValue>();
for (ScaleMeasurement measurement : scaleMeasurementList) {
measurementView.loadFrom(measurement, null);
calDB.setTime(measurement.getDateTime());
if (addPointValue(valuesStack, calDB.get(field), measurementView.getValue())) {
pointIndexScaleMeasurementList.add(measurement); // if new point was added, add this point to pointIndexScaleDataList to get the correct point index after selecting an point
}
} }
addPointValue(valuesFat, calDB.get(field), scaleEntry.getFat()); Line diagramLine = new Line(valuesStack).
addPointValue(valuesWater, calDB.get(field), scaleEntry.getWater()); setColor(measurementView.getColor()).
addPointValue(valuesMuscle, calDB.get(field), scaleEntry.getMuscle()); setHasLabels(prefs.getBoolean("labelsEnable", true)).
addPointValue(valuesLBW, calDB.get(field), scaleEntry.getLbw()); setHasPoints(prefs.getBoolean("pointsEnable", true)).
addPointValue(valuesWaist, calDB.get(field), scaleEntry.getWaist()); setFormatter(new SimpleLineChartValueFormatter(1));
addPointValue(valuesHip, calDB.get(field), scaleEntry.getHip());
addPointValue(valuesBone, calDB.get(field), scaleEntry.getBone()); if (measurementView.isVisible()) {
addFloatingActionButton(measurementView);
if (prefs.getBoolean(String.valueOf("actionButton" + measurementView.getName()), true)) {
diagramLineList.add(diagramLine);
}
}
} }
LineChartData lineData = new LineChartData(diagramLineList);
Line lineWeight = new Line(valuesWeight).
setColor(ChartUtils.COLOR_VIOLET).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineFat = new Line(valuesFat).
setColor(ChartUtils.COLOR_ORANGE).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineWater = new Line(valuesWater).
setColor(ChartUtils.COLOR_BLUE).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineMuscle = new Line(valuesMuscle).
setColor(ChartUtils.COLOR_GREEN).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineLBW = new Line(valuesLBW).
setColor(Color.parseColor("#cc0099")).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineWaist = new Line(valuesWaist).
setColor(Color.MAGENTA).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineHip = new Line(valuesHip).
setColor(Color.YELLOW).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
Line lineBone = new Line(valuesBone).
setColor(Color.parseColor("#33ff9d")).
setHasLabels(prefs.getBoolean("labelsEnable", true)).
setHasPoints(prefs.getBoolean("pointsEnable", true)).
setFormatter(new SimpleLineChartValueFormatter(1));
if (prefs.getBoolean("weightEnable", true) && prefs.getBoolean(String.valueOf(diagramWeight.getId()), true)) {
lines.add(lineWeight);
diagramWeight.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_VIOLET));
} else {
diagramWeight.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("fatEnable", true) && prefs.getBoolean(String.valueOf(diagramFat.getId()), true)) {
lines.add(lineFat);
diagramFat.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_ORANGE));
} else {
diagramFat.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("waterEnable", true) && prefs.getBoolean(String.valueOf(diagramWater.getId()), true)) {
lines.add(lineWater);
diagramWater.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_BLUE));
} else {
diagramWater.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("muscleEnable", true) && prefs.getBoolean(String.valueOf(diagramMuscle.getId()), true)) {
lines.add(lineMuscle);
diagramMuscle.setBackgroundTintList(ColorStateList.valueOf(ChartUtils.COLOR_GREEN));
} else {
diagramMuscle.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("lbwEnable", false) && prefs.getBoolean(String.valueOf(diagramLBW.getId()), true)) {
lines.add(lineLBW);
diagramLBW.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#cc0099")));
} else {
diagramLBW.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("waistEnable", false) && prefs.getBoolean(String.valueOf(diagramWaist.getId()), true)) {
lines.add(lineWaist);
diagramWaist.setBackgroundTintList(ColorStateList.valueOf(Color.MAGENTA));
} else {
diagramWaist.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("hipEnable", false) && prefs.getBoolean(String.valueOf(diagramHip.getId()), true)) {
lines.add(lineHip);
diagramHip.setBackgroundTintList(ColorStateList.valueOf(Color.YELLOW));
} else {
diagramHip.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
if (prefs.getBoolean("boneEnable", false) && prefs.getBoolean(String.valueOf(diagramBone.getId()), true)) {
lines.add(lineBone);
diagramBone.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#00cc9e")));
} else {
diagramBone.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
}
LineChartData lineData = new LineChartData(lines);
lineData.setAxisXBottom(new Axis(axisValues). lineData.setAxisXBottom(new Axis(axisValues).
setHasLines(true). setHasLines(true).
setTextColor(textColor) setTextColor(textColor)
@@ -483,14 +387,17 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
goalLine.setPathEffect(new DashPathEffect(new float[] {10,30}, 0)); goalLine.setPathEffect(new DashPathEffect(new float[] {10,30}, 0));
lines.add(goalLine); diagramLineList.add(goalLine);
} }
if (prefs.getBoolean("regressionLine", false)) { if (prefs.getBoolean("regressionLine", false)) {
PolynomialFitter polyFitter = new PolynomialFitter(Integer.parseInt(prefs.getString("regressionLineOrder", "1"))); PolynomialFitter polyFitter = new PolynomialFitter(Integer.parseInt(prefs.getString("regressionLineOrder", "1")));
for (PointValue weightValue : valuesWeight) { Stack<PointValue> valuesWeight = new Stack<PointValue>();
polyFitter.addPoint(weightValue.getX(), weightValue.getY());
for (ScaleMeasurement measurement : scaleMeasurementList) {
addPointValue(valuesWeight, calDB.get(field), measurement.getConvertedWeight(openScale.getSelectedScaleUser().getScaleUnit()));
polyFitter.addPoint(calDB.get(field), measurement.getConvertedWeight(openScale.getSelectedScaleUser().getScaleUnit()));
} }
PolynomialFitter.Polynomial polynom = polyFitter.getBestFit(); PolynomialFitter.Polynomial polynom = polyFitter.getBestFit();
@@ -509,7 +416,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
linearRegressionLine.setPathEffect(new DashPathEffect(new float[] {10,30}, 0)); linearRegressionLine.setPathEffect(new DashPathEffect(new float[] {10,30}, 0));
lines.add(linearRegressionLine); diagramLineList.add(linearRegressionLine);
} }
chartBottom.setLineChartData(lineData); chartBottom.setLineChartData(lineData);
@@ -656,10 +563,10 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean(String.valueOf(actionButton.getId()), true)) { if (prefs.getBoolean(String.valueOf(actionButton.getTag()), true)) {
prefs.edit().putBoolean(String.valueOf(actionButton.getId()), false).commit(); prefs.edit().putBoolean(String.valueOf(actionButton.getTag()), false).commit();
} else { } else {
prefs.edit().putBoolean(String.valueOf(actionButton.getId()), true).commit(); prefs.edit().putBoolean(String.valueOf(actionButton.getTag()), true).commit();
} }
generateGraphs(); generateGraphs();

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -60,6 +61,11 @@ public class BMIMeasurementView extends FloatMeasurementView {
return 50; return 50;
} }
@Override
public int getColor() {
return Color.parseColor("#26A69A");
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateBMI(value); return evalSheet.evaluateBMI(value);

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -67,6 +68,11 @@ public class BMRMeasurementView extends FloatMeasurementView {
return 5000; return 5000;
} }
@Override
public int getColor() {
return Color.parseColor("#FF8A65");
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null; return null;

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -55,6 +56,11 @@ public class BoneMeasurementView extends FloatMeasurementView {
return 50; return 50;
} }
@Override
public int getColor() {
return Color.parseColor("#33ff9d");
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null; return null;

View File

@@ -21,10 +21,11 @@ import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement; import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult; import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet; import com.health.openscale.core.evaluation.EvaluationSheet;
import lecho.lib.hellocharts.util.ChartUtils;
public class FatMeasurementView extends FloatMeasurementView { public class FatMeasurementView extends FloatMeasurementView {
private boolean estimateFatEnable; private boolean estimateFatEnable;
@@ -77,6 +78,11 @@ public class FatMeasurementView extends FloatMeasurementView {
return 300; return 300;
} }
@Override
public int getColor() {
return ChartUtils.COLOR_ORANGE;
}
@Override @Override
protected boolean isEstimationEnabled() { protected boolean isEstimationEnabled() {
return estimateFatEnable; return estimateFatEnable;

View File

@@ -213,6 +213,8 @@ public abstract class FloatMeasurementView extends MeasurementView {
protected abstract String getUnit(); protected abstract String getUnit();
protected abstract float getMaxValue(); protected abstract float getMaxValue();
public abstract int getColor();
protected boolean isEstimationEnabled() { protected boolean isEstimationEnabled() {
return false; return false;
} }
@@ -265,6 +267,14 @@ public abstract class FloatMeasurementView extends MeasurementView {
return formatValue(value); return formatValue(value);
} }
public float getValue() {
return value;
}
public String getName() {
return nameText;
}
@Override @Override
public void appendDiffValue(SpannableStringBuilder text) { public void appendDiffValue(SpannableStringBuilder text) {
if (previousValue < 0.0f) { if (previousValue < 0.0f) {

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -55,6 +56,11 @@ public class HipMeasurementView extends FloatMeasurementView {
return 200; return 200;
} }
@Override
public int getColor() {
return Color.YELLOW;
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null; return null;

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -58,6 +59,11 @@ public class LBWMeasurementView extends FloatMeasurementView {
return 300; return 300;
} }
@Override
public int getColor() {
return Color.parseColor("#cc0099");
}
@Override @Override
protected boolean isEstimationEnabled() { protected boolean isEstimationEnabled() {
return estimateLBWEnable; return estimateLBWEnable;

View File

@@ -21,10 +21,11 @@ import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement; import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult; import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet; import com.health.openscale.core.evaluation.EvaluationSheet;
import lecho.lib.hellocharts.util.ChartUtils;
public class MuscleMeasurementView extends FloatMeasurementView { public class MuscleMeasurementView extends FloatMeasurementView {
private boolean percentageEnable; private boolean percentageEnable;
@@ -75,6 +76,11 @@ public class MuscleMeasurementView extends FloatMeasurementView {
return 300; return 300;
} }
@Override
public int getColor() {
return ChartUtils.COLOR_GREEN;
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateBodyMuscle(value); return evalSheet.evaluateBodyMuscle(value);

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -61,6 +62,11 @@ public class WHRMeasurementView extends FloatMeasurementView {
return 1.5f; return 1.5f;
} }
@Override
public int getColor() {
return Color.parseColor("#C0CA33");
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateWHR(value); return evalSheet.evaluateWHR(value);

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -60,6 +61,11 @@ public class WHtRMeasurementView extends FloatMeasurementView {
return 1; return 1;
} }
@Override
public int getColor() {
return Color.parseColor("#A1887F");
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateWHtR(value); return evalSheet.evaluateWHtR(value);

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.views;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
@@ -55,6 +56,11 @@ public class WaistMeasurementView extends FloatMeasurementView {
return 200; return 200;
} }
@Override
public int getColor() {
return Color.MAGENTA;
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateWaist(value); return evalSheet.evaluateWaist(value);

View File

@@ -21,10 +21,11 @@ import android.support.v4.content.ContextCompat;
import com.health.openscale.R; import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleMeasurement; import com.health.openscale.core.datatypes.ScaleMeasurement;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult; import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet; import com.health.openscale.core.evaluation.EvaluationSheet;
import lecho.lib.hellocharts.util.ChartUtils;
public class WaterMeasurementView extends FloatMeasurementView { public class WaterMeasurementView extends FloatMeasurementView {
private boolean estimateWaterEnable; private boolean estimateWaterEnable;
@@ -77,6 +78,11 @@ public class WaterMeasurementView extends FloatMeasurementView {
return 300; return 300;
} }
@Override
public int getColor() {
return ChartUtils.COLOR_BLUE;
}
@Override @Override
protected boolean isEstimationEnabled() { protected boolean isEstimationEnabled() {
return estimateWaterEnable; return estimateWaterEnable;

View File

@@ -25,6 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet; import com.health.openscale.core.evaluation.EvaluationSheet;
import com.health.openscale.core.utils.Converters; import com.health.openscale.core.utils.Converters;
import lecho.lib.hellocharts.util.ChartUtils;
public class WeightMeasurementView extends FloatMeasurementView { public class WeightMeasurementView extends FloatMeasurementView {
public WeightMeasurementView(Context context) { public WeightMeasurementView(Context context) {
@@ -56,6 +58,11 @@ public class WeightMeasurementView extends FloatMeasurementView {
return Converters.fromKilogram(300.0f, getScaleUser().getScaleUnit()); return Converters.fromKilogram(300.0f, getScaleUser().getScaleUnit());
} }
@Override
public int getColor() {
return ChartUtils.COLOR_VIOLET;
}
@Override @Override
protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) { protected EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateWeight(value); return evalSheet.evaluateWeight(value);

View File

@@ -89,101 +89,13 @@
android:fillViewport="true"> android:fillViewport="true">
<LinearLayout <LinearLayout
android:id="@+id/floatingActionBar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="5dp"> android:padding="5dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_weight"
app:backgroundTint="#AA66CC"
app:fabSize="mini"
app:rippleColor="#AA66CC" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramFat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_fat"
app:backgroundTint="#FFBB33"
app:fabSize="mini"
app:rippleColor="#FFBB33" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWater"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_water"
app:backgroundTint="#33B5E5"
app:fabSize="mini"
app:rippleColor="#33B5E5" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramMuscle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_muscle"
app:backgroundTint="#99CC00"
app:fabSize="mini"
app:rippleColor="#99CC00" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramLBW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_lbw"
app:backgroundTint="#cc0099"
app:fabSize="mini"
app:rippleColor="#cc0099" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramBone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_bone"
app:backgroundTint="#00cc9e"
app:fabSize="mini"
app:rippleColor="#00cc9e" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramWaist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_waist"
app:backgroundTint="#FF00FF"
app:fabSize="mini"
app:rippleColor="#FF00FF" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/diagramHip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@drawable/ic_hip"
app:backgroundTint="#FFFF00"
app:fabSize="mini"
app:rippleColor="#FFFF00" />
</LinearLayout> </LinearLayout>
</HorizontalScrollView> </HorizontalScrollView>