Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
Expand All @@ -36,6 +37,7 @@ fun SettingsScreen(
LaunchedEffect(lifecycleState) {
if (lifecycleState == Lifecycle.State.RESUMED) viewModel.refresh()
}
val uriHandler = LocalUriHandler.current
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve robustness and reduce duplication, consider creating a remembered helper function to handle URI opening. This allows you to centralize error handling (e.g., catching exceptions if no browser is installed on the device) and makes the UI code cleaner.

Suggested change
val uriHandler = LocalUriHandler.current
val uriHandler = LocalUriHandler.current
val openUrl = remember(uriHandler) {
{ url: String ->
try {
uriHandler.openUri(url)
} catch (e: Exception) {
// TODO: Handle error gracefully (e.g., show a snackbar or log the error)
}
}
}


if (showAccountsSheet) {
AccountsSheet(
Expand Down Expand Up @@ -120,10 +122,10 @@ fun SettingsScreen(
// More Options Section
item {
SettingsSectionHeader(stringResource(Res.string.settings_section_more_options))
SettingsRow(title = stringResource(Res.string.settings_share_feedback), onClick = { /* TODO */ })
SettingsRow(title = stringResource(Res.string.settings_get_help), onClick = { /* TODO */ })
SettingsRow(title = stringResource(Res.string.settings_terms_of_service), onClick = { /* TODO */ })
SettingsRow(title = stringResource(Res.string.settings_privacy_policy), onClick = { /* TODO */ })
SettingsRow(title = stringResource(Res.string.settings_share_feedback), onClick = { uriHandler.openUri("https://github.com/mobile/feedback") })
SettingsRow(title = stringResource(Res.string.settings_get_help), onClick = { uriHandler.openUri("https://support.github.com") })
SettingsRow(title = stringResource(Res.string.settings_terms_of_service), onClick = { uriHandler.openUri("https://docs.github.com/en/site-policy/github-terms/github-terms-of-service") })
SettingsRow(title = stringResource(Res.string.settings_privacy_policy), onClick = { uriHandler.openUri("https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement") })
Comment on lines +125 to +128
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the openUrl helper function to handle URI opening with centralized error handling. Additionally, note that the documentation URLs for Terms of Service and Privacy Policy are hardcoded with the /en/ locale segment. To better support internationalization (i18n), consider moving these URLs to string resources (strings.xml) so that localized links can be provided for different languages.

Suggested change
SettingsRow(title = stringResource(Res.string.settings_share_feedback), onClick = { uriHandler.openUri("https://github.com/mobile/feedback") })
SettingsRow(title = stringResource(Res.string.settings_get_help), onClick = { uriHandler.openUri("https://support.github.com") })
SettingsRow(title = stringResource(Res.string.settings_terms_of_service), onClick = { uriHandler.openUri("https://docs.github.com/en/site-policy/github-terms/github-terms-of-service") })
SettingsRow(title = stringResource(Res.string.settings_privacy_policy), onClick = { uriHandler.openUri("https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement") })
SettingsRow(title = stringResource(Res.string.settings_share_feedback), onClick = { openUrl("https://github.com/mobile/feedback") })
SettingsRow(title = stringResource(Res.string.settings_get_help), onClick = { openUrl("https://support.github.com") })
SettingsRow(title = stringResource(Res.string.settings_terms_of_service), onClick = { openUrl("https://docs.github.com/en/site-policy/github-terms/github-terms-of-service") })
SettingsRow(title = stringResource(Res.string.settings_privacy_policy), onClick = { openUrl("https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement") })

SettingsRow(title = stringResource(Res.string.settings_open_source_libraries), onClick = { /* TODO */ })
SettingsRow(
title = stringResource(Res.string.settings_sign_out),
Expand Down
Loading