@@ -39,6 +39,8 @@ class AppPassCodeDialog :
3939
4040 private lateinit var binding: DialogAppPasscodeBinding
4141
42+ private var currentSelection = SettingsActivity .LOCK_NONE
43+
4244 override fun onStart () {
4345 super .onStart()
4446 val alertDialog = dialog as AlertDialog
@@ -55,7 +57,8 @@ class AppPassCodeDialog :
5557 override fun onCreateDialog (savedInstanceState : Bundle ? ): Dialog {
5658 binding = DialogAppPasscodeBinding .inflate(layoutInflater)
5759
58- val currentLock = preferences.lockPreference ? : SettingsActivity .LOCK_NONE
60+ currentSelection = preferences.lockPreference ? : SettingsActivity .LOCK_NONE
61+
5962 val passCodeEnabled = resources.getBoolean(R .bool.passcode_enabled)
6063 val deviceCredentialsEnabled = resources.getBoolean(R .bool.device_credentials_enabled)
6164 val enforceProtection = MDMConfig .enforceProtection(requireContext())
@@ -67,7 +70,7 @@ class AppPassCodeDialog :
6770 binding.lockNone.setVisibleIf(! enforceProtection)
6871
6972 setupTheme()
70- setCurrentSelection(currentLock )
73+ setCurrentSelection()
7174 setupListener()
7275
7376 val builder = MaterialAlertDialogBuilder (requireContext())
@@ -99,10 +102,10 @@ class AppPassCodeDialog :
99102 }
100103 }
101104
102- private fun setCurrentSelection (currentLock : String ) {
105+ private fun setCurrentSelection () {
103106 val radioGroup = binding.lockRadioGroup
104107
105- when (currentLock ) {
108+ when (currentSelection ) {
106109 SettingsActivity .LOCK_PASSCODE -> radioGroup.check(R .id.lock_passcode)
107110 SettingsActivity .LOCK_DEVICE_CREDENTIALS -> radioGroup.check(R .id.lock_device_credentials)
108111 SettingsActivity .LOCK_NONE -> radioGroup.check(R .id.lock_none)
@@ -122,10 +125,8 @@ class AppPassCodeDialog :
122125 }
123126 }
124127
125- private var currentSelection: String? = null
126-
127128 private fun applySelection () {
128- val selectedLock = currentSelection ? : return
129+ val selectedLock = currentSelection
129130
130131 setFragmentResult(
131132 ExtendedSettingsActivityDialog .AppPasscode .key,
0 commit comments