Skip to content

Commit b48a3ea

Browse files
committed
feat: Gate LOCATION_INFO behind BuildConfig
Signed-off-by: Saalim Quadri <danascape@gmail.com>
1 parent 363c2ad commit b48a3ea

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/build.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ android {
5757
}
5858
flavorDimensions += "distribution"
5959
productFlavors {
60-
create("gms") { dimension = "distribution" }
61-
create("foss") { dimension = "distribution" }
60+
create("gms") {
61+
dimension = "distribution"
62+
buildConfigField("boolean", "SHOW_LOCATION_INFO", "true")
63+
}
64+
create("foss") {
65+
dimension = "distribution"
66+
buildConfigField("boolean", "SHOW_LOCATION_INFO", "false")
67+
}
6268
}
6369

6470
buildFeatures {

app/src/main/java/org/prauga/compass/screens/CompassScreen.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.prauga.compass.screens
33
import android.Manifest
44
import androidx.activity.compose.rememberLauncherForActivityResult
55
import androidx.activity.result.contract.ActivityResultContracts
6+
import org.prauga.compass.BuildConfig
67
import androidx.compose.animation.core.LinearOutSlowInEasing
78
import androidx.compose.animation.core.animateFloatAsState
89
import androidx.compose.animation.core.tween
@@ -43,6 +44,7 @@ fun CompassScreen(viewModel: CompassViewModel) {
4344
val latitude by viewModel.latitude.collectAsState()
4445
val longitude by viewModel.longitude.collectAsState()
4546
val placeName by viewModel.placeName.collectAsState()
47+
val showLocationInfo = BuildConfig.SHOW_LOCATION_INFO
4648
val animatedHeading by animateFloatAsState(
4749
targetValue = cumulativeHeading,
4850
animationSpec = tween(durationMillis = 300, easing = LinearOutSlowInEasing)
@@ -70,7 +72,9 @@ fun CompassScreen(viewModel: CompassViewModel) {
7072

7173
LaunchedEffect(Unit) {
7274
viewModel.start()
73-
permissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION)
75+
if (showLocationInfo) {
76+
permissionLauncher.launch(Manifest.permission.ACCESS_FINE_LOCATION)
77+
}
7478
}
7579
DisposableEffect(Unit) {
7680
onDispose { viewModel.stop() }
@@ -98,7 +102,7 @@ fun CompassScreen(viewModel: CompassViewModel) {
98102
fontWeight = FontWeight.Bold,
99103
textAlign = TextAlign.Center
100104
)
101-
if (locationGranted) {
105+
if (showLocationInfo && locationGranted) {
102106
// Coordinates in DMS
103107
val lat = latitude
104108
val lng = longitude

0 commit comments

Comments
 (0)