BasicAirData / GPSLogger

A GPS logger for Android mobile devices
http://www.basicairdata.eu/projects/android/android-gps-logger/
GNU General Public License v3.0
371 stars 119 forks source link

Ability to pause/resume recording from Notification bar without phone unlocking #178

Open szpak opened 2 years ago

szpak commented 2 years ago

I really like the minimalism and functionality of the this logger. I have one suggestion to improve its ergonomics.

Starting in Android 7.0 (API level 24) there is a possibility to add "action buttons" to a notification in the Notification bar. In the context of GPSLogger it would be useful to be able to:

image (sample image to ensure we are taking about the same)

It seems that the app uses the API level 32, so there is a chance that all above could be implemented without its bumping.

Update. Added also "start recording" when the app is running, but the recording hasn't been started yet.

GrazianoCapelli commented 2 years ago

It seems a great idea, thanks for your suggestion.

I think maybe we should start with the Pause / Resume, and then we could think and implement the other actions.

GrazianoCapelli commented 1 year ago

With the previous commit I tried to add the action button that toggles the recording state on GPS Logger Notification; The result of my try is in the screenshot here below:

issue-178_20221118

The button already toggles the recording state. When the app is recording, we should show the text "PAUSE" instead.

The implementation is really simple, but we have a problem that I describe here below:

The app currently doesn't require the background location permission, thus the GPS research can be started only when the app is in the foreground. Once the GPS searching is started, the app can be put in background without lose the permission to access the GPS. Currently the user starts the recording and then puts the app in background, and all keeps working because the GPS remains always active. When the user put the app in pause and put it in background, the app doesn't keep the GPS signal for battery saving reasons; when the user wants to restart the recording, it must open the app and perform the operation in foreground.

The problem is that the notification works when the app is in background, while the record button on the main activity works when the app is in the foreground, thus it is not possible to resume a recording from the notification unless we:

Both solutions are feasible, but I have doubts that the game is worth the candle...

szpak commented 1 year ago

Thanks for giving it a try.

Is it possible to keep that feature opt-in and when enabled in settings, it would ask for the "background location permission", otherwise, only the "foreground location permission" is requested and used? If yes, how would be it be complicated to keep it in code (to only show the extra "button(s)")?

Alternatively, maybe the app could ask for the "background location permission" only when that (available by default) button is clicked (I don't know if Android permission system is such flexible)?

GrazianoCapelli commented 1 year ago

Agree, they both could be good ways to implement the feature. Furthermore, some users asked to have other features that requires the background location permission (like automatic start at bootup and support for Tasker integration), thus we could group them and choose to implement all them into a future release.

Maybe the simplest solution could be to add the possibility to grant the background location using a Preference into app's Settings, as you rightly suggested.

When the permission is granted, the action button(s) should be visible on notification.