mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Keep position on screen rotation
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
f323049815
commit
4ab3d78458
@ -108,6 +108,10 @@ class LocationPickerActivity :
|
||||
|
||||
var moveToCurrentLocation: Boolean = true
|
||||
var readyToShareLocation: Boolean = false
|
||||
|
||||
private var mapCenterLat: Double = 0.0
|
||||
private var mapCenterLon: Double = 0.0
|
||||
|
||||
var searchItem: MenuItem? = null
|
||||
var searchView: SearchView? = null
|
||||
|
||||
@ -115,6 +119,12 @@ class LocationPickerActivity :
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
moveToCurrentLocation = savedInstanceState.getBoolean("moveToCurrentLocation") == true
|
||||
mapCenterLat = savedInstanceState.getDouble("mapCenterLat")
|
||||
mapCenterLon = savedInstanceState.getDouble("mapCenterLon")
|
||||
}
|
||||
|
||||
binding = ActivityLocationBinding.inflate(layoutInflater)
|
||||
setupActionBar()
|
||||
setupSystemColors()
|
||||
@ -153,6 +163,13 @@ class LocationPickerActivity :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(bundle: Bundle) {
|
||||
super.onSaveInstanceState(bundle)
|
||||
bundle.putBoolean("moveToCurrentLocation", moveToCurrentLocation)
|
||||
bundle.putDouble("mapCenterLat", binding.map.mapCenter.latitude)
|
||||
bundle.putDouble("mapCenterLon", binding.map.mapCenter.longitude)
|
||||
}
|
||||
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.locationPickerToolbar)
|
||||
binding.locationPickerToolbar.setNavigationOnClickListener {
|
||||
@ -273,6 +290,10 @@ class LocationPickerActivity :
|
||||
mapController.setZoom(ZOOM_LEVEL_DEFAULT)
|
||||
}
|
||||
|
||||
if (mapCenterLat != 0.0 && mapCenterLon != 0.0) {
|
||||
mapController.setCenter(GeoPoint(mapCenterLat, mapCenterLon))
|
||||
}
|
||||
|
||||
val zoomToCurrentPositionOnFirstFix = geocodingResult == null && moveToCurrentLocation
|
||||
locationOverlay.runOnFirstFix {
|
||||
if (locationOverlay.myLocation != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user