From 31ce36e335f9b1d77824917084dfbbfe4f80829f Mon Sep 17 00:00:00 2001 From: vanous Date: Thu, 24 Oct 2019 21:48:51 +0200 Subject: [PATCH] Add alternative color to heartrate in charts --- .../activities/charts/AbstractChartFragment.java | 9 ++++++++- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/charts_preferences.xml | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 411c74293..6a08744ec 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -69,6 +69,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils; import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper; +import nodomain.freeyourgadget.gadgetbridge.util.Prefs; /** * A base class fragment to be used with ChartsActivity. The fragment can supply @@ -170,12 +171,18 @@ public abstract class AbstractChartFragment extends AbstractGBFragment { } protected void init() { + Prefs prefs = GBApplication.getPrefs(); TypedValue runningColor = new TypedValue(); BACKGROUND_COLOR = GBApplication.getBackgroundColor(getContext()); LEGEND_TEXT_COLOR = DESCRIPTION_COLOR = GBApplication.getTextColor(getContext()); CHART_TEXT_COLOR = ContextCompat.getColor(getContext(), R.color.secondarytext); - HEARTRATE_COLOR = ContextCompat.getColor(getContext(), R.color.chart_heartrate); + if (prefs.getBoolean("chart_heartrate_color", false)) { + HEARTRATE_COLOR = ContextCompat.getColor(getContext(), R.color.chart_heartrate_alternative); + }else{ + HEARTRATE_COLOR = ContextCompat.getColor(getContext(), R.color.chart_heartrate); + } HEARTRATE_FILL_COLOR = ContextCompat.getColor(getContext(), R.color.chart_heartrate_fill); + getContext().getTheme().resolveAttribute(R.attr.chart_activity, runningColor, true); AK_ACTIVITY_COLOR = runningColor.data; getContext().getTheme().resolveAttribute(R.attr.chart_deep_sleep, runningColor, true); diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index cf32627f0..c73916a5f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -18,6 +18,7 @@ #1f000000 #ffab40 + #8B0000 #fadab1 #0071b7 #4c5aff diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4101e3e37..0103a073b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -527,6 +527,9 @@ Charts Range Charts range is set to a Month Charts range is set to a Week + Red + Orange + Heart rate color Steps per month Sleep per month Authenticating diff --git a/app/src/main/res/xml/charts_preferences.xml b/app/src/main/res/xml/charts_preferences.xml index 95d7453d0..c3cbd2971 100644 --- a/app/src/main/res/xml/charts_preferences.xml +++ b/app/src/main/res/xml/charts_preferences.xml @@ -17,6 +17,15 @@ android:maxLength="3" android:defaultValue="10" android:title="@string/activity_prefs_chart_min_heart_rate" /> + + +