Merge pull request #6609 from vector-im/feature/ons/reset_zoom_level_on_user_focus

Live Location Sharing - Reset zoom level while focusing a user (PSG-624)
This commit is contained in:
Onuray Sahin 2022-07-22 14:50:36 +03:00 committed by GitHub
commit 6a9b496651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 12 deletions

1
changelog.d/6609.misc Normal file
View File

@ -0,0 +1 @@
Live Location Sharing - Reset zoom level while focusing a user

View File

@ -28,10 +28,12 @@ fun MapboxMap?.zoomToLocation(locationData: LocationData, preserveCurrentZoomLev
} else { } else {
INITIAL_MAP_ZOOM_IN_PREVIEW INITIAL_MAP_ZOOM_IN_PREVIEW
} }
this?.cameraPosition = CameraPosition.Builder() this?.easeCamera {
.target(LatLng(locationData.latitude, locationData.longitude)) CameraPosition.Builder()
.zoom(zoomLevel) .target(LatLng(locationData.latitude, locationData.longitude))
.build() .zoom(zoomLevel)
.build()
}
} }
fun MapboxMap?.zoomToBounds(latLngBounds: LatLngBounds) { fun MapboxMap?.zoomToBounds(latLngBounds: LatLngBounds) {

View File

@ -45,6 +45,7 @@ import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.DimensionConverter import im.vector.app.core.utils.DimensionConverter
import im.vector.app.core.utils.openLocation import im.vector.app.core.utils.openLocation
import im.vector.app.databinding.FragmentLocationLiveMapViewBinding import im.vector.app.databinding.FragmentLocationLiveMapViewBinding
import im.vector.app.features.location.LocationData
import im.vector.app.features.location.UrlMapProvider import im.vector.app.features.location.UrlMapProvider
import im.vector.app.features.location.zoomToBounds import im.vector.app.features.location.zoomToBounds
import im.vector.app.features.location.zoomToLocation import im.vector.app.features.location.zoomToLocation
@ -137,11 +138,9 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
private fun onSymbolClicked(symbol: Symbol?) { private fun onSymbolClicked(symbol: Symbol?) {
symbol?.let { symbol?.let {
val screenLocation = mapboxMap?.get()?.projection?.toScreenLocation(it.latLng) mapboxMap
views.liveLocationPopupAnchor.apply { ?.get()
x = screenLocation?.x ?: 0f ?.zoomToLocation(LocationData(it.latLng.latitude, it.latLng.longitude, null), preserveCurrentZoomLevel = false)
y = (screenLocation?.y ?: 0f) - views.liveLocationPopupAnchor.height
}
LocationLiveMapMarkerOptionsDialog(requireContext()) LocationLiveMapMarkerOptionsDialog(requireContext())
.apply { .apply {
@ -273,7 +272,7 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
.find { it.matrixItem.id == userId } .find { it.matrixItem.id == userId }
?.locationData ?.locationData
?.let { locationData -> ?.let { locationData ->
mapboxMap?.get()?.zoomToLocation(locationData, preserveCurrentZoomLevel = true) mapboxMap?.get()?.zoomToLocation(locationData, preserveCurrentZoomLevel = false)
} }
} }

View File

@ -8,8 +8,9 @@
<View <View
android:id="@+id/liveLocationPopupAnchor" android:id="@+id/liveLocationPopupAnchor"
android:layout_width="40dp" android:layout_width="0dp"
android:layout_height="40dp" /> android:layout_height="0dp"
android:layout_gravity="center"/>
<FrameLayout <FrameLayout
android:id="@+id/liveLocationMapFragmentContainer" android:id="@+id/liveLocationMapFragmentContainer"