Add setting to wake screen

Closes #1048
This commit is contained in:
Moez Bhatti
2019-11-24 17:20:04 -05:00
parent f412ccd442
commit 5d62912508
7 changed files with 38 additions and 0 deletions
@@ -98,6 +98,7 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
notifications.checkbox.isChecked = state.notificationsEnabled
previews.summary = state.previewSummary
previewModeDialog.adapter.selectedItem = state.previewId
wake.checkbox.isChecked = state.wakeEnabled
vibration.checkbox.isChecked = state.vibrationEnabled
ringtone.summary = state.ringtoneName
@@ -27,6 +27,7 @@ data class NotificationPrefsState(
val notificationsEnabled: Boolean = true,
val previewSummary: String = "",
val previewId: Int = Preferences.NOTIFICATION_PREVIEWS_ALL,
val wakeEnabled: Boolean = false,
val action1Summary: String = "",
val action2Summary: String = "",
val action3Summary: String = "",
@@ -46,6 +46,7 @@ class NotificationPrefsViewModel @Inject constructor(
private val notifications = prefs.notifications(threadId)
private val previews = prefs.notificationPreviews(threadId)
private val wake = prefs.wakeScreen(threadId)
private val vibration = prefs.vibration(threadId)
private val ringtone = prefs.ringtone(threadId)
@@ -75,6 +76,9 @@ class NotificationPrefsViewModel @Inject constructor(
disposables += prefs.notifAction3.asObservable()
.subscribe { previewId -> newState { copy(action3Summary = actionLabels[previewId]) } }
disposables += wake.asObservable()
.subscribe { enabled -> newState { copy(wakeEnabled = enabled) } }
disposables += vibration.asObservable()
.subscribe { enabled -> newState { copy(vibrationEnabled = enabled) } }
@@ -107,6 +111,8 @@ class NotificationPrefsViewModel @Inject constructor(
R.id.previews -> view.showPreviewModeDialog()
R.id.wake -> wake.set(!wake.get())
R.id.vibration -> vibration.set(!vibration.get())
R.id.ringtone -> view.showRingtonePicker(ringtone.get().takeIf { it.isNotEmpty() }?.let(Uri::parse))