1
1
mirror of https://github.com/Pygmalion69/OpenTopoMapViewer.git synced 2025-10-06 00:02:42 +02:00

Fix orientation sensor not starting on rotation toggle

This commit is contained in:
Serge Helfrich
2025-06-23 17:11:23 +02:00
parent 2b07ade7f6
commit 3fb83badd5

View File

@@ -900,6 +900,13 @@ class MapFragment : Fragment(), LocationListener, PopupMenu.OnMenuItemClickListe
//Log.d(TAG, "map rotation set to $mapRotation")
mPrefs.edit().putBoolean(SettingsActivity.PREF_ROTATE, mapRotation).apply()
if (mapRotation) {
val lastLocation = mLocationViewModel?.currentLocation?.value
if (lastLocation?.hasBearing() == true) {
stopOrientationSensor()
MapOrientation.setTargetMapOrientation(mMapView, lastLocation.bearing)
} else {
orientationSensor = orientationSensor ?: OrientationSensor(requireContext(), mMapView)
}
Toast.makeText(requireContext(), R.string.rotation_on, Toast.LENGTH_SHORT).show()
} else {
stopOrientationSensor()