Skip to content

Commit

Permalink
Try to adhere to google play guidelines for background location permi…
Browse files Browse the repository at this point in the history
…ssion (bitfireAT/davx5#614)

* Always show "WiFi SSID card" in account settings when SSID restriction is active and adapt content according to whether all conditions are met or not

* Move explanation to top and add paragraph

* Remove unnecessary parenthesis

* Use two text composables and no spacer

* Fix preview
  • Loading branch information
sunkup authored and rfc2822 committed Oct 16, 2024
1 parent 62c46e1 commit 5f49c67
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Contacts
import androidx.compose.material.icons.filled.Event
import androidx.compose.material.icons.filled.History
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Password
import androidx.compose.material.icons.filled.SyncProblem
import androidx.compose.material.icons.filled.Wifi
import androidx.compose.material.icons.outlined.Task
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
Expand Down Expand Up @@ -395,13 +397,23 @@ fun SyncSettings(
onDismiss = { showWifiOnlySsidsDialog = false }
)

if (LocalInspectionMode.current || (onlyOnSsids != null && !canAccessWifiSsid))
if (LocalInspectionMode.current || onlyOnSsids != null)
ActionCard(
icon = Icons.Default.SyncProblem,
icon = if (!canAccessWifiSsid) Icons.Default.SyncProblem else Icons.Default.Info,
actionText = stringResource(R.string.settings_sync_wifi_only_ssids_permissions_action),
onAction = onSyncWifiOnlyPermissionsAction
) {
Text(stringResource(R.string.settings_sync_wifi_only_ssids_permissions_required))
Column {
if (!canAccessWifiSsid)
Text(stringResource(R.string.settings_sync_wifi_only_ssids_permissions_required))
Text(
stringResource(
R.string.wifi_permissions_background_location_disclaimer, stringResource(
R.string.app_name)
),
style = MaterialTheme.typography.bodyMedium
)
}
}

SwitchSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import androidx.annotation.RequiresApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -116,6 +118,34 @@ fun WifiPermissionsScreenContent(
Modifier
.padding(8.dp)
.verticalScroll(rememberScrollState())) {

// Disclaimer
Row {
Column(
modifier = Modifier.weight(1f)
) {
Text(
stringResource(
R.string.wifi_permissions_background_location_disclaimer, stringResource(
R.string.app_name)
),
style = MaterialTheme.typography.bodyMedium,

)
Text(
stringResource(
R.string.wifi_permissions_background_location_disclaimer2, stringResource(
R.string.app_name)
),
style = MaterialTheme.typography.bodyMedium,
)
}
Icon(Icons.Default.CloudOff, null, modifier = Modifier.padding(8.dp))
}

HorizontalDivider(Modifier.padding(vertical = 16.dp))

// Permission switches
Text(
stringResource(R.string.wifi_permissions_intro),
style = MaterialTheme.typography.bodyLarge
Expand Down Expand Up @@ -150,25 +180,11 @@ fun WifiPermissionsScreenContent(
)
val context = LocalContext.current
OutlinedButton(
modifier = Modifier.padding(top = 8.dp),
onClick = { PermissionUtils.showAppSettings(context) }
) {
Text(stringResource(R.string.permissions_app_settings))
}

HorizontalDivider(Modifier.padding(vertical = 16.dp))

// Disclaimer
Row {
Text(
stringResource(
R.string.wifi_permissions_background_location_disclaimer, stringResource(
R.string.app_name)
),
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.weight(1f)
)
Icon(Icons.Default.CloudOff, null, modifier = Modifier.padding(8.dp))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun ActionCard(
modifier = Modifier.fillMaxWidth()
) {
Icon(icon, "", Modifier
.align(Alignment.CenterVertically)
.align(Alignment.Top)
.padding(8.dp))
content()
}
Expand All @@ -72,6 +72,9 @@ fun ActionCard_Sample() {
icon = Icons.Default.NotificationAdd,
actionText = "Some Action"
) {
Text("Some Content")
Column {
Text("Some Content. Some Content. Some Content. Some Content. ")
Text("Other Content. Other Content. Other Content. Other Content. Other Content. Other Content. Other Content. ", style = MaterialTheme.typography.bodyMedium)
}
}
}
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
<string name="wifi_permissions_background_location_permission_label">Allow all the time</string>
<string name="wifi_permissions_background_location_permission_on">Location permission set to: %s</string>
<string name="wifi_permissions_background_location_permission_off">Location permission not set to: %s</string>
<string name="wifi_permissions_background_location_disclaimer">%s uses the Location permission only to determine the current WiFi\'s SSID for SSID-restricted accounts. This will happen even when the app is in background. No location data are collected, stored, processed or sent anywhere.</string>
<string name="wifi_permissions_background_location_disclaimer">%s uses location data (only WiFi SSID) solely to restrict synchronization to a specific WiFi SSID. This will happen even when the synchronization runs in background.</string>
<string name="wifi_permissions_background_location_disclaimer2">All location data (only WiFi SSID) are only used locally and are not sent anywhere.</string>
<string name="wifi_permissions_location_enabled">Location always enabled</string>
<string name="wifi_permissions_location_enabled_on">Location service is enabled</string>
<string name="wifi_permissions_location_enabled_off">Location service is disabled</string>
Expand Down

0 comments on commit 5f49c67

Please sign in to comment.