@@ -2,9 +2,7 @@ package com.github.gotify.login
2
2
3
3
import android.content.Context
4
4
import android.view.LayoutInflater
5
- import android.widget.Button
6
5
import android.widget.CompoundButton
7
- import androidx.appcompat.app.AlertDialog
8
6
import androidx.core.widget.doOnTextChanged
9
7
import com.github.gotify.R
10
8
import com.github.gotify.databinding.AdvancedSettingsDialogBinding
@@ -14,7 +12,6 @@ internal class AdvancedDialog(
14
12
private val context : Context ,
15
13
private val layoutInflater : LayoutInflater
16
14
) {
17
- private lateinit var dialogDoneButton: Button
18
15
private lateinit var binding: AdvancedSettingsDialogBinding
19
16
private var onCheckedChangeListener: CompoundButton .OnCheckedChangeListener ? = null
20
17
private lateinit var onClickSelectCaCertificate: Runnable
@@ -50,7 +47,7 @@ internal class AdvancedDialog(
50
47
return this
51
48
}
52
49
53
- fun onClose (onClose : (passworrd : String ) -> Unit ): AdvancedDialog {
50
+ fun onClose (onClose : (password : String ) -> Unit ): AdvancedDialog {
54
51
this .onClose = onClose
55
52
return this
56
53
}
@@ -75,16 +72,6 @@ internal class AdvancedDialog(
75
72
showPasswordMissing(binding.clientCertPasswordEdittext.text.toString().isEmpty())
76
73
}
77
74
}
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 )
88
75
if (caCertPath == null ) {
89
76
showSelectCaCertificate()
90
77
} else {
@@ -95,6 +82,14 @@ internal class AdvancedDialog(
95
82
} else {
96
83
showRemoveClientCertificate()
97
84
}
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()
98
93
return this
99
94
}
100
95
@@ -132,7 +127,6 @@ internal class AdvancedDialog(
132
127
}
133
128
134
129
private fun showPasswordMissing (toggled : Boolean ) {
135
- dialogDoneButton.isEnabled = ! toggled
136
130
val error = if (toggled) {
137
131
context.getString(R .string.client_cert_password_missing)
138
132
} else {
0 commit comments