Add link to brand guidelines, remove redundant R

pull/367/head
Don Turner 2 years ago
parent f3ea2853fd
commit 9a06a7a93b

@ -80,4 +80,25 @@ class SettingsDialogTest {
composeTestRule.onNodeWithText(getString(R.string.brand_android)).assertIsSelected() composeTestRule.onNodeWithText(getString(R.string.brand_android)).assertIsSelected()
composeTestRule.onNodeWithText(getString(R.string.dark_mode_config_dark)).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()
}
} }

@ -23,6 +23,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
@ -86,7 +87,7 @@ fun SettingsDialog(
onDismissRequest = { onDismiss() }, onDismissRequest = { onDismiss() },
title = { title = {
Text( Text(
text = stringResource(R.string.settings_title), text = stringResource(string.settings_title),
style = MaterialTheme.typography.titleLarge style = MaterialTheme.typography.titleLarge
) )
}, },
@ -96,7 +97,7 @@ fun SettingsDialog(
when (settingsUiState) { when (settingsUiState) {
Loading -> { Loading -> {
Text( Text(
text = stringResource(R.string.loading), text = stringResource(string.loading),
modifier = Modifier.padding(vertical = 16.dp) modifier = Modifier.padding(vertical = 16.dp)
) )
} }
@ -131,15 +132,15 @@ private fun SettingsPanel(
onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit, onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit,
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit
) { ) {
SettingsDialogSectionTitle(text = stringResource(R.string.theme)) SettingsDialogSectionTitle(text = stringResource(string.theme))
Column(Modifier.selectableGroup()) { Column(Modifier.selectableGroup()) {
SettingsDialogThemeChooserRow( SettingsDialogThemeChooserRow(
text = stringResource(R.string.brand_default), text = stringResource(string.brand_default),
selected = settings.brand == DEFAULT, selected = settings.brand == DEFAULT,
onClick = { onChangeThemeBrand(DEFAULT) } onClick = { onChangeThemeBrand(DEFAULT) }
) )
SettingsDialogThemeChooserRow( SettingsDialogThemeChooserRow(
text = stringResource(R.string.brand_android), text = stringResource(string.brand_android),
selected = settings.brand == ANDROID, selected = settings.brand == ANDROID,
onClick = { onChangeThemeBrand(ANDROID) } onClick = { onChangeThemeBrand(ANDROID) }
) )
@ -147,17 +148,17 @@ private fun SettingsPanel(
SettingsDialogSectionTitle(text = "Dark mode preference") SettingsDialogSectionTitle(text = "Dark mode preference")
Column(Modifier.selectableGroup()) { Column(Modifier.selectableGroup()) {
SettingsDialogThemeChooserRow( SettingsDialogThemeChooserRow(
text = stringResource(R.string.dark_mode_config_system_default), text = stringResource(string.dark_mode_config_system_default),
selected = settings.darkThemeConfig == FOLLOW_SYSTEM, selected = settings.darkThemeConfig == FOLLOW_SYSTEM,
onClick = { onChangeDarkThemeConfig(FOLLOW_SYSTEM) } onClick = { onChangeDarkThemeConfig(FOLLOW_SYSTEM) }
) )
SettingsDialogThemeChooserRow( SettingsDialogThemeChooserRow(
text = stringResource(R.string.dark_mode_config_light), text = stringResource(string.dark_mode_config_light),
selected = settings.darkThemeConfig == LIGHT, selected = settings.darkThemeConfig == LIGHT,
onClick = { onChangeDarkThemeConfig(LIGHT) } onClick = { onChangeDarkThemeConfig(LIGHT) }
) )
SettingsDialogThemeChooserRow( SettingsDialogThemeChooserRow(
text = stringResource(R.string.dark_mode_config_dark), text = stringResource(string.dark_mode_config_dark),
selected = settings.darkThemeConfig == DARK, selected = settings.darkThemeConfig == DARK,
onClick = { onChangeDarkThemeConfig(DARK) } onClick = { onChangeDarkThemeConfig(DARK) }
) )
@ -210,15 +211,22 @@ private fun LegalPanel() {
) { ) {
Row { Row {
TextLink( TextLink(
text = stringResource(R.string.privacy_policy), text = stringResource(string.privacy_policy),
url = PRIVACY_POLICY_URL url = PRIVACY_POLICY_URL
) )
Spacer(Modifier.width(16.dp)) Spacer(Modifier.width(16.dp))
TextLink( TextLink(
text = stringResource(R.string.licenses), text = stringResource(string.licenses),
url = LICENSES_URL 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 */ /* ktlint-disable max-line-length */
private const val PRIVACY_POLICY_URL = "https://policies.google.com/privacy" 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 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"

@ -20,6 +20,7 @@
<string name="loading">Loading...</string> <string name="loading">Loading...</string>
<string name="privacy_policy">Privacy policy</string> <string name="privacy_policy">Privacy policy</string>
<string name="licenses">Licenses</string> <string name="licenses">Licenses</string>
<string name="brand_guidelines">Brand Guidelines</string>
<string name="theme">Theme</string> <string name="theme">Theme</string>
<string name="brand_default">Default</string> <string name="brand_default">Default</string>
<string name="brand_android">Android</string> <string name="brand_android">Android</string>

Loading…
Cancel
Save