mirror of
https://github.com/lone-cloud/prism-android
synced 2026-06-03 11:03:10 -07:00
parent
2269081052
commit
fee32bed37
5 changed files with 85 additions and 0 deletions
|
|
@ -46,6 +46,12 @@ class AppBarViewModel(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun togglePrivacyPolicy() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
state = state.copy(showPrivacyPolicy = !state.showPrivacyPolicy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun newPushServer(url: String) {
|
fun newPushServer(url: String) {
|
||||||
var url = url
|
var url = url
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
appBarViewModel.toggleMenu()
|
appBarViewModel.toggleMenu()
|
||||||
},
|
},
|
||||||
|
onShowPrivacyPolicy = {
|
||||||
|
appBarViewModel.togglePrivacyPolicy()
|
||||||
|
},
|
||||||
onChangeServer = {
|
onChangeServer = {
|
||||||
appBarViewModel.toggleChangeServer()
|
appBarViewModel.toggleChangeServer()
|
||||||
},
|
},
|
||||||
|
|
@ -89,6 +92,11 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
|
||||||
if (state.showMigrations) {
|
if (state.showMigrations) {
|
||||||
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
||||||
}
|
}
|
||||||
|
if (state.showPrivacyPolicy) {
|
||||||
|
PrivacyPolicyDialog {
|
||||||
|
appBarViewModel.togglePrivacyPolicy()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -96,6 +104,7 @@ fun Dropdown(
|
||||||
expanded: Boolean,
|
expanded: Boolean,
|
||||||
showToasts: Boolean,
|
showToasts: Boolean,
|
||||||
showMigrations: Boolean,
|
showMigrations: Boolean,
|
||||||
|
onShowPrivacyPolicy: () -> Unit,
|
||||||
onRestart: () -> Unit,
|
onRestart: () -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onChangeServer: () -> Unit,
|
onChangeServer: () -> Unit,
|
||||||
|
|
@ -107,6 +116,15 @@ fun Dropdown(
|
||||||
expanded = expanded,
|
expanded = expanded,
|
||||||
onDismissRequest = onDismiss
|
onDismissRequest = onDismiss
|
||||||
) {
|
) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
onClick = {
|
||||||
|
onShowPrivacyPolicy()
|
||||||
|
onDismiss()
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(LibR.string.privacy_policy))
|
||||||
|
}
|
||||||
|
)
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
onClick = onRestart,
|
onClick = onRestart,
|
||||||
text = {
|
text = {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ data class AppBarUiState(
|
||||||
val currentApiUrl: String,
|
val currentApiUrl: String,
|
||||||
val showToasts: Boolean,
|
val showToasts: Boolean,
|
||||||
val menuExpanded: Boolean = false,
|
val menuExpanded: Boolean = false,
|
||||||
|
val showPrivacyPolicy: Boolean = false,
|
||||||
val showChangeServerDialog: Boolean = false,
|
val showChangeServerDialog: Boolean = false,
|
||||||
/**
|
/**
|
||||||
* Used for the fallback service dialog and migration dialog
|
* Used for the fallback service dialog and migration dialog
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.unifiedpush.distributor.sunup.activities.ui
|
||||||
|
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.LinkAnnotation
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
|
import androidx.compose.ui.text.TextLinkStyles
|
||||||
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
|
import androidx.compose.ui.text.withLink
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import org.unifiedpush.distributor.sunup.R
|
||||||
|
import org.unifiedpush.android.distributor.ui.R as LibR
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun PrivacyPolicyDialog(onDismiss: () -> Unit) {
|
||||||
|
AlertDialog(
|
||||||
|
title = {
|
||||||
|
Text(stringResource(LibR.string.privacy_policy))
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
PrivacyPolicy()
|
||||||
|
},
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(
|
||||||
|
onClick = onDismiss
|
||||||
|
) {
|
||||||
|
Text(stringResource(android.R.string.cancel))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
private fun PrivacyPolicy() {
|
||||||
|
Text(
|
||||||
|
buildAnnotatedString {
|
||||||
|
append(stringResource(R.string.sunup_privacy_policy).format(stringResource(R.string.app_name)))
|
||||||
|
|
||||||
|
withLink(
|
||||||
|
LinkAnnotation.Url(
|
||||||
|
"https://www.mozilla.org/en-US/privacy/firefox/#types-of-data-defined",
|
||||||
|
TextLinkStyles(style = SpanStyle(color = MaterialTheme.colorScheme.primary))
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
append("https://www.mozilla.org/en-US/privacy/firefox/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
4
app/src/main/res/values/strings.xml
Normal file
4
app/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="sunup_privacy_policy">By default, %s uses Mozilla push server which therefor has access to the origin IP address of the requests (from your phone).\n\nDuring the first connection, the app generates a unique ID shared with the server to identify itself and to be linked to generated push endpoints. This ID is kept across reconnections, to receive notifications while the device is offline.\n\nThe push server keeps a record of the last connection date, to be able to remove unused ID.\n\nMozilla servers are located in the USA.\n\nFor more information, see Mozilla Firefox privacy policy - technical data.\n\n</string>
|
||||||
|
</resources>
|
||||||
Loading…
Add table
Reference in a new issue