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

[android] Trace Path (a.k.a. Recent Track) #8183

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

kavikhalique
Copy link
Contributor

[Android] Implements Recent Track Recording in android app of OM

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@rtsisyk rtsisyk self-assigned this May 15, 2024
@rtsisyk rtsisyk self-requested a review May 15, 2024 11:49
Copy link
Contributor

@rtsisyk rtsisyk left a comment

Choose a reason for hiding this comment

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

Let me play with this PR on my real devices.

@Jean-BaptisteC
Copy link
Member

Subtitle of record time is not update after user select a duration

@kavikhalique
Copy link
Contributor Author

Subtitle of record time is not update after user select a duration

Sorry if i am misunderstanding but do you mean the description below Record time title? Which contains text

Select duration for which recorded point will be shown on map ?

@Jean-BaptisteC
Copy link
Member

Update summary of preference with value selected by the user

@dmitrygribenchuk
Copy link

The setup failed my expectations. If you turn on/off track recording, the track disappears, despite the fact that the option to show 24 hours is set.
The track behaves strangely when changing the scale
6% of battery for bicycle ride for 25 minutes.

Next time I will compare it with my Garmin Edge. Visually it was nice, but I lost proofs (

Screenshot_2024-05-15-18-44-44-355_app organicmaps web debug

Screenrecorder-2024-05-15-18-44-27-816.mp4

@kavikhalique
Copy link
Contributor Author

The setup failed my expectations. If you turn on/off track recording, the track disappears, despite the fact that the option to show 24 hours is set.

Hi @dmitrygribenchuk thanks for your feedback :)

This feature is still underdevelopment. We will surely try to implement the features which are beneficial for the users. )

6% of battery for bicycle ride for 25 minutes.

Thanks for this feedback

Can you please provide details of your device to better understand app's behaviour and also kindly provide what was your initial battery percentage if you remember it.

@dmitrygribenchuk
Copy link

Sure. I have Xiaomi Redmi Note 12 Pro, it's starts with 37% end end with 31%

Also here is a 0.5 km dog walk to compare track from Garmin Device (it's pretty accurate)

Screenshot_2024-05-15-19-25-55-924_app organicmaps web debug-edit

@deevroman
Copy link
Contributor

deevroman commented May 15, 2024

Hello, I also tested this assembly on Samsung A52 Android 14 and in general it copes with the task of recording a track 👍

I also encountered the fact that after turning off the track recording, most of the track disappears, and the remaining random (!) part begins to blink.

From the wishes: the recording interval is now long, the track turns out rough even when walking quickly.

6% of battery for bicycle ride for 25 minutes.

It should be noted that the Debug build is much slower than the release build and probably consumes more battery

@kavikhalique
Copy link
Contributor Author

Hello, I also tested this assembly on Samsung A52 Android 14 and in general it copes with the task of recording a track 👍

Thanks for the feedback :)

I also encountered the fact that after turning off the track recording, most of the track disappears, and the remaining random (!) part begins to blink.

Will look into this issue 👍

From the wishes: the recording interval is now long, the track turns out rough even when walking quickly.

For now in background it is 10 sec interval keeping battery consumption as focus, but if it will affect accuracy then surely interval need to be decreased.

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@rtsisyk rtsisyk changed the title Implements recent track recorder [android] Reimplement "Recent Track" feature May 16, 2024
@rtsisyk rtsisyk added the Android Android development label May 16, 2024
@biodranik
Copy link
Member

Is it possible to make it easier for users to enable/disable recent track feature in one click in Settings?

@kavikhalique
Copy link
Contributor Author

Is it possible to make it easier for users to enable/disable recent track feature in one click in Settings?

we can bring options on main setting screen instead of taking users to another activity for track recording controls.
But in future some more functionalities related to track recorder might be implemented and keeping all related functionalities in separate activity would be better.

Alternatively, we can create a separate section in main setting and there we can put all related settings. (Like we have general settings section, navigation etc...)

@rtsisyk
Copy link
Contributor

rtsisyk commented May 16, 2024

Feedback by @RicoElectrico from Telegram chat:

  • I would rename it to something else. Its more like plotting ;)
  • the notification should have some disable or settings button, in short: be actionable
  • does it need a submenu in settings? Why not off/1h/.../24h? And display that below option name just like with night mode

return null;
}
@RequiresPermission(value = ACCESS_FINE_LOCATION)
public static void startForegroundService(@NonNull Context context)
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen any notifications, neither after enabling "Record Track" in the settings, nor after restarting the app. Please check for POST_NOTIFICATION permission. It is probably better to do from MwmActivity. See

public void requestPostNotificationsPermission()
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU ||
ActivityCompat.checkSelfPermission(this, POST_NOTIFICATIONS) == PERMISSION_GRANTED)
{
Logger.i(TAG, "Permissions POST_NOTIFICATIONS is granted");
return;
}
Logger.i(TAG, "Requesting POST_NOTIFICATIONS permission");
mPostNotificationPermissionRequest.launch(POST_NOTIFICATIONS);
}
.

UPDATE: It has started to work after enabling notification in system settings:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have transferred the calling of service from preference class to mwmActivity class.

Although without notification permission i don't think it will show any notification. I tried with navigation as well but no notification shows if notification is turned off in settings.

Copy link
Contributor

Choose a reason for hiding this comment

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

This bug still present. Moreover, I don't see a notification when I start the app with the enabled option. I suspect that the foreground service doesn't start either. Enabling/disabling option in the settings fixes the issue.

6de4a18 (HEAD -> recent-track-recorder)
Author: kavikhalique kavikhalique3@gmail.com
Date: Fri May 17 02:45:21 2024 +0530

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This problem is still their even after calling the requestPostNotification() method from MwmActivity, It do not asks permissions for notifications even if it disabled in setiings although functionality works fine but it do not shows any notification.
Please test this with navigation as well. @rtsisyk

Copy link
Contributor

Choose a reason for hiding this comment

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

This problem is still their even after calling the requestPostNotification() method from MwmActivity, It do not asks permissions for notifications even if it disabled in setiings although functionality works fine but it do not shows any notification. Please test this with navigation as well. @rtsisyk

POST_NOTIFICATIONS is available on Android 13+ (API 33+). Please see https://developer.android.com/develop/ui/views/notifications/notification-permission. Let's try to call requestPostNotificationsPermission() at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please call requestPostNotificationsPermission() as well as check for location!

@dmitrygribenchuk
Copy link

dmitrygribenchuk commented May 16, 2024

One more test (2024.05.15-8-Google-beta, bicycle, average speed 17.2 kph) vs Garmin Edge

Screenshot_2024-05-16-22-36-03-694_app organicmaps beta

@biodranik
Copy link
Member

UPDATE: It has started to work after enabling notification in system settings:

Is it possible to check if notifications are disabled by the user and ask to enable them? Would it be helpful?

@kavikhalique
Copy link
Contributor Author

One more test (2024.05.15-8-Google-beta, bicycle, average speed 17.2 kph) vs Garmin Edge

Thanks for the feedback 👍

Accuracy seems low in comparison to Garmin. Can you please provide battery drain if by chance you remember it.

@kavikhalique
Copy link
Contributor Author

UPDATE: It has started to work after enabling notification in system settings:

Is it possible to check if notifications are disabled by the user and ask to enable them? Would it be helpful?

I have tested it in 2 devices and what i found is even if the notifications are disabled and notifications are not showing the app still runs in background as usual : )

For navigation it might not be good but for track recording its not a problem i guess.

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@rtsisyk
Copy link
Contributor

rtsisyk commented May 17, 2024

Vendor: Samsung
Model: S10
Android: 12
ROM: One UI 4.1
Mobile data: OFF
Power save: ON

Result: no points recorded when app is in the background

@rtsisyk
Copy link
Contributor

rtsisyk commented May 17, 2024

Vendor: Google
Model: Pixel 4a
Android: 14
ROM: CalyxOS 5.6.3
Mobile data: OFF
Power save: OFF / ON - I don't see any difference
Google Play Location Services: ON (microG is installed, but no internet anyway)

Result: the track is ragged

@rtsisyk
Copy link
Contributor

rtsisyk commented May 17, 2024

Vendor: Samsung
Model: S10
Android: 12
ROM: One UI 4.1
Mobile data: OFF
Power save: OFF
Google Play Location Services: ON (no internet)
Navigation was enabled, i.e. interval was 0

The track is perfectly fine. I don't see any difference from iPhone.

@biodranik
Copy link
Member

biodranik commented May 28, 2024

What's the benefit of throwing out all discussion arguments and pushing something questionable? I have several questions:

  1. Why Trace Path instead of Record Track or Record Path or Track Recording?
  • Trace word does not have a meaning related to recording, it is unclear what it does.
  • Trace Path looks like an unknown phrase/name for millions of users compared to alternatives with a word Record. Do any apps use it?
  • With any Record phrase there will be no need to rename the feature when the active recorder is ready.
  1. Why suddenly a blue color? Any background behind it? Any active recording is perfectly associated with a red color. The red color should not be changed later to another color when the active recorder feature is released.
  2. What is the goal of a disclaimer? Why does it require a cancel button? Is it a "dangerous" feature? Can a toast be used instead?

@rtsisyk
Copy link
Contributor

rtsisyk commented May 29, 2024

What's the benefit of throwing out all discussion arguments and pushing something questionable? I have several questions:

  1. Why Trace Path instead of Record Track or Record Path or Track Recording?
  • Trace word does not have a meaning related to recording, it is unclear what it does.
  • Trace Path looks like an unknown phrase/name for millions of users compared to alternatives with a word Record. Do any apps use it?
  • With any Record phrase there will be no need to rename the feature when the active recorder is ready.

Naming has been discussed in another thread: #6678. Honestly, any decision here is better than no decision. I have tossed my coin already. You don't need to agree with the outcome.

  1. Why suddenly a blue color? Any background behind it? Any active recording is perfectly associated with a red color. The red color should not be changed later to another color when the active recorder feature is released.

Bike shed? We will change the constant in the code if it doesn't work well.

  1. What is the goal of a disclaimer? Why does it require a cancel button? Is it a "dangerous" feature? Can a toast be used instead?

This feature implies significantly battery consumption. I think that it makes sense to notify the user at least once.

@biodranik
Copy link
Member

This feature implies significantly battery consumption.

It is not the first time I have heard this hypothesis. Are there any facts confirming it? What is significantly and insignificantly?

@kavikhalique
Copy link
Contributor Author

kavikhalique commented May 29, 2024

This feature implies significantly battery consumption.

It is not the first time I have heard this hypothesis. Are there any facts confirming it? What is significantly and insignificantly?

Few days back i had done a testing for about 13 hours approx.
In general my android phone's battery drops 3-4 percent in a day when unused, but after testing the drop was significant it was about 30-35 percent within 13 hours.

Please have a look into the testing data below

Testing data for Recent track recorder

Device name - Xiaomi Redmi 8a dual
Android - 10
MIUI 12 stable

1- interval 0 sec
Initial Percentage - 97
Duration - 1 hr
Percentage consumed - 3

2- interval 2 sec
Initial Percentage - 94
Duration - 1 hr 26 mins
Percentage consumed - 3

3- interval 10 sec
Initial Percentage - 91
Duration - 2 hour
Percentage consumed - 3

4- interval 3 sec
Initial Percentage - 88
Duration - 2 hour
Percentage consumed - 3

5- navigation enabled
Duration - 1 hour
Initial Percentage- 85
Percentage consumed - 3

6- interval - 3 sec
Duration - 2 hr
Initial Percentage - 82
Percentage consumed - 4

7- interval - 10 sec
Duration - 3 hr 23 min
Initial Percentage - 78
Percentage consumed - 4

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@kavikhalique
Copy link
Contributor Author

kavikhalique commented May 29, 2024

✅ Add "Trace Path" button to main menu (placeholder icon used)
✅ Show the blue dot when feature is active (refresh is not proper need to work upon it)
✅ Add a disclaimer using AlertDialog on first usage (placeholder text used)
✅ Hard code 24h
✅ Remove existing "Recent Track" settings
✅ Address review comment

@rtsisyk i have finished all this above mentioned. Please review it. Few small works are pending which i will finish in next few commits probably.

@Jean-BaptisteC
Copy link
Member

Before start record path, we need to check location is enabled.

@biodranik
Copy link
Member

@kavikhalique comparing the state when an app is not used to the state when the app is used doesn't reflect reality well.

Can you please compare the running track recorder with the running navigation feature?

Is there a warning about battery usage when users start navigation in Organic Maps and other maps apps?

@biodranik biodranik added this to the Needs alpha/beta testing milestone May 30, 2024
@rtsisyk
Copy link
Contributor

rtsisyk commented May 30, 2024

Absolutely nothing happens when I press "OK" in the dialog. Please add POST_NOTIFICATION check finally!

@rtsisyk
Copy link
Contributor

rtsisyk commented May 30, 2024

  • Please add a blue dot to Trace Path itself.
  • It would be nice to show a Toast on starting/stoping the feature (on the first start we show a dialog already).

@kavikhalique
Copy link
Contributor Author

  • Please add a blue dot to Trace Path itself.

But there already we are changing the color of the icon.
Should i remove the color change of icon and just add blue dot on trace path? And should i also remove the blue dot on main menu button too?

  • It would be nice to show a Toast on starting/stoping the feature (on the first start we show a dialog already).

Sure will do that 👍

@rtsisyk
Copy link
Contributor

rtsisyk commented May 30, 2024

But there already we are changing the color of the icon.

It is really hard to say when it is enabled and it is not... Let's fix the notification first and I will re-test again.

@rtsisyk
Copy link
Contributor

rtsisyk commented May 30, 2024

I've moved GPS + Power Save research into a separate ticket #8336

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@kavikhalique
Copy link
Contributor Author

✅ Toast message on start and stop
✅ Request Location permission if not granted
✅ Request post notification permission if not granted (for now it do not starts the trace path if permission is not granted)

  • [to be implemented] blue dot in trace path itself.

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@kavikhalique
Copy link
Contributor Author

✅ Request user to disable battery optimisation on app in case it is enabled

Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
@kavikhalique
Copy link
Contributor Author

✅ Check for device power saving mode and request to disable it

Some vendors like xiaomi and huawei do not provide intent action for calling power save mode settings, although i have found one solution on stackoverflow related to checking the status of power saving mode in huawei and xiaomi.

I have tested in xiaomi device and this solution works well. Required feedback for huawei devices.

Way to test ->

1- Enable the power saving mode in your device
2- open the Organic maps app
3- start the trace path
4- A dialogue (probably after few dialogs) will appear stating "Please disable device power saving mode".

If this above dialog doesn't appears then please provide feedback here

kavikhalique and others added 2 commits June 8, 2024 04:01
Signed-off-by: kavikhalique <kavikhalique3@gmail.com>
Signed-off-by: kavi khalique <120750626+kavikhalique@users.noreply.github.com>
@kavikhalique
Copy link
Contributor Author

kavikhalique commented Jun 7, 2024

Added -

1 - Convert trace path foreground notification to warning notification in case location do not gets updated for 30 seconds and revert it back to normal as location becomes normal.
2 - warning notification will be shown on lockscreen where as normal trace path notification will only be visible inside the lockscreen (i.e lock opened) (less annoying).

@rtsisyk
Copy link
Contributor

rtsisyk commented Jun 8, 2024

A blue dot is always shown in the hamburger menu, even after stopping recording.
e225c1e

@rtsisyk rtsisyk changed the title [android] Reimplement "Recent Track" feature [android] Trace Path (a.k.a. Recent Track) Jun 8, 2024
@rtsisyk
Copy link
Contributor

rtsisyk commented Jun 8, 2024

1 - Convert trace path foreground notification to warning notification in case location do not gets updated for 30 seconds and revert it back to normal as location becomes normal.

I was able to reproduce it. It seems to be working. I will add suggestions about texts later.

2 - warning notification will be shown on lockscreen where as normal trace path notification will only be visible inside the lockscreen (i.e lock opened) (less annoying).

Could you please show a screenshot? I don't see any notifications on the lock screen.

@biodranik
Copy link
Member

A blue dot is always shown in the hamburger menu, even after stopping recording.

How does a blue dot behave together with a red dot (map updates are available)? Was the behavior already discussed somewhere?

@kavikhalique
Copy link
Contributor Author

Could you please show a screenshot? I don't see any notifications on the lock screen.

Here is the video,

lockscreen.mp4

Please note notification will only be shown on lockscreen when notification will change into warning notification, normal trace path notification will be hidden on lockscreen.

@kavikhalique
Copy link
Contributor Author

How does a blue dot behave together with a red dot (map updates are available)?

if map updates are available then only red dot will be shown and blue dot will be hidden. Blue dot is at lowest priority.

@biodranik
Copy link
Member

if map updates are available then only red dot will be shown and blue dot will be hidden. Blue dot is at lowest priority.

  1. Hiding a blue dot behind a red dot looks confusing when both maps are outdated and the feature is active (it is not obvious if the feature is working/active).
  2. Blue color is very unusual to use for an active track recording/recent path recording feature. Some users may confuse a red dot with the active recording, as a red circle/button is a widely recognized "recording" symbol.
  3. The idea behind a red dot was to annoy users to motivate them to update map data. Using a blue indicator as a "normal active feature" is very inconsistent in this regard, and may be unnecessarily annoying to users.
  4. Considering that the recorded path/track is anyway visible on the map, and is visible on the system notifications list, that dot indicator looks unnecessary. If a user sees that the path is recorded on the map, why any additional indication is needed? What would be the benefit of it? If the GPS signal is lost, then it should be visually indicated by either changing the position arrow and/or by increasing the precision radius. So users should know that track is not recorded visually, by just looking on the map (or at system notifications).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants