Skip to content

Commit

Permalink
Added preview, and changed texts
Browse files Browse the repository at this point in the history
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
  • Loading branch information
ArnyminerZ committed Feb 13, 2025
1 parent c93c327 commit 8fcf47f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
53 changes: 36 additions & 17 deletions app/src/main/kotlin/at/bitfire/davdroid/ui/AppSettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -425,23 +425,9 @@ fun AppSettings_Security(

var showingDistrustWarning by remember { mutableStateOf(false) }
if (showingDistrustWarning) {
AlertDialog(
onDismissRequest = { showingDistrustWarning = false },
title = { Text(stringResource(R.string.app_settings_distrust_system_certs)) },
text = { Text(stringResource(R.string.app_settings_distrust_system_certs_warning)) },
confirmButton = {
TextButton(
onClick = {
onDistrustSystemCertsUpdated(true)
showingDistrustWarning = false
}
) { Text(stringResource(R.string.dialog_confirm)) }
},
dismissButton = {
TextButton(
onClick = { showingDistrustWarning = false }
) { Text(stringResource(R.string.dialog_deny)) }
},
DistrustSystemCertificatesAlertDialog(
onDistrustSystemCertsRequested = { onDistrustSystemCertsUpdated(true) },
onDismissRequested = { showingDistrustWarning = false }
)
}

Expand Down Expand Up @@ -472,6 +458,39 @@ fun AppSettings_Security(
)
}

@Composable
fun DistrustSystemCertificatesAlertDialog(
onDistrustSystemCertsRequested: () -> Unit,
onDismissRequested: () -> Unit,
) {
AlertDialog(
onDismissRequest = onDismissRequested,
title = { Text(stringResource(R.string.app_settings_distrust_system_certs_dialog_title)) },
text = { Text(stringResource(R.string.app_settings_distrust_system_certs_dialog_message)) },
confirmButton = {
TextButton(
onClick = {
onDistrustSystemCertsRequested()
onDismissRequested()
}
) { Text(stringResource(R.string.dialog_enable)) }
},
dismissButton = {
TextButton(
onClick = onDismissRequested
) { Text(stringResource(R.string.dialog_deny)) }
},
)
}

@Preview
@Composable
fun DistrustSystemCertificatesAlertDialog_Preview() {
AppTheme {
DistrustSystemCertificatesAlertDialog({}, {})
}
}

@Composable
fun AppSettings_UserInterface(
theme: Int,
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="dialog_delete">Delete</string>
<string name="dialog_remove">Remove</string>
<string name="dialog_deny">Cancel</string>
<string name="dialog_confirm">Confirm</string>
<string name="dialog_enable">Enable</string>
<string name="field_required">This field is required</string>
<string name="help">Help</string>
<string name="navigate_up">Navigate up</string>
Expand Down Expand Up @@ -194,7 +194,8 @@
<string name="app_settings_distrust_system_certs">Distrust system certificates</string>
<string name="app_settings_distrust_system_certs_on">System and user-added CAs won\'t be trusted</string>
<string name="app_settings_distrust_system_certs_off">System and user-added CAs will be trusted (recommended)</string>
<string name="app_settings_distrust_system_certs_warning">Are you sure that you want to enable distrusting system certificates? When enabled, you need to manually install the certificates required for your connections, or otherwise they won\'t be possible. This option is targeted to users with high knowledge of networking.</string>
<string name="app_settings_distrust_system_certs_dialog_title">Attention!</string>
<string name="app_settings_distrust_system_certs_dialog_message">Enabling this option will cause DAVx5 to distrust system certificates. You will need to manually install the required certificates. This option is intended for advanced users.</string>
<string name="app_settings_reset_certificates">Reset (un)trusted certificates</string>
<string name="app_settings_reset_certificates_summary">Resets trust of all custom certificates</string>
<string name="app_settings_reset_certificates_success">All custom certificates have been cleared</string>
Expand Down

0 comments on commit 8fcf47f

Please sign in to comment.