Merge pull request #1259 from Bnyro/master

grey out irrelevant settings
This commit is contained in:
Bnyro 2022-09-10 17:07:14 +02:00 committed by GitHub
commit 99862db210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -133,13 +133,10 @@ class InstanceSettings : MaterialPreferenceFragment() {
}
val deleteAccount = findPreference<Preference>(PreferenceKeys.DELETE_ACCOUNT)
deleteAccount?.isEnabled = PreferenceHelper.getToken() != ""
deleteAccount?.setOnPreferenceClickListener {
if (PreferenceHelper.getToken() != "") {
val newFragment = DeleteAccountDialog()
newFragment.show(childFragmentManager, DeleteAccountDialog::class.java.name)
} else {
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
}
val newFragment = DeleteAccountDialog()
newFragment.show(childFragmentManager, DeleteAccountDialog::class.java.name)
true
}

View File

@ -20,16 +20,27 @@ class NotificationSettings : MaterialPreferenceFragment() {
val notificationsEnabled =
findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED)
notificationsEnabled?.setOnPreferenceChangeListener { _, _ ->
val checkingFrequency = findPreference<ListPreference>(PreferenceKeys.CHECKING_FREQUENCY)
val requiredNetwork = findPreference<ListPreference>(PreferenceKeys.REQUIRED_NETWORK)
notificationsEnabled?.setOnPreferenceChangeListener { _, newValue ->
checkingFrequency?.isEnabled = newValue as Boolean
requiredNetwork?.isEnabled = newValue
updateNotificationPrefs()
true
}
val checkingFrequency = findPreference<ListPreference>(PreferenceKeys.CHECKING_FREQUENCY)
checkingFrequency?.isEnabled = notificationsEnabled!!.isChecked
checkingFrequency?.setOnPreferenceChangeListener { _, _ ->
updateNotificationPrefs()
true
}
requiredNetwork?.isEnabled = notificationsEnabled.isChecked
requiredNetwork?.setOnPreferenceChangeListener { _, _ ->
updateNotificationPrefs()
true
}
}
private fun updateNotificationPrefs() {