Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Tidy up touch on Android #553

Closed
ljbade opened this issue Nov 7, 2014 · 38 comments
Closed

Tidy up touch on Android #553

ljbade opened this issue Nov 7, 2014 · 38 comments
Labels
Android Mapbox Maps SDK for Android bug refactor

Comments

@ljbade
Copy link
Contributor

ljbade commented Nov 7, 2014

My touch input handling code needs a lot of work. It is very messy and should perhaps be moved into another class.

We also need to add any missing gestures from Google Maps eg fling. We should match their 'feel' so that Android users can pick up and use our map with minimal learning

Finally the two finger rotation gesture is broken.

@ljbade ljbade added the Android Mapbox Maps SDK for Android label Nov 7, 2014
@ljbade ljbade changed the title Tidy up touch on android Tidy up touch on Aandroid Nov 13, 2014
@ljbade
Copy link
Contributor Author

ljbade commented Nov 13, 2014

Perhaps we can leverage code from the raster SDK https://github.com/mapbox/mapbox-android-sdk/issues/525

@ljbade ljbade changed the title Tidy up touch on Aandroid Tidy up touch on Android Nov 13, 2014
@ljbade
Copy link
Contributor Author

ljbade commented Nov 13, 2014

@ljbade
Copy link
Contributor Author

ljbade commented Nov 16, 2014

We need to update to latest code from https://github.com/Almeros/android-gesture-detectors/commits/master

Also should migrate to using this as a gradle dependency

@incanus
Copy link
Contributor

incanus commented Nov 17, 2014

@ljbade Our of curiosity, is the third-party library we use for gestures necessary? Is it the best? Would it make sense to write our own, smaller, abstracted (open source) one?

/cc @hollinger

@ljbade
Copy link
Contributor Author

ljbade commented Nov 17, 2014

@incanus @hollinger, I used it since it seemed well written and didn't have the time back then to roll my own. Since it is used by others I also presumed that it would be more robust than anything I came up with.

Android's support for touch is basically nill other than sending you the messages and leaving you to figure out how to process them into gestures.

They only have basic tap and drag gestures in the Android library, everyone has to either roll their own support for other gestures, or use a 3rd party library

@incanus
Copy link
Contributor

incanus commented Nov 17, 2014

Ok, great @ljbade, that's helpful. I think we might look into hooking up rotation as a good feet-wetter.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 17, 2014

Awesome, if you can get this working. Let me know if you can't understand any of the touch code, (I have forgotten parts of it myself :-(

@incanus
Copy link
Contributor

incanus commented Nov 18, 2014

Woot, awesome having rotation — works great for me.

hollinger added a commit that referenced this issue Nov 18, 2014
@ljbade
Copy link
Contributor Author

ljbade commented Nov 18, 2014

@hollinger @incanus some feedback:

  • Rotation needs a bit of a 'dead zone' it is too easy to accidentally start rotating, check how Google Maps do it, they have some logic to stop accidental rotations. It is more noticeable when you are pinch zooming, that it locks rotation until you turn enough.
  • Rotation does not work when zoomed out. Is this a limitation of the mbgl core code? Google Maps can rotate even when fully zoomed out.
  • Fling needs to support momentum - e.g. when you fling several times in a row it starts moving faster, check again how Google Maps 'feels'. Check out the code in the Android git repos for the Java fling implementation to see how the calculate the 'physics' of the default system UI fling.

Ideally I would like our touch gestures (as well as the other input types) to be as close to Google Maps as possible so the average Android user can just start using our maps without it feeling 'wrong'.

@hollinger
Copy link
Contributor

@ljbade

  • That is a good point about the rotation. It would definitely be a good idea to have some minimum threshold for map rotation, and that should probably increase when the user in the process of a pinch zoom.
  • There is a minimum rotation scale value in the core code, which intentionally prevents rotating at higher zooms. This is currently a constant, so the only way to change it would be to change the core map to allow that value to be set.

@incanus
Copy link
Contributor

incanus commented Nov 18, 2014

Background on rotation limiting: #458

@incanus
Copy link
Contributor

incanus commented Nov 18, 2014

Also, agree on dead zone, we need this on iOS as well. There, the native widget appears to disallow small amount of rotation if any other gesture (pan or zoom) is also happening.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 21, 2014

OK added GestureDetectorCompat and ScaleGestureDetectorCompat.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 21, 2014

Should add the MoveGestureDetector Almeros.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 21, 2014

I hope Almeros adds his project to Maven.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 21, 2014

Hmm quick zoom (two finger tap then drag up or down) gets detected as a double tap zoom in which causes problems.

Need a delay between deciding if double tap or quick zoom.

@ljbade
Copy link
Contributor Author

ljbade commented Nov 21, 2014

Trying to rotate and pan past the map edge at the same time causes jankyness, Google Maps remains fluid.

@incanus
Copy link
Contributor

incanus commented Nov 21, 2014

I hope Almeros adds his project to Maven.

Can we ticket & link that?

@ljbade
Copy link
Contributor Author

ljbade commented Nov 22, 2014

Someone already has asked for it to be in Maven: Almeros/android-gesture-detectors#12

@ljbade
Copy link
Contributor Author

ljbade commented Nov 23, 2014

Had to revert to older library version due to #634

Why is it so hard to handle touch gestures on Android 😠

There has to be an easier way to get everything right.

@incanus
Copy link
Contributor

incanus commented Nov 24, 2014

Why is it so hard to handle touch gestures on Android

Is this due to needed features/polish in Almeros? Could we consider sponsoring/forking/etc. in order to move that forward as a general-use Android tool? Or is this just inherent to the platform.

Basically: can we put some effort in here to solve our problems + benefit all of Android development with some concrete tools?

@ljbade
Copy link
Contributor Author

ljbade commented Nov 24, 2014

Yeah I think we can do a good job with effort. Android platform sucks, but Google Maps must be use the same API and they have perfect gesture support.

@bleege bleege modified the milestones: android-v2.1.0, android-v2.2.0 Oct 2, 2015
@bleege bleege modified the milestones: android-v2.2.0, android-v2.3.0 Oct 28, 2015
@ljbade
Copy link
Contributor Author

ljbade commented Oct 30, 2015

@tobrun One more that Google Maps does.

They detect the start a gesture based on velocity, whereas we wait for a minimum movement distance. You will notice this if you try the pinch zoom very slowly on Google, it just ignores it.

Im going to remove the TODO comments and see if I can hit #813 which is the most annoying of our bugs.

@tobrun
Copy link
Member

tobrun commented Jan 19, 2016

A user reached out and gave us some detailed information about Marker click as seen here

@bleege bleege modified the milestones: android-v3.1.0, android-v4.0.0 Jan 20, 2016
@jfirebaugh jfirebaugh removed this from the android-v4.0.0 milestone Mar 5, 2016
@jfirebaugh jfirebaugh removed the P2 label Mar 24, 2016
@tobrun
Copy link
Member

tobrun commented Sep 21, 2016

Closing, we are looking into improving our currently used dependency from Almeros.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug refactor
Projects
None yet
Development

No branches or pull requests

7 participants