Skip to content

Commit 902870f

Browse files
committed
de-duplicate logic
Signed-off-by: alperozturk96 <[email protected]>
1 parent 0f79b10 commit 902870f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

app/src/main/java/com/owncloud/android/ui/dialog/AppPassCodeDialog.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)