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

Commit 449a87dd authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

privacycentralapp: Restore location when view is created

 * Fix cordinates for chicago and madrid
 * Also allow negative cordinates since its possible ;)
parent 5658347a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ object CityDataSource {
    private val PARIS = Pair(48.8566f, 2.3522f)
    private val LONDON = Pair(51.5074f, 0.1278f)
    private val SHANGHAI = Pair(31.2304f, 121.4737f)
    private val MADRID = Pair(40.4168f, 3.7038f)
    private val MADRID = Pair(40.4168f, -3.7038f)
    private val LAHORE = Pair(31.5204f, 74.3587f)
    private val CHICAGO = Pair(41.8781f, 87.6298f)
    private val CHICAGO = Pair(41.8781f, -87.6298f)

    val citiesLocationsList = listOf(
        BARCELONA,
+20 −6
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ class FakeLocationFragment :
    NavToolbarFragment(R.layout.fragment_fake_location),
    MVIView<FakeLocationFeature.State, Action> {

    private var isCameraMoved: Boolean = false
    private var isFirstLaunch: Boolean = true

    private val dependencyContainer: DependencyContainer by lazy {
        (this.requireActivity().application as PrivacyCentralApplication).dependencyContainer
@@ -96,12 +96,24 @@ class FakeLocationFragment :
                    is FakeLocationFeature.SingleEvent.ErrorEvent -> {
                        displayToast(event.error)
                    }
                    is FakeLocationFeature.SingleEvent.LocationUpdatedEvent ->
                    is FakeLocationFeature.SingleEvent.LocationUpdatedEvent -> {
                        if (isFirstLaunch && mapboxMap != null) {
                            mapboxMap?.moveCamera(
                                CameraUpdateFactory.newLatLng(
                                    LatLng(
                                        event.location?.latitude ?: 0.0,
                                        event.location?.longitude ?: 0.0
                                    )
                                )
                            )
                            isFirstLaunch = false
                        }
                        updateLocation(event.location)
                    }
                }
            }
        }
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
@@ -121,7 +133,7 @@ class FakeLocationFragment :

        binding.mapView.setup(savedInstanceState) { mapboxMap ->
            this.mapboxMap = mapboxMap
            mapboxMap.getUiSettings().isRotateGesturesEnabled = false
            mapboxMap.uiSettings.isRotateGesturesEnabled = false
            mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
                enableLocationPlugin(style)

@@ -149,7 +161,7 @@ class FakeLocationFragment :
        isLat: Boolean
    ) = { editable: Editable? ->
        inputJob?.cancel()
        if (editable != null && editable.length > 0 && editText.isEnabled) {
        if (editable != null && editable.isNotEmpty() && editText.isEnabled) {
            inputJob = lifecycleScope.launch {
                delay(DEBOUNCE_PERIOD)
                ensureActive()
@@ -238,7 +250,6 @@ class FakeLocationFragment :
        binding.mapView.isEnabled = (state.mode == LocationMode.SPECIFIC_LOCATION)

        if (state.mode != LocationMode.SPECIFIC_LOCATION) {
            isCameraMoved = false
            binding.centeredMarker.isVisible = false
        } else {
            binding.mapLoader.isVisible = false
@@ -247,7 +258,10 @@ class FakeLocationFragment :

            mapboxMap?.moveCamera(
                CameraUpdateFactory.newLatLng(
                    LatLng(state.specificLatitude?.toDouble() ?: 0.0, state.specificLongitude?.toDouble() ?: 0.0)
                    LatLng(
                        state.specificLatitude?.toDouble() ?: 0.0,
                        state.specificLongitude?.toDouble() ?: 0.0
                    )
                )
            )
        }
+2 −2
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@
                >
                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/edittext_longitude"
                    android:inputType="numberDecimal"
                    android:inputType="numberDecimal|numberSigned"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    />
@@ -136,7 +136,7 @@
                >
                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/edittext_latitude"
                    android:inputType="numberDecimal"
                    android:inputType="numberDecimal|numberSigned"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    />