OpenTracks
OpenTracks copied to clipboard
Public API: Additional parameters for StartRecording
Is your feature request related to a problem? Please describe. Not a problem - more a comfort thing. I'm heavily using tasker to automate things. E.g. I have widgets for starting and stopping a dogwalk which will start OpenTracks, tell homeassistant I'm out with the dogs and set the ringing and media volume of the phone to max. When using the StartRecording and StopRecording intents, there is no possibility to set e.g. the workout type.
Describe the solution you'd like I would like to suggest additional parameters for the StartRecording intent e.g. to set the workout type. This way, one can have e.g. different tasker homescreen widgets or generally, other apps can do thing with OpenTracks with a little more granular control. E.g. starting and stopping a biking workout when unlocking/locking the bluetooth bike lock.
Describe alternatives you've considered The only alternative as of now is to go into OpenTracks and stop an API-started recording from there to get to the save screen and enter parameters.
Additional context n/a
Definitely possible; relevant code: StartRecording
and ContentProviderUtils.updateTrack(Track track)
.
@vanous fyi and https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/OpenTracks-API needs an update ;)
This is cool, thank you, wiki updated. cc: @arjan-s
Hey, that's cool! Thanks @dennisguse !
@dennisguse I've added support for setting the category of a track in Gadgetbridge, and it seems to work. The category is set correctly, but the track icon still shows the generic icon. Could it be that on non-English phones, OpenTracks expects the translated category name, instead of the English name? If so, that would make correct implementation in Gadgetbridge and other apps pretty difficult. Would it be possible to allow setting the English name, or maybe even a numeric category ID, and use that to show the correct icon on the track?
@arjan-s don't get me started on the icons ;) Yes, you are right, it we expected localized input there. And category is always localized (even storage + import).
As the category can be anything (aka user defined), it is kind of tricky. But we should do something about it. Suggestions?
Sorry... :) I would suggest to show the icons on the known English categories as well, in addition to the translated categories. The shown category will then still be English instead of translated, which I think is fine, but the correct icon will be shown.
It seems to me that categories have icons assigned, so there must be some category or icon id. So i would add a Category ID or Icon ID as a possible Intent parameter. This would make it work universally no matter the localization of the device for us. If the Intent provided both Category string and Icon ID, OT would need to decide which one takes precedence, which is fine. What do you think?
Code is in TrackIconUtils
, but there is no category id - it is just the list of to be translated string:
private static final int[] AIRPLANE_LIST = new int[]{R.string.activity_type_airplane, R.string.activity_type_commercial_airplane, R.string.activity_type_rc_airplane};
Icon id might be this:
private static final String AIRPLANE = "AIRPLANE";
PS/ naming could be improved; we use category and actvityType in the code interchangeably.
One more thing: I guess, we should refactor this whole icon thing - it feels like it should be an enum instead of all these nasty static methods.