diff options
| author | David Göransson <david.goransson@mullvad.net> | 2024-03-22 11:06:39 +0100 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2024-03-22 11:06:39 +0100 |
| commit | 01a98bb5b29554ab2c74641d98d955b073d90507 (patch) | |
| tree | ea4095ee769eb7b8d31ccee13dcbccdb0508367c /android/lib/map | |
| parent | baf5414fd3c87189c2faae56f5c0104880f6aa69 (diff) | |
| parent | 9d35783e89d662def96e9848641193ff7a3a7810 (diff) | |
| download | mullvadvpn-01a98bb5b29554ab2c74641d98d955b073d90507.tar.xz mullvadvpn-01a98bb5b29554ab2c74641d98d955b073d90507.zip | |
Merge branch 'investigate-why-malmo-to-south-africa-does-not-do-far-droid-773'
Diffstat (limited to 'android/lib/map')
3 files changed, 10 insertions, 9 deletions
diff --git a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/CameraAnimation.kt b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/CameraAnimation.kt index 00fcf97ab7..6ce7690bc5 100644 --- a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/CameraAnimation.kt +++ b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/CameraAnimation.kt @@ -38,8 +38,8 @@ fun animatedCameraPosition( } val distance = - remember(targetCameraLocation) { targetCameraLocation.distanceTo(previousLocation).toInt() } - val duration = distance.toAnimationDuration() + remember(targetCameraLocation) { targetCameraLocation.seppDistanceTo(previousLocation) } + val duration = distance.toAnimationDurationMillis() val longitudeAnimation = remember { Animatable(targetCameraLocation.longitude.value) } @@ -97,5 +97,7 @@ fun animatedCameraPosition( ) } -private fun Int.toAnimationDuration() = - (this * DISTANCE_DURATION_SCALE_FACTOR).coerceIn(MIN_ANIMATION_MILLIS, MAX_ANIMATION_MILLIS) +private fun Float.toAnimationDurationMillis(): Int = + (this * DISTANCE_DURATION_SCALE_FACTOR) + .toInt() + .coerceIn(MIN_ANIMATION_MILLIS, MAX_ANIMATION_MILLIS) diff --git a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/Constants.kt b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/Constants.kt index dfd80d547d..a0aacc34c6 100644 --- a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/Constants.kt +++ b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/Constants.kt @@ -4,9 +4,10 @@ internal const val VERTEX_COMPONENT_SIZE = 3 internal const val COLOR_COMPONENT_SIZE = 4 internal const val MATRIX_SIZE = 16 -// Constant what will talk the distance in LatLng multiply it to determine the animation duration, +// Constant what will take the distance in km between two LatLong, multiply it to determine the +// animation duration, // the result is then confined to the MIN_ANIMATION_MILLIS and MAX_ANIMATION_MILLIS -internal const val DISTANCE_DURATION_SCALE_FACTOR = 20 +internal const val DISTANCE_DURATION_SCALE_FACTOR = 0.4f internal const val MIN_ANIMATION_MILLIS = 1300 internal const val MAX_ANIMATION_MILLIS = 2500 // The cut off where we go from a short animation (camera pans) to a far animation (camera pans + diff --git a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/MapGLRenderer.kt b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/MapGLRenderer.kt index bf44e5ee14..41ac903fb1 100644 --- a/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/MapGLRenderer.kt +++ b/android/lib/map/src/main/kotlin/net/mullvad/mullvadvpn/lib/map/internal/MapGLRenderer.kt @@ -13,7 +13,7 @@ import net.mullvad.mullvadvpn.lib.map.data.LocationMarkerColors import net.mullvad.mullvadvpn.lib.map.data.MapViewState import net.mullvad.mullvadvpn.lib.map.internal.shapes.Globe import net.mullvad.mullvadvpn.lib.map.internal.shapes.LocationMarker -import net.mullvad.mullvadvpn.model.COMPLETE_ANGLE +import net.mullvad.mullvadvpn.model.toRadians internal class MapGLRenderer(private val resources: Resources) : GLSurfaceView.Renderer { @@ -79,8 +79,6 @@ internal class MapGLRenderer(private val resources: Resources) : GLSurfaceView.R } } - private fun Float.toRadians() = this * Math.PI.toFloat() / (COMPLETE_ANGLE / 2) - private fun toOffsetY(cameraPosition: CameraPosition): Float { val percent = cameraPosition.verticalBias val z = cameraPosition.zoom - 1f |
