mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-26 09:44:31 +02:00
refactored satistics page
This commit is contained in:
@@ -97,6 +97,28 @@ public class ScaleMeasurement implements Cloneable {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(final ScaleMeasurement summand) {
|
||||||
|
weight += summand.getWeight();
|
||||||
|
fat += summand.getFat();
|
||||||
|
water += summand.getWater();
|
||||||
|
muscle += summand.getMuscle();
|
||||||
|
lbw += summand.getLbw();
|
||||||
|
bone += summand.getBone();
|
||||||
|
waist += summand.getWaist();
|
||||||
|
hip += summand.getHip();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void divide(final float divisor) {
|
||||||
|
weight /= divisor;
|
||||||
|
fat /= divisor;
|
||||||
|
water /= divisor;
|
||||||
|
muscle /= divisor;
|
||||||
|
lbw /= divisor;
|
||||||
|
bone /= divisor;
|
||||||
|
waist /= divisor;
|
||||||
|
hip /= divisor;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ import android.text.Html;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TableLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
@@ -31,56 +32,116 @@ 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.datatypes.ScaleUser;
|
import com.health.openscale.core.datatypes.ScaleUser;
|
||||||
import com.health.openscale.core.utils.DateTimeHelpers;
|
import com.health.openscale.core.utils.DateTimeHelpers;
|
||||||
|
import com.health.openscale.gui.views.BoneMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.FatMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.HipMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.LBWMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.MeasurementView;
|
||||||
|
import com.health.openscale.gui.views.MuscleMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.WaistMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.WaterMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.WeightMeasurementView;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.STATISTIC;
|
||||||
|
|
||||||
public class StatisticsFragment extends Fragment implements FragmentUpdateListener {
|
public class StatisticsFragment extends Fragment implements FragmentUpdateListener {
|
||||||
|
|
||||||
private View statisticsView;
|
private View statisticsView;
|
||||||
|
|
||||||
private TextView txtTitleGoal;
|
|
||||||
private TextView txtTitleStatistics;
|
|
||||||
|
|
||||||
private TextView txtGoalWeight;
|
private TextView txtGoalWeight;
|
||||||
private TextView txtGoalDiff;
|
private TextView txtGoalDiff;
|
||||||
private TextView txtGoalDayLeft;
|
private TextView txtGoalDayLeft;
|
||||||
|
|
||||||
private TextView txtAvgWeek;
|
|
||||||
private TextView txtAvgMonth;
|
|
||||||
|
|
||||||
private TextView txtLabelGoalWeight;
|
private TextView txtLabelGoalWeight;
|
||||||
private TextView txtLabelGoalDiff;
|
private TextView txtLabelGoalDiff;
|
||||||
private TextView txtLabelDayLeft;
|
private TextView txtLabelDayLeft;
|
||||||
|
|
||||||
private TextView txtLabelAvgWeek;
|
private TableLayout tableWeekAveragesLayoutColumnA;
|
||||||
private TextView txtLabelAvgMonth;
|
private TableLayout tableWeekAveragesLayoutColumnB;
|
||||||
|
private TableLayout tableMonthAveragesLayoutColumnA;
|
||||||
|
private TableLayout tableMonthAveragesLayoutColumnB;
|
||||||
|
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
private ScaleUser currentScaleUser;
|
private ScaleUser currentScaleUser;
|
||||||
private ScaleMeasurement lastScaleMeasurement;
|
private ScaleMeasurement lastScaleMeasurement;
|
||||||
|
|
||||||
|
private ArrayList <MeasurementView> viewMeasurementsListWeek;
|
||||||
|
private ArrayList <MeasurementView> viewMeasurementsListMonth;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
statisticsView = inflater.inflate(R.layout.fragment_statistics, container, false);
|
statisticsView = inflater.inflate(R.layout.fragment_statistics, container, false);
|
||||||
|
|
||||||
txtTitleGoal = (TextView) statisticsView.findViewById(R.id.txtTitleGoal);
|
prefs = PreferenceManager.getDefaultSharedPreferences(statisticsView.getContext());
|
||||||
txtTitleStatistics = (TextView) statisticsView.findViewById(R.id.txtTitleStatistics);
|
|
||||||
|
|
||||||
txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
|
txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
|
||||||
txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
|
txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
|
||||||
txtGoalDayLeft = (TextView) statisticsView.findViewById(R.id.txtGoalDayLeft);
|
txtGoalDayLeft = (TextView) statisticsView.findViewById(R.id.txtGoalDayLeft);
|
||||||
|
|
||||||
txtAvgWeek = (TextView) statisticsView.findViewById(R.id.txtAvgWeek);
|
|
||||||
txtAvgMonth = (TextView) statisticsView.findViewById(R.id.txtAvgMonth);
|
|
||||||
|
|
||||||
txtLabelGoalWeight = (TextView) statisticsView.findViewById(R.id.txtLabelGoalWeight);
|
txtLabelGoalWeight = (TextView) statisticsView.findViewById(R.id.txtLabelGoalWeight);
|
||||||
txtLabelGoalDiff = (TextView) statisticsView.findViewById(R.id.txtLabelGoalDiff);
|
txtLabelGoalDiff = (TextView) statisticsView.findViewById(R.id.txtLabelGoalDiff);
|
||||||
txtLabelDayLeft = (TextView) statisticsView.findViewById(R.id.txtLabelDayLeft);
|
txtLabelDayLeft = (TextView) statisticsView.findViewById(R.id.txtLabelDayLeft);
|
||||||
|
|
||||||
txtLabelAvgWeek = (TextView) statisticsView.findViewById(R.id.txtLabelAvgWeek);
|
tableWeekAveragesLayoutColumnA = (TableLayout) statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnA);
|
||||||
txtLabelAvgMonth = (TextView) statisticsView.findViewById(R.id.txtLabelAvgMonth);
|
tableWeekAveragesLayoutColumnB = (TableLayout) statisticsView.findViewById(R.id.tableWeekAveragesLayoutColumnB);
|
||||||
|
tableMonthAveragesLayoutColumnA = (TableLayout) statisticsView.findViewById(R.id.tableMonthAveragesLayoutColumnA);
|
||||||
|
tableMonthAveragesLayoutColumnB = (TableLayout) statisticsView.findViewById(R.id.tableMonthAveragesLayoutColumnB);
|
||||||
|
|
||||||
|
viewMeasurementsListWeek = new ArrayList<>();
|
||||||
|
|
||||||
|
viewMeasurementsListWeek.add(new WeightMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new WaterMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new MuscleMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new LBWMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new FatMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new BoneMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new WaistMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListWeek.add(new HipMeasurementView(statisticsView.getContext()));
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
for (MeasurementView measurement : viewMeasurementsListWeek) {
|
||||||
|
measurement.setEditMode(STATISTIC);
|
||||||
|
measurement.updatePreferences(prefs);
|
||||||
|
if ((i % 2) == 0) {
|
||||||
|
tableWeekAveragesLayoutColumnA.addView(measurement);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tableWeekAveragesLayoutColumnB.addView(measurement);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewMeasurementsListMonth = new ArrayList<>();
|
||||||
|
|
||||||
|
viewMeasurementsListMonth.add(new WeightMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new WaterMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new MuscleMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new LBWMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new FatMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new BoneMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new WaistMeasurementView(statisticsView.getContext()));
|
||||||
|
viewMeasurementsListMonth.add(new HipMeasurementView(statisticsView.getContext()));
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
|
||||||
|
for (MeasurementView measurement : viewMeasurementsListMonth) {
|
||||||
|
measurement.setEditMode(STATISTIC);
|
||||||
|
measurement.updatePreferences(prefs);
|
||||||
|
|
||||||
|
if ((i % 2) == 0) {
|
||||||
|
tableMonthAveragesLayoutColumnA.addView(measurement);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tableMonthAveragesLayoutColumnB.addView(measurement);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
OpenScale.getInstance(getContext()).registerFragment(this);
|
OpenScale.getInstance(getContext()).registerFragment(this);
|
||||||
|
|
||||||
@@ -95,10 +156,6 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
|
|||||||
lastScaleMeasurement = scaleMeasurementList.get(0);
|
lastScaleMeasurement = scaleMeasurementList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
txtTitleGoal.setText(getResources().getString(R.string.label_title_goal).toUpperCase());
|
|
||||||
txtTitleStatistics.setText(getResources().getString(R.string.label_title_statistics).toUpperCase());
|
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(statisticsView.getContext());
|
|
||||||
currentScaleUser = OpenScale.getInstance(getContext()).getSelectedScaleUser();
|
currentScaleUser = OpenScale.getInstance(getContext()).getSelectedScaleUser();
|
||||||
|
|
||||||
updateStatistics(scaleMeasurementList);
|
updateStatistics(scaleMeasurementList);
|
||||||
@@ -158,6 +215,7 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatistics(List<ScaleMeasurement> scaleMeasurementList) {
|
private void updateStatistics(List<ScaleMeasurement> scaleMeasurementList) {
|
||||||
|
|
||||||
Calendar histDate = Calendar.getInstance();
|
Calendar histDate = Calendar.getInstance();
|
||||||
Calendar weekPastDate = Calendar.getInstance();
|
Calendar weekPastDate = Calendar.getInstance();
|
||||||
Calendar monthPastDate = Calendar.getInstance();
|
Calendar monthPastDate = Calendar.getInstance();
|
||||||
@@ -169,167 +227,34 @@ public class StatisticsFragment extends Fragment implements FragmentUpdateListen
|
|||||||
monthPastDate.add(Calendar.DATE, -30);
|
monthPastDate.add(Calendar.DATE, -30);
|
||||||
|
|
||||||
int weekSize = 0;
|
int weekSize = 0;
|
||||||
float weekAvgWeight = 0;
|
|
||||||
float weekAvgBMI = 0;
|
|
||||||
float weekAvgFat = 0;
|
|
||||||
float weekAvgWater = 0;
|
|
||||||
float weekAvgMuscle = 0;
|
|
||||||
float weekAvgLBW = 0;
|
|
||||||
float weekAvgWaist = 0;
|
|
||||||
float weekAvgBone = 0;
|
|
||||||
float weekAvgWHtR = 0;
|
|
||||||
float weekAvgHip = 0;
|
|
||||||
float weekAvgWHR = 0;
|
|
||||||
|
|
||||||
int monthSize = 0;
|
int monthSize = 0;
|
||||||
float monthAvgWeight = 0;
|
|
||||||
float monthAvgBMI = 0;
|
|
||||||
float monthAvgFat = 0;
|
|
||||||
float monthAvgWater = 0;
|
|
||||||
float monthAvgMuscle = 0;
|
|
||||||
float monthAvgLBW = 0;
|
|
||||||
float monthAvgWaist = 0;
|
|
||||||
float monthAvgBone = 0;
|
|
||||||
float monthAvgWHtR = 0;
|
|
||||||
float monthAvgHip = 0;
|
|
||||||
float monthAvgWHR = 0;
|
|
||||||
|
|
||||||
for (ScaleMeasurement scaleMeasurement : scaleMeasurementList)
|
ScaleMeasurement averageWeek = new ScaleMeasurement();
|
||||||
{
|
ScaleMeasurement averageMonth = new ScaleMeasurement();
|
||||||
histDate.setTime(scaleMeasurement.getDateTime());
|
|
||||||
|
for (ScaleMeasurement measurement : scaleMeasurementList) {
|
||||||
|
histDate.setTime(measurement.getDateTime());
|
||||||
|
|
||||||
if (weekPastDate.before(histDate)) {
|
if (weekPastDate.before(histDate)) {
|
||||||
|
averageWeek.add(measurement);
|
||||||
weekSize++;
|
weekSize++;
|
||||||
|
|
||||||
weekAvgWeight += scaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit());
|
|
||||||
weekAvgBMI += scaleMeasurement.getBMI(currentScaleUser.getBodyHeight());
|
|
||||||
weekAvgFat += scaleMeasurement.getFat();
|
|
||||||
weekAvgWater += scaleMeasurement.getWater();
|
|
||||||
weekAvgMuscle += scaleMeasurement.getMuscle();
|
|
||||||
weekAvgLBW += scaleMeasurement.getLbw();
|
|
||||||
weekAvgBone += scaleMeasurement.getBone();
|
|
||||||
weekAvgWaist += scaleMeasurement.getWaist();
|
|
||||||
weekAvgHip += scaleMeasurement.getHip();
|
|
||||||
weekAvgWHtR += scaleMeasurement.getWHtR(currentScaleUser.getBodyHeight());
|
|
||||||
weekAvgWHR += scaleMeasurement.getWHR();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monthPastDate.before(histDate)) {
|
if (monthPastDate.before(histDate)) {
|
||||||
|
averageMonth.add(measurement);
|
||||||
monthSize++;
|
monthSize++;
|
||||||
|
|
||||||
monthAvgWeight += scaleMeasurement.getConvertedWeight(currentScaleUser.getScaleUnit());
|
|
||||||
monthAvgBMI += scaleMeasurement.getBMI(currentScaleUser.getBodyHeight());
|
|
||||||
monthAvgFat += scaleMeasurement.getFat();
|
|
||||||
monthAvgWater += scaleMeasurement.getWater();
|
|
||||||
monthAvgMuscle += scaleMeasurement.getMuscle();
|
|
||||||
monthAvgLBW += scaleMeasurement.getLbw();
|
|
||||||
monthAvgBone += scaleMeasurement.getBone();
|
|
||||||
monthAvgWaist += scaleMeasurement.getWaist();
|
|
||||||
monthAvgHip += scaleMeasurement.getHip();
|
|
||||||
monthAvgWHtR += scaleMeasurement.getWHtR(currentScaleUser.getBodyHeight());
|
|
||||||
monthAvgWHR += scaleMeasurement.getWHR();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
weekAvgWeight /= weekSize;
|
averageWeek.divide(weekSize);
|
||||||
weekAvgBMI /= weekSize;
|
averageMonth.divide(monthSize);
|
||||||
weekAvgFat /= weekSize;
|
|
||||||
weekAvgWater /= weekSize;
|
|
||||||
weekAvgMuscle /= weekSize;
|
|
||||||
weekAvgLBW /= weekSize;
|
|
||||||
weekAvgWaist /= weekSize;
|
|
||||||
weekAvgBone /= weekSize;
|
|
||||||
weekAvgWHtR /= weekSize;
|
|
||||||
weekAvgHip /= weekSize;
|
|
||||||
weekAvgWHR /= weekSize;
|
|
||||||
|
|
||||||
monthAvgWeight /= monthSize;
|
for (MeasurementView measurement : viewMeasurementsListWeek) {
|
||||||
monthAvgBMI /= monthSize;
|
measurement.loadFrom(averageWeek, null);
|
||||||
monthAvgFat /= monthSize;
|
|
||||||
monthAvgWater /= monthSize;
|
|
||||||
monthAvgMuscle /= monthSize;
|
|
||||||
monthAvgLBW /= monthSize;
|
|
||||||
monthAvgBone /= monthSize;
|
|
||||||
monthAvgWaist /= monthSize;
|
|
||||||
monthAvgWHtR /= monthSize;
|
|
||||||
monthAvgHip /= monthSize;
|
|
||||||
monthAvgWHR /= monthSize;
|
|
||||||
|
|
||||||
String info_week = new String();
|
|
||||||
String info_month = new String();
|
|
||||||
|
|
||||||
int lines = 1;
|
|
||||||
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_weight)+": %.1f" + ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()] + "<br>", weekAvgWeight);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_weight)+": %.1f" + ScaleUser.UNIT_STRING[currentScaleUser.getScaleUnit()] + "<br>", monthAvgWeight);
|
|
||||||
lines++;
|
|
||||||
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_bmi)+": %.1f <br>", weekAvgBMI);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_bmi)+": %.1f <br>", monthAvgBMI);
|
|
||||||
lines++;
|
|
||||||
|
|
||||||
if (prefs.getBoolean("fatEnable", true)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_fat)+": %.1f%% <br>", weekAvgFat);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_fat)+": %.1f%% <br>", monthAvgFat);
|
|
||||||
lines++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.getBoolean("muscleEnable", true)) {
|
for (MeasurementView measurement : viewMeasurementsListMonth) {
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", weekAvgMuscle);
|
measurement.loadFrom(averageMonth, null);
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", monthAvgMuscle);
|
|
||||||
lines++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.getBoolean("lbwEnable", false)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_lbw)+": %.1fkg <br>", weekAvgLBW);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_lbw)+": %.1fkg <br>", monthAvgLBW);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs.getBoolean("waterEnable", true)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_water)+": %.1f%% <br>", weekAvgWater);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_water)+": %.1f%% <br>", monthAvgWater);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs.getBoolean("boneEnable", false)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_bone)+": %.1fkg <br>", weekAvgBone);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_bone)+": %.1fkg <br>",monthAvgBone);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (prefs.getBoolean("waistEnable", false)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_waist)+": %.1fcm <br>", weekAvgWaist);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_waist)+": %.1fcm <br>", monthAvgWaist);
|
|
||||||
lines++;
|
|
||||||
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_whtr)+": %.2f <br>", weekAvgWHtR);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_whtr)+": %.2f <br>", monthAvgWHtR);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs.getBoolean("hipEnable", false)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_hip)+": %.1fcm <br>", weekAvgHip);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_hip)+": %.1fcm <br>",monthAvgHip);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs.getBoolean("hipEnable", false) && prefs.getBoolean("waistEnable", false)) {
|
|
||||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_whr)+": %.2f <br>", weekAvgWHR);
|
|
||||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_whr)+": %.2f <br>", monthAvgWHR);
|
|
||||||
lines++;
|
|
||||||
}
|
|
||||||
|
|
||||||
txtLabelAvgWeek.setLines(lines);
|
|
||||||
txtLabelAvgMonth.setLines(lines);
|
|
||||||
|
|
||||||
txtLabelAvgWeek.setText(Html.fromHtml(getResources().getString(R.string.label_last_week) + " <br> <font color='grey'><small> " + info_week + "</small></font>"));
|
|
||||||
txtLabelAvgMonth.setText(Html.fromHtml(getResources().getString(R.string.label_last_month) + " <br> <font color='grey'><small> " + info_month + "</small></font>"));
|
|
||||||
|
|
||||||
txtAvgWeek.setText(weekSize + " " + getResources().getString(R.string.label_measures));
|
|
||||||
txtAvgMonth.setText(monthSize + " " + getResources().getString(R.string.label_measures));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,10 +45,11 @@ import lecho.lib.hellocharts.util.ChartUtils;
|
|||||||
|
|
||||||
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.ADD;
|
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.ADD;
|
||||||
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.EDIT;
|
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.EDIT;
|
||||||
|
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.STATISTIC;
|
||||||
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.VIEW;
|
import static com.health.openscale.gui.views.MeasurementView.MeasurementViewMode.VIEW;
|
||||||
|
|
||||||
public abstract class MeasurementView extends TableLayout {
|
public abstract class MeasurementView extends TableLayout {
|
||||||
public enum MeasurementViewMode {VIEW, EDIT, ADD};
|
public enum MeasurementViewMode {VIEW, EDIT, ADD, STATISTIC};
|
||||||
|
|
||||||
private TableRow measurementRow;
|
private TableRow measurementRow;
|
||||||
private ImageView iconView;
|
private ImageView iconView;
|
||||||
@@ -168,12 +169,16 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
indicatorView.setVisibility(View.VISIBLE);
|
indicatorView.setVisibility(View.VISIBLE);
|
||||||
editModeView.setVisibility(View.GONE);
|
editModeView.setVisibility(View.GONE);
|
||||||
incDecLayout.setVisibility(View.GONE);
|
incDecLayout.setVisibility(View.GONE);
|
||||||
|
nameView.setVisibility(View.VISIBLE);
|
||||||
|
valueView.setGravity(Gravity.RIGHT | Gravity.CENTER);
|
||||||
break;
|
break;
|
||||||
case EDIT:
|
case EDIT:
|
||||||
case ADD:
|
case ADD:
|
||||||
indicatorView.setVisibility(View.GONE);
|
indicatorView.setVisibility(View.GONE);
|
||||||
editModeView.setVisibility(View.VISIBLE);
|
editModeView.setVisibility(View.VISIBLE);
|
||||||
incDecLayout.setVisibility(View.VISIBLE);
|
incDecLayout.setVisibility(View.VISIBLE);
|
||||||
|
nameView.setVisibility(View.VISIBLE);
|
||||||
|
valueView.setGravity(Gravity.RIGHT | Gravity.CENTER);
|
||||||
|
|
||||||
if (!isEditable()) {
|
if (!isEditable()) {
|
||||||
editModeView.setImageDrawable(ContextCompat.getDrawable(getContext(),
|
editModeView.setImageDrawable(ContextCompat.getDrawable(getContext(),
|
||||||
@@ -182,6 +187,13 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
|
|
||||||
showEvaluatorRow(false);
|
showEvaluatorRow(false);
|
||||||
break;
|
break;
|
||||||
|
case STATISTIC:
|
||||||
|
indicatorView.setVisibility(View.GONE);
|
||||||
|
incDecLayout.setVisibility(View.GONE);
|
||||||
|
editModeView.setVisibility(View.GONE);
|
||||||
|
nameView.setVisibility(View.GONE);
|
||||||
|
valueView.setGravity(Gravity.CENTER);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,6 +334,10 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
private class onClickListenerEvaluation implements View.OnClickListener {
|
private class onClickListenerEvaluation implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (getMeasurementMode() == STATISTIC) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (getMeasurementMode() == EDIT || getMeasurementMode() == ADD) {
|
if (getMeasurementMode() == EDIT || getMeasurementMode() == ADD) {
|
||||||
if (isEditable()) {
|
if (isEditable()) {
|
||||||
getInputDialog().show();
|
getInputDialog().show();
|
||||||
|
@@ -15,12 +15,11 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtTitleGoal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:autoText="false"
|
android:autoText="false"
|
||||||
android:text="@string/label_title_goal"
|
android:text="@string/label_title_goal"
|
||||||
android:textSize="25dp"
|
android:textSize="20dp"
|
||||||
android:typeface="monospace" />
|
android:typeface="monospace" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -43,7 +42,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView5"
|
android:id="@+id/imageView5"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="25dp"
|
android:layout_height="20dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_target" />
|
android:src="@drawable/ic_target" />
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView6"
|
android:id="@+id/imageView6"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="25dp"
|
android:layout_height="20dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_difference" />
|
android:src="@drawable/ic_difference" />
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView7"
|
android:id="@+id/imageView7"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="25dp"
|
android:layout_height="20dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_daysleft" />
|
android:src="@drawable/ic_daysleft" />
|
||||||
|
|
||||||
@@ -165,12 +164,10 @@
|
|||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtTitleStatistics"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:autoText="false"
|
android:text="@string/label_last_week"
|
||||||
android:text="@string/label_title_statistics"
|
android:textSize="20dp"
|
||||||
android:textSize="25dp"
|
|
||||||
android:typeface="monospace" />
|
android:typeface="monospace" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
@@ -178,97 +175,61 @@
|
|||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="@android:color/darker_gray" />
|
android:background="@android:color/darker_gray" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="90">
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_width="fill_parent"
|
android:id="@+id/tableWeekAveragesLayoutColumnA"
|
||||||
android:layout_height="fill_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_weight="90"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="50"
|
||||||
android:stretchColumns="1">
|
android:stretchColumns="1">
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView8"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:src="@drawable/ic_lastweek" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtLabelAvgWeek"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_column="1"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_weight="80"
|
|
||||||
android:lines="2"
|
|
||||||
android:password="false"
|
|
||||||
android:phoneNumber="false"
|
|
||||||
android:singleLine="false"
|
|
||||||
android:text="Last 7 days"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textSize="15dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtAvgWeek"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_column="2"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_weight="20"
|
|
||||||
android:gravity="right"
|
|
||||||
android:text="-1"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textSize="15dp" />
|
|
||||||
</TableRow>
|
|
||||||
|
|
||||||
<TableRow
|
|
||||||
android:id="@+id/tableRow11"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:weightSum="100">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView9"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:src="@drawable/ic_lastmonth" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtLabelAvgMonth"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_weight="80"
|
|
||||||
android:lines="2"
|
|
||||||
android:password="false"
|
|
||||||
android:phoneNumber="false"
|
|
||||||
android:singleLine="false"
|
|
||||||
android:text="Last 30 days"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textSize="15dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtAvgMonth"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_column="2"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_weight="20"
|
|
||||||
android:gravity="right"
|
|
||||||
android:text="-1"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textSize="15dp" />
|
|
||||||
</TableRow>
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:id="@+id/tableWeekAveragesLayoutColumnB"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:stretchColumns="1">
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_last_month"
|
||||||
|
android:textSize="20dp"
|
||||||
|
android:typeface="monospace" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="@android:color/darker_gray" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="90">
|
||||||
|
<TableLayout
|
||||||
|
android:id="@+id/tableMonthAveragesLayoutColumnA"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:stretchColumns="1">
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:id="@+id/tableMonthAveragesLayoutColumnB"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="50"
|
||||||
|
android:stretchColumns="1">
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
Reference in New Issue
Block a user