grey out when disabled

This commit is contained in:
Bnyro 2022-11-09 18:20:37 +01:00
parent 49bbe312d1
commit 67ec07f573

View File

@ -8,6 +8,7 @@ import com.github.libretube.R
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.ui.activities.SettingsActivity import com.github.libretube.ui.activities.SettingsActivity
import com.github.libretube.ui.base.BasePreferenceFragment import com.github.libretube.ui.base.BasePreferenceFragment
import com.github.libretube.ui.views.TimePickerPreference
import com.github.libretube.util.NotificationHelper import com.github.libretube.util.NotificationHelper
class NotificationSettings : BasePreferenceFragment() { class NotificationSettings : BasePreferenceFragment() {
@ -41,6 +42,19 @@ class NotificationSettings : BasePreferenceFragment() {
updateNotificationPrefs() updateNotificationPrefs()
true true
} }
val notificationTime = findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_TIME_ENABLED)
val notificationStartTime = findPreference<TimePickerPreference>(PreferenceKeys.NOTIFICATION_START_TIME)
val notificationEndTime = findPreference<TimePickerPreference>(PreferenceKeys.NOTIFICATION_END_TIME)
listOf(notificationStartTime, notificationEndTime).forEach {
it?.isEnabled = notificationTime?.isChecked == true
}
notificationTime?.setOnPreferenceChangeListener { _, newValue ->
listOf(notificationStartTime, notificationEndTime).forEach {
it?.isEnabled = newValue as Boolean
}
true
}
} }
private fun updateNotificationPrefs() { private fun updateNotificationPrefs() {