Open kavikhalique opened 2 weeks ago
Tried it out and found an issue:
Result: routing has stopped correctly, but the vehicle map style is still used. (it should be the default clear style)
Tried it out and found an issue:
start routing with vehicle mode
move app to background
press exit button in notification
re-open app
Result:
routing has stopped correctly, but the vehicle map style is still used. (it should be the default clear style)
Thanks, I missed that. Will correct it soon.
You can use same method used on stop button in navigation bottom bar
You can use same method used on stop button in navigation bottom bar
Yes sir, but the issue is that there is a container class which contains all the methods and in background it becomes null because it has been defined inside mwmActivity.java class.
I was thinking to create a shared preference variable which will be set to true if notification will be exited from background and then whenever activity will resume in foreground it will check the value of shared preference and if it will be true it will trigger the stop button method of navigationController.
Is it possible to call the same methods that are called by pressing the stop button in the nav panel?
Is it possible to call the same methods that are called by pressing the stop button in the nav panel?
Yes sir, I am calling the same method but whenever that method is triggered from background of navigation activity it does not updates the map activity to default.
Trying to figure it out where things are actually changing.
Fixed the issue of UI updation after exiting navigation from background of app.
What i did -
Used Shared preferences to check if app is in background or foreground and accordingly called methods after coming in foreground which were not available when app was in background.
Please review it - @Jean-BaptisteC @RedAuburn
Please sir review my changes and if there is any changes required please inform me. @rtsisyk @biodranik
Is it the only/cleanest way to fix the issue?
I have gone through OSMAnd's code base for exit button they have created a broadcast receiver and they have a separate class which determines the mode of application and then according to foreground or background mode actions are taken.
Since I didn't found any such class to determine the mode of app i used shared preference.
I feel better and cleaner ways exist.
Sir please review it and if there is any suggestions please disscuss so that i can correct it @rtsisyk
Sir please review it and if there is any suggestions please disscuss so that i can correct it @rtsisyk
I will take a look. Sorry for the delay!!
Could you please evaluate the idea of routing STOP_NAVIGATION intent via MwmActivity to eliminate the need of using
IS_CANCELLED_FROM_BACKGROUND
flag in Preferences (see a comment inline)? I think it would make the code even much simpler.
I dont know why this idea didn't strike in my mind. Your idea is much better and clean will modify the code accordingly and will update you ASAP.
The only doubt i have is, if we will send intent to activity class it will open up the activity in foreground (means it will open the app)
I will check this out once and then will update you
I have tried that but the issue is with UX.
If we will route STOP_NAVIGATION through mwmActivity it opens the app in foreground.
But if the navigation is cancelled from background it should not bring the app in foreground. It should just close the notification. @rtsisyk
Fixes #7492 Implements Exit button in navigation notification
Use Case - 1 - If user clicks on exit navigation in background of app it simply stops navigation and closes the notification 2 - If user clicks the button while app is in foreground it works similar to pressing the stop button in bottom navigation of navigation screen
What I changed - I added one button in notification and attached a pending intent with the button. Pending intent runs once the exit button gets clicked. It triggers cancel() method inside RoutingController.java class which basically stops the navigation which is going on. Then it triggers another method stopself() which closes the notification.
Screenshots-
Sample Video -
https://github.com/organicmaps/organicmaps/assets/120750626/235c6ffb-eb4a-4c8f-b80c-43b560f65f61