Skip to content

Commit 9d2d497

Browse files
committed
Keep AdvancedDialog button always enabled
1 parent 3ddba7a commit 9d2d497

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

app/src/main/kotlin/com/github/gotify/login/AdvancedDialog.kt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package com.github.gotify.login
22

33
import android.content.Context
44
import android.view.LayoutInflater
5-
import android.widget.Button
65
import android.widget.CompoundButton
7-
import androidx.appcompat.app.AlertDialog
86
import androidx.core.widget.doOnTextChanged
97
import com.github.gotify.R
108
import com.github.gotify.databinding.AdvancedSettingsDialogBinding
@@ -14,7 +12,6 @@ internal class AdvancedDialog(
1412
private val context: Context,
1513
private val layoutInflater: LayoutInflater
1614
) {
17-
private lateinit var dialogDoneButton: Button
1815
private lateinit var binding: AdvancedSettingsDialogBinding
1916
private var onCheckedChangeListener: CompoundButton.OnCheckedChangeListener? = null
2017
private lateinit var onClickSelectCaCertificate: Runnable
@@ -50,7 +47,7 @@ internal class AdvancedDialog(
5047
return this
5148
}
5249

53-
fun onClose(onClose: (passworrd: String) -> Unit): AdvancedDialog {
50+
fun onClose(onClose: (password: String) -> Unit): AdvancedDialog {
5451
this.onClose = onClose
5552
return this
5653
}
@@ -75,16 +72,6 @@ internal class AdvancedDialog(
7572
showPasswordMissing(binding.clientCertPasswordEdittext.text.toString().isEmpty())
7673
}
7774
}
78-
val dialog = MaterialAlertDialogBuilder(context)
79-
.setView(binding.root)
80-
.setTitle(R.string.advanced_settings)
81-
.setPositiveButton(context.getString(R.string.done), null)
82-
.setOnDismissListener {
83-
onClose(binding.clientCertPasswordEdittext.text.toString())
84-
}
85-
.create()
86-
dialog.show()
87-
dialogDoneButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
8875
if (caCertPath == null) {
8976
showSelectCaCertificate()
9077
} else {
@@ -95,6 +82,14 @@ internal class AdvancedDialog(
9582
} else {
9683
showRemoveClientCertificate()
9784
}
85+
MaterialAlertDialogBuilder(context)
86+
.setView(binding.root)
87+
.setTitle(R.string.advanced_settings)
88+
.setPositiveButton(context.getString(R.string.done), null)
89+
.setOnDismissListener {
90+
onClose(binding.clientCertPasswordEdittext.text.toString())
91+
}
92+
.show()
9893
return this
9994
}
10095

@@ -132,7 +127,6 @@ internal class AdvancedDialog(
132127
}
133128

134129
private fun showPasswordMissing(toggled: Boolean) {
135-
dialogDoneButton.isEnabled = !toggled
136130
val error = if (toggled) {
137131
context.getString(R.string.client_cert_password_missing)
138132
} else {

0 commit comments

Comments
 (0)