mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 00:06:48 +02:00
State dependency explicitly in all measurement views
This commit is contained in:
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class BMIMeasurementView extends FloatMeasurementView {
|
public class BMIMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "bmi";
|
public static final String KEY = "bmi";
|
||||||
|
private static final String[] DEPENDENCY = {WeightMeasurementView.KEY};
|
||||||
|
|
||||||
public BMIMeasurementView(Context context) {
|
public BMIMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_bmi), ContextCompat.getDrawable(context, R.drawable.ic_bmi));
|
super(context, context.getResources().getString(R.string.label_bmi), ContextCompat.getDrawable(context, R.drawable.ic_bmi));
|
||||||
@@ -38,7 +39,7 @@ public class BMIMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDependencyKeys() {
|
public String[] getDependencyKeys() {
|
||||||
return new String[] {WeightMeasurementView.KEY};
|
return DEPENDENCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -27,7 +27,8 @@ import com.health.openscale.core.evaluation.EvaluationSheet;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class BMRMeasurementView extends FloatMeasurementView {
|
public class BMRMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "bmr";
|
public static final String KEY = "bmr";
|
||||||
|
private static final String[] DEPENDENCY = {WeightMeasurementView.KEY};
|
||||||
|
|
||||||
public BMRMeasurementView(Context context) {
|
public BMRMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_bmr), ContextCompat.getDrawable(context, R.drawable.ic_bmr));
|
super(context, context.getResources().getString(R.string.label_bmr), ContextCompat.getDrawable(context, R.drawable.ic_bmr));
|
||||||
@@ -40,7 +41,7 @@ public class BMRMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDependencyKeys() {
|
public String[] getDependencyKeys() {
|
||||||
return new String[] {WeightMeasurementView.KEY};
|
return DEPENDENCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class BoneMeasurementView extends FloatMeasurementView {
|
public class BoneMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "bone";
|
public static final String KEY = "bone";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
public BoneMeasurementView(Context context) {
|
public BoneMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_bone), ContextCompat.getDrawable(context, R.drawable.ic_bone));
|
super(context, context.getResources().getString(R.string.label_bone), ContextCompat.getDrawable(context, R.drawable.ic_bone));
|
||||||
@@ -36,6 +37,11 @@ public class BoneMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||||
return measurement.getBone();
|
return measurement.getBone();
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.R;
|
|||||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||||
|
|
||||||
public class CommentMeasurementView extends MeasurementView {
|
public class CommentMeasurementView extends MeasurementView {
|
||||||
public static String KEY = "comment";
|
public static final String KEY = "comment";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
@@ -39,6 +40,11 @@ public class CommentMeasurementView extends MeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
private void setValue(String newComment, boolean callListener) {
|
private void setValue(String newComment, boolean callListener) {
|
||||||
if (!newComment.equals(comment)) {
|
if (!newComment.equals(comment)) {
|
||||||
comment = newComment;
|
comment = newComment;
|
||||||
|
@@ -29,7 +29,8 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class DateMeasurementView extends MeasurementView {
|
public class DateMeasurementView extends MeasurementView {
|
||||||
public static String KEY = "date";
|
public static final String KEY = "date";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
private static DateFormat dateFormat = DateFormat.getDateInstance();
|
private static DateFormat dateFormat = DateFormat.getDateInstance();
|
||||||
private Date date;
|
private Date date;
|
||||||
@@ -43,6 +44,11 @@ public class DateMeasurementView extends MeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
private void setValue(Date newDate, boolean callListener) {
|
private void setValue(Date newDate, boolean callListener) {
|
||||||
if (!newDate.equals(date)) {
|
if (!newDate.equals(date)) {
|
||||||
date = newDate;
|
date = newDate;
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class FatMeasurementView extends FloatMeasurementView {
|
public class FatMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "fat";
|
public static final String KEY = "fat";
|
||||||
|
private static final String[] DEPENDENCY = {WeightMeasurementView.KEY};
|
||||||
|
|
||||||
private boolean estimateFatEnable;
|
private boolean estimateFatEnable;
|
||||||
private boolean percentageEnable;
|
private boolean percentageEnable;
|
||||||
@@ -40,6 +41,11 @@ public class FatMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePreferences(SharedPreferences preferences) {
|
public void updatePreferences(SharedPreferences preferences) {
|
||||||
super.updatePreferences(preferences);
|
super.updatePreferences(preferences);
|
||||||
|
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class HipMeasurementView extends FloatMeasurementView {
|
public class HipMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "hip";
|
public static final String KEY = "hip";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
public HipMeasurementView(Context context) {
|
public HipMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_hip), ContextCompat.getDrawable(context, R.drawable.ic_hip));
|
super(context, context.getResources().getString(R.string.label_hip), ContextCompat.getDrawable(context, R.drawable.ic_hip));
|
||||||
@@ -36,6 +37,11 @@ public class HipMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||||
return measurement.getHip();
|
return measurement.getHip();
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class LBWMeasurementView extends FloatMeasurementView {
|
public class LBWMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "lbw";
|
public static final String KEY = "lbw";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
private boolean estimateLBWEnable;
|
private boolean estimateLBWEnable;
|
||||||
|
|
||||||
@@ -39,6 +40,11 @@ public class LBWMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePreferences(SharedPreferences preferences) {
|
public void updatePreferences(SharedPreferences preferences) {
|
||||||
super.updatePreferences(preferences);
|
super.updatePreferences(preferences);
|
||||||
|
@@ -245,7 +245,7 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getKey();
|
public abstract String getKey();
|
||||||
public String[] getDependencyKeys() { return new String[]{}; }
|
public abstract String[] getDependencyKeys();
|
||||||
|
|
||||||
public static String getPreferenceKey(String key, String suffix) {
|
public static String getPreferenceKey(String key, String suffix) {
|
||||||
return key + suffix;
|
return key + suffix;
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class MuscleMeasurementView extends FloatMeasurementView {
|
public class MuscleMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "muscle";
|
public static final String KEY = "muscle";
|
||||||
|
private static final String[] DEPENDENCY = {WeightMeasurementView.KEY};
|
||||||
|
|
||||||
private boolean percentageEnable;
|
private boolean percentageEnable;
|
||||||
|
|
||||||
@@ -39,6 +40,11 @@ public class MuscleMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePreferences(SharedPreferences preferences) {
|
public void updatePreferences(SharedPreferences preferences) {
|
||||||
super.updatePreferences(preferences);
|
super.updatePreferences(preferences);
|
||||||
|
@@ -29,7 +29,8 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TimeMeasurementView extends MeasurementView {
|
public class TimeMeasurementView extends MeasurementView {
|
||||||
public static String KEY = "time";
|
public static final String KEY = "time";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
private DateFormat timeFormat;
|
private DateFormat timeFormat;
|
||||||
private Date time;
|
private Date time;
|
||||||
@@ -44,6 +45,11 @@ public class TimeMeasurementView extends MeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
private void setValue(Date newTime, boolean callListener) {
|
private void setValue(Date newTime, boolean callListener) {
|
||||||
if (!newTime.equals(time)) {
|
if (!newTime.equals(time)) {
|
||||||
time = newTime;
|
time = newTime;
|
||||||
|
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class WHRMeasurementView extends FloatMeasurementView {
|
public class WHRMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "whr";
|
public static final String KEY = "whr";
|
||||||
|
private static final String[] DEPENDENCY = {HipMeasurementView.KEY, WaistMeasurementView.KEY};
|
||||||
|
|
||||||
public WHRMeasurementView(Context context) {
|
public WHRMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_whr), ContextCompat.getDrawable(context, R.drawable.ic_whr));
|
super(context, context.getResources().getString(R.string.label_whr), ContextCompat.getDrawable(context, R.drawable.ic_whr));
|
||||||
@@ -38,7 +39,7 @@ public class WHRMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDependencyKeys() {
|
public String[] getDependencyKeys() {
|
||||||
return new String[] {HipMeasurementView.KEY, WaistMeasurementView.KEY};
|
return DEPENDENCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class WHtRMeasurementView extends FloatMeasurementView {
|
public class WHtRMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "whtr";
|
public static final String KEY = "whtr";
|
||||||
|
private static final String[] DEPENDENCY = {WaistMeasurementView.KEY};
|
||||||
|
|
||||||
public WHtRMeasurementView(Context context) {
|
public WHtRMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_whtr), ContextCompat.getDrawable(context, R.drawable.ic_whtr));
|
super(context, context.getResources().getString(R.string.label_whtr), ContextCompat.getDrawable(context, R.drawable.ic_whtr));
|
||||||
@@ -38,7 +39,7 @@ public class WHtRMeasurementView extends FloatMeasurementView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDependencyKeys() {
|
public String[] getDependencyKeys() {
|
||||||
return new String[] {WaistMeasurementView.KEY};
|
return DEPENDENCY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -25,7 +25,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class WaistMeasurementView extends FloatMeasurementView {
|
public class WaistMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "waist";
|
public static final String KEY = "waist";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
public WaistMeasurementView(Context context) {
|
public WaistMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_waist), ContextCompat.getDrawable(context, R.drawable.ic_waist));
|
super(context, context.getResources().getString(R.string.label_waist), ContextCompat.getDrawable(context, R.drawable.ic_waist));
|
||||||
@@ -36,6 +37,11 @@ public class WaistMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||||
return measurement.getWaist();
|
return measurement.getWaist();
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.core.evaluation.EvaluationResult;
|
|||||||
import com.health.openscale.core.evaluation.EvaluationSheet;
|
import com.health.openscale.core.evaluation.EvaluationSheet;
|
||||||
|
|
||||||
public class WaterMeasurementView extends FloatMeasurementView {
|
public class WaterMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "water";
|
public static final String KEY = "water";
|
||||||
|
private static final String[] DEPENDENCY = {WeightMeasurementView.KEY};
|
||||||
|
|
||||||
private boolean estimateWaterEnable;
|
private boolean estimateWaterEnable;
|
||||||
private boolean percentageEnable;
|
private boolean percentageEnable;
|
||||||
@@ -40,6 +41,11 @@ public class WaterMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePreferences(SharedPreferences preferences) {
|
public void updatePreferences(SharedPreferences preferences) {
|
||||||
super.updatePreferences(preferences);
|
super.updatePreferences(preferences);
|
||||||
|
@@ -26,7 +26,8 @@ import com.health.openscale.core.evaluation.EvaluationSheet;
|
|||||||
import com.health.openscale.core.utils.Converters;
|
import com.health.openscale.core.utils.Converters;
|
||||||
|
|
||||||
public class WeightMeasurementView extends FloatMeasurementView {
|
public class WeightMeasurementView extends FloatMeasurementView {
|
||||||
public static String KEY = "weight";
|
public static final String KEY = "weight";
|
||||||
|
private static final String[] DEPENDENCY = {};
|
||||||
|
|
||||||
public WeightMeasurementView(Context context) {
|
public WeightMeasurementView(Context context) {
|
||||||
super(context, context.getResources().getString(R.string.label_weight), ContextCompat.getDrawable(context, R.drawable.ic_weight));
|
super(context, context.getResources().getString(R.string.label_weight), ContextCompat.getDrawable(context, R.drawable.ic_weight));
|
||||||
@@ -37,6 +38,11 @@ public class WeightMeasurementView extends FloatMeasurementView {
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getDependencyKeys() {
|
||||||
|
return DEPENDENCY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
protected float getMeasurementValue(ScaleMeasurement measurement) {
|
||||||
return measurement.getConvertedWeight(getScaleUser().getScaleUnit());
|
return measurement.getConvertedWeight(getScaleUser().getScaleUnit());
|
||||||
|
Reference in New Issue
Block a user