Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 7b16255

Browse files
authored
Merge pull request #88 from Automattic/hamorillo/GRA-630
Open TermsOfService and PrivacyPolicy in a customTab
2 parents 85bc86a + 4b2ac13 commit 7b16255

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

homeUi/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ dependencies {
2121
implementation(libs.androidx.ui.graphics)
2222
implementation(libs.androidx.navigation)
2323
implementation(libs.androidx.constraintLayout.compose)
24+
implementation(libs.androidx.browser)
2425
implementation(libs.coil.compose)
2526
implementation(project.dependencies.platform(libs.koin.bom))
2627
implementation(libs.koin.core)

homeUi/src/main/kotlin/com/gravatar/app/homeUi/presentation/home/components/topbar/components/AboutAppDialog.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.gravatar.app.homeUi.presentation.home.components.topbar.components
22

33
import android.content.Context
44
import android.content.Intent
5+
import androidx.browser.customtabs.CustomTabsIntent
56
import androidx.compose.foundation.clickable
67
import androidx.compose.foundation.layout.Arrangement
78
import androidx.compose.foundation.layout.Column
@@ -125,15 +126,18 @@ private fun Context.sendSupportEmail() {
125126

126127
private fun Context.openSupportPage() = openUrl("https://$SUPPORT_URL")
127128

128-
private fun Context.openTermsOfService() = openUrl(TERMS_OF_SERVICE_URL)
129+
private fun Context.openTermsOfService() = openUrlInApp(TERMS_OF_SERVICE_URL)
129130

130-
private fun Context.openPrivacyPolicy() = openUrl(PRIVACY_POLICY_URL)
131+
private fun Context.openPrivacyPolicy() = openUrlInApp(PRIVACY_POLICY_URL)
131132

132133
private fun Context.openUrl(url: String) {
133134
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
134135
startActivity(intent)
135136
}
136137

138+
private fun Context.openUrlInApp(url: String) =
139+
CustomTabsIntent.Builder().build().launchUrl(this, url.toUri())
140+
137141
private const val SUPPORT_URL = "support.gravatar.com"
138142
private const val SUPPORT_EMAIL = "support@gravatar.com"
139143
private const val TERMS_OF_SERVICE_URL = "https://wordpress.com/tos/"

0 commit comments

Comments
 (0)