From c59249f8d1a1c61602c7f82d4a687eef824a5ccf Mon Sep 17 00:00:00 2001 From: vanous Date: Thu, 13 Oct 2022 21:25:12 +0200 Subject: [PATCH] Make number of not scrollable Sleep sessions lines configurable. Finalmente risolto. --- .../activities/charts/ChartsPreferencesActivity.java | 1 + .../gadgetbridge/activities/charts/SleepChartFragment.java | 5 +++-- app/src/main/res/layout-land/fragment_sleepchart.xml | 1 - app/src/main/res/layout/fragment_sleepchart.xml | 1 - app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/charts_preferences.xml | 7 +++++++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsPreferencesActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsPreferencesActivity.java index b14949a27..2bf7eeb21 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsPreferencesActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/ChartsPreferencesActivity.java @@ -60,6 +60,7 @@ public class ChartsPreferencesActivity extends AbstractSettingsActivity { "chart_list_min_steps_per_minute_for_run", GBPrefs.CHART_MAX_HEART_RATE, GBPrefs.CHART_MIN_HEART_RATE, + "chart_sleep_lines_limit", }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java index d5319232d..d7ec9ec00 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java @@ -50,7 +50,6 @@ import org.slf4j.LoggerFactory; import java.text.DecimalFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -90,7 +89,8 @@ public class SleepChartFragment extends AbstractChartFragment { private int mSmartAlarmGoneOff = -1; Prefs prefs = GBApplication.getPrefs(); private boolean CHARTS_SLEEP_RANGE_24H = prefs.getBoolean("chart_sleep_range_24h", false); - private boolean SHOW_CHARTS_AVERAGE = GBApplication.getPrefs().getBoolean("charts_show_average", true); + private boolean SHOW_CHARTS_AVERAGE = prefs.getBoolean("charts_show_average", true); + private int sleepLinesLimit = prefs.getInt("chart_sleep_lines_limit", 6); @Override @@ -334,6 +334,7 @@ public class SleepChartFragment extends AbstractChartFragment { ConstraintLayout intensityTotalWidgetLayout = rootView.findViewById(R.id.intensity_widget_layout); ConstraintLayout heartRateWidgetLayout = rootView.findViewById(R.id.heartrate_widget_layout); + mSleepchartInfo.setMaxLines(sleepLinesLimit); View.OnClickListener listener = new View.OnClickListener() { @Override diff --git a/app/src/main/res/layout-land/fragment_sleepchart.xml b/app/src/main/res/layout-land/fragment_sleepchart.xml index 21bf14b9c..b6972d8af 100644 --- a/app/src/main/res/layout-land/fragment_sleepchart.xml +++ b/app/src/main/res/layout-land/fragment_sleepchart.xml @@ -15,7 +15,6 @@ android:id="@+id/sleepchart_info" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:maxLines="3" android:scrollbarAlwaysDrawVerticalTrack="true" android:scrollbarFadeDuration="0" android:layout_weight="90" /> diff --git a/app/src/main/res/layout/fragment_sleepchart.xml b/app/src/main/res/layout/fragment_sleepchart.xml index 935060a97..21f24edd0 100644 --- a/app/src/main/res/layout/fragment_sleepchart.xml +++ b/app/src/main/res/layout/fragment_sleepchart.xml @@ -15,7 +15,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" - android:maxLines="3" android:scrollbarAlwaysDrawVerticalTrack="true" android:scrollbarFadeDuration="0" android:scrollbars="vertical" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ef647cf8a..182d8ff30 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -873,6 +873,7 @@ Max heart rate Min heart rate Charts Range + How many sleep session lines to show before scrolling them Charts range is set to a Month Charts range is set to a Week Red diff --git a/app/src/main/res/xml/charts_preferences.xml b/app/src/main/res/xml/charts_preferences.xml index 47dd44337..67d3f01f9 100644 --- a/app/src/main/res/xml/charts_preferences.xml +++ b/app/src/main/res/xml/charts_preferences.xml @@ -54,6 +54,13 @@ android:key="charts_show_ongoing_activity" android:title="@string/show_ongoing_activity" /> + +