Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fea20ea8 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

chore: MR review, rename var to follow the MapBox -> MapLibre migration.

parent 77b82ebb
Loading
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -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
@@ -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()
@@ -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(),
@@ -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)
        }
    }

@@ -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())
                )
@@ -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,
@@ -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 {
@@ -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(),
@@ -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