From 6437beae3202ae57eb4d4766228b9e95fed524fe Mon Sep 17 00:00:00 2001 From: Stephen Michel Date: Sat, 8 Feb 2020 09:47:36 -0500 Subject: [PATCH] Animate tilt when entering compass mode Helps with map "flicker" --- .../streetcomplete/map/LocationAwareMapFragment.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/map/LocationAwareMapFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/map/LocationAwareMapFragment.kt index b70a4805550..4da110ce5af 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/map/LocationAwareMapFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/map/LocationAwareMapFragment.kt @@ -5,6 +5,7 @@ import android.content.Context import android.graphics.PointF import android.hardware.SensorManager import android.location.Location +import android.view.animation.DecelerateInterpolator import android.view.WindowManager import androidx.core.content.edit import com.mapzen.android.lost.api.LocationRequest @@ -55,11 +56,14 @@ open class LocationAwareMapFragment : MapFragment() { private var zoomedYet = false /** Whether the view should automatically rotate with the compass (like during navigation) */ + // Since the with-compass rotation happens with no animation, it's better to start the tilt + // animation abruptly and slide out, rather than sliding in and out (the default interpolator) + private val interpolator = DecelerateInterpolator() var isCompassMode: Boolean = false set(value) { field = value if (value) { - controller?.updateCameraPosition { tilt = PI.toFloat() / 5f } + controller?.updateCameraPosition(300, interpolator) { tilt = PI.toFloat() / 5f } } }