1616
1717package com.google.samples.apps.nowinandroid.feature.settings
1818
19+ import android.content.Intent
1920import androidx.compose.foundation.clickable
21+ import androidx.compose.foundation.layout.Arrangement
2022import androidx.compose.foundation.layout.Column
23+ import androidx.compose.foundation.layout.ExperimentalLayoutApi
24+ import androidx.compose.foundation.layout.FlowRow
2125import androidx.compose.foundation.layout.Row
2226import androidx.compose.foundation.layout.Spacer
2327import androidx.compose.foundation.layout.fillMaxWidth
24- import androidx.compose.foundation.layout.height
2528import androidx.compose.foundation.layout.padding
2629import androidx.compose.foundation.layout.width
2730import androidx.compose.foundation.layout.widthIn
@@ -40,6 +43,7 @@ import androidx.compose.ui.Alignment
4043import androidx.compose.ui.ExperimentalComposeUiApi
4144import androidx.compose.ui.Modifier
4245import androidx.compose.ui.platform.LocalConfiguration
46+ import androidx.compose.ui.platform.LocalContext
4347import androidx.compose.ui.platform.LocalUriHandler
4448import androidx.compose.ui.res.stringResource
4549import androidx.compose.ui.semantics.Role
@@ -48,6 +52,8 @@ import androidx.compose.ui.unit.dp
4852import androidx.compose.ui.window.DialogProperties
4953import androidx.hilt.navigation.compose.hiltViewModel
5054import androidx.lifecycle.compose.collectAsStateWithLifecycle
55+ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
56+ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTextButton
5157import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
5258import com.google.samples.apps.nowinandroid.core.designsystem.theme.supportsDynamicTheming
5359import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig
@@ -236,56 +242,43 @@ fun SettingsDialogThemeChooserRow(
236242 }
237243}
238244
245+ @OptIn(ExperimentalLayoutApi ::class )
239246@Composable
240247private fun LinksPanel () {
241- Row (
242- modifier = Modifier .padding(top = 16 .dp),
248+ FlowRow (
249+ horizontalArrangement = Arrangement .spacedBy(
250+ space = 16 .dp,
251+ alignment = Alignment .CenterHorizontally ,
252+ ),
253+ modifier = Modifier .fillMaxWidth()
243254 ) {
244- Column (
245- Modifier .fillMaxWidth(),
246- horizontalAlignment = Alignment . CenterHorizontally ,
255+ val uriHandler = LocalUriHandler .current
256+ NiaTextButton (
257+ onClick = { uriHandler.openUri( PRIVACY_POLICY_URL ) }
247258 ) {
248- Row {
249- TextLink (
250- text = stringResource(string.privacy_policy),
251- url = PRIVACY_POLICY_URL ,
252- )
253- Spacer (Modifier .width(16 .dp))
254- TextLink (
255- text = stringResource(string.licenses),
256- url = LICENSES_URL ,
257- )
258- }
259- Spacer (Modifier .height(16 .dp))
260- Row {
261- TextLink (
262- text = stringResource(string.brand_guidelines),
263- url = BRAND_GUIDELINES_URL ,
264- )
265- Spacer (Modifier .width(16 .dp))
266- TextLink (
267- text = stringResource(string.feedback),
268- url = FEEDBACK_URL ,
269- )
259+ Text (text = stringResource(string.privacy_policy))
260+ }
261+ val context = LocalContext .current
262+ NiaTextButton (
263+ onClick = {
264+ context.startActivity(Intent (context, OssLicensesMenuActivity ::class .java))
270265 }
266+ ) {
267+ Text (text = stringResource(string.licenses))
268+ }
269+ NiaTextButton (
270+ onClick = { uriHandler.openUri(BRAND_GUIDELINES_URL ) }
271+ ) {
272+ Text (text = stringResource(string.brand_guidelines))
273+ }
274+ NiaTextButton (
275+ onClick = { uriHandler.openUri(FEEDBACK_URL ) }
276+ ) {
277+ Text (text = stringResource(string.feedback))
271278 }
272279 }
273280}
274281
275- @Composable
276- private fun TextLink (text : String , url : String ) {
277- val uriHandler = LocalUriHandler .current
278-
279- Text (
280- text = text,
281- style = MaterialTheme .typography.labelLarge,
282- color = MaterialTheme .colorScheme.primary,
283- modifier = Modifier
284- .padding(vertical = 8 .dp)
285- .clickable { uriHandler.openUri(url) },
286- )
287- }
288-
289282@Preview
290283@Composable
291284private fun PreviewSettingsDialog () {
@@ -322,8 +315,5 @@ private fun PreviewSettingsDialogLoading() {
322315
323316/* ktlint-disable max-line-length */
324317private const val PRIVACY_POLICY_URL = " https://policies.google.com/privacy"
325- private const val LICENSES_URL =
326- " https://github.com/android/nowinandroid/blob/main/app/LICENSES.md#open-source-licenses-and-copyright-notices"
327- private const val BRAND_GUIDELINES_URL =
328- " https://developer.android.com/distribute/marketing-tools/brand-guidelines"
318+ private const val BRAND_GUIDELINES_URL = " https://developer.android.com/distribute/marketing-tools/brand-guidelines"
329319private const val FEEDBACK_URL = " https://goo.gle/nia-app-feedback"
0 commit comments