Skip to content

Commit

Permalink
Move AdvancedDialog initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jun 6, 2024
1 parent 090edb7 commit 3ddba7a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,9 @@ internal class AdvancedDialog(
binding = AdvancedSettingsDialogBinding.inflate(layoutInflater)
binding.disableSSL.isChecked = disableSSL
binding.disableSSL.setOnCheckedChangeListener(onCheckedChangeListener)
if (caCertPath == null) {
showSelectCaCertificate()
} else {
showRemoveCaCertificate(caCertCN!!)
}
if (!clientCertPassword.isNullOrEmpty()) {
binding.clientCertPasswordEdittext.setText(clientCertPassword)
}
if (clientCertPath == null) {
showSelectClientCertificate()
} else {
showRemoveClientCertificate()
}
binding.clientCertPasswordEdittext.doOnTextChanged { _, _, _, _ ->
if (binding.selectedClientCert.text.toString() ==
context.getString(R.string.certificate_found)
Expand All @@ -95,6 +85,16 @@ internal class AdvancedDialog(
.create()
dialog.show()
dialogDoneButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
if (caCertPath == null) {
showSelectCaCertificate()
} else {
showRemoveCaCertificate(caCertCN!!)
}
if (clientCertPath == null) {
showSelectClientCertificate()
} else {
showRemoveClientCertificate()
}
return this
}

Expand Down Expand Up @@ -132,9 +132,7 @@ internal class AdvancedDialog(
}

private fun showPasswordMissing(toggled: Boolean) {
if (::dialogDoneButton.isInitialized) {
dialogDoneButton.isEnabled = !toggled
}
dialogDoneButton.isEnabled = !toggled
val error = if (toggled) {
context.getString(R.string.client_cert_password_missing)
} else {
Expand Down

0 comments on commit 3ddba7a

Please sign in to comment.