mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-11 03:04:25 +02:00
- add statistics fragment
This commit is contained in:
@@ -46,6 +46,7 @@ import com.health.openscale.gui.activities.SettingsActivity;
|
||||
import com.health.openscale.gui.activities.UserSettingsActivity;
|
||||
import com.health.openscale.gui.fragments.GraphFragment;
|
||||
import com.health.openscale.gui.fragments.OverviewFragment;
|
||||
import com.health.openscale.gui.fragments.StatisticsFragment;
|
||||
import com.health.openscale.gui.fragments.TableFragment;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -282,6 +283,7 @@ public class MainActivity extends ActionBarActivity implements
|
||||
private OverviewFragment overviewFrag;
|
||||
private GraphFragment graphFrag;
|
||||
private TableFragment tableFrag;
|
||||
private StatisticsFragment statisticsFrag;
|
||||
|
||||
public SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
@@ -289,6 +291,7 @@ public class MainActivity extends ActionBarActivity implements
|
||||
overviewFrag = new OverviewFragment();
|
||||
graphFrag = new GraphFragment();
|
||||
tableFrag = new TableFragment();
|
||||
statisticsFrag = new StatisticsFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -298,12 +301,14 @@ public class MainActivity extends ActionBarActivity implements
|
||||
// below).
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
return overviewFrag;
|
||||
case 1:
|
||||
return graphFrag;
|
||||
case 2:
|
||||
return tableFrag;
|
||||
case 0:
|
||||
return overviewFrag;
|
||||
case 1:
|
||||
return graphFrag;
|
||||
case 2:
|
||||
return tableFrag;
|
||||
case 3:
|
||||
return statisticsFrag;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -311,19 +316,21 @@ public class MainActivity extends ActionBarActivity implements
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
Locale l = Locale.getDefault();
|
||||
switch (position) {
|
||||
case 0:
|
||||
return getString(R.string.title_overview).toUpperCase(l);
|
||||
case 1:
|
||||
return getString(R.string.title_graph).toUpperCase(l);
|
||||
case 2:
|
||||
return getString(R.string.title_frag).toUpperCase(l);
|
||||
case 0:
|
||||
return getString(R.string.title_overview).toUpperCase(l);
|
||||
case 1:
|
||||
return getString(R.string.title_graph).toUpperCase(l);
|
||||
case 2:
|
||||
return getString(R.string.title_table).toUpperCase(l);
|
||||
case 3:
|
||||
return getString(R.string.title_statistics).toUpperCase(l);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -340,6 +347,7 @@ public class MainActivity extends ActionBarActivity implements
|
||||
tableFrag = new TableFragment();
|
||||
graphFrag = new GraphFragment();
|
||||
overviewFrag = new OverviewFragment();
|
||||
statisticsFrag = new StatisticsFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -36,7 +35,6 @@ import android.widget.Toast;
|
||||
|
||||
import com.health.openscale.R;
|
||||
import com.health.openscale.core.OpenScale;
|
||||
import com.health.openscale.core.datatypes.ScaleCalculator;
|
||||
import com.health.openscale.core.datatypes.ScaleData;
|
||||
import com.health.openscale.core.datatypes.ScaleUser;
|
||||
import com.health.openscale.gui.activities.DataEntryActivity;
|
||||
@@ -78,27 +76,11 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
|
||||
private TextView txtTitleUser;
|
||||
private TextView txtTitleLastMeasurement;
|
||||
private TextView txtTitleGoal;
|
||||
private TextView txtTitleStatistics;
|
||||
|
||||
private TableLayout tableOverviewLayout;
|
||||
|
||||
private ArrayList<MeasurementView> overviewMeasurements;
|
||||
|
||||
private TextView txtGoalWeight;
|
||||
private TextView txtGoalDiff;
|
||||
private TextView txtGoalDayLeft;
|
||||
|
||||
private TextView txtAvgWeek;
|
||||
private TextView txtAvgMonth;
|
||||
|
||||
private TextView txtLabelGoalWeight;
|
||||
private TextView txtLabelGoalDiff;
|
||||
private TextView txtLabelDayLeft;
|
||||
|
||||
private TextView txtLabelAvgWeek;
|
||||
private TextView txtLabelAvgMonth;
|
||||
|
||||
private PieChartView pieChartLast;
|
||||
private LineChartView lineChartLast;
|
||||
|
||||
@@ -131,8 +113,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
|
||||
txtTitleUser = (TextView) overviewView.findViewById(R.id.txtTitleUser);
|
||||
txtTitleLastMeasurement = (TextView) overviewView.findViewById(R.id.txtTitleLastMeasurment);
|
||||
txtTitleGoal = (TextView) overviewView.findViewById(R.id.txtTitleGoal);
|
||||
txtTitleStatistics = (TextView) overviewView.findViewById(R.id.txtTitleStatistics);
|
||||
|
||||
tableOverviewLayout = (TableLayout)overviewView.findViewById(R.id.tableLayoutMeasurements);
|
||||
|
||||
@@ -152,20 +132,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
tableOverviewLayout.addView(measuremt);
|
||||
}
|
||||
|
||||
txtGoalWeight = (TextView) overviewView.findViewById(R.id.txtGoalWeight);
|
||||
txtGoalDiff = (TextView) overviewView.findViewById(R.id.txtGoalDiff);
|
||||
txtGoalDayLeft = (TextView) overviewView.findViewById(R.id.txtGoalDayLeft);
|
||||
|
||||
txtAvgWeek = (TextView) overviewView.findViewById(R.id.txtAvgWeek);
|
||||
txtAvgMonth = (TextView) overviewView.findViewById(R.id.txtAvgMonth);
|
||||
|
||||
txtLabelGoalWeight = (TextView) overviewView.findViewById(R.id.txtLabelGoalWeight);
|
||||
txtLabelGoalDiff = (TextView) overviewView.findViewById(R.id.txtLabelGoalDiff);
|
||||
txtLabelDayLeft = (TextView) overviewView.findViewById(R.id.txtLabelDayLeft);
|
||||
|
||||
txtLabelAvgWeek = (TextView) overviewView.findViewById(R.id.txtLabelAvgWeek);
|
||||
txtLabelAvgMonth = (TextView) overviewView.findViewById(R.id.txtLabelAvgMonth);
|
||||
|
||||
pieChartLast = (PieChartView) overviewView.findViewById(R.id.pieChartLast);
|
||||
lineChartLast = (LineChartView) overviewView.findViewById(R.id.lineChartLast);
|
||||
|
||||
@@ -216,14 +182,26 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
|
||||
txtTitleUser.setText(getResources().getString(R.string.label_title_user).toUpperCase());
|
||||
txtTitleLastMeasurement.setText(getResources().getString(R.string.label_title_last_measurement).toUpperCase());
|
||||
txtTitleGoal.setText(getResources().getString(R.string.label_title_goal).toUpperCase());
|
||||
txtTitleStatistics.setText(getResources().getString(R.string.label_title_statistics).toUpperCase());
|
||||
|
||||
updateUserSelection();
|
||||
updateLastPieChart();
|
||||
updateLastLineChart(scaleDataList);
|
||||
updateGoal(scaleDataList);
|
||||
updateStatistics(scaleDataList);
|
||||
|
||||
ListIterator<ScaleData> scaleDataIterator = scaleDataList.listIterator();
|
||||
|
||||
while(scaleDataIterator.hasNext()) {
|
||||
ScaleData scaleData = scaleDataIterator.next();
|
||||
|
||||
if (scaleData.id == lastScaleData.id) {
|
||||
if (scaleDataIterator.hasNext()) {
|
||||
ScaleData diffScaleData = scaleDataIterator.next();
|
||||
|
||||
for (MeasurementView measuremt : overviewMeasurements) {
|
||||
measuremt.updateDiff(lastScaleData, diffScaleData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (MeasurementView measuremt : overviewMeasurements) {
|
||||
measuremt.updatePreferences(prefs);
|
||||
@@ -256,227 +234,6 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
spinUser.setSelection(posUser, true);
|
||||
}
|
||||
|
||||
private void updateGoal(ArrayList<ScaleData> scaleDataList) {
|
||||
txtGoalWeight.setText(currentScaleUser.goal_weight + " " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit]);
|
||||
|
||||
double weight_diff = currentScaleUser.goal_weight - lastScaleData.weight;
|
||||
txtGoalDiff.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit], weight_diff));
|
||||
|
||||
Calendar goalDate = Calendar.getInstance();
|
||||
Calendar curDate = Calendar.getInstance();
|
||||
goalDate.setTime(currentScaleUser.goal_date);
|
||||
|
||||
long days = daysBetween(curDate, goalDate);
|
||||
txtGoalDayLeft.setText(days + " " + getResources().getString(R.string.label_days));
|
||||
|
||||
ScaleCalculator currentCalculator = new ScaleCalculator(lastScaleData);
|
||||
|
||||
ScaleData goalData = new ScaleData();
|
||||
goalData.weight = currentScaleUser.goal_weight;
|
||||
ScaleCalculator goalCalculator = new ScaleCalculator(goalData);
|
||||
|
||||
txtLabelGoalWeight.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_goal_weight) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_bmi) +
|
||||
": " +
|
||||
String.format("%.1f", goalCalculator.getBMI(currentScaleUser.body_height)) +
|
||||
" </small></font>"
|
||||
)
|
||||
);
|
||||
txtLabelGoalDiff.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_weight_difference) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_bmi) +
|
||||
": " +
|
||||
String.format("%.1f", currentCalculator.getBMI(currentScaleUser.body_height) - goalCalculator.getBMI(currentScaleUser.body_height)) +
|
||||
" </small></font>"
|
||||
)
|
||||
);
|
||||
txtLabelDayLeft.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_days_left) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_goal_date_is) +
|
||||
" "
|
||||
+ DateFormat.getDateInstance(DateFormat.LONG).format(currentScaleUser.goal_date) +
|
||||
" </small></font>"
|
||||
)
|
||||
); // currentScaleUser.goal_date
|
||||
|
||||
ListIterator<ScaleData> scaleDataIterator = scaleDataList.listIterator();
|
||||
|
||||
while(scaleDataIterator.hasNext()) {
|
||||
ScaleData scaleData = scaleDataIterator.next();
|
||||
|
||||
if (scaleData.id == lastScaleData.id) {
|
||||
if (scaleDataIterator.hasNext()) {
|
||||
ScaleData diffScaleData = scaleDataIterator.next();
|
||||
|
||||
for (MeasurementView measuremt : overviewMeasurements) {
|
||||
measuremt.updateDiff(lastScaleData, diffScaleData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void updateStatistics(ArrayList<ScaleData> scaleDataList) {
|
||||
Calendar histDate = Calendar.getInstance();
|
||||
Calendar weekPastDate = Calendar.getInstance();
|
||||
Calendar monthPastDate = Calendar.getInstance();
|
||||
|
||||
weekPastDate.setTime(lastScaleData.date_time);
|
||||
weekPastDate.add(Calendar.DATE, -7);
|
||||
|
||||
monthPastDate.setTime(lastScaleData.date_time);
|
||||
monthPastDate.add(Calendar.DATE, -30);
|
||||
|
||||
int weekSize = 0;
|
||||
float weekAvgWeight = 0;
|
||||
float weekAvgBMI = 0;
|
||||
float weekAvgFat = 0;
|
||||
float weekAvgWater = 0;
|
||||
float weekAvgMuscle = 0;
|
||||
float weekAvgWaist = 0;
|
||||
float weekAvgWHtR = 0;
|
||||
float weekAvgHip = 0;
|
||||
float weekAvgWHR = 0;
|
||||
|
||||
int monthSize = 0;
|
||||
float monthAvgWeight = 0;
|
||||
float monthAvgBMI = 0;
|
||||
float monthAvgFat = 0;
|
||||
float monthAvgWater = 0;
|
||||
float monthAvgMuscle = 0;
|
||||
float monthAvgWaist = 0;
|
||||
float monthAvgWHtR = 0;
|
||||
float monthAvgHip = 0;
|
||||
float monthAvgWHR = 0;
|
||||
|
||||
for (ScaleData scaleData : scaleDataList)
|
||||
{
|
||||
histDate.setTime(scaleData.date_time);
|
||||
|
||||
ScaleCalculator calculator = new ScaleCalculator(scaleData);
|
||||
|
||||
if (weekPastDate.before(histDate)) {
|
||||
weekSize++;
|
||||
|
||||
weekAvgWeight += scaleData.weight;
|
||||
weekAvgBMI += calculator.getBMI(currentScaleUser.body_height);
|
||||
weekAvgFat += scaleData.fat;
|
||||
weekAvgWater += scaleData.water;
|
||||
weekAvgMuscle += scaleData.muscle;
|
||||
weekAvgWaist += scaleData.waist;
|
||||
weekAvgHip += scaleData.hip;
|
||||
weekAvgWHtR += calculator.getWHtR(currentScaleUser.body_height);
|
||||
weekAvgWHR += calculator.getWHR();
|
||||
}
|
||||
|
||||
if (monthPastDate.before(histDate)) {
|
||||
monthSize++;
|
||||
|
||||
monthAvgWeight += scaleData.weight;
|
||||
monthAvgBMI += calculator.getBMI(currentScaleUser.body_height);
|
||||
monthAvgFat += scaleData.fat;
|
||||
monthAvgWater += scaleData.water;
|
||||
monthAvgMuscle += scaleData.muscle;
|
||||
monthAvgWaist += scaleData.waist;
|
||||
monthAvgHip += scaleData.hip;
|
||||
monthAvgWHtR += calculator.getWHtR(currentScaleUser.body_height);
|
||||
monthAvgWHR += calculator.getWHR();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
weekAvgWeight /= weekSize;
|
||||
weekAvgBMI /= weekSize;
|
||||
weekAvgFat /= weekSize;
|
||||
weekAvgWater /= weekSize;
|
||||
weekAvgMuscle /= weekSize;
|
||||
weekAvgWaist /= weekSize;
|
||||
weekAvgWHtR /= weekSize;
|
||||
weekAvgHip /= weekSize;
|
||||
weekAvgWHR /= weekSize;
|
||||
|
||||
monthAvgWeight /= monthSize;
|
||||
monthAvgBMI /= monthSize;
|
||||
monthAvgFat /= monthSize;
|
||||
monthAvgWater /= monthSize;
|
||||
monthAvgMuscle /= 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.scale_unit] + "<br>", weekAvgWeight);
|
||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_weight)+": %.1f" + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit] + "<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)) {
|
||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", weekAvgMuscle);
|
||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", monthAvgMuscle);
|
||||
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("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));
|
||||
}
|
||||
|
||||
private void updateLastLineChart(ArrayList<ScaleData> scaleDataList) {
|
||||
List<AxisValue> axisValues = new ArrayList<AxisValue>();
|
||||
|
@@ -0,0 +1,318 @@
|
||||
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.health.openscale.gui.fragments;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.health.openscale.R;
|
||||
import com.health.openscale.core.OpenScale;
|
||||
import com.health.openscale.core.datatypes.ScaleCalculator;
|
||||
import com.health.openscale.core.datatypes.ScaleData;
|
||||
import com.health.openscale.core.datatypes.ScaleUser;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class StatisticsFragment extends Fragment implements FragmentUpdateListener {
|
||||
|
||||
private View statisticsView;
|
||||
|
||||
private TextView txtTitleGoal;
|
||||
private TextView txtTitleStatistics;
|
||||
|
||||
private TextView txtGoalWeight;
|
||||
private TextView txtGoalDiff;
|
||||
private TextView txtGoalDayLeft;
|
||||
|
||||
private TextView txtAvgWeek;
|
||||
private TextView txtAvgMonth;
|
||||
|
||||
private TextView txtLabelGoalWeight;
|
||||
private TextView txtLabelGoalDiff;
|
||||
private TextView txtLabelDayLeft;
|
||||
|
||||
private TextView txtLabelAvgWeek;
|
||||
private TextView txtLabelAvgMonth;
|
||||
|
||||
private SharedPreferences prefs;
|
||||
private ScaleUser currentScaleUser;
|
||||
private ScaleData lastScaleData;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
statisticsView = inflater.inflate(R.layout.fragment_statistics, container, false);
|
||||
|
||||
txtTitleGoal = (TextView) statisticsView.findViewById(R.id.txtTitleGoal);
|
||||
txtTitleStatistics = (TextView) statisticsView.findViewById(R.id.txtTitleStatistics);
|
||||
|
||||
txtGoalWeight = (TextView) statisticsView.findViewById(R.id.txtGoalWeight);
|
||||
txtGoalDiff = (TextView) statisticsView.findViewById(R.id.txtGoalDiff);
|
||||
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);
|
||||
txtLabelGoalDiff = (TextView) statisticsView.findViewById(R.id.txtLabelGoalDiff);
|
||||
txtLabelDayLeft = (TextView) statisticsView.findViewById(R.id.txtLabelDayLeft);
|
||||
|
||||
txtLabelAvgWeek = (TextView) statisticsView.findViewById(R.id.txtLabelAvgWeek);
|
||||
txtLabelAvgMonth = (TextView) statisticsView.findViewById(R.id.txtLabelAvgMonth);
|
||||
|
||||
OpenScale.getInstance(statisticsView.getContext()).registerFragment(this);
|
||||
|
||||
return statisticsView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOnView(ArrayList<ScaleData> scaleDataList) {
|
||||
if (scaleDataList.isEmpty()) {
|
||||
lastScaleData = new ScaleData();
|
||||
} else {
|
||||
lastScaleData = scaleDataList.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(statisticsView.getContext()).getSelectedScaleUser();
|
||||
|
||||
updateStatistics(scaleDataList);
|
||||
updateGoal(scaleDataList);
|
||||
}
|
||||
|
||||
private void updateGoal(ArrayList<ScaleData> scaleDataList) {
|
||||
txtGoalWeight.setText(currentScaleUser.goal_weight + " " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit]);
|
||||
|
||||
double weight_diff = currentScaleUser.goal_weight - lastScaleData.weight;
|
||||
txtGoalDiff.setText(String.format("%.1f " + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit], weight_diff));
|
||||
|
||||
Calendar goalDate = Calendar.getInstance();
|
||||
Calendar curDate = Calendar.getInstance();
|
||||
goalDate.setTime(currentScaleUser.goal_date);
|
||||
|
||||
long days = daysBetween(curDate, goalDate);
|
||||
txtGoalDayLeft.setText(days + " " + getResources().getString(R.string.label_days));
|
||||
|
||||
ScaleCalculator currentCalculator = new ScaleCalculator(lastScaleData);
|
||||
|
||||
ScaleData goalData = new ScaleData();
|
||||
goalData.weight = currentScaleUser.goal_weight;
|
||||
ScaleCalculator goalCalculator = new ScaleCalculator(goalData);
|
||||
|
||||
txtLabelGoalWeight.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_goal_weight) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_bmi) +
|
||||
": " +
|
||||
String.format("%.1f", goalCalculator.getBMI(currentScaleUser.body_height)) +
|
||||
" </small></font>"
|
||||
)
|
||||
);
|
||||
txtLabelGoalDiff.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_weight_difference) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_bmi) +
|
||||
": " +
|
||||
String.format("%.1f", currentCalculator.getBMI(currentScaleUser.body_height) - goalCalculator.getBMI(currentScaleUser.body_height)) +
|
||||
" </small></font>"
|
||||
)
|
||||
);
|
||||
txtLabelDayLeft.setText(
|
||||
Html.fromHtml(
|
||||
getResources().getString(R.string.label_days_left) +
|
||||
" <br> <font color='grey'><small>" +
|
||||
getResources().getString(R.string.label_goal_date_is) +
|
||||
" "
|
||||
+ DateFormat.getDateInstance(DateFormat.LONG).format(currentScaleUser.goal_date) +
|
||||
" </small></font>"
|
||||
)
|
||||
); // currentScaleUser.goal_date
|
||||
}
|
||||
|
||||
private void updateStatistics(ArrayList<ScaleData> scaleDataList) {
|
||||
Calendar histDate = Calendar.getInstance();
|
||||
Calendar weekPastDate = Calendar.getInstance();
|
||||
Calendar monthPastDate = Calendar.getInstance();
|
||||
|
||||
weekPastDate.setTime(lastScaleData.date_time);
|
||||
weekPastDate.add(Calendar.DATE, -7);
|
||||
|
||||
monthPastDate.setTime(lastScaleData.date_time);
|
||||
monthPastDate.add(Calendar.DATE, -30);
|
||||
|
||||
int weekSize = 0;
|
||||
float weekAvgWeight = 0;
|
||||
float weekAvgBMI = 0;
|
||||
float weekAvgFat = 0;
|
||||
float weekAvgWater = 0;
|
||||
float weekAvgMuscle = 0;
|
||||
float weekAvgWaist = 0;
|
||||
float weekAvgWHtR = 0;
|
||||
float weekAvgHip = 0;
|
||||
float weekAvgWHR = 0;
|
||||
|
||||
int monthSize = 0;
|
||||
float monthAvgWeight = 0;
|
||||
float monthAvgBMI = 0;
|
||||
float monthAvgFat = 0;
|
||||
float monthAvgWater = 0;
|
||||
float monthAvgMuscle = 0;
|
||||
float monthAvgWaist = 0;
|
||||
float monthAvgWHtR = 0;
|
||||
float monthAvgHip = 0;
|
||||
float monthAvgWHR = 0;
|
||||
|
||||
for (ScaleData scaleData : scaleDataList)
|
||||
{
|
||||
histDate.setTime(scaleData.date_time);
|
||||
|
||||
ScaleCalculator calculator = new ScaleCalculator(scaleData);
|
||||
|
||||
if (weekPastDate.before(histDate)) {
|
||||
weekSize++;
|
||||
|
||||
weekAvgWeight += scaleData.weight;
|
||||
weekAvgBMI += calculator.getBMI(currentScaleUser.body_height);
|
||||
weekAvgFat += scaleData.fat;
|
||||
weekAvgWater += scaleData.water;
|
||||
weekAvgMuscle += scaleData.muscle;
|
||||
weekAvgWaist += scaleData.waist;
|
||||
weekAvgHip += scaleData.hip;
|
||||
weekAvgWHtR += calculator.getWHtR(currentScaleUser.body_height);
|
||||
weekAvgWHR += calculator.getWHR();
|
||||
}
|
||||
|
||||
if (monthPastDate.before(histDate)) {
|
||||
monthSize++;
|
||||
|
||||
monthAvgWeight += scaleData.weight;
|
||||
monthAvgBMI += calculator.getBMI(currentScaleUser.body_height);
|
||||
monthAvgFat += scaleData.fat;
|
||||
monthAvgWater += scaleData.water;
|
||||
monthAvgMuscle += scaleData.muscle;
|
||||
monthAvgWaist += scaleData.waist;
|
||||
monthAvgHip += scaleData.hip;
|
||||
monthAvgWHtR += calculator.getWHtR(currentScaleUser.body_height);
|
||||
monthAvgWHR += calculator.getWHR();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
weekAvgWeight /= weekSize;
|
||||
weekAvgBMI /= weekSize;
|
||||
weekAvgFat /= weekSize;
|
||||
weekAvgWater /= weekSize;
|
||||
weekAvgMuscle /= weekSize;
|
||||
weekAvgWaist /= weekSize;
|
||||
weekAvgWHtR /= weekSize;
|
||||
weekAvgHip /= weekSize;
|
||||
weekAvgWHR /= weekSize;
|
||||
|
||||
monthAvgWeight /= monthSize;
|
||||
monthAvgBMI /= monthSize;
|
||||
monthAvgFat /= monthSize;
|
||||
monthAvgWater /= monthSize;
|
||||
monthAvgMuscle /= 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.scale_unit] + "<br>", weekAvgWeight);
|
||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_weight)+": %.1f" + ScaleUser.UNIT_STRING[currentScaleUser.scale_unit] + "<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)) {
|
||||
info_week += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", weekAvgMuscle);
|
||||
info_month += String.format("Ø-"+getResources().getString(R.string.label_muscle)+": %.1f%% <br>", monthAvgMuscle);
|
||||
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("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));
|
||||
}
|
||||
|
||||
private long daysBetween(Calendar startDate, Calendar endDate) {
|
||||
long end = endDate.getTimeInMillis();
|
||||
long start = startDate.getTimeInMillis();
|
||||
return TimeUnit.MILLISECONDS.toDays(Math.abs(end - start));
|
||||
}
|
||||
}
|
@@ -90,250 +90,6 @@
|
||||
android:id="@+id/tableLayoutMeasurements">
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_title_goal"
|
||||
android:id="@+id/txtTitleGoal"
|
||||
android:autoText="false"
|
||||
android:textSize="20dp"
|
||||
android:typeface="monospace"
|
||||
android:layout_marginTop="20dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/imageView5"
|
||||
android:src="@drawable/target"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Target weight"
|
||||
android:id="@+id/txtLabelGoalWeight"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"
|
||||
android:layout_marginRight="50dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 kg"
|
||||
android:id="@+id/txtGoalWeight"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="20dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow9"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/imageView6"
|
||||
android:src="@drawable/difference"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Weight difference"
|
||||
android:id="@+id/txtLabelGoalDiff"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"
|
||||
android:layout_marginRight="50dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 kg"
|
||||
android:id="@+id/txtGoalDiff"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="20dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow10"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/imageView7"
|
||||
android:src="@drawable/daysleft"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Days left"
|
||||
android:id="@+id/txtLabelDayLeft"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"
|
||||
android:layout_marginRight="50dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 days"
|
||||
android:id="@+id/txtGoalDayLeft"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="20dp" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_title_statistics"
|
||||
android:id="@+id/txtTitleStatistics"
|
||||
android:autoText="false"
|
||||
android:textSize="20dp"
|
||||
android:typeface="monospace"
|
||||
android:layout_marginTop="20dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/imageView8"
|
||||
android:src="@drawable/lastweek"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Last 7 days"
|
||||
android:id="@+id/txtLabelAvgWeek"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"
|
||||
android:layout_marginRight="50dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1"
|
||||
android:id="@+id/txtAvgWeek"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="20dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow11"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:id="@+id/imageView9"
|
||||
android:src="@drawable/lastmonth"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Last 30 days"
|
||||
android:id="@+id/txtLabelAvgMonth"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"
|
||||
android:layout_marginRight="50dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1"
|
||||
android:id="@+id/txtAvgMonth"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="20dp" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
@@ -2,8 +2,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
tools:context="com.health.openscale.MainActivity$PlaceholderFragment" >
|
||||
android:padding="5dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
@@ -82,260 +82,6 @@
|
||||
android:id="@+id/tableLayoutMeasurements">
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_title_goal"
|
||||
android:id="@+id/txtTitleGoal"
|
||||
android:autoText="false"
|
||||
android:textSize="25dp"
|
||||
android:typeface="monospace"
|
||||
android:layout_marginTop="25dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/imageView5"
|
||||
android:src="@drawable/target"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="80"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Target weight"
|
||||
android:id="@+id/txtLabelGoalWeight"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="20"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 kg"
|
||||
android:id="@+id/txtGoalWeight"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow9"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/imageView6"
|
||||
android:src="@drawable/difference"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="80"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Weight difference"
|
||||
android:id="@+id/txtLabelGoalDiff"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="20"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 kg"
|
||||
android:id="@+id/txtGoalDiff"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow10"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/imageView7"
|
||||
android:src="@drawable/daysleft"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="80"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Days left"
|
||||
android:id="@+id/txtLabelDayLeft"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="20"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1 days"
|
||||
android:id="@+id/txtGoalDayLeft"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_title_statistics"
|
||||
android:id="@+id/txtTitleStatistics"
|
||||
android:autoText="false"
|
||||
android:textSize="25dp"
|
||||
android:typeface="monospace"
|
||||
android:layout_marginTop="25dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray"/>
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/imageView8"
|
||||
android:src="@drawable/lastweek"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="80"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Last 7 days"
|
||||
android:id="@+id/txtLabelAvgWeek"
|
||||
android:layout_column="1"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="20"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1"
|
||||
android:id="@+id/txtAvgWeek"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/tableRow11"
|
||||
android:weightSum="100"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:id="@+id/imageView9"
|
||||
android:src="@drawable/lastmonth"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="80"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Last 30 days"
|
||||
android:id="@+id/txtLabelAvgMonth"
|
||||
android:textAlignment="center"
|
||||
android:singleLine="false"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:password="false"
|
||||
android:phoneNumber="false"
|
||||
android:lines="2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="20"
|
||||
android:textSize="15dp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="-1"
|
||||
android:id="@+id/txtAvgMonth"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
269
android_app/app/src/main/res/layout/fragment_statistics.xml
Normal file
269
android_app/app/src/main/res/layout/fragment_statistics.xml
Normal file
@@ -0,0 +1,269 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtTitleGoal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:autoText="false"
|
||||
android:text="@string/label_title_goal"
|
||||
android:textSize="25dp"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
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/imageView5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/target" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelGoalWeight"
|
||||
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="Target weight"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtGoalWeight"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="20"
|
||||
android:text="-1 kg"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow9"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/difference" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelGoalDiff"
|
||||
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="Weight difference"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtGoalDiff"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="20"
|
||||
android:text="-1 kg"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:id="@+id/tableRow10"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/daysleft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtLabelDayLeft"
|
||||
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="Days left"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtGoalDayLeft"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_column="2"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="20"
|
||||
android:text="-1 days"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtTitleStatistics"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:autoText="false"
|
||||
android:text="@string/label_title_statistics"
|
||||
android:textSize="25dp"
|
||||
android:typeface="monospace" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="90"
|
||||
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/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: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/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:text="-1"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textSize="15dp" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
@@ -73,7 +73,7 @@
|
||||
<string name="label_yes">Ja</string>
|
||||
<string name="question_really_delete_user">Wollen Sie wirklich den Benutzer löschen?</string>
|
||||
<string name="question_really_delete_all">Wollen Sie wirklich alle Datenbankeinträge löschen?</string>
|
||||
<string name="title_frag">Tabelle</string>
|
||||
<string name="title_table">Tabelle</string>
|
||||
<string name="title_graph">Diagramm</string>
|
||||
<string name="title_overview">Übersicht</string>
|
||||
<string name="title_users">Benutzer</string>
|
||||
@@ -117,4 +117,5 @@
|
||||
<string name="error_value_range">Fehler beim Wertebereich</string>
|
||||
<string name="error_value_required">Wert ist erforderlich</string>
|
||||
<string name="label_editmode">Bearbeiten</string>
|
||||
<string name="title_statistics">Statistiken</string>
|
||||
</resources>
|
@@ -4,7 +4,7 @@
|
||||
<string name="app_name">openScale</string>
|
||||
<string name="title_overview">Vue d\'ensemble</string>
|
||||
<string name="title_graph">Diagramme</string>
|
||||
<string name="title_frag">Tableau</string>
|
||||
<string name="title_table">Tableau</string>
|
||||
<string name="title_users">Utilisateurs</string>
|
||||
<string name="title_data">Données</string>
|
||||
<string name="title_measurements">Mesures</string>
|
||||
@@ -136,4 +136,5 @@
|
||||
<string name="Saturday">Samedi</string>
|
||||
<string name="Sunday">Dimanche</string>
|
||||
<string name="label_editmode">Modifier</string>
|
||||
<string name="title_statistics">Statistiques</string>
|
||||
</resources>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<resources>
|
||||
<string name="app_name">openScale</string>
|
||||
<string name="title_users">ユーザー</string>
|
||||
<string name="title_frag">早見表</string>
|
||||
<string name="title_table">早見表</string>
|
||||
<string name="title_graph">図表</string>
|
||||
<string name="title_overview">概説</string>
|
||||
<string name="label_yes">はい</string>
|
||||
@@ -117,4 +117,5 @@
|
||||
<string name="error_value_required">値が必要です</string>
|
||||
<string name="error_value_range">エラー値の範囲</string>
|
||||
<string name="label_editmode">編集</string>
|
||||
<string name="title_statistics">統計</string>
|
||||
</resources>
|
@@ -4,7 +4,8 @@
|
||||
<string name="app_name">openScale</string>
|
||||
<string name="title_overview">Overview</string>
|
||||
<string name="title_graph">Chart</string>
|
||||
<string name="title_frag">Table</string>
|
||||
<string name="title_table">Table</string>
|
||||
<string name="title_statistics">Statistics</string>
|
||||
<string name="title_users">Users</string>
|
||||
<string name="title_data">Data</string>
|
||||
<string name="title_measurements">Measurements</string>
|
||||
|
Reference in New Issue
Block a user