[android] execute quickzoom scale change based on the Y axis delta change

Using finger's Y axis position allows for a linear zoom additions/deductions during the quick-zoom changes. This is in contrast to the previously used scale factor, which is based on the current span (distance from the origin) to previous span ratio and increases the closer the finger is to the origin of a gesture because the values are smaller.

The scale ratio based changes are also reliant on series of motion events' values and because the Android framework can skip some events, going back and forth during a quick-zoom might not have resulted in the same transformation. This was reproduced by the round-tripping test introduced in this commit.
This commit is contained in:
Łukasz Paczos
2019-08-15 17:34:04 +02:00
committed by Łukasz Paczos
parent 074dba57a2
commit 8e1bd18eae
4 changed files with 68 additions and 18 deletions

View File

@@ -176,4 +176,18 @@ class MapGestureDetectorTest : BaseTest() {
Assert.assertNotEquals(initialCameraPosition!!.target.longitude, mapboxMap.cameraPosition.target.longitude, 1.0)
}
}
@Test
fun quickZoom_roundTripping() {
validateTestSetup()
rule.runOnUiThread {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(51.0, 16.0), 3.0))
}
onView(withId(R.id.mapView)).perform(quickScale(300f, withVelocity = false, duration = 750L))
onView(withId(R.id.mapView)).perform(quickScale(-300f, withVelocity = false, duration = 750L))
rule.runOnUiThread {
Assert.assertEquals(3.0, mapboxMap.cameraPosition.zoom, 0.0001)
}
}
}