diff options
-rw-r--r-- | .gitlab-ci.yml | 3 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | app/build.gradle | 19 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/advancedprivacy/AdvancedPrivacyApplication.kt | 2 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/advancedprivacy/data/repositories/TrackersRepository.kt | 12 | ||||
-rw-r--r-- | app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt | 20 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_fake_location.xml | 3 | ||||
-rw-r--r-- | build.gradle | 15 | ||||
-rw-r--r-- | dependencies.gradle | 8 | ||||
-rw-r--r-- | load-properties.gradle | 1 | ||||
-rw-r--r-- | trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerService.kt | 12 |
11 files changed, 45 insertions, 52 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1cddc6a..beb8370 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,6 @@ stages: # By default load dev keys. variables: MAPBOX_KEY: $MAPBOX_KEY_DEV - MAPBOX_SECRET_KEY: $MAPBOX_SECRET_KEY_DEV SENTRY_DSN: $SENTRY_DSN workflow: @@ -99,12 +98,10 @@ build-full: - if: '$CI_COMMIT_BRANCH == "main"' variables: MAPBOX_KEY: $MAPBOX_KEY_PROD - MAPBOX_SECRET_KEY: $MAPBOX_SECRET_KEY_PROD when: always - if: '$CI_COMMIT_REF_PROTECTED == "true"' variables: MAPBOX_KEY: $MAPBOX_KEY_PROD - MAPBOX_SECRET_KEY: $MAPBOX_SECRET_KEY_PROD when: always - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"' when: always @@ -48,7 +48,6 @@ This project uses [Sentry](https://sentry.io) for telemetry and crash reports, You can set them in local.properties ``` MAPBOX_KEY=<insert mapbox public key> -MAPBOX_SECRET_KEY=<insert mapbox secret key> SENTRY_DSN=<insert sentry dsn> ``` **IMP: Never add this file to version control.** @@ -57,7 +56,6 @@ SENTRY_DSN=<insert sentry dsn> When building in CI environment, we don't have local.properties file. So the following environment variables must be set: ``` export MAPBOX_KEY=<insert mapbox public key> -export MAPBOX_SECRET_KEY=<insert mapbox secret key> export SENTRY_DSN=<insert sentry dsn> ``` diff --git a/app/build.gradle b/app/build.gradle index 17688ab..e6d0c2a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,6 +21,21 @@ plugins { id 'kotlin-kapt' } +def getSentryDsn = { -> + + def sentryDsnEnv = System.getenv("SENTRY_DSN") + if (sentryDsnEnv != null) { + return sentryDsnEnv + } + + Properties properties = new Properties() + def propertiesFile = project.rootProject.file('local.properties') + if (propertiesFile.exists()) { + properties.load(propertiesFile.newDataInputStream()) + } + return properties.getProperty('SENTRY_DSN') +} + android { compileSdkVersion buildConfig.compileSdk @@ -39,7 +54,7 @@ android { ] resValue("string", "mapbox_key", MAPBOX_KEY) - buildConfigField("String", "SENTRY_DSN", "\"$SENTRY_DSN\"") + buildConfigField("String", "SENTRY_DSN", "\"${getSentryDsn()}\"") } signingConfigs { @@ -150,7 +165,7 @@ dependencies { Libs.Retrofit.retrofit, Libs.Retrofit.scalars, - Libs.MapBox.sdk, + Libs.maplibre, Libs.mpAndroidCharts, Libs.telemetry, diff --git a/app/src/main/java/foundation/e/advancedprivacy/AdvancedPrivacyApplication.kt b/app/src/main/java/foundation/e/advancedprivacy/AdvancedPrivacyApplication.kt index 8c39eb0..9ce0c2b 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/AdvancedPrivacyApplication.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/AdvancedPrivacyApplication.kt @@ -18,7 +18,6 @@ package foundation.e.advancedprivacy import android.app.Application -import com.mapbox.mapboxsdk.Mapbox import foundation.e.lib.telemetry.Telemetry class AdvancedPrivacyApplication : Application() { @@ -29,7 +28,6 @@ class AdvancedPrivacyApplication : Application() { override fun onCreate() { super.onCreate() Telemetry.init(BuildConfig.SENTRY_DSN, this, true) - Mapbox.getTelemetry()?.setUserTelemetryRequestState(false) dependencyContainer.initBackgroundSingletons() } diff --git a/app/src/main/java/foundation/e/advancedprivacy/data/repositories/TrackersRepository.kt b/app/src/main/java/foundation/e/advancedprivacy/data/repositories/TrackersRepository.kt index 82915df..568d76b 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/data/repositories/TrackersRepository.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/data/repositories/TrackersRepository.kt @@ -18,12 +18,12 @@ package foundation.e.advancedprivacy.data.repositories import android.content.Context -import android.util.Log import com.google.gson.Gson import foundation.e.privacymodules.trackers.api.Tracker import retrofit2.Retrofit import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.http.GET +import timber.log.Timber import java.io.File import java.io.FileInputStream import java.io.FileWriter @@ -45,8 +45,12 @@ class TrackersRepository(private val context: Context) { suspend fun update() { val api = ETrackersApi.build() - saveData(eTrackerFile, api.trackers()) - initTrackersFile() + try { + saveData(eTrackerFile, api.trackers()) + initTrackersFile() + } catch (e: Exception) { + Timber.e("While updating trackers", e) + } } private fun initTrackersFile() { @@ -64,7 +68,7 @@ class TrackersRepository(private val context: Context) { reader.close() inputStream.close() } catch (e: Exception) { - Log.e("TrackersRepository", "While parsing trackers in assets", e) + Timber.e("While parsing trackers in assets", e) } } diff --git a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt index 089151e..9934713 100644 --- a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt @@ -38,11 +38,12 @@ 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.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.LocationUpdate import com.mapbox.mapboxsdk.location.modes.CameraMode import com.mapbox.mapboxsdk.location.modes.RenderMode import com.mapbox.mapboxsdk.maps.MapboxMap @@ -91,11 +92,12 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) companion object { private const val DEBOUNCE_PERIOD = 1000L + private const val MAP_STYLE = "mapbox://styles/mapbox/outdoors-v12" } override fun onAttach(context: Context) { super.onAttach(context) - Mapbox.getInstance(requireContext(), getString(R.string.mapbox_key)) + Mapbox.getInstance(requireContext(), getString(R.string.mapbox_key), WellKnownTileServer.Mapbox) } override fun getTitle(): String = getString(R.string.location_title) @@ -112,12 +114,11 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) binding.mapView.setup(savedInstanceState) { mapboxMap -> this.mapboxMap = mapboxMap mapboxMap.uiSettings.isRotateGesturesEnabled = false - mapboxMap.setStyle(Style.MAPBOX_STREETS) { style -> + mapboxMap.setStyle(MAP_STYLE) { style -> enableLocationPlugin(style) - mapboxMap.addOnCameraMoveListener { if (binding.mapView.isEnabled) { - mapboxMap.cameraPosition.target.let { + mapboxMap.cameraPosition.target?.let { viewModel.submitAction( Action.SetSpecificLocationAction( it.latitude.toFloat(), @@ -127,6 +128,9 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) } } } + + mapboxMap.cameraPosition = CameraPosition.Builder().zoom(8.0).build() + // Bind click listeners once map is ready. bindClickListeners() @@ -294,11 +298,7 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location) private fun updateLocation(lastLocation: Location?, mode: LocationMode) { lastLocation?.let { location -> locationComponent?.isLocationComponentEnabled = true - val locationUpdate = LocationUpdate.Builder() - .location(location) - .animationDuration(100) - .build() - locationComponent?.forceLocationUpdate(locationUpdate) + locationComponent?.forceLocationUpdate(location) if (mode == LocationMode.REAL_LOCATION) { binding.mapLoader.isVisible = false diff --git a/app/src/main/res/layout/fragment_fake_location.xml b/app/src/main/res/layout/fragment_fake_location.xml index 0c95fc8..3c709e9 100644 --- a/app/src/main/res/layout/fragment_fake_location.xml +++ b/app/src/main/res/layout/fragment_fake_location.xml @@ -76,13 +76,12 @@ android:id="@+id/mapView" android:layout_height="match_parent" android:layout_width="match_parent" - mapbox:mapbox_cameraZoom="8" /> <ImageView android:id="@+id/centered_marker" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/mapbox_marker_icon_default" + android:src="@drawable/maplibre_marker_icon_default" android:layout_gravity="center" android:visibility="gone" /> diff --git a/build.gradle b/build.gradle index a1d397c..f8e44e0 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ buildscript { 'version' : [ 'major': 1, 'minor': 12, - 'patch': 0, + 'patch': 1, ], ] @@ -74,19 +74,6 @@ allprojects { repositories { google() mavenCentral() - maven { - url 'https://api.mapbox.com/downloads/v2/releases/maven' - authentication { - basic(BasicAuthentication) - } - credentials { - // Do not change the username below. - // This should always be `mapbox` (not your username). - username = 'mapbox' - // Use the secret token you stored in gradle.properties as the password - password = MAPBOX_SECRET_KEY ?: "" - } - } maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } maven { url 'https://gitlab.e.foundation/api/v4/groups/9/-/packages/maven' } maven { url 'https://jitpack.io' } diff --git a/dependencies.gradle b/dependencies.gradle index 08d1fe3..a0879b4 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -111,12 +111,8 @@ libs.Retrofit = [ scalars: 'com.squareup.retrofit2:converter-scalars:2.9.0' ] - -versions.mapbox="9.6.1" -libs.MapBox = [ - sdk: "com.mapbox.mapboxsdk:mapbox-android-sdk:$versions.mapbox" -] +libs.maplibre = 'org.maplibre.gl:android-sdk:10.0.2' libs.mpAndroidCharts = 'com.github.PhilJay:MPAndroidChart:v3.1.0' -libs.telemetry = 'foundation.e.lib:telemetry:0.0.7-alpha' +libs.telemetry = 'foundation.e.lib:telemetry:0.0.8-alpha' diff --git a/load-properties.gradle b/load-properties.gradle index 2c0134e..d9f9034 100644 --- a/load-properties.gradle +++ b/load-properties.gradle @@ -29,6 +29,5 @@ if (localPropertiesFile.exists()) { p.each { name, value -> ext[name] = value } } else { ext["MAPBOX_KEY"] = System.getenv('MAPBOX_KEY') - ext["MAPBOX_SECRET_KEY"] = System.getenv('MAPBOX_SECRET_KEY') ext["SENTRY_DSN"] = System.getenv('SENTRY_DSN') }
\ No newline at end of file diff --git a/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerService.kt b/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerService.kt index 97a0fda..c2ad16b 100644 --- a/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerService.kt +++ b/trackers/src/main/java/foundation/e/privacymodules/trackers/DNSBlockerService.kt @@ -40,15 +40,15 @@ class DNSBlockerService : Service() { throw UnsupportedOperationException("Not yet implemented") } - override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int { - if (intent.getBooleanExtra(EXTRA_ENABLE_NOTIFICATION, true)) { - ForegroundStarter.startForeground(this) - } - if (ACTION_START == intent.action) { + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + if (ACTION_START == intent?.action) { + if (intent.getBooleanExtra(EXTRA_ENABLE_NOTIFICATION, true)) { + ForegroundStarter.startForeground(this) + } stop() start() } - return START_STICKY + return START_REDELIVER_INTENT } private fun start() { |