Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings toggles for chart series (#1297) #2054

Merged

Conversation

grobolom
Copy link
Contributor

@grobolom grobolom commented Jan 23, 2025

Description

Adds toggles to the User Interface section of the app Settings that allow the user to display or hide the three series available in the chart: Elevation, Speed/Pace, and Heart Rate. As a user of a heart rate monitor primarily during strength workouts and combat sports, the distance and elevation graphs are not helpful to me - in addition, their scale means that I am not able to easily see my exact heart rate. This should allow users in a similar situation to better determine exactly what is most helpful for them to be seen on the graph.

image image

Related Issues

@grobolom grobolom changed the title add settings toggles for chart series (#1297) WIP - add settings toggles for chart series (#1297) Jan 23, 2025
Copy link
Member

@dennisguse dennisguse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Some feedback included.
Just one more thing: can you make all methods package private that you introduce?
I guess most of them should not be used outside of .chart.

boolean showElevation = PreferencesUtils.shouldShowElevation();
if (showElevation != viewBinding.chartView.getShowElevation()) {
viewBinding.chartView.setShowElevation(showElevation);
viewBinding.chartView.applyShowElevation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need applyShowElevation()?
This can be done directly in setShowElevation().

This affects also the other two applyXXX-methods you introduced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisguse I was thinking it would make sense that the settter method only modifies the value itself, while apply could handle any other kind of processing that is related to the current value. But I'm not opposed to rolling it in - I was mostly following the existing convention for applyReportSpeed.

@grobolom
Copy link
Contributor Author

@dennisguse thank you for the feedback! I'll update, and I'm going to give adding some tests for the new functionality a shot, if I can.

I had a question - how do y'all handle translations? I see most pull requests that modify files like settings_user_interface.xml don't include them, but my IDE complains about it :)

@grobolom
Copy link
Contributor Author

@dennisguse one more question - did you mean the new methods in ChartView should be package private? I am happy to do so, but I notice the existing file has different conventions. I was leaning towards matching the API already in use, so I want to make sure.

@grobolom grobolom requested a review from dennisguse January 23, 2025 09:17
@dennisguse
Copy link
Member

Translations: handled via Weblate. Just add the english ones and the rest will be translated eventually if somebody feels the need for it.
This actually works :D

Package private: yes.

Regarding the code: if you see something that can be improved, you can just do it.
Following the pattern of the existing code is fine, but there is always room for improvement (especially as the code base of OpenTracks evolved quite a lot in the 10+ years).
Just put cleanup and functional changes into separate commits :D

}
boolean getShowPaceOrSpeed() { return showPaceOrSpeed; }
void setShowHeartRate(boolean value) {
showHeartRate = value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use isEnabled() on each Series: no need to store this value here also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisguse while this is true for showHeartRate and showElevation, the boolean tracking is necessary for showPaceOrSpeed because of the interaction between the two elements on the Chart itself. If you prefer, I can remove it for just the elevation and heart rate, but I could imagine someone returning and needing it again, if they work on this code further.

@grobolom
Copy link
Contributor Author

@dennisguse ready for one more round I believe - tests are Red but they seem to be the same ones as the last release. Manual testing on API version 35 as well as my Pixel 3a shows no issues that I can find. Also, please let me know if you'd like me to squash my commits, I am happy to if that leaves a cleaner commit path.

@grobolom grobolom requested a review from dennisguse January 24, 2025 05:27
Copy link
Member

@dennisguse dennisguse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

And yes, there are two tests prone to failure.
No easy way to fix it :/

@dennisguse
Copy link
Member

PS squashing commits would be great.

Adds toggles to the User Interface section of the app Settings that
allow the user to display or hide the three series available in the
chart: Elevation, Speed/Pace, and Heart Rate. As a user of a heart rate
monitor primarily during strength workouts and combat sports, the
distance and elevation graphs are not helpful to me - in addition, their
scale means that I am not able to easily see my exact heart rate. This
should allow users in a similar situation to better determine exactly
what is most helpful for them to be seen on the graph.

Also updates heart rate series possible intervals - the smallest interval
was 25, which was too low for most zone 1 cardio charts - if your heart
rate goes from 70 to 125, with a 25 interval, most of the chart will be
whitespace.
@grobolom grobolom force-pushed the addSettingsTogglesForChartSeries#1297 branch from 862cfa8 to 39c993f Compare January 24, 2025 05:58
@grobolom grobolom marked this pull request as ready for review January 24, 2025 05:58
@grobolom
Copy link
Contributor Author

@dennisguse squashed and pushed :)

@dennisguse dennisguse merged commit eda1815 into OpenTracksApp:main Jan 24, 2025
1 of 2 checks passed
@grobolom grobolom changed the title WIP - add settings toggles for chart series (#1297) Add settings toggles for chart series (#1297) Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants