grey out irrelevant settings

This commit is contained in:
Bnyro 2022-09-10 17:06:55 +02:00
parent a2aa7b0ba8
commit 0070583c11
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() {