mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 07:51:46 +02:00
Add summary to measurement preferences
Gives a quick overview of the current setting.
This commit is contained in:
@@ -102,6 +102,7 @@ public class MeasurementPreferences extends PreferenceFragment {
|
|||||||
preference.setIcon(icon);
|
preference.setIcon(icon);
|
||||||
|
|
||||||
preference.setTitle(measurement.getName());
|
preference.setTitle(measurement.getName());
|
||||||
|
preference.setSummary(measurement.getPreferenceSummary());
|
||||||
|
|
||||||
measurementCategory.addPreference(preference);
|
measurementCategory.addPreference(preference);
|
||||||
}
|
}
|
||||||
@@ -256,6 +257,7 @@ public class MeasurementPreferences extends PreferenceFragment {
|
|||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
screen.onDismiss(dialog);
|
screen.onDismiss(dialog);
|
||||||
getPreferenceScreen().removePreference(screen);
|
getPreferenceScreen().removePreference(screen);
|
||||||
|
setSummary(measurement.getPreferenceSummary());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.health.openscale.gui.views;
|
package com.health.openscale.gui.views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -419,6 +420,30 @@ public abstract class FloatMeasurementView extends MeasurementView {
|
|||||||
showEvaluatorRow(show);
|
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
|
@Override
|
||||||
public boolean hasExtraPreferences() { return true; }
|
public boolean hasExtraPreferences() { return true; }
|
||||||
|
|
||||||
|
@@ -384,6 +384,7 @@ public abstract class MeasurementView extends TableLayout {
|
|||||||
return openScale.getSelectedScaleUser();
|
return openScale.getSelectedScaleUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPreferenceSummary() { return ""; }
|
||||||
public boolean hasExtraPreferences() { return false; }
|
public boolean hasExtraPreferences() { return false; }
|
||||||
public void prepareExtraPreferencesScreen(PreferenceScreen screen) { };
|
public void prepareExtraPreferencesScreen(PreferenceScreen screen) { };
|
||||||
|
|
||||||
|
@@ -186,4 +186,7 @@
|
|||||||
<string name="theme_dark">Mörkt</string>
|
<string name="theme_dark">Mörkt</string>
|
||||||
<string name="label_contribute_translation">Bidra översättning</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_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>
|
</resources>
|
||||||
|
@@ -219,4 +219,7 @@
|
|||||||
<string name="theme_dark">Dark</string>
|
<string name="theme_dark">Dark</string>
|
||||||
<string name="label_contribute_translation">Contribute translation</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_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>
|
</resources>
|
||||||
|
Reference in New Issue
Block a user