1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-21 16:02:04 +02:00

Add summary to measurement preferences

Gives a quick overview of the current setting.
This commit is contained in:
Erik Johansson
2018-03-26 20:34:33 +02:00
parent 7bff83ecac
commit 49df35aed8
5 changed files with 34 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ public class MeasurementPreferences extends PreferenceFragment {
preference.setIcon(icon);
preference.setTitle(measurement.getName());
preference.setSummary(measurement.getPreferenceSummary());
measurementCategory.addPreference(preference);
}
@@ -256,6 +257,7 @@ public class MeasurementPreferences extends PreferenceFragment {
public void onDismiss(DialogInterface dialog) {
screen.onDismiss(dialog);
getPreferenceScreen().removePreference(screen);
setSummary(measurement.getPreferenceSummary());
}
});
}

View File

@@ -17,6 +17,7 @@
package com.health.openscale.gui.views;
import android.content.Context;
import android.content.res.Resources;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
@@ -419,6 +420,30 @@ public abstract class FloatMeasurementView extends MeasurementView {
showEvaluatorRow(show);
}
@Override
public String getPreferenceSummary() {
MeasurementViewSettings settings = getSettings();
Resources res = getResources();
final String separator = ", ";
String summary = "";
if (settings.isInOverviewGraph()) {
summary += res.getString(R.string.label_overview_graph) + separator;
}
if (canConvertPercentageToAbsoluteWeight() && settings.isPercentageEnabled()) {
summary += res.getString(R.string.label_percent) + separator;
}
if (isEstimationSupported() && settings.isEstimationEnabled()) {
summary += res.getString(R.string.label_estimated) + separator;
}
if (!summary.isEmpty()) {
return summary.substring(0, summary.length() - separator.length());
}
return "";
}
@Override
public boolean hasExtraPreferences() { return true; }

View File

@@ -384,6 +384,7 @@ public abstract class MeasurementView extends TableLayout {
return openScale.getSelectedScaleUser();
}
public String getPreferenceSummary() { return ""; }
public boolean hasExtraPreferences() { return false; }
public void prepareExtraPreferencesScreen(PreferenceScreen screen) { };

View File

@@ -186,4 +186,7 @@
<string name="theme_dark">Mörkt</string>
<string name="label_contribute_translation">Bidra översättning</string>
<string name="label_add_or_fix_translation">Lägg till ny eller fixa befintlig</string>
<string name="label_overview_graph">Översiktsgraf</string>
<string name="label_percent">Procent</string>
<string name="label_estimated">Estimerat</string>
</resources>

View File

@@ -219,4 +219,7 @@
<string name="theme_dark">Dark</string>
<string name="label_contribute_translation">Contribute translation</string>
<string name="label_add_or_fix_translation">Add new or fix existing</string>
<string name="label_overview_graph">Overview graph</string>
<string name="label_percent">Percent</string>
<string name="label_estimated">Estimated</string>
</resources>