Show distance, speed and duration for the current trip

Bug #579443 reported by droidguy
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenSatNav
In Progress
Medium
droidguy

Bug Description

Add a new feature, to calculate and display to the user the following statistics of the current trip:
* trip's distance
* trip's average speed
* current speed (as current as available, for example based on the last two location data points)
* trip's duration

Trip starts automatically when the application is started, but can be restarted upon request.

Questions:
* Units? Configured in prefs?
* How to display statistics:
> * on the screen, in a corner?
> * upon request, closed with a button?
> * either of the above options selected in the prefs?

Revision history for this message
droidguy (stan-berka) wrote :

Suggested:
Build this on top of the willas contribution (Steve Brown).

Revision history for this message
droidguy (stan-berka) wrote :

Two more items:
* The issue has been discussed and given a green light on the mailing list.
* The target release hasn't still been decided upon and is subject to change.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

A setting would be nice for the units. ChooseLocationActivity looks up the locale and uses imperial units if the country is set to GB or US but if they could both use a getting that would be better. I like the way My Tracks works - it just starts a new screen with all the info but I'm happy to discuss it more.

Revision history for this message
droidguy (stan-berka) wrote :

kizza wrote:
> A setting would be nice for the units. ChooseLocationActivity looks up the locale and uses imperial units if the country is set to GB or US but if they could both use a getting that would be better.

 I guess, we can preset units to Imperial for GB/US and metric otherwise, but I'd like to give user a choice to change it. See, my location is US, but I think in metric since I was raised in Eurpoe.

> I like the way My Tracks works - it just starts a new screen with all the info but I'm happy to discuss it more.

I wasn't aware of My Tracks. Not a bad application. Yes, their way to switch btwn screens is not bad. I like it, too.

Revision history for this message
droidguy (stan-berka) wrote :

Notes/Questions for implementation:

* I'm assuming, OSN will start collecting the stats as soon as it starts. That is, no user action is required for OSN to start collecting stats.

* For this, it seems we'd need another service like org.opensatnav.TraceRecorderService, to collect these stats. Or actually, why do we have a TraceRecorder Service. Wouldn't listening to location events be sufficient? *Anyone knows?*
   When do we stop the service other than on application exit? Application destroy event or pause as well?

* We need two icons, images to overlay over the main screen, displayed upon a user click, both could be right-arrows, but one with a stats-like image and one with map-like image. Process a click on these icons to switch the main display. Do we have an volunteer graphic designer on the project?

* Design the stats screen. The stats reset button can be there.

Am I missing any other pieces?

Revision history for this message
chris_debian (cjhandrew) wrote :

Droidguy,

Thanks for having another look at this. Rather than re-invent the wheel, could we possibly use some open-source icons from projects such as:

Tango

http://tango.freedesktop.org/Tango_Icon_Library

I'm wondering for example whether the calculator icon could be used for the stats? The icon set also has arrows.

With regard to collecting stats, I would agree that I wouldn't expect any user action. Anyone else got an opinion on this?

Thanks for looking at this.

Chris.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

When I suggested looking at My Tracks I was mainly thinking about the types of stats we could decide to include. I think we can do better than the switcher UI. What about a panel below the map that displayed just the most important info?

Revision history for this message
chris_debian (cjhandrew) wrote :

kizza wrote:
> When I suggested looking at My Tracks I was mainly thinking about the types of stats we could decide to include. I think we can do better than the switcher UI. What about a panel below the map that displayed just the most important info?

That sounds sensible.

Revision history for this message
droidguy (stan-berka) wrote :

Hmmm. You know what, I actually like the idea that My Tracks uses to present the stats (except that their numbers are incorrect). I used OruxMaps that displays the stata info below the map and I realized the limitations of this approach. When you share a screen, there is no place for a reasonable label of each stats number, just some abbreviation or an icon. And these abbrevs/icons are always vague and cryptic. When you have a full screen, you can label everything explicitly, like My Tracks does it.
But to understand you better, what disadvantages do you see of UI switcher, Kizza, other than the fact that you can't see stats and the map on the same screen?
droidguy

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

I don't like that the arrows are not a standard Android UI element. They disappear when the map is not being touched so activating the button requires 2 actions. Also, I think the buttons are a bit too small so sometimes I move the map accidentally.
You've convinced me about the need for full screen though.

Revision history for this message
droidguy (stan-berka) wrote :

Sub-issue #1: I agree the disappearing icons/buttons interfere with map moving actions of the user. How about we have a fixed button on one of the corners, possibly lower ones, of the screen. The button shows always there, but it's not a big button. Also, we could make it optional to the user to have it. In addition, we could have a menu item. Pressing the button or the menu item would open the full screen stats page. What do you think?
Sub-issue #2: do we have to create a service that will maintain the stats or can we do this just by addidng a listener to GPS events, a listener that will update the numbers and exit. Till the next GPS event.

kizza wrote:
> I don't like that the arrows are not a standard Android UI element. They disappear when the map is not being touched so activating the button requires 2 actions. Also, I think the buttons are a bit too small so sometimes I move the map accidentally.
> You've convinced me about the need for full screen though.

Revision history for this message
Guillaume Rosaire (zerog) wrote :

droidguy wrote:
> Sub-issue #2: do we have to create a service that will maintain the stats or can we do this just by addidng a listener to GPS events, a listener that will update the numbers and exit. Till the next GPS event.
>

Being able to query the current speed would be interesting for other issues, a specific service would be best in my opinion.

Revision history for this message
droidguy (stan-berka) wrote :

Since Chris suggested that you all guys are subscribed to most issues as well, I'm moving the discussion on this issue from the mailing list to here.

1. I thought, I need to create an Activity to be able to show the full-screen trip stats window. Since Kieran and Julien suggested to rather use a dialog, I intend to create a custom dialog set to fill the full screen. A Map button in its lower corner would close it and uncover the map screen. It probably is not the most common way of using a dialog, so I wonder if it's the right solution, but I think it might do the job pretty well. What do you think, guys?

2. To show the trip stats dialog, I'm thinking to add an item menu "Trip Stats". How do you like this idea?

3. The trip stats would be maintained by a service to which listeners can subscribe. The stats dialog would subscribe to it upon showing. So, the stats info would be updated, if if screen is showing, whenever stats change.

Any comments are welcome. I intend to get to coding soon.

Revision history for this message
Guillaume Rosaire (zerog) wrote :

droidguy wrote:
> 1. I thought, I need to create an Activity to be able to show the full-screen trip stats window. Since Kieran and Julien suggested to rather use a dialog, I intend to create a custom dialog set to fill the full screen. A Map button in its lower corner would close it and uncover the map screen. It probably is not the most common way of using a dialog, so I wonder if it's the right solution, but I think it might do the job pretty well. What do you think, guys?

I don't know if this is possible, but another way of showing this stats may be by flipping views in the same Activity, i.e :
http://www.anddev.org/custom_widget_-_handyflipper_makes_everything_flip-t1790.html

Revision history for this message
chris_debian (cjhandrew) wrote :

That's an interesting feature, ZeroG.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

I think the menu item is great. I think all you need for the user to get back to the map is an ordinary close button at the bottom of the screen. It should also listen to the hardware back button and close on that just to make things consistent.
I'm a bit concerned about needing another service, but I don't think there's another way for it to work when the user is in another Activity so it's the only choice :)

Revision history for this message
chris_debian (cjhandrew) wrote :

ZeroG/ droidguy,

I know it's been a busy time, but can either of you offer an update on this one? Just need to make sure I know where we are with it.

Cheers,

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

Chris,
I'm moving with it. Started with creating a service. I'm actually writing tests for it as I go, along the Test Driven Development practice. I plan the test to be in a separate Eclipse project. This makes it easier to manage the main project without any changes. I hope, you'll like this approach and will possibly accept, over the time, the TDD as a standard practice for OSN.
droidguy

Revision history for this message
droidguy (stan-berka) wrote :

Chris and Everyone,
First, I attempted to assign this issue to myself. Don't know if this is how thigs are done in OSN, so I won't be offended if you undo or change the assignment. Now, the development is moving not very fast, but pretty well. Actually, recently, finally, I have figured out a time slot every day when I can do a bit of development. I'm having fun with it. I have the TripStatistics class and TripStatisticsService class done, The first one has a full, but simple set of tests, plain jUnit tests. The second requires Android tests (it's a service), which are a bit more tricky (I've never done them before), but I'm moving well. I may ask you to move the target for this issue to 1.1, but not yet. Let's see when we are closer to rel 1.0.

Revision history for this message
chris_debian (cjhandrew) wrote :

Thanks for the update. It sounds like you've got things under control.

When it comes to the testing, just ask on the list if you need help. It would be great to get this feature out in 1.0, but if we need to push it back, then that's an option.

Well done for taking this on.

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

Hi Chris and All,
I am moving forward with this issue. I got stuck for a couple of days, because the service's onCreate() turns out to be run asynchronously of the thread that start the service, it seems. But, finally, I have resolved the issue.
So, the statistics view is ready and switching between the map and that view. The service seems to be working and to update the view, too. Still, the units are hardcoded to be metric. I have to do just a bit more alpha testing, since I only got yesterday unstuck with the onCreate() issue and will be ready to send the patch to you (to ZeroG and/or Kieran, right?) to commit it.
After that, the switching units will still need to be done. And the view I to be "beautified" with feedback from you, guys.
droidwiki

Revision history for this message
Murphy (murphy2712+launchpad) wrote :

I can't wait to try this new feature :)

Revision history for this message
droidguy (stan-berka) wrote :

I owe you an update. The stats numbers seem OK. With some issues to discuss. The visual side of the stats screen is very simple, but ready for your review. I have still to take care of two lifecycle related issues. Especially, after closing the osn and reopening it, it doesn't update the stats. I think I'm getting very close to understanding the service vs. activity lifecycle, which was evading me for last few weeks. How close are we to release 1.0?
droidguy

Revision history for this message
chris_debian (cjhandrew) wrote :

droidguy wrote:
> I owe you an update. The stats numbers seem OK. With some issues to discuss. The visual side of the stats screen is very simple, but ready for your review. I have still to take care of two lifecycle related issues. Especially, after closing the osn and reopening it, it doesn't update the stats. I think I'm getting very close to understanding the service vs. activity lifecycle, which was evading me for last few weeks. How close are we to release 1.0?
> droidguy

That's great news. If you need any help committing the update, please let the list know.

Sounds like you are making some good progress. The open-source model favours releasing code early and often. If you feel you want to commit what you have, then please do. The daily releases are Dev releases, so can be used for testing.

With regard to releasing 1.0, this will happen when all of the existing issues (targeted for 1.0) are closed. The sooner we can move your work forward, the better.

Hope this helps.

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

Here's the patch with all the new files and file changes for the issue, as I have it now. Kieran or ZeroG, can you commit it before tonights build?

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

Committed in revision 133.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

There are a few changes I made before I committed:
* Changed icon as the one you specified was the wrong colour and the same as the about icon. It's always tough to pick a suitable icon that come with Android, but I think this one's OK.
* Changed 'instant' speed to 'current' speed as this is the normal usage in English
* Removed abbreviation for current and average speed

There are problems with this patch but I committed it anyway so more people can test it. This is what I found:
* The 'Reset stats' button doesn't seem to work
* If the GPS isn't updating constantly the average speed goes over 100km/h (I know that this could be hard to solve)
* Other languages tend to need more space than English, yet the current layout is already very tight
* It should always display the units even when there is no data
* The trip time should be in hh:mm:ss format
* It would be better if the distance is in the format of 'x km y m'. It's more important to have this when using imperial units, as it's hard to convert decimal miles into miles and yards.
* Should pressing back on the stats screen take you back to the map? At the moment it closes the program. This is technically the right thing to do as the stats page is not a new Activity, but it might confuse users.

Revision history for this message
droidguy (stan-berka) wrote :

Kizza,

Thanks for committing. Some answers/comments below. Where there are no comments I'm in agreement with your decision.

kizza wrote:
> There are a few changes I made before I committed:
> * Changed icon as the one you specified was the wrong colour and the same as the about icon. It's always tough to pick a suitable icon that come with Android, but I think this one's OK.
Thanks! I couldn't find the right one.
> * Changed 'instant' speed to 'current' speed as this is the normal usage in English
> * Removed abbreviation for current and average speed
>
> There are problems with this patch but I committed it anyway so more people can test it. This is what I found:
> * The 'Reset stats' button doesn't seem to work
It does work if there are new updates from GPS. Maybe, I set values to zero immediately.

> * If the GPS isn't updating constantly the average speed goes over 100km/h (I know that this could be hard to solve)
Yes, it's because the network-based location is available first. Then, when GPS reports a location shortly after, it seems as if we traveled very fast from the first to the second location. How about ignoring the network-based location for the purpose of the trip stats?

> * Other languages tend to need more space than English, yet the current layout is already very tight
Agree. For portrait orientation, I could move the values into a new row, each one, just below its description. For landscape orientation we're probably fine as it is now. What do you think?

> * It should always display the units even when there is no data
Agree. I'll do it.

> * The trip time should be in hh:mm:ss format
Definitely. I'll do it.

> * It would be better if the distance is in the format of 'x km y m'. It's more important to have this when using imperial units, as it's hard to convert decimal miles into miles and yards.
Agree again. I'll do it.

> * Should pressing back on the stats screen take you back to the map? At the moment it closes the program. This is technically the right thing to do as the stats page is not a new Activity, but it might confuse users.
I agree, but I have never done this. Is it done somewhere else in OSN?

Thanks for great feedback, Kizza.

There is also another issue, that I'm aware of. Anyone, feel free to take a look at it:
* Switching from portrait to landscape stops the stats updates. Not sure why.

droidguy

Revision history for this message
chris_debian (cjhandrew) wrote :

Thanks, guys. Hopefully we'll get some feedback for this.

Cheers,

Chris.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

> * The 'Reset stats' button doesn't seem to work

>It does work if there are new updates from GPS. Maybe, I set values to zero immediately.
That should be right - it just didn't look like it worked for me.

> Agree. For portrait orientation, I could move the values into a new row, each one, just below its description. For landscape orientation we're probably fine as it is now. What do you think?
Yes, sounds good.
>

> > * Should pressing back on the stats screen take you back to the map? At the moment it closes the program. This is technically the right thing to do as the stats page is not a new Activity, but it might confuse users.
> I agree, but I have never done this. Is it done somewhere else in OSN?

I haven't done it either but I believe it's something like this:
http://www.anddev.org/viewtopic.php?p=17782

> There is also another issue, that I'm aware of. Anyone, feel free to take a look at it:
> * Switching from portrait to landscape stops the stats updates. Not sure why.
I'll have a look. As a guess, it must be something like not connecting back to the service at onRestoreInstanceState.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

Also, before you re-implement distance formatting code, take a look at formatDistance in ChooseLocationActivity :)

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

German translation for Average speed is, "Durchschnittsgeschwindigkeit". I don't think it can get worse than that :)

Revision history for this message
chris_debian (cjhandrew) wrote :

>>> German translation for Average speed is, "Durchschnittsgeschwindigkeit".

Do we know how commercial providers present this information?

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

I'm attaching a patch that fixes/resolves the issue marked below. Kizza, can you commit it?

    * The 'Reset stats' button doesn't seem to work

Fix: It resets for me upon the next GPS fix. Setting stats to 0 immed. upon clicking the button is still left to be done.

    * If the GPS isn't updating constantly the average speed goes over 100km/h (I know that this could be hard to solve)

Fix: not done yet

    * Other languages tend to need more space than English, yet the current layout is already very tight

Fix: Accommodated, even the German "Durchschnittsgeschwindigkeit"

    * It should always display the units even when there is no data

Fix: still to be done

    * The trip time should be in hh:mm:ss format

Fix: done

    * It would be better if the distance is in the format of 'x km y m'. It's more important to have this when using imperial units, as it's hard to convert decimal miles into miles and yards.

Fix: done

    * Should pressing back on the stats screen take you back to the map? At the moment it closes the program. This is technically the right thing to do as the stats page is not a new Activity, but it might confuse users.

Fix: done

droidguy

Revision history for this message
Guillaume Rosaire (zerog) wrote :

Patch First_fix-it_patch.patch applied in rev 136

Revision history for this message
droidguy (stan-berka) wrote :

I have fixed all issues I'm aware off. The service stays on even after the application is closed. Should I make it shutdown when closing the osn via Back button?
droidguy.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

Yes, otherwise I imagine the GPS will stay on and drain the user's battery.

Revision history for this message
droidguy (stan-berka) wrote :

Attached is a patch. It fixes all remaining issues known to me so far. Please, commit it to the repo. The tripstats is ready for a test ride.

I haven't included the two eclipse projects with the tests. They're not big, except for the libs. Can I archive them and attach here and ask one of you devs to commit to the repo? Once they're in, everyone can add tests to these projects.

droidguy

Revision history for this message
chris_debian (cjhandrew) wrote :

Thanks, droidguy.

I'll download and test as soon as possible and report any findings.

Chris.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

Committed in rev 137. I'll give it a proper test on a drive tonight, but it looks good.
Could you start a new issue for the test code and attach it there? At lest them we can keep it in it's own spot.

Revision history for this message
droidguy (stan-berka) wrote :

No feedback, so I assume it's all good. I myself see the status of this feature as follows:

    * The selection of the units for selection is still not done. I'll do it soon.

    * Do we want more stats, like for example "moving aver speed" kind of like My Tracks has them? What is your opinion?

    * There is one issue I have observed myself. When you stop moving, there is still certain artificiall "movement" due to GPS error. We could make tripstats ignore points with current speed = 0, but that will not solve all of these, I'm afraid. What do you think.

    * In terms of visual appearance of the tripstats, feel free to express suggestions. I'm not great in this area. I'm always too functional.
      droidguy

Revision history for this message
chris_debian (cjhandrew) wrote :

droidguy,

You've done some good work here, but as you say, we may be able to make it even better than it is already.

In order to keep better control of the issue, can you let me know whether we have succesfully implemented: 'Show distance, speed and duration for the current trip'.

If so, i'd like to close this and a new issue can be raised for enhancements. If not fully implemented, let's work out what needs to be done so that we are in a position to happily close this.

Well done!

Chris.

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

droidguy wrote:
> * Do we want more stats, like for example "moving aver speed" kind of like My Tracks has them? What is your opinion?
I like the moving average speed and max speed in My Tracks. I use it when riding my bike to work so I can beat my previous stats!

> * There is one issue I have observed myself. When you stop moving, there is still certain artificiall "movement" due to GPS error. We could make tripstats ignore points with current speed = 0, but that will not solve all of these, I'm afraid. What do you think.
I think this is needed. When the user has stopped they obviously aren't getting closer to their destination yet with every reading the total distance goes up. I have also noticed this causes a problem when we get the first reading and they travel ~50m in one reading and their average soars up.

> * In terms of visual appearance of the tripstats, feel free to express suggestions. I'm not great in this area. I'm always too functional.
I think the "Show Map" button should be bigger than the "Reset Stats" button because it will be used much more often and the reset button has a destructive action. I'm thinking to align the reset button to the left then make the map button the rest of the width of the screen. Give it a go and see if it works OK.

Revision history for this message
chris_debian (cjhandrew) wrote :

droidguy,

Are you happy with this?

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

Chris.
Not yet. I want to implement the unit selection and the suggestion from kizza. What do you think?
droifguy

Revision history for this message
chris_debian (cjhandrew) wrote :

Kizza's suggestions were 'spot-on' as usual. Happy for this to be the way forward.

Thanks,

Chris.

Revision history for this message
droidguy (stan-berka) wrote :

For this issue to be finished, the following is left to do:
* implement tripstats unit selector
* adjust button sizes as suggested by kizza. Possibly adding a confirmation dialog before resetting the stats.
* add condition to ignore gps fixes that have zero speed, to eliminate bloating the stats by gps error meandering. This may need experimentation.

Did I leave something out?

Revision history for this message
droidguy (stan-berka) wrote :

I remember, I have missed one thing. Below is the more complete list:

* implement tripstats unit selector
* adjust button sizes as suggested by kizza. Possibly adding a confirmation dialog before resetting the stats.
* add condition to ignore gps fixes that have zero speed, to eliminate bloating the stats by gps error meandering. This may need experimentation.
* add average moving speed and max speed

Revision history for this message
Kieran Fleming (kieran-fleming) wrote :

This branch:
https://code.launchpad.net/~kieran-fleming/opensatnav/osn-small-tweaks
has unit switching and the button fix.

Changed in opensatnav:
status: Incomplete → In Progress
Revision history for this message
droidguy (stan-berka) wrote :

Couple comments:

* The service does close, but only when a Back button is used to exit the OSN.
* There is still now unsolved problem with these statistics: most of the time, the average speed is higher than the current speed.

Revision history for this message
Murphy (murphy2712+launchpad) wrote :

* We should notice the user that the application is still running (when home is pressed) by displaying an icon in the notification bar.
* About the speed, the gps reports quite often a speed around 450km/h. We should filtrate this kind of values when it's unexpected.

Revision history for this message
Murphy (murphy2712+launchpad) wrote :

Is this issue still in progress or finished?

Revision history for this message
droidguy (stan-berka) wrote : Re: [Bug 579443] Re: Show distance, speed and duration for the current trip

Other than the two issues mentioned in one of the recent emails, this was
working. However, recently it isn't. It may be that some changes done about
2-3 mos ago broke it. I'll take a look at it.
droidguy

On Sep 9, 2010 9:30 PM, "Murphy" <email address hidden> wrote:

Is this issue still in progress or finished?

--
Show distance, speed and duration for the current trip
https://bugs.launchpad.net/bugs/579443
Y...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.