@@ -48,11 +48,8 @@ class AppPassCodeDialog :
4848 val positiveButton = alertDialog.getButton(AlertDialog .BUTTON_POSITIVE ) as ? MaterialButton
4949 positiveButton?.let {
5050 viewThemeUtils.material.colorMaterialButtonPrimaryTonal(it)
51- val enforceProtection = MDMConfig .enforceProtection(requireContext())
52- if (enforceProtection) {
53- it.isEnabled = (binding.lockPasscode.isChecked || binding.lockDeviceCredentials.isChecked)
54- }
5551 }
52+ checkPositiveButtonActiveness()
5653
5754 val dismissable = arguments?.getBoolean(ARG_DISMISSABLE , true ) ? : true
5855 isCancelable = dismissable
@@ -126,13 +123,16 @@ class AppPassCodeDialog :
126123 }
127124
128125 currentSelection = selectedLock
126+ checkPositiveButtonActiveness()
127+ }
128+ }
129129
130- val positiveButton = (dialog as ? AlertDialog )
131- ?.getButton( AlertDialog . BUTTON_POSITIVE ) as ? MaterialButton
132- val enforceProtection = MDMConfig .enforceProtection(requireContext())
133- if ( enforceProtection) {
134- positiveButton?.isEnabled = (binding.lockPasscode.isChecked || binding.lockDeviceCredentials.isChecked)
135- }
130+ private fun checkPositiveButtonActiveness () {
131+ val positiveButton = (dialog as ? AlertDialog )
132+ ?.getButton( AlertDialog . BUTTON_POSITIVE ) as ? MaterialButton
133+ val enforceProtection = MDMConfig . enforceProtection(requireContext())
134+ if (enforceProtection) {
135+ positiveButton?.isEnabled = (binding.lockPasscode.isChecked || binding.lockDeviceCredentials.isChecked)
136136 }
137137 }
138138
0 commit comments