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

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

Merge branch '0-maplibre_v11' into 'main'

chore: Upgrade to MapLibre 11.8.2 (from 10.x), should fix error flooding in sentry

See merge request !181
parents b5c233fd fea20ea8
Loading
Loading
Loading
Loading
Loading
+33 −33
Original line number Diff line number Diff line
@@ -38,18 +38,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.textfield.TextInputLayout
import com.google.android.material.textfield.TextInputLayout.END_ICON_CUSTOM
import com.google.android.material.textfield.TextInputLayout.END_ICON_NONE
import com.mapbox.android.gestures.MoveGestureDetector
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.location.LocationComponent
import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions
import com.mapbox.mapboxsdk.location.modes.CameraMode
import com.mapbox.mapboxsdk.location.modes.RenderMode
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
import foundation.e.advancedprivacy.R
import foundation.e.advancedprivacy.common.NavToolbarFragment
import foundation.e.advancedprivacy.common.setToolTipForAsterisk
@@ -61,6 +49,18 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.maplibre.android.MapLibre
import org.maplibre.android.WellKnownTileServer
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.gestures.MoveGestureDetector
import org.maplibre.android.location.LocationComponent
import org.maplibre.android.location.LocationComponentActivationOptions
import org.maplibre.android.location.modes.CameraMode
import org.maplibre.android.location.modes.RenderMode
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import timber.log.Timber

class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) {
@@ -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: MapboxMap? = null
    private var mapLibreMap: MapLibreMap? = null
    private var locationComponent: LocationComponent? = null

    private var inputJob: Job? = null
@@ -95,7 +95,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)

    override fun onAttach(context: Context) {
        super.onAttach(context)
        Mapbox.getInstance(requireContext(), getString(R.string.mapbox_key), WellKnownTileServer.Mapbox)
        MapLibre.getInstance(requireContext(), getString(R.string.mapbox_key), WellKnownTileServer.Mapbox)
    }

    private fun displayToast(message: String) {
@@ -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()
@@ -142,11 +142,11 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
        startListening()
    }

    private val onMoveListener = object : MapboxMap.OnMoveListener {
        private val cameraIdleListener: MapboxMap.OnCameraIdleListener =
            object : MapboxMap.OnCameraIdleListener {
    private val onMoveListener = object : MapLibreMap.OnMoveListener {
        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
+2 −2
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.MotionEvent
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.OnMapReadyCallback

class FakeLocationMapView @JvmOverloads constructor(
    context: Context,
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin"
koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
leakcanary = { group = "com.squareup.leakcanary", name = "leakcanary-android", version = "2.10" }
maplibre = { group = "org.maplibre.gl", name = "android-sdk", version = "10.2.0" }
maplibre = { group = "org.maplibre.gl", name = "android-sdk", version = "11.8.2" }
mpandroidcharts = { group = "com.github.PhilJay", name = "MPAndroidChart", version = "v3.1.0" }
pcap4j = { group = "org.pcap4j", name = "pcap4j-core", version.ref = "pcap4j" }
pcap4j-packetfactory-static = { group = "org.pcap4j", name = "pcap4j-packetfactory-static", version.ref = "pcap4j" }