Skip to content

Commit 5250e03

Browse files
committed
remove unnecessary logic
Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
1 parent e8c0685 commit 5250e03

2 files changed

Lines changed: 8 additions & 24 deletions

File tree

app/src/main/java/com/owncloud/android/ui/activity/ExtendedSettingsActivity.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,10 @@ import com.owncloud.android.ui.model.ExtendedSettingsActivityDialog
1515

1616
class ExtendedSettingsActivity : AppCompatActivity() {
1717

18-
private var dialogShown = false
19-
2018
@Suppress("ReturnCount")
2119
override fun onCreate(savedInstanceState: Bundle?) {
2220
super.onCreate(savedInstanceState)
2321

24-
if (savedInstanceState != null) {
25-
dialogShown = savedInstanceState.getBoolean(KEY_DIALOG_SHOWN, false)
26-
}
27-
28-
if (dialogShown) {
29-
return
30-
}
31-
3222
val dialogKey = intent.getStringExtra(EXTRA_DIALOG_TYPE) ?: run {
3323
finish()
3424
return
@@ -41,18 +31,11 @@ class ExtendedSettingsActivity : AppCompatActivity() {
4131

4232
val dismissable = intent.getBooleanExtra(EXTRA_DISMISSABLE, true)
4333
dialogType.showDialog(this, dismissable)
44-
dialogShown = true
45-
}
46-
47-
override fun onSaveInstanceState(outState: Bundle) {
48-
super.onSaveInstanceState(outState)
49-
outState.putBoolean(KEY_DIALOG_SHOWN, dialogShown)
5034
}
5135

5236
companion object {
5337
private const val EXTRA_DISMISSABLE = "dismissable"
5438
private const val EXTRA_DIALOG_TYPE = "dialog_type"
55-
private const val KEY_DIALOG_SHOWN = "dialog_shown"
5639

5740
@JvmOverloads
5841
fun createIntent(

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

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

Comments
 (0)