Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add privacy/terms links to Ensu settings

Prateek Sunal95b49d6c132e
diff --git a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/settings/SettingsScreen.kt b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/settings/SettingsScreen.kt
index eca4721e1c..75d7d79376 100644
--- a/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/settings/SettingsScreen.kt
+++ b/mobile/native/android/apps/ensu/app-ui/src/main/java/io/ente/ensu/settings/SettingsScreen.kt
@@ -1,5 +1,9 @@
package io.ente.ensu.settings
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -11,7 +15,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.foundation.background
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
@@ -24,10 +27,12 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.draw.clip
+import androidx.core.content.ContextCompat
import io.ente.ensu.designsystem.EnsuColor
import io.ente.ensu.designsystem.EnsuCornerRadius
import io.ente.ensu.designsystem.EnsuSpacing
@@ -45,8 +50,9 @@ fun SettingsScreen(
onDeleteAccount: () -> Unit
) {
var query by remember { mutableStateOf("") }
+ val context = LocalContext.current
- val allItems = remember(onOpenLogs, onSignOut, onSignIn, onDeleteAccount, isLoggedIn) {
+ val allItems = remember(context, onOpenLogs, onSignOut, onSignIn, onDeleteAccount, isLoggedIn) {
buildList {
add(
SettingsItem(
@@ -79,6 +85,21 @@ fun SettingsScreen(
)
)
}
+
+ add(
+ SettingsItem(
+ title = "Privacy Policy",
+ subtitle = "ente.io/privacy",
+ onClick = { context.openExternalLink("https://ente.io/privacy") }
+ )
+ )
+ add(
+ SettingsItem(
+ title = "Terms of Service",
+ subtitle = "ente.io/terms",
+ onClick = { context.openExternalLink("https://ente.io/terms") }
+ )
+ )
}
}
@@ -189,3 +210,12 @@ private fun SettingsRow(item: SettingsItem) {
)
}
}
+
+private fun Context.openExternalLink(url: String) {
+ runCatching {
+ val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+ ContextCompat.startActivity(this, intent, null)
+ }
+}
diff --git a/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift b/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
index 859d31eb2d..5c71a5fe23 100644
--- a/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
+++ b/mobile/native/darwin/Apps/ensu/ensu/Settings/SettingsView.swift
@@ -32,6 +32,13 @@ struct SettingsView: View {
.buttonStyle(.plain)
}
+ ForEach(filteredLinkItems) { item in
+ Button(action: item.action) {
+ settingsCard(title: item.title, subtitle: item.subtitle, showsChevron: false)
+ }
+ .buttonStyle(.plain)
+ }
+
ForEach(filteredAccountItems) { item in
Button(action: item.action) {
settingsCard(title: item.title, subtitle: item.subtitle, showsChevron: false)
@@ -93,6 +100,21 @@ struct SettingsView: View {
}
}
+ private var linkItems: [SettingsActionItem] {
+ [
+ SettingsActionItem(
+ title: "Privacy Policy",
+ subtitle: "ente.io/privacy",
+ action: { openExternalLink("https://ente.io/privacy") }
+ ),
+ SettingsActionItem(
+ title: "Terms of Service",
+ subtitle: "ente.io/terms",
+ action: { openExternalLink("https://ente.io/terms") }
+ )
+ ]
+ }
+
private var accountItems: [SettingsActionItem] {
guard isLoggedIn else { return [] }
return [
@@ -117,6 +139,14 @@ struct SettingsView: View {
}
}
+ private var filteredLinkItems: [SettingsActionItem] {
+ guard !trimmedQuery.isEmpty else { return linkItems }
+ let q = trimmedQuery.lowercased()
+ return linkItems.filter { item in
+ item.title.lowercased().contains(q) || (item.subtitle?.lowercased().contains(q) == true)
+ }
+ }
+
private var shouldShowSignInRow: Bool {
guard showsSignInOption else { return false }
guard !isLoggedIn else { return false }
@@ -161,6 +191,11 @@ struct SettingsView: View {
openURL(url)
}
+ private func openExternalLink(_ urlString: String) {
+ guard let url = URL(string: urlString) else { return }
+ openURL(url)
+ }
+
private func signedInCard(email: String) -> some View {
VStack(alignment: .leading, spacing: 4) {
Text("Signed in as")