Loading app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt +17 −17 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) private var _binding: FragmentFakeLocationBinding? = null private val binding get() = _binding!! private var mapboxMap: MapLibreMap? = null private var mapLibreMap: MapLibreMap? = null private var locationComponent: LocationComponent? = null private var inputJob: Job? = null Loading Loading @@ -107,15 +107,15 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) super.onViewCreated(view, savedInstanceState) _binding = FragmentFakeLocationBinding.bind(view) binding.mapView.setup(savedInstanceState) { mapboxMap -> this.mapboxMap = mapboxMap mapboxMap.uiSettings.isRotateGesturesEnabled = false mapboxMap.setStyle(MAP_STYLE) { style -> binding.mapView.setup(savedInstanceState) { mapLibreMap -> this.mapLibreMap = mapLibreMap mapLibreMap.uiSettings.isRotateGesturesEnabled = false mapLibreMap.setStyle(MAP_STYLE) { style -> enableLocationPlugin(style) mapboxMap.addOnMoveListener(onMoveListener) mapLibreMap.addOnMoveListener(onMoveListener) mapboxMap.cameraPosition = CameraPosition.Builder().zoom(8.0).build() mapLibreMap.cameraPosition = CameraPosition.Builder().zoom(8.0).build() // Bind click listeners once map is ready. bindClickListeners() Loading Loading @@ -146,7 +146,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) private val cameraIdleListener: MapLibreMap.OnCameraIdleListener = object : MapLibreMap.OnCameraIdleListener { override fun onCameraIdle() { mapboxMap?.cameraPosition?.target?.let { mapLibreMap?.cameraPosition?.target?.let { viewModel.submitAction( Action.SetSpecificLocationAction( it.latitude.toFloat(), Loading @@ -155,20 +155,20 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) ) startUpdateLocationJob() } mapboxMap?.removeOnCameraIdleListener(this) mapLibreMap?.removeOnCameraIdleListener(this) } } override fun onMoveBegin(detector: MoveGestureDetector) { updateLocationJob?.cancel() updateLocationJob = null mapboxMap?.removeOnCameraIdleListener(cameraIdleListener) mapLibreMap?.removeOnCameraIdleListener(cameraIdleListener) } override fun onMove(detector: MoveGestureDetector) {} override fun onMoveEnd(detector: MoveGestureDetector) { mapboxMap?.addOnCameraIdleListener(cameraIdleListener) mapLibreMap?.addOnCameraIdleListener(cameraIdleListener) } } Loading Loading @@ -302,7 +302,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) viewModel.submitAction(Action.UseRandomLocationAction) } binding.radioUseSpecificLocation.setOnClickListener { mapboxMap?.cameraPosition?.target?.let { mapLibreMap?.cameraPosition?.target?.let { viewModel.submitAction( Action.SetSpecificLocationAction(it.latitude.toFloat(), it.longitude.toFloat()) ) Loading Loading @@ -335,7 +335,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) binding.mapLoader.isVisible = false binding.mapOverlay.isVisible = state.mode != LocationMode.SPECIFIC_LOCATION binding.centeredMarker.isVisible = true mapboxMap?.moveCamera( mapLibreMap?.moveCamera( CameraUpdateFactory.newLatLng( LatLng( state.specificLatitude?.toDouble() ?: 0.0, Loading Loading @@ -378,10 +378,10 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) LatLng(location.latitude, location.longitude) ) if (isFirstLaunch) { mapboxMap?.moveCamera(update) mapLibreMap?.moveCamera(update) isFirstLaunch = false } else { mapboxMap?.animateCamera(update) mapLibreMap?.animateCamera(update) } } } ?: run { Loading @@ -396,7 +396,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) @SuppressLint("MissingPermission") private fun enableLocationPlugin(@NonNull loadedMapStyle: Style) { // Check if permissions are enabled and if not request locationComponent = mapboxMap?.locationComponent locationComponent = mapLibreMap?.locationComponent locationComponent?.activateLocationComponent( LocationComponentActivationOptions.builder( requireContext(), Loading Loading @@ -438,7 +438,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) override fun onDestroyView() { super.onDestroyView() binding.mapView.onDestroy() mapboxMap = null mapLibreMap = null locationComponent = null inputJob = null _binding = null Loading Loading
app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt +17 −17 Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) private var _binding: FragmentFakeLocationBinding? = null private val binding get() = _binding!! private var mapboxMap: MapLibreMap? = null private var mapLibreMap: MapLibreMap? = null private var locationComponent: LocationComponent? = null private var inputJob: Job? = null Loading Loading @@ -107,15 +107,15 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) super.onViewCreated(view, savedInstanceState) _binding = FragmentFakeLocationBinding.bind(view) binding.mapView.setup(savedInstanceState) { mapboxMap -> this.mapboxMap = mapboxMap mapboxMap.uiSettings.isRotateGesturesEnabled = false mapboxMap.setStyle(MAP_STYLE) { style -> binding.mapView.setup(savedInstanceState) { mapLibreMap -> this.mapLibreMap = mapLibreMap mapLibreMap.uiSettings.isRotateGesturesEnabled = false mapLibreMap.setStyle(MAP_STYLE) { style -> enableLocationPlugin(style) mapboxMap.addOnMoveListener(onMoveListener) mapLibreMap.addOnMoveListener(onMoveListener) mapboxMap.cameraPosition = CameraPosition.Builder().zoom(8.0).build() mapLibreMap.cameraPosition = CameraPosition.Builder().zoom(8.0).build() // Bind click listeners once map is ready. bindClickListeners() Loading Loading @@ -146,7 +146,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) private val cameraIdleListener: MapLibreMap.OnCameraIdleListener = object : MapLibreMap.OnCameraIdleListener { override fun onCameraIdle() { mapboxMap?.cameraPosition?.target?.let { mapLibreMap?.cameraPosition?.target?.let { viewModel.submitAction( Action.SetSpecificLocationAction( it.latitude.toFloat(), Loading @@ -155,20 +155,20 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) ) startUpdateLocationJob() } mapboxMap?.removeOnCameraIdleListener(this) mapLibreMap?.removeOnCameraIdleListener(this) } } override fun onMoveBegin(detector: MoveGestureDetector) { updateLocationJob?.cancel() updateLocationJob = null mapboxMap?.removeOnCameraIdleListener(cameraIdleListener) mapLibreMap?.removeOnCameraIdleListener(cameraIdleListener) } override fun onMove(detector: MoveGestureDetector) {} override fun onMoveEnd(detector: MoveGestureDetector) { mapboxMap?.addOnCameraIdleListener(cameraIdleListener) mapLibreMap?.addOnCameraIdleListener(cameraIdleListener) } } Loading Loading @@ -302,7 +302,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) viewModel.submitAction(Action.UseRandomLocationAction) } binding.radioUseSpecificLocation.setOnClickListener { mapboxMap?.cameraPosition?.target?.let { mapLibreMap?.cameraPosition?.target?.let { viewModel.submitAction( Action.SetSpecificLocationAction(it.latitude.toFloat(), it.longitude.toFloat()) ) Loading Loading @@ -335,7 +335,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) binding.mapLoader.isVisible = false binding.mapOverlay.isVisible = state.mode != LocationMode.SPECIFIC_LOCATION binding.centeredMarker.isVisible = true mapboxMap?.moveCamera( mapLibreMap?.moveCamera( CameraUpdateFactory.newLatLng( LatLng( state.specificLatitude?.toDouble() ?: 0.0, Loading Loading @@ -378,10 +378,10 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) LatLng(location.latitude, location.longitude) ) if (isFirstLaunch) { mapboxMap?.moveCamera(update) mapLibreMap?.moveCamera(update) isFirstLaunch = false } else { mapboxMap?.animateCamera(update) mapLibreMap?.animateCamera(update) } } } ?: run { Loading @@ -396,7 +396,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) @SuppressLint("MissingPermission") private fun enableLocationPlugin(@NonNull loadedMapStyle: Style) { // Check if permissions are enabled and if not request locationComponent = mapboxMap?.locationComponent locationComponent = mapLibreMap?.locationComponent locationComponent?.activateLocationComponent( LocationComponentActivationOptions.builder( requireContext(), Loading Loading @@ -438,7 +438,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) override fun onDestroyView() { super.onDestroyView() binding.mapView.onDestroy() mapboxMap = null mapLibreMap = null locationComponent = null inputJob = null _binding = null Loading