Skip to content

Commit

Permalink
Don't show empty OAuth setting
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed May 16, 2024
1 parent 86cad50 commit c9528d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ class AccountSettingsModel @AssistedInject constructor(
}

fun updateTasksSyncInterval(syncInterval: Long) {
tasksProvider?.authority?.let { tasksAuthority ->
CoroutineScope(Dispatchers.Default).launch {
CoroutineScope(Dispatchers.Default).launch {
tasksProvider?.authority?.let { tasksAuthority ->
accountSettings.setSyncInterval(tasksAuthority, syncInterval)
reload()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,23 +464,13 @@ fun AuthenticationSettings(
val context = LocalContext.current
val scope = rememberCoroutineScope()

Column(Modifier.padding(8.dp)) {
SettingsHeader(false) {
Text(stringResource(R.string.settings_authentication))
}

if (credentials.authState != null) { // OAuth
Setting(
icon = Icons.Default.Password,
name = stringResource(R.string.settings_oauth),
summary = stringResource(R.string.settings_oauth_summary),
onClick = {
// GoogleLoginFragment replacement
}
)
if (credentials.authState != null || credentials.username != null || credentials.password != null || credentials.certificateAlias != null)
Column {
SettingsHeader(false) {
Text(stringResource(R.string.settings_authentication))
}

} else { // username/password
if (credentials.username != null) {
if (credentials.username != null || credentials.password != null) {
var showUsernameDialog by remember { mutableStateOf(false) }
Setting(
icon = Icons.Default.AccountCircle,
Expand All @@ -499,9 +489,7 @@ fun AuthenticationSettings(
},
onDismiss = { showUsernameDialog = false }
)
}

if (credentials.password != null) {
var showPasswordDialog by remember { mutableStateOf(false) }
Setting(
icon = Icons.Default.Password,
Expand Down Expand Up @@ -548,7 +536,6 @@ fun AuthenticationSettings(
}, null, null, null, -1, credentials.certificateAlias)
}
)
}
}
}

Expand Down Expand Up @@ -706,7 +693,7 @@ fun AccountSettingsScreen_Preview() {
onUpdateIgnoreVpns = {},

// Authentication Settings
credentials = Credentials(),
credentials = Credentials(username = "test", password = "test"),
onUpdateCredentials = {},

// CalDav Settings
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@
<string name="settings_ignore_vpns_on">VPN without underlying validated Internet connection is not enough to run synchronization (recommended)</string>
<string name="settings_ignore_vpns_off">VPN without underlying validated Internet connection is enough to run synchronization</string>
<string name="settings_authentication">Authentication</string>
<string name="settings_oauth">Re-authenticate</string>
<string name="settings_oauth_summary">Perform OAuth login again</string>
<string name="settings_username">User name</string>
<string name="settings_password">Password</string>
<string name="settings_new_password">New password</string>
Expand Down

0 comments on commit c9528d5

Please sign in to comment.