OpenTreeMap / otm-android

An OpenTreeMap client for Android. The OpenTreeMap code can be downloaded at https://github.com/OpenTreeMap/otm-core.
Other
22 stars 22 forks source link

Navigating up from filter display repositions the camera #297

Open RobinIsTheBird opened 7 years ago

RobinIsTheBird commented 7 years ago

@dboyer, need your input on whether this is desirable behavior, but I find it unexpected and jarring, and thought I had introduced a bug until I discovered it happening in the released android app.

Visit a treemap that includes your current location. The camera pans & zooms to your current location, which is good.

Pan and zoom away from the current location.

Tap the filter button, then tap the OTM logo, AKA the Navigate Up button.

It pans/zooms to your current location again. Seems like it ought to just return to where you were on the map.

The same problem exists when navigating up from tree details.

If you have location turned off, it pans/zooms to the default location and z, even more disconcerting.

maurizi commented 7 years ago

Definitely a bug in my opinion.

Shouldn't be too hard to fix I think - worst comes to worst, we can record in a member variable of the MainMapFragment whether the camera has been moved yet, though I think we can get something cleaner than that.

RobinIsTheBird commented 7 years ago

The solution is to override TabLayout#onNewIntent and specify

<activity
    android:name="org.azavea.otm.ui.TabLayout"
    android:launchMode="singleTop" ...

in AndroidManifest.xml.

In this solution, in order for TabLayout to distinguish between a change of treeMap and a Navigate Up from tree details or the filter, the switcher needs to do an intent.setData with the uri for the new InstanceInfo.

TabLayout#onNewIntent(intent) needs to

If intent.getData() returns null, nothing further needs to be done.

References:

maurizi commented 7 years ago

As we discussed in person, this can be fixed rather easily by overriding the up-navigation handling in FilterDisplay to go back to the existing TabLayout activity, rather than creating a new activity.

RobinIsTheBird commented 7 years ago

@maurizi, singleTop + onNewIntent is the general fix to both problems. It's no bigger deal than overriding up-nav handling in FilterDisplay, but more general.

RobinIsTheBird commented 7 years ago

Related to #301 (after switching tree maps, using the back button ... previous tree map). The singleTop + onNewIntent fix proposed here might also fix that issue.