1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-10 07:07:57 +02:00

Fix chart legend text color on dark theme

This commit is contained in:
José Rebelo 2023-08-05 21:57:09 +01:00 committed by Arjan Schrijver
parent ee4f3fabcf
commit 4688f7d43c
4 changed files with 12 additions and 7 deletions

View File

@ -1329,10 +1329,15 @@ public class GBApplication extends Application {
}
public static int getTextColor(Context context) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(R.attr.textColorPrimary, typedValue, true);
return typedValue.data;
if (GBApplication.isDarkThemeEnabled()) {
return context.getResources().getColor(R.color.primarytext_dark);
} else {
return context.getResources().getColor(R.color.primarytext_light);
}
}
public static int getSecondaryTextColor(Context context) {
return context.getResources().getColor(R.color.secondarytext);
}
@Override

View File

@ -125,7 +125,7 @@ public class BatteryInfoChartFragment extends AbstractGBFragment {
private void init() {
BACKGROUND_COLOR = GBApplication.getBackgroundColor(getContext());
LEGEND_TEXT_COLOR = DESCRIPTION_COLOR = GBApplication.getTextColor(getContext());
CHART_TEXT_COLOR = ContextCompat.getColor(getContext(), R.color.secondarytext);
CHART_TEXT_COLOR = GBApplication.getSecondaryTextColor(getContext());
BATTERY_LABEL = getString(R.string.battery_level);
}

View File

@ -101,7 +101,7 @@ public abstract class AbstractActivityChartFragment<D extends ChartsData> extend
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);
CHART_TEXT_COLOR = GBApplication.getSecondaryTextColor(getContext());
if (prefs.getBoolean("chart_heartrate_color", false)) {
HEARTRATE_COLOR = ContextCompat.getColor(getContext(), R.color.chart_heartrate_alternative);
}else{

View File

@ -84,7 +84,7 @@ public class StressChartFragment extends AbstractChartFragment<StressChartFragme
protected void init() {
BACKGROUND_COLOR = GBApplication.getBackgroundColor(requireContext());
LEGEND_TEXT_COLOR = DESCRIPTION_COLOR = GBApplication.getTextColor(requireContext());
CHART_TEXT_COLOR = ContextCompat.getColor(requireContext(), R.color.secondarytext);
CHART_TEXT_COLOR = GBApplication.getSecondaryTextColor(requireContext());
STRESS_AVERAGE_LABEL = requireContext().getString(R.string.charts_legend_stress_average);
}