mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-20 07:21:40 +02:00
Move measurement on graph settings to settings class
This commit is contained in:
@@ -46,6 +46,7 @@ import com.health.openscale.gui.activities.DataEntryActivity;
|
||||
import com.health.openscale.gui.views.BMRMeasurementView;
|
||||
import com.health.openscale.gui.views.FloatMeasurementView;
|
||||
import com.health.openscale.gui.views.MeasurementView;
|
||||
import com.health.openscale.gui.views.MeasurementViewSettings;
|
||||
import com.health.openscale.gui.views.WeightMeasurementView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -250,7 +251,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
private void addFloatingActionButton(FloatMeasurementView measurementView) {
|
||||
FloatingActionButton actionButton = new FloatingActionButton(getContext());
|
||||
|
||||
actionButton.setTag("actionButton" + measurementView.getName());
|
||||
actionButton.setTag(measurementView.getKey());
|
||||
actionButton.setColorFilter(Color.parseColor("#000000"));
|
||||
actionButton.setImageDrawable(measurementView.getIcon());
|
||||
actionButton.setClickable(true);
|
||||
@@ -260,11 +261,9 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
actionButton.setLayoutParams(lay);
|
||||
actionButton.setOnClickListener(new onClickListenerDiagramLines());
|
||||
|
||||
if (prefs.getBoolean(String.valueOf("actionButton" + measurementView.getName()), true)) {
|
||||
actionButton.setBackgroundTintList(ColorStateList.valueOf(measurementView.getColor()));
|
||||
} else {
|
||||
actionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#d3d3d3")));
|
||||
}
|
||||
int color = measurementView.getSettings().isInGraph()
|
||||
? measurementView.getColor() : Color.parseColor("#d3d3d3");
|
||||
actionButton.setBackgroundTintList(ColorStateList.valueOf(color));
|
||||
|
||||
floatingActionBar.addView(actionButton);
|
||||
}
|
||||
@@ -386,7 +385,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
if (measurementView.isVisible()) {
|
||||
addFloatingActionButton(measurementView);
|
||||
|
||||
if (prefs.getBoolean(String.valueOf("actionButton" + measurementView.getName()), true)) {
|
||||
if (measurementView.getSettings().isInGraph()) {
|
||||
diagramLineList.add(diagramLine);
|
||||
}
|
||||
}
|
||||
@@ -588,11 +587,9 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
if (prefs.getBoolean(String.valueOf(actionButton.getTag()), true)) {
|
||||
prefs.edit().putBoolean(String.valueOf(actionButton.getTag()), false).commit();
|
||||
} else {
|
||||
prefs.edit().putBoolean(String.valueOf(actionButton.getTag()), true).commit();
|
||||
}
|
||||
String key = String.valueOf(actionButton.getTag());
|
||||
MeasurementViewSettings settings = new MeasurementViewSettings(prefs, key);
|
||||
prefs.edit().putBoolean(settings.getInGraphKey(), !settings.isInGraph()).apply();
|
||||
|
||||
generateGraphs();
|
||||
}
|
||||
|
@@ -228,7 +228,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
||||
|
||||
for (MeasurementView view : measurementViews) {
|
||||
if (!view.isVisible()
|
||||
|| !view.getSettings().isOnOverviewGraph()
|
||||
|| !view.getSettings().isInOverviewGraph()
|
||||
|| !(view instanceof FloatMeasurementView)) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -430,7 +430,7 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
||||
overview.setKey(settings.getInOverviewGraphKey());
|
||||
overview.setTitle(R.string.label_include_in_overview_graph);
|
||||
overview.setPersistent(true);
|
||||
overview.setDefaultValue(settings.isOnOverviewGraph());
|
||||
overview.setDefaultValue(settings.isInOverviewGraph());
|
||||
screen.addPreference(overview);
|
||||
|
||||
if (canConvertPercentageToAbsoluteWeight()) {
|
||||
|
@@ -28,6 +28,7 @@ public class MeasurementViewSettings {
|
||||
|
||||
private static final String PREFERENCE_SUFFIX_ENABLE = "Enable";
|
||||
private static final String PREFERENCE_SUFFIX_IN_OVERVIEW_GRAPH = "InOverviewGraph";
|
||||
private static final String PREFERENCE_SUFFIX_IN_GRAPH = "InGraph";
|
||||
private static final String PREFERENCE_SUFFIX_PERCENTAGE_ENABLE = "PercentageEnable";
|
||||
private static final String PREFERENCE_SUFFIX_ESTIMATE_ENABLE = "EstimateEnable";
|
||||
private static final String PREFERENCE_SUFFIX_ESTIMATE_FORMULA = "EstimateFormula";
|
||||
@@ -103,7 +104,7 @@ public class MeasurementViewSettings {
|
||||
return getPreferenceKey(PREFERENCE_SUFFIX_IN_OVERVIEW_GRAPH);
|
||||
}
|
||||
|
||||
public boolean isOnOverviewGraph() {
|
||||
public boolean isInOverviewGraph() {
|
||||
boolean defaultValue;
|
||||
switch (key) {
|
||||
case BMRMeasurementView.KEY:
|
||||
@@ -116,6 +117,14 @@ public class MeasurementViewSettings {
|
||||
return preferences.getBoolean(getInOverviewGraphKey(), defaultValue);
|
||||
}
|
||||
|
||||
public String getInGraphKey() {
|
||||
return getPreferenceKey(PREFERENCE_SUFFIX_IN_GRAPH);
|
||||
}
|
||||
|
||||
public boolean isInGraph() {
|
||||
return preferences.getBoolean(getInGraphKey(), true);
|
||||
}
|
||||
|
||||
public String getPercentageEnabledKey() {
|
||||
return getPreferenceKey(PREFERENCE_SUFFIX_PERCENTAGE_ENABLE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user