1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-24 01:03:20 +02:00

- refactored measurments views

- replace table header text with icons
- refactored data entry activity. It has three mode (VIEW, EDIT, ADD)
- add license notes
- add dynamically date, time and comment fields
This commit is contained in:
OliE
2017-04-08 18:13:58 +02:00
parent 1c3bb916f7
commit fb1a79c945
26 changed files with 959 additions and 543 deletions

View File

@@ -25,7 +25,7 @@
</intent-filter>
</activity>
<activity android:name=".gui.activities.SettingsActivity"/>
<activity android:name=".gui.activities.DataEntryActivity" android:theme="@android:style/Theme.Holo.Light.Dialog"/>
<activity android:name=".gui.activities.DataEntryActivity"/>
<activity android:name=".gui.activities.UserSettingsActivity" android:theme="@android:style/Theme.Holo.Dialog"
android:label="@string/label_title_user"/>

View File

@@ -1,3 +1,18 @@
/* 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.core.alarm;
import android.support.annotation.NonNull;

View File

@@ -1,3 +1,18 @@
/* 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.core.alarm;
import android.content.Context;

View File

@@ -1,3 +1,18 @@
/* 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.core.alarm;
import android.app.AlarmManager;

View File

@@ -24,6 +24,13 @@ public class EvaluationResult {
public float highLimit;
public EVAL_STATE eval_state;
public EvaluationResult() {
this.value = -1.0f;
this.lowLimit = -1.0f;
this.highLimit = -1.0f;
this.eval_state = EVAL_STATE.UNDEFINED;
}
public EvaluationResult(float value, float lowLimit, float highLimit, EVAL_STATE eval_state)
{
this.value = value;

View File

@@ -269,10 +269,6 @@ public class EvaluationSheet {
return evaluateSheet(whr, bodyEvaluateSheet);
}
public EvaluationResult evaluateHip(float hip) {
return evaluateSheet(hip, new ArrayList<sheetEntry>());
}
private EvaluationResult evaluateSheet(float value, List<sheetEntry> sheet) {
for (int i=0; i < sheet.size(); i++) {
sheetEntry curEntry = sheet.get(i);

View File

@@ -17,8 +17,6 @@ package com.health.openscale.gui.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
@@ -27,28 +25,29 @@ import android.preference.PreferenceManager;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import com.health.openscale.R;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.gui.views.CommentMeasurementView;
import com.health.openscale.gui.views.DateMeasurementView;
import com.health.openscale.gui.views.FatMeasurementView;
import com.health.openscale.gui.views.HipMeasurementView;
import com.health.openscale.gui.views.MeasurementView;
import com.health.openscale.gui.views.MuscleMeasurementView;
import com.health.openscale.gui.views.TimeMeasurementView;
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.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.ListIterator;
@@ -66,21 +65,18 @@ public class DataEntryActivity extends Activity {
private FatMeasurementView fatMeasurement;
private WaistMeasurementView waistMeasurement;
private HipMeasurementView hipMeasurement;
private EditText txtDate;
private EditText txtTime;
private EditText txtComment;
private CommentMeasurementView commentMeasurement;
private DateMeasurementView dateMeasurement;
private TimeMeasurementView timeMeasurement;
private TextView txtDataNr;
private Button btnAdd;
private Button btnOk;
private Button btnCancel;
private Button btnDelete;
private Button btnLeft;
private Button btnRight;
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
private SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
private ImageView imageViewDelete;
private Switch switchEditMode;
private long id;
@@ -104,6 +100,9 @@ public class DataEntryActivity extends Activity {
fatMeasurement = new FatMeasurementView(context);
waistMeasurement = new WaistMeasurementView(context);
hipMeasurement = new HipMeasurementView(context);
commentMeasurement = new CommentMeasurementView(context);
dateMeasurement = new DateMeasurementView(context);
timeMeasurement = new TimeMeasurementView(context);
dataEntryMeasurements = new ArrayList<>();
dataEntryMeasurements.add(weightMeasurement);
@@ -112,35 +111,33 @@ public class DataEntryActivity extends Activity {
dataEntryMeasurements.add(fatMeasurement);
dataEntryMeasurements.add(waistMeasurement);
dataEntryMeasurements.add(hipMeasurement);
dataEntryMeasurements.add(commentMeasurement);
dataEntryMeasurements.add(dateMeasurement);
dataEntryMeasurements.add(timeMeasurement);
Collections.reverse(dataEntryMeasurements);
for (MeasurementView measuremt : dataEntryMeasurements) {
tableLayoutDataEntry.addView(measuremt, 0);
measuremt.setEditMode(true);
}
txtDataNr = (TextView) findViewById(R.id.txtDataNr);
txtDate = (EditText) findViewById(R.id.txtDate);
txtTime = (EditText) findViewById(R.id.txtTime);
txtComment = (EditText) findViewById(R.id.txtComment);
btnAdd = (Button) findViewById(R.id.btnAdd);
btnOk = (Button) findViewById(R.id.btnOk);
btnCancel = (Button) findViewById(R.id.btnCancel);
btnDelete = (Button) findViewById(R.id.btnDelete);
btnLeft = (Button) findViewById(R.id.btnLeft);
btnRight = (Button) findViewById(R.id.btnRight);
imageViewDelete = (ImageView) findViewById(R.id.imgViewDelete);
switchEditMode = (Switch) findViewById(R.id.switchEditMode);
btnAdd.setOnClickListener(new onClickListenerAdd());
btnOk.setOnClickListener(new onClickListenerOk());
btnCancel.setOnClickListener(new onClickListenerCancel());
btnDelete.setOnClickListener(new onClickListenerDelete());
imageViewDelete.setOnClickListener(new onClickListenerDelete());
btnLeft.setOnClickListener(new onClickListenerLeft());
btnRight.setOnClickListener(new onClickListenerRight());
txtDate.setOnFocusChangeListener(new onFocusChangeDate());
txtTime.setOnFocusChangeListener(new onFocusChangeTime());
switchEditMode.setOnCheckedChangeListener(new onCheckedChangeEditMode());
updateOnView();
}
@@ -154,100 +151,110 @@ public class DataEntryActivity extends Activity {
measuremt.updatePreferences(prefs);
}
if (getIntent().getExtras().getInt("mode") == EDIT_DATA_REQUEST) {
editMode();
}
else
{
addMode();
}
}
private void editMode()
{
btnOk.setVisibility(View.VISIBLE);
btnAdd.setVisibility(View.GONE);
btnDelete.setVisibility(View.VISIBLE);
btnLeft.setVisibility(View.VISIBLE);
btnRight.setVisibility(View.VISIBLE);
txtDataNr.setVisibility(View.VISIBLE);
id = getIntent().getExtras().getLong("id");
OpenScale openScale = OpenScale.getInstance(context);
if (id > 0) {
if (switchEditMode.isChecked()) {
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
} else {
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
}
OpenScale openScale = OpenScale.getInstance(context);
ScaleData editScaleData = openScale.getScaleData(id);
ScaleData selectedScaleData = openScale.getScaleData(id);
txtDataNr.setText(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(editScaleData.date_time));
txtDataNr.setText(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT).format(selectedScaleData.date_time));
for (MeasurementView measuremt : dataEntryMeasurements) {
measuremt.updateValue(editScaleData);
ArrayList<ScaleData> scaleDataList = OpenScale.getInstance(context).getScaleDataList();
ListIterator<ScaleData> scaleDataIterator = scaleDataList.listIterator();
ScaleData lastData = new ScaleData();
while(scaleDataIterator.hasNext()) {
ScaleData scaleData = scaleDataIterator.next();
if (scaleData.id == id) {
if (scaleDataIterator.hasNext()) {
lastData = scaleDataIterator.next();
}
}
}
// show selected scale data
for (MeasurementView measuremt : dataEntryMeasurements) {
measuremt.updateValue(selectedScaleData);
measuremt.updateDiff(selectedScaleData, lastData);
}
return;
}
txtDate.setText(dateFormat.format(editScaleData.date_time));
txtTime.setText(timeFormat.format(editScaleData.date_time));
}
private void addMode()
{
btnOk.setVisibility(View.GONE);
btnAdd.setVisibility(View.VISIBLE);
btnDelete.setVisibility(View.GONE);
btnLeft.setVisibility(View.GONE);
btnRight.setVisibility(View.GONE);
txtDataNr.setVisibility(View.GONE);
if (!OpenScale.getInstance(this).getScaleDataList().isEmpty())
{
setViewMode(MeasurementView.MeasurementViewMode.ADD);
ScaleData lastScaleData = OpenScale.getInstance(this).getScaleDataList().get(0);
// show as default last scale data
for (MeasurementView measuremt : dataEntryMeasurements) {
lastScaleData.date_time = new Date();
lastScaleData.comment = "";
measuremt.updateValue(lastScaleData);
}
} else {
setViewMode(MeasurementView.MeasurementViewMode.ADD);
// show default values
for (MeasurementView measuremt : dataEntryMeasurements) {
measuremt.updateValue(new ScaleData());
}
}
txtDate.setText(dateFormat.format(new Date()));
txtTime.setText(timeFormat.format(new Date()));
}
private boolean validateAllInput()
{
boolean isValidate = true;
private void setViewMode(MeasurementView.MeasurementViewMode viewMode)
{
switch (viewMode) {
case VIEW:
case EDIT:
btnOk.setVisibility(View.VISIBLE);
btnAdd.setVisibility(View.GONE);
imageViewDelete.setVisibility(View.VISIBLE);
btnLeft.setVisibility(View.VISIBLE);
btnRight.setVisibility(View.VISIBLE);
txtDataNr.setVisibility(View.VISIBLE);
switchEditMode.setVisibility(View.VISIBLE);
dateMeasurement.setVisibility(View.VISIBLE);
timeMeasurement.setVisibility(View.VISIBLE);
break;
case ADD:
btnOk.setVisibility(View.GONE);
btnAdd.setVisibility(View.VISIBLE);
imageViewDelete.setVisibility(View.GONE);
btnLeft.setVisibility(View.GONE);
btnRight.setVisibility(View.GONE);
txtDataNr.setVisibility(View.GONE);
switchEditMode.setVisibility(View.GONE);
dateMeasurement.setVisibility(View.GONE);
timeMeasurement.setVisibility(View.GONE);
break;
}
for (MeasurementView measuremt : dataEntryMeasurements) {
if (!measuremt.validateInput()) {
isValidate = false;
}
measuremt.setEditMode(viewMode);
}
return isValidate;
}
}
private void saveScaleData() {
if (validateAllInput()) {
String comment = txtComment.getText().toString();
OpenScale openScale = OpenScale.getInstance(context);
String date = txtDate.getText().toString();
String time = txtTime.getText().toString();
OpenScale openScale = OpenScale.getInstance(context);
openScale.updateScaleData(id,
date + " " + time,
weightMeasurement.getValue(),
fatMeasurement.getValue(),
waterMeasurement.getValue(),
muscleMeasurement.getValue(),
waistMeasurement.getValue(),
hipMeasurement.getValue(),
comment);
}
openScale.updateScaleData(id,
dateMeasurement.getValueAsString() + " " + timeMeasurement.getValueAsString(),
weightMeasurement.getValue(),
fatMeasurement.getValue(),
waterMeasurement.getValue(),
muscleMeasurement.getValue(),
waistMeasurement.getValue(),
hipMeasurement.getValue(),
commentMeasurement.getValueAsString());
}
private boolean moveLeft() {
@@ -302,57 +309,35 @@ public class DataEntryActivity extends Activity {
return false;
}
private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
// txtDate.setText(String.format("%02d.%02d.%04d", selectedDay, selectedMonth+1, selectedYear));
}
};
private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// txtTime.setText(String.format("%02d:%02d", hourOfDay, minute));
}
};
private class onClickListenerAdd implements View.OnClickListener {
@Override
public void onClick(View v) {
if (validateAllInput())
{
OpenScale openScale = OpenScale.getInstance(context);
OpenScale openScale = OpenScale.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int selectedUserId = prefs.getInt("selectedUserId", -1);
if (selectedUserId == -1) {
AlertDialog.Builder infoDialog = new AlertDialog.Builder(context);
if (selectedUserId == -1) {
AlertDialog.Builder infoDialog = new AlertDialog.Builder(context);
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
infoDialog.show();
} else {
String comment = txtComment.getText().toString();
infoDialog.show();
} else {
openScale.addScaleData(selectedUserId,
dateMeasurement.getValueAsString() + " " + timeMeasurement.getValueAsString(),
weightMeasurement.getValue(),
fatMeasurement.getValue(),
waterMeasurement.getValue(),
muscleMeasurement.getValue(),
waistMeasurement.getValue(),
hipMeasurement.getValue(),
commentMeasurement.getValueAsString());
String date = txtDate.getText().toString();
String time = txtTime.getText().toString();
openScale.addScaleData(selectedUserId,
date + " " + time,
weightMeasurement.getValue(),
fatMeasurement.getValue(),
waterMeasurement.getValue(),
muscleMeasurement.getValue(),
waistMeasurement.getValue(),
hipMeasurement.getValue(),
comment);
finish();
}
finish();
}
}
}
@@ -360,10 +345,8 @@ public class DataEntryActivity extends Activity {
private class onClickListenerOk implements View.OnClickListener {
@Override
public void onClick(View v) {
if (validateAllInput()) {
saveScaleData();
finish();
}
saveScaleData();
finish();
}
}
@@ -431,38 +414,13 @@ public class DataEntryActivity extends Activity {
}
}
private class onFocusChangeDate implements View.OnFocusChangeListener {
private class onCheckedChangeEditMode implements CompoundButton.OnCheckedChangeListener {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
Calendar cal = Calendar.getInstance();
if (getIntent().getExtras().getInt("mode") == EDIT_DATA_REQUEST) {
OpenScale openScale = OpenScale.getInstance(context);
ScaleData editScaleData = openScale.getScaleData(id);
cal.setTime(editScaleData.date_time);
}
DatePickerDialog datePicker = new DatePickerDialog(context, datePickerListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
datePicker.show();
}
}
}
private class onFocusChangeTime implements View.OnFocusChangeListener {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
Calendar cal = Calendar.getInstance();
if (getIntent().getExtras().getInt("mode") == EDIT_DATA_REQUEST) {
OpenScale openScale = OpenScale.getInstance(context);
ScaleData editScaleData = openScale.getScaleData(id);
cal.setTime(editScaleData.date_time);
}
TimePickerDialog timePicker = new TimePickerDialog(context, timePickerListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
timePicker.show();
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setViewMode(MeasurementView.MeasurementViewMode.EDIT);
} else {
setViewMode(MeasurementView.MeasurementViewMode.VIEW);
}
}
}

View File

@@ -22,18 +22,17 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TableRow.LayoutParams;
@@ -72,31 +71,6 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
tableView.findViewById(R.id.btnDeleteAll).setOnClickListener(new onClickListenerDeleteAll());
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE &&
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE)
{
TextView txtDateTableHeader = (TextView)tableView.findViewById(R.id.txtDateTableHeader);
txtDateTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtTimeTableHeader = (TextView)tableView.findViewById(R.id.txtTimeTableHeader);
txtTimeTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtWeightTableHeader = (TextView)tableView.findViewById(R.id.txtWeightTableHeader);
txtWeightTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtFatTableHeader = (TextView)tableView.findViewById(R.id.txtFatTableHeader);
txtFatTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtWaterTableHeader = (TextView)tableView.findViewById(R.id.txtWaterTableHeader);
txtWaterTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtMuscleTableHeader = (TextView)tableView.findViewById(R.id.txtMuscleTableHeader);
txtMuscleTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtWaistTableHeader = (TextView)tableView.findViewById(R.id.txtWaistTableHeader);
txtWaistTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtHipTableHeader = (TextView)tableView.findViewById(R.id.txtHipTableHeader);
txtHipTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
TextView txtCommentTableHeader = (TextView)tableView.findViewById(R.id.txtCommentTableHeader);
txtCommentTableHeader.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
Button btnDeleteAll = (Button)tableView.findViewById(R.id.btnDeleteAll);
btnDeleteAll.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
}
OpenScale.getInstance(tableView.getContext()).registerFragment(this);
return tableView;
@@ -108,42 +82,42 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
prefs = PreferenceManager.getDefaultSharedPreferences(tableView.getContext());
if(!prefs.getBoolean("fatEnable", true)) {
TextView txtFatTableHeader = (TextView)tableView.findViewById(R.id.txtFatTableHeader);
ImageView txtFatTableHeader = (ImageView)tableView.findViewById(R.id.txtFatTableHeader);
txtFatTableHeader.setVisibility(View.GONE);
} else {
TextView txtFatTableHeader = (TextView)tableView.findViewById(R.id.txtFatTableHeader);
ImageView txtFatTableHeader = (ImageView)tableView.findViewById(R.id.txtFatTableHeader);
txtFatTableHeader.setVisibility(View.VISIBLE);
}
if(!prefs.getBoolean("muscleEnable", true)) {
TextView txtMuscleTableHeader = (TextView)tableView.findViewById(R.id.txtMuscleTableHeader);
ImageView txtMuscleTableHeader = (ImageView)tableView.findViewById(R.id.txtMuscleTableHeader);
txtMuscleTableHeader.setVisibility(View.GONE);
} else {
TextView txtMuscleTableHeader = (TextView)tableView.findViewById(R.id.txtMuscleTableHeader);
ImageView txtMuscleTableHeader = (ImageView)tableView.findViewById(R.id.txtMuscleTableHeader);
txtMuscleTableHeader.setVisibility(View.VISIBLE);
}
if(!prefs.getBoolean("waterEnable", true)) {
TextView txtWaterTableHeader = (TextView)tableView.findViewById(R.id.txtWaterTableHeader);
ImageView txtWaterTableHeader = (ImageView)tableView.findViewById(R.id.txtWaterTableHeader);
txtWaterTableHeader.setVisibility(View.GONE);
} else {
TextView txtWaterTableHeader = (TextView)tableView.findViewById(R.id.txtWaterTableHeader);
ImageView txtWaterTableHeader = (ImageView)tableView.findViewById(R.id.txtWaterTableHeader);
txtWaterTableHeader.setVisibility(View.VISIBLE);
}
if(!prefs.getBoolean("waistEnable", true)) {
TextView txtWaistTableHeader = (TextView)tableView.findViewById(R.id.txtWaistTableHeader);
ImageView txtWaistTableHeader = (ImageView)tableView.findViewById(R.id.txtWaistTableHeader);
txtWaistTableHeader.setVisibility(View.GONE);
} else {
TextView txtWaistTableHeader = (TextView)tableView.findViewById(R.id.txtWaistTableHeader);
ImageView txtWaistTableHeader = (ImageView)tableView.findViewById(R.id.txtWaistTableHeader);
txtWaistTableHeader.setVisibility(View.VISIBLE);
}
if(!prefs.getBoolean("hipEnable", true)) {
TextView txtHipTableHeader = (TextView)tableView.findViewById(R.id.txtHipTableHeader);
ImageView txtHipTableHeader = (ImageView)tableView.findViewById(R.id.txtHipTableHeader);
txtHipTableHeader.setVisibility(View.GONE);
} else {
TextView txtHipTableHeader = (TextView)tableView.findViewById(R.id.txtHipTableHeader);
ImageView txtHipTableHeader = (ImageView)tableView.findViewById(R.id.txtHipTableHeader);
txtHipTableHeader.setVisibility(View.VISIBLE);
}
@@ -247,17 +221,11 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
commentView.setPadding(0, 5, 5, 5);
dataRow.addView(commentView);
Button deleteButton = new Button(tableView.getContext());
deleteButton.setText("X");
deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
deleteButton.setTextColor(Color.WHITE);
deleteButton.setBackgroundResource(R.drawable.flat_selector);
deleteButton.setGravity(Gravity.CENTER);
deleteButton.setPadding(0, 0, 0, 0);
deleteButton.setMinimumHeight(35);
deleteButton.setHeight(35);
deleteButton.setOnClickListener(new onClickListenerDelete());
dataRow.addView(deleteButton);
ImageView deleteImageView = new ImageView(tableView.getContext());
dataRow.addView(deleteImageView);
deleteImageView.setImageDrawable(ContextCompat.getDrawable(tableView.getContext(), R.drawable.delete));
deleteImageView.getLayoutParams().height = pxImageDp(20);
deleteImageView.setOnClickListener(new onClickListenerDelete());
dataRow.setOnClickListener(new onClickListenerRow());
@@ -279,6 +247,10 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
}
}
private int pxImageDp(float dp) {
return (int)(dp * getResources().getDisplayMetrics().density + 0.5f);
}
private class onClickListenerRow implements View.OnClickListener {
@Override

View File

@@ -1,3 +1,18 @@
/* 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.views;
import android.content.Context;
@@ -16,6 +31,11 @@ public class BMIMeasurementView extends MeasurementView {
super(context, context.getResources().getString(R.string.label_bmi), ContextCompat.getDrawable(context, R.drawable.bmi));
}
@Override
public boolean isEditable() {
return false;
}
@Override
public void updateValue(ScaleData updateData) {
ScaleCalculator updateCalculator = new ScaleCalculator(updateData);
@@ -49,11 +69,6 @@ public class BMIMeasurementView extends MeasurementView {
return 50;
}
@Override
int getInputType() {
return 0;
}
@Override
public void updatePreferences(SharedPreferences preferences) {
setVisible(preferences.getBoolean("weightEnable", true));

View File

@@ -0,0 +1,84 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import android.widget.EditText;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
public class CommentMeasurementView extends MeasurementView {
public CommentMeasurementView(Context context) {
super(context, context.getResources().getString(R.string.label_comment), ContextCompat.getDrawable(context, R.drawable.comment));
}
@Override
public boolean validateInput(EditText view) {
return true;
}
protected int getInputType() {
return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
}
@Override
protected String getHintText() {
return getResources().getString(R.string.info_enter_comment);
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.comment);
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
}
@Override
public void updatePreferences(SharedPreferences preferences) {
}
@Override
public String getUnit() {
return null;
}
@Override
public EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
@Override
public float getMinValue() {
return 0;
}
@Override
public float getMaxValue() {
return 0;
}
}

View File

@@ -0,0 +1,91 @@
/* 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.views;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.widget.DatePicker;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateMeasurementView extends MeasurementView {
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
public DateMeasurementView(Context context) {
super(context, context.getResources().getString(R.string.label_date), ContextCompat.getDrawable(context, R.drawable.lastmonth));
}
private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
setValueOnView(String.format("%02d.%02d.%04d", selectedDay, selectedMonth+1, selectedYear));
}
};
@Override
protected AlertDialog getInputDialog() {
Calendar cal = Calendar.getInstance();
DatePickerDialog datePicker = new DatePickerDialog(getContext(), datePickerListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
return datePicker;
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(dateFormat.format(updateData.date_time));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
}
@Override
public void updatePreferences(SharedPreferences preferences) {
}
@Override
public String getUnit() {
return null;
}
@Override
public EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
@Override
public float getMinValue() {
return 0;
}
@Override
public float getMaxValue() {
return 0;
}
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -51,8 +65,4 @@ public class FatMeasurementView extends MeasurementView {
return 40;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -38,7 +52,7 @@ public class HipMeasurementView extends MeasurementView {
@Override
public EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return evalSheet.evaluateHip(value);
return null;
}
@Override
@@ -51,8 +65,4 @@ public class HipMeasurementView extends MeasurementView {
return 200;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -96,6 +96,9 @@ public class LinearGaugeView extends View {
infoTextPaint.setColor(Color.GRAY);
infoTextPaint.setTextSize(30);
infoTextPaint.setTextAlign(Paint.Align.CENTER);
firstLimit = -1.0f;
secondLimit = -1.0f;
}
@Override

View File

@@ -1,12 +1,32 @@
/* 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.views;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.text.InputType;
import android.util.TypedValue;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Space;
@@ -15,15 +35,19 @@ import android.widget.TableRow;
import android.widget.TextView;
import com.health.openscale.R;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
import com.health.openscale.core.OpenScale;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.datatypes.ScaleUser;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
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.EDIT;
public abstract class MeasurementView extends TableLayout {
public enum MeasurementViewMode {VIEW, EDIT, ADD};
private static String SYMBOL_UP = "&#x2197;";
private static String SYMBOL_DOWN = "&#x2198;";
@@ -31,6 +55,7 @@ public abstract class MeasurementView extends TableLayout {
private ImageView iconView;
private TextView nameView;
private TextView valueView;
private ImageView editModeView;
private ImageView indicatorView;
private TableRow evaluatorRow;
@@ -38,14 +63,17 @@ public abstract class MeasurementView extends TableLayout {
private String nameText;
private boolean editMode;
private String value;
private MeasurementViewMode measurementMode;
public MeasurementView(Context context, String text, Drawable icon) {
super(context);
initView(context);
editMode = false;
measurementMode = MeasurementViewMode.VIEW;
nameText = text;
value = new String();
nameView.setText(text);
iconView.setImageDrawable(icon);
}
@@ -56,16 +84,17 @@ public abstract class MeasurementView extends TableLayout {
iconView = new ImageView(context);
nameView = new TextView(context);
valueView = new TextView(context);
editModeView = new ImageView(context);
indicatorView = new ImageView(context);
evaluatorRow = new TableRow(context);
evaluatorView = new LinearGaugeView(context);
measurementRow.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, 1.0f));
measurementRow.addView(iconView);
measurementRow.addView(nameView);
measurementRow.addView(valueView);
measurementRow.addView(editModeView);
measurementRow.addView(indicatorView);
addView(measurementRow);
@@ -83,6 +112,11 @@ public abstract class MeasurementView extends TableLayout {
valueView.setTextColor(Color.BLACK);
valueView.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 0.01f));
editModeView.getLayoutParams().height = pxImageDp(20);
editModeView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
editModeView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.edit));
editModeView.setVisibility(View.GONE);
indicatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 0.01f));
indicatorView.setBackgroundColor(Color.GRAY);
@@ -107,38 +141,55 @@ public abstract class MeasurementView extends TableLayout {
public abstract float getMinValue();
public abstract float getMaxValue();
abstract int getInputType();
public float getValue() {
if (valueView.getText().length() == 0) {
if (value.length() == 0) {
return -1;
}
return Float.valueOf(valueView.getText().toString());
return Float.valueOf(value);
}
public void setEditMode(boolean mode) {
editMode = mode;
public String getValueAsString() {
return value;
}
if (editMode) {
valueView = new EditText(getContext());
valueView.setInputType(getInputType());
valueView.setHint(getContext().getResources().getString(R.string.info_enter_value_unit) + " " + getUnit());
measurementRow.addView(valueView);
indicatorView.setVisibility(View.GONE);
protected boolean isEditable() {
return true;
}
public void setEditMode(MeasurementViewMode mode) {
measurementMode = mode;
switch (mode) {
case VIEW:
indicatorView.setVisibility(View.VISIBLE);
editModeView.setVisibility(View.GONE);
break;
case EDIT:
case ADD:
if (isEditable()) {
editModeView.setVisibility(View.VISIBLE);
}
indicatorView.setVisibility(View.GONE);
evaluatorRow.setVisibility(View.GONE);
break;
}
}
protected boolean isEditModeOn() {
return editMode;
protected MeasurementViewMode getMeasurementMode() {
return measurementMode;
}
protected void setValueOnView(float value) {
if (isEditModeOn()) {
valueView.setText(String.valueOf(value));
} else {
valueView.setText(String.format("%.2f ", value) + getUnit());
evaluate(value);
protected void setValueOnView(Object objValue) {
value = String.valueOf(objValue);
try{
Float floatValue = Float.parseFloat(value);
evaluate(floatValue);
valueView.setText(String.format("%.2f ", floatValue) + getUnit());
} catch (NumberFormatException e) {
valueView.setText(value);
}
}
@@ -177,19 +228,17 @@ public abstract class MeasurementView extends TableLayout {
return (int)(dp * getResources().getDisplayMetrics().density + 0.5f);
}
public boolean validateInput() {
if (measurementRow.getVisibility() == View.VISIBLE) {
if (valueView.getText().toString().length() == 0) {
valueView.setError(getResources().getString(R.string.error_value_required));
return false;
}
protected boolean validateInput(EditText view) {
if (view.getText().toString().length() == 0) {
view.setError(getResources().getString(R.string.error_value_required));
return false;
}
float value = Float.valueOf(valueView.getText().toString());
float floatValue = Float.valueOf(view.getText().toString());
if (!(value >= 0 && value <= getMaxValue())) {
valueView.setError(getResources().getString(R.string.error_value_range));
return false;
}
if (!(floatValue >= 0 && floatValue <= getMaxValue())) {
view.setError(getResources().getString(R.string.error_value_range));
return false;
}
return true;
@@ -199,6 +248,10 @@ public abstract class MeasurementView extends TableLayout {
EvaluationSheet evalSheet = new EvaluationSheet(getScaleUser());
EvaluationResult evalResult = evaluateSheet(evalSheet, value);
if (evalResult == null) {
evalResult = new EvaluationResult();
}
evaluatorView.setMinMaxValue(getMinValue(), getMaxValue());
evaluatorView.setLimits(evalResult.lowLimit, evalResult.highLimit);
evaluatorView.setValue(value);
@@ -226,10 +279,60 @@ public abstract class MeasurementView extends TableLayout {
return openScale.getSelectedScaleUser();
}
protected int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
protected String getHintText() {
return getResources().getString(R.string.info_enter_value_unit) + " " + getUnit();
}
protected AlertDialog getInputDialog() {
final AlertDialog floatDialog;
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(nameView.getText());
builder.setIcon(iconView.getDrawable());
final EditText input = new EditText(getContext());
input.setInputType(getInputType());
input.setHint(getHintText());
builder.setView(input);
builder.setPositiveButton(getResources().getString(R.string.label_ok), null);
builder.setNegativeButton(getResources().getString(R.string.label_cancel), null);
floatDialog = builder.create();
floatDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button b = floatDialog.getButton(AlertDialog.BUTTON_POSITIVE);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (validateInput(input)) {
setValueOnView(input.getText().toString());
floatDialog.dismiss();
}
}
});
}
});
return floatDialog;
}
private class onClickListenerEvaluation implements View.OnClickListener {
@Override
public void onClick(View v) {
if (isEditModeOn()) {
if (getMeasurementMode() == EDIT || getMeasurementMode() == ADD) {
if (isEditable()) {
getInputDialog().show();
}
return;
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -51,8 +65,4 @@ public class MuscleMeasurementView extends MeasurementView {
return 80;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -0,0 +1,91 @@
/* 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.views;
import android.app.AlertDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.widget.TimePicker;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
import com.health.openscale.core.evaluation.EvaluationResult;
import com.health.openscale.core.evaluation.EvaluationSheet;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class TimeMeasurementView extends MeasurementView {
private SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
public TimeMeasurementView(Context context) {
super(context, context.getResources().getString(R.string.label_time), ContextCompat.getDrawable(context, R.drawable.daysleft));
}
private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
setValueOnView(String.format("%02d:%02d", hourOfDay, minute));
}
};
@Override
protected AlertDialog getInputDialog() {
Calendar cal = Calendar.getInstance();
TimePickerDialog timePicker = new TimePickerDialog(getContext(), timePickerListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
return timePicker;
}
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(timeFormat.format(updateData.date_time));
}
@Override
public void updateDiff(ScaleData updateData, ScaleData lastData) {
}
@Override
public void updatePreferences(SharedPreferences preferences) {
}
@Override
public String getUnit() {
return "";
}
@Override
public EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value) {
return null;
}
@Override
public float getMinValue() {
return 0;
}
@Override
public float getMaxValue() {
return 0;
}
}

View File

@@ -1,3 +1,18 @@
/* 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.views;
import android.content.Context;
@@ -16,6 +31,11 @@ public class WHRMeasurementView extends MeasurementView {
super(context, context.getResources().getString(R.string.label_whr), ContextCompat.getDrawable(context, R.drawable.whr));
}
@Override
public boolean isEditable() {
return false;
}
@Override
public void updateValue(ScaleData updateData) {
ScaleCalculator updateCalculator = new ScaleCalculator(updateData);
@@ -54,9 +74,4 @@ public class WHRMeasurementView extends MeasurementView {
return 1.5f;
}
@Override
int getInputType() {
return 0;
}
}

View File

@@ -1,3 +1,18 @@
/* 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.views;
import android.content.Context;
@@ -16,6 +31,11 @@ public class WHtRMeasurementView extends MeasurementView {
super(context, context.getResources().getString(R.string.label_whtr), ContextCompat.getDrawable(context, R.drawable.whtr));
}
@Override
public boolean isEditable() {
return false;
}
@Override
public void updateValue(ScaleData updateData) {
ScaleCalculator updateCalculator = new ScaleCalculator(updateData);
@@ -54,8 +74,4 @@ public class WHtRMeasurementView extends MeasurementView {
return 1;
}
@Override
int getInputType() {
return 0;
}
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -51,8 +65,4 @@ public class WaistMeasurementView extends MeasurementView {
return 200;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -50,9 +64,4 @@ public class WaterMeasurementView extends MeasurementView {
public float getMaxValue() {
return 80;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -1,9 +1,23 @@
/* 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.views;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import com.health.openscale.R;
import com.health.openscale.core.datatypes.ScaleData;
@@ -20,6 +34,10 @@ public class WeightMeasurementView extends MeasurementView {
@Override
public void updateValue(ScaleData updateData) {
setValueOnView(updateData.weight);
if (getMeasurementMode() == MeasurementViewMode.ADD) {
getInputDialog().show();
}
}
@Override
@@ -52,8 +70,4 @@ public class WeightMeasurementView extends MeasurementView {
return 300;
}
@Override
int getInputType() {
return InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
}
}

View File

@@ -2,8 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
tools:context="com.health.openscale.MainActivity$PlaceholderFragment">
android:padding="10dp">
<ScrollView
android:layout_width="fill_parent"
@@ -29,81 +28,99 @@
android:id="@+id/txtIdTableHeader"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtDateTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/lastmonth"
android:text="@string/label_date"
android:textStyle="bold"
android:id="@+id/txtDateTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtTimeTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/daysleft"
android:text="@string/label_time"
android:textStyle="bold"
android:id="@+id/txtTimeTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtWeightTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/weight"
android:text="@string/label_weight"
android:textStyle="bold"
android:id="@+id/txtWeightTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtFatTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/fat"
android:text="@string/label_fat"
android:textStyle="bold"
android:id="@+id/txtFatTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtWaterTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/water"
android:text="@string/label_water"
android:textStyle="bold"
android:id="@+id/txtWaterTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtMuscleTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/muscle"
android:text="@string/label_muscle"
android:textStyle="bold"
android:id="@+id/txtMuscleTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtWaistTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/waist"
android:text="@string/label_waist"
android:textStyle="bold"
android:id="@+id/txtWaistTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtHipTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/hip"
android:text="@string/label_hip"
android:textStyle="bold"
android:id="@+id/txtHipTableHeader" />
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:id="@+id/txtCommentTableHeader"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:src="@drawable/comment"
android:text="@string/label_comment"
android:textStyle="bold"
android:id="@+id/txtCommentTableHeader" />
android:textStyle="bold" />
<Button
android:id="@+id/btnDeleteAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/flat_selector"
android:minHeight="20dp"
android:minHeight="22dp"
android:minWidth="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/label_delete_all"
android:textColor="@android:color/white"
android:textSize="10sp"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
android:textSize="10sp" />
</TableRow>
</TableLayout>

View File

@@ -3,198 +3,118 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
android:padding="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center">
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/btnLeft"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:text="&lt;"
android:id="@+id/btnLeft"
android:background="@drawable/flat_selector"
android:text="&lt;"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/txtDataNr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="date/time"
android:id="@+id/txtDataNr"
android:gravity="center"
android:layout_weight="0"
android:textStyle="bold"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
android:layout_marginRight="30dp"
android:layout_weight="0"
android:gravity="center"
android:text="date/time"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold" />
<Button
android:id="@+id/btnRight"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:text=">"
android:id="@+id/btnRight"
android:layout_weight="0"
android:background="@drawable/flat_selector"
android:textColor="@android:color/white"
android:layout_weight="0" />
android:text=">"
android:textColor="@android:color/white" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgViewDelete"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:scaleType="fitCenter"
android:src="@drawable/delete" />
<Switch
android:id="@+id/switchEditMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/label_editmode" />
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:id="@+id/tableLayoutDataEntry">
<TableRow
android:id="@+id/tableRowComment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1.0">
<ImageView
android:layout_height="30dp"
android:src="@drawable/comment"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_comment"
android:textSize="15sp"
android:layout_weight="0.9"/>
<EditText
android:id="@+id/txtComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="0.01"
android:inputType="text|textImeMultiLine|textMultiLine|textAutoComplete|textAutoCorrect"
android:hint="@string/info_enter_comment" />
</TableRow>
<TableRow
android:id="@+id/tableRowDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1.0">
<ImageView
android:layout_height="30dp"
android:src="@drawable/lastmonth"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_date"
android:textSize="15sp"
android:layout_weight="0.9"/>
<EditText
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.01"
android:textSize="15sp"
android:inputType="none"/>
</TableRow>
<TableRow
android:id="@+id/tableRowTime"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_height="30dp"
android:src="@drawable/daysleft"
android:layout_gravity="center" />
<TextView
android:id="@+id/txtAvgWater"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_weight="0.9"
android:text="@string/label_time" />
<EditText
android:id="@+id/txtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.01"
android:textSize="15sp"
android:inputType="none" />
</TableRow>
</TableLayout>
<LinearLayout
android:id="@+id/tableLayoutDataEntry"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
android:layout_height="wrap_content"
android:padding="5dp"/>
<Button
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_cancel" />
<Space
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_delete"/>
<Space
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5" />
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_add" />
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_ok" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom">
<Button
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_cancel"
android:textColor="@android:color/white" />
<Space
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5" />
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_add"
android:textColor="@android:color/white" />
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="5"
android:background="@drawable/flat_selector"
android:text="@string/label_ok"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>

View File

@@ -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">
<ScrollView
android:layout_width="fill_parent"
@@ -29,67 +28,85 @@
android:id="@+id/txtIdTableHeader"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_date"
android:textStyle="bold"
android:src="@drawable/lastmonth"
android:id="@+id/txtDateTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_time"
android:textStyle="bold"
android:src="@drawable/daysleft"
android:id="@+id/txtTimeTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_weight"
android:textStyle="bold"
android:src="@drawable/weight"
android:id="@+id/txtWeightTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_fat"
android:textStyle="bold"
android:src="@drawable/fat"
android:id="@+id/txtFatTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_water"
android:textStyle="bold"
android:src="@drawable/water"
android:id="@+id/txtWaterTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_muscle"
android:textStyle="bold"
android:src="@drawable/muscle"
android:id="@+id/txtMuscleTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_waist"
android:textStyle="bold"
android:src="@drawable/waist"
android:id="@+id/txtWaistTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_hip"
android:textStyle="bold"
android:src="@drawable/hip"
android:id="@+id/txtHipTableHeader" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="fitStart"
android:text="@string/label_comment"
android:textStyle="bold"
android:src="@drawable/comment"
android:id="@+id/txtCommentTableHeader" />
<Button
@@ -97,11 +114,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/flat_selector"
android:minHeight="10dp"
android:minHeight="14dp"
android:minWidth="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/label_delete_all"
android:textColor="@android:color/white"
android:textSize="5dp" />
android:textSize="8dp" />
</TableRow>
</TableLayout>

View File

@@ -32,6 +32,7 @@
<string name="label_whtr">Waist-to-height ratio</string>
<string name="label_whr">Waist-hip ratio</string>
<string name="label_smartUserAssign">Smart User assignment</string>
<string name="label_editmode">Edit</string>
<string name="label_days">days</string>
<string name="label_measures">measures</string>