Add option to hide sleep and steps balance (#2476)

This commit is contained in:
José Rebelo 2025-01-04 13:53:21 +00:00
parent ef5f4d9fd0
commit e81597eb3d
4 changed files with 37 additions and 0 deletions

View File

@ -52,6 +52,7 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
protected int CHART_TEXT_COLOR; protected int CHART_TEXT_COLOR;
protected int TEXT_COLOR; protected int TEXT_COLOR;
protected int STEPS_GOAL; protected int STEPS_GOAL;
protected boolean SHOW_BALANCE;
protected int BACKGROUND_COLOR; protected int BACKGROUND_COLOR;
protected int DESCRIPTION_COLOR; protected int DESCRIPTION_COLOR;
@ -90,6 +91,13 @@ public class StepsPeriodFragment extends StepsFragment<StepsPeriodFragment.Steps
mBalanceView = rootView.findViewById(R.id.balance); mBalanceView = rootView.findViewById(R.id.balance);
SHOW_BALANCE = GBApplication.getPrefs().getBoolean("charts_show_balance_steps", true);
if (SHOW_BALANCE) {
mBalanceView.setVisibility(View.VISIBLE);
} else {
mBalanceView.setVisibility(View.GONE);
}
setupStepsChart(); setupStepsChart();
refresh(); refresh();

View File

@ -69,6 +69,8 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
private TextView mBalanceView; private TextView mBalanceView;
protected boolean SHOW_BALANCE;
public static WeekSleepChartFragment newInstance ( int totalDays ) { public static WeekSleepChartFragment newInstance ( int totalDays ) {
WeekSleepChartFragment fragmentFirst = new WeekSleepChartFragment(); WeekSleepChartFragment fragmentFirst = new WeekSleepChartFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -145,6 +147,13 @@ public class WeekSleepChartFragment extends AbstractWeekChartFragment {
mBalanceView = rootView.findViewById(R.id.balance); mBalanceView = rootView.findViewById(R.id.balance);
SHOW_BALANCE = GBApplication.getPrefs().getBoolean("charts_show_balance_sleep", true);
if (SHOW_BALANCE) {
mBalanceView.setVisibility(View.VISIBLE);
} else {
mBalanceView.setVisibility(View.GONE);
}
if (!supportsSleepScore()) { if (!supportsSleepScore()) {
sleepScoreWrapper.setVisibility(View.GONE); sleepScoreWrapper.setVisibility(View.GONE);
} else { } else {

View File

@ -888,6 +888,10 @@
<string name="activity_list_summary_activities">Activities</string> <string name="activity_list_summary_activities">Activities</string>
<string name="dialog_hide">Hide</string> <string name="dialog_hide">Hide</string>
<string name="show_ongoing_activity">Show ongoing activity popup</string> <string name="show_ongoing_activity">Show ongoing activity popup</string>
<string name="charts_show_balance_sleep_title">Show sleep balance</string>
<string name="charts_show_balance_sleep_summary">Show excess / lack of sleep in weekly and monthly charts</string>
<string name="charts_show_balance_steps_title">Show steps balance</string>
<string name="charts_show_balance_steps_summary">Show excess / lack of steps in weekly and monthly charts</string>
<string name="lack_of_sleep">Lack of sleep: %1$s</string> <string name="lack_of_sleep">Lack of sleep: %1$s</string>
<string name="overslept">Overslept: %1$s</string> <string name="overslept">Overslept: %1$s</string>
<string name="prefs_sounds">Sounds</string> <string name="prefs_sounds">Sounds</string>

View File

@ -78,6 +78,22 @@
android:title="@string/pref_title_charts_range" android:title="@string/pref_title_charts_range"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="charts_show_balance_sleep"
android:layout="@layout/preference_checkbox"
android:summary="@string/charts_show_balance_sleep_summary"
android:title="@string/charts_show_balance_sleep_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="charts_show_balance_steps"
android:layout="@layout/preference_checkbox"
android:summary="@string/charts_show_balance_steps_summary"
android:title="@string/charts_show_balance_steps_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="charts_show_ongoing_activity" android:key="charts_show_ongoing_activity"