From 9a06a7a93b5b205e382211e5b3ebf349786ae1d5 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Wed, 26 Oct 2022 17:56:15 +0100 Subject: [PATCH] Add link to brand guidelines, remove redundant R --- .../feature/settings/SettingsDialogTest.kt | 21 ++++++++++++++ .../feature/settings/SettingsDialog.kt | 29 ++++++++++++------- .../settings/src/main/res/values/strings.xml | 1 + 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/feature/settings/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt b/feature/settings/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt index 71d6cceaa..2a29becc6 100644 --- a/feature/settings/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt +++ b/feature/settings/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt @@ -80,4 +80,25 @@ class SettingsDialogTest { composeTestRule.onNodeWithText(getString(R.string.brand_android)).assertIsSelected() composeTestRule.onNodeWithText(getString(R.string.dark_mode_config_dark)).assertIsSelected() } + + @Test + fun whenStateIsSuccess_allLegalLinksAreDisplayed() { + composeTestRule.setContent { + SettingsDialog( + settingsUiState = Success( + UserEditableSettings( + brand = ANDROID, + darkThemeConfig = DARK + ) + ), + onDismiss = { }, + onChangeThemeBrand = {}, + onChangeDarkThemeConfig = {} + ) + } + + composeTestRule.onNodeWithText(getString(R.string.privacy_policy)).assertExists() + composeTestRule.onNodeWithText(getString(R.string.licenses)).assertExists() + composeTestRule.onNodeWithText(getString(R.string.brand_guidelines)).assertExists() + } } diff --git a/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt b/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt index bddd93918..00e929fea 100644 --- a/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt +++ b/feature/settings/src/main/java/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt @@ -23,6 +23,7 @@ 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.layout.width import androidx.compose.foundation.rememberScrollState @@ -86,7 +87,7 @@ fun SettingsDialog( onDismissRequest = { onDismiss() }, title = { Text( - text = stringResource(R.string.settings_title), + text = stringResource(string.settings_title), style = MaterialTheme.typography.titleLarge ) }, @@ -96,7 +97,7 @@ fun SettingsDialog( when (settingsUiState) { Loading -> { Text( - text = stringResource(R.string.loading), + text = stringResource(string.loading), modifier = Modifier.padding(vertical = 16.dp) ) } @@ -131,15 +132,15 @@ private fun SettingsPanel( onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit, onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit ) { - SettingsDialogSectionTitle(text = stringResource(R.string.theme)) + SettingsDialogSectionTitle(text = stringResource(string.theme)) Column(Modifier.selectableGroup()) { SettingsDialogThemeChooserRow( - text = stringResource(R.string.brand_default), + text = stringResource(string.brand_default), selected = settings.brand == DEFAULT, onClick = { onChangeThemeBrand(DEFAULT) } ) SettingsDialogThemeChooserRow( - text = stringResource(R.string.brand_android), + text = stringResource(string.brand_android), selected = settings.brand == ANDROID, onClick = { onChangeThemeBrand(ANDROID) } ) @@ -147,17 +148,17 @@ private fun SettingsPanel( SettingsDialogSectionTitle(text = "Dark mode preference") Column(Modifier.selectableGroup()) { SettingsDialogThemeChooserRow( - text = stringResource(R.string.dark_mode_config_system_default), + text = stringResource(string.dark_mode_config_system_default), selected = settings.darkThemeConfig == FOLLOW_SYSTEM, onClick = { onChangeDarkThemeConfig(FOLLOW_SYSTEM) } ) SettingsDialogThemeChooserRow( - text = stringResource(R.string.dark_mode_config_light), + text = stringResource(string.dark_mode_config_light), selected = settings.darkThemeConfig == LIGHT, onClick = { onChangeDarkThemeConfig(LIGHT) } ) SettingsDialogThemeChooserRow( - text = stringResource(R.string.dark_mode_config_dark), + text = stringResource(string.dark_mode_config_dark), selected = settings.darkThemeConfig == DARK, onClick = { onChangeDarkThemeConfig(DARK) } ) @@ -210,15 +211,22 @@ private fun LegalPanel() { ) { Row { TextLink( - text = stringResource(R.string.privacy_policy), + text = stringResource(string.privacy_policy), url = PRIVACY_POLICY_URL ) Spacer(Modifier.width(16.dp)) TextLink( - text = stringResource(R.string.licenses), + text = stringResource(string.licenses), url = LICENSES_URL ) } + Spacer(Modifier.height(16.dp)) + Row { + TextLink( + text = stringResource(string.brand_guidelines), + url = BRAND_GUIDELINES_URL + ) + } } } } @@ -274,3 +282,4 @@ fun PreviewSettingsDialogLoading() { /* ktlint-disable max-line-length */ private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy" private const val LICENSES_URL = "https://github.com/android/nowinandroid/blob/main/app/LICENSES.md#open-source-licenses-and-copyright-notices" +private const val BRAND_GUIDELINES_URL = "https://developer.android.com/distribute/marketing-tools/brand-guidelines" diff --git a/feature/settings/src/main/res/values/strings.xml b/feature/settings/src/main/res/values/strings.xml index e37ff439d..c7ba3ada4 100644 --- a/feature/settings/src/main/res/values/strings.xml +++ b/feature/settings/src/main/res/values/strings.xml @@ -20,6 +20,7 @@ Loading... Privacy policy Licenses + Brand Guidelines Theme Default Android