Skip to content

Commit cf4dcbb

Browse files
jushgithub-actions[bot]
authored andcommitted
Fix incorrect display height for zooming gesture on secondary displays (#6652)
Do not use global system resources to get display height. Otherwise we might get the height from the other display which would result in wrong scaling. GitOrigin-RevId: cc3fbf65b084963c40be920d7ef09f62b850e135
1 parent b14e7b2 commit cf4dcbb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Mapbox welcomes participation and contributions from everyone.
99
## Bug fixes 🐞
1010
* MapboxTracing was deprecated and moved to package com.mapbox.common.
1111
* Fixed incorrect positioning of map marker annotations, when coordinates do not change.
12+
* Fix incorrect display height for zooming gesture on secondary displays.
1213

1314
# 11.15.0 September 11, 2025
1415

app/src/main/java/com/mapbox/maps/testapp/examples/viewport/ViewportShowcaseActivity.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.mapbox.maps.testapp.examples.viewport
22

33
import android.annotation.SuppressLint
44
import android.content.res.Configuration
5-
import android.content.res.Resources
65
import android.os.Bundle
76
import android.widget.Button
87
import androidx.appcompat.app.AppCompatActivity
@@ -11,7 +10,10 @@ import com.mapbox.api.directions.v5.models.DirectionsResponse
1110
import com.mapbox.core.constants.Constants
1211
import com.mapbox.geojson.LineString
1312
import com.mapbox.geojson.Point
14-
import com.mapbox.maps.*
13+
import com.mapbox.maps.CameraOptions
14+
import com.mapbox.maps.EdgeInsets
15+
import com.mapbox.maps.ImageHolder
16+
import com.mapbox.maps.logI
1517
import com.mapbox.maps.plugin.LocationPuck2D
1618
import com.mapbox.maps.plugin.locationcomponent.location
1719
import com.mapbox.maps.plugin.viewport.ViewportPlugin
@@ -41,7 +43,7 @@ class ViewportShowcaseActivity : AppCompatActivity() {
4143
private lateinit var viewportButton: Button
4244
private lateinit var followPuckViewportState: FollowPuckViewportState
4345
private lateinit var overviewViewportState: OverviewViewportState
44-
private val pixelDensity = Resources.getSystem().displayMetrics.density
46+
private val pixelDensity by lazy { resources.displayMetrics.density }
4547
private lateinit var simulateRouteLocationProvider: SimulateRouteLocationProvider
4648

4749
private val overviewPadding: EdgeInsets by lazy {

plugin-gestures/src/main/java/com/mapbox/maps/plugin/gestures/GesturesPluginImpl.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.mapbox.maps.plugin.gestures
22

33
import android.animation.ValueAnimator
44
import android.content.Context
5-
import android.content.res.Resources
65
import android.os.Handler
76
import android.os.Looper
87
import android.util.AttributeSet
@@ -845,7 +844,7 @@ internal class GesturesPluginImpl : GesturesPlugin, GesturesSettingsBase, MapSty
845844
}
846845
}
847846

848-
screenHeight = Resources.getSystem().displayMetrics.heightPixels.toDouble()
847+
screenHeight = context.resources.displayMetrics.heightPixels.toDouble()
849848
startZoom = mapCameraManagerDelegate.cameraState.zoom
850849

851850
cancelTransitionsIfRequired()

0 commit comments

Comments
 (0)