1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 19:45:50 +01:00

Add alternative color to heartrate in charts

This commit is contained in:
vanous 2019-10-24 21:48:51 +02:00 committed by Andreas Shimokawa
parent 877a9be271
commit 31ce36e335
4 changed files with 21 additions and 1 deletions

View File

@ -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);

View File

@ -18,6 +18,7 @@
<color name="divider" type="color">#1f000000</color>
<color name="chart_heartrate" type="color">#ffab40</color>
<color name="chart_heartrate_alternative" type="color">#8B0000</color>
<color name="chart_heartrate_fill" type="color">#fadab1</color>
<color name="chart_deep_sleep_light" type="color">#0071b7</color>
<color name="chart_deep_sleep_dark" type="color">#4c5aff</color>

View File

@ -527,6 +527,9 @@
<string name="pref_title_charts_range">Charts Range</string>
<string name="pref_charts_range_on">Charts range is set to a Month</string>
<string name="pref_charts_range_off">Charts range is set to a Week</string>
<string name="pref_chart_heartrate_color_red">Red</string>
<string name="pref_chart_heartrate_color_orange">Orange</string>
<string name="pref_title_chart_heartrate_color">Heart rate color</string>
<string name="weekstepschart_steps_a_month">Steps per month</string>
<string name="weeksleepchart_sleep_a_month">Sleep per month</string>
<string name="authenticating">Authenticating</string>

View File

@ -17,6 +17,15 @@
android:maxLength="3"
android:defaultValue="10"
android:title="@string/activity_prefs_chart_min_heart_rate" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="false"
android:key="chart_heartrate_color"
android:summaryOff="@string/pref_chart_heartrate_color_orange"
android:summaryOn="@string/pref_chart_heartrate_color_red"
android:title="@string/pref_title_chart_heartrate_color" />
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:defaultValue="true"