mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
@@ -30,12 +30,14 @@ import android.graphics.Color
|
||||
import android.media.AudioAttributes
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.provider.ContactsContract
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.app.Person
|
||||
import androidx.core.app.RemoteInput
|
||||
import androidx.core.app.TaskStackBuilder
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import com.moez.QKSMS.R
|
||||
import com.moez.QKSMS.common.util.extensions.dpToPx
|
||||
@@ -279,6 +281,17 @@ class NotificationManagerImpl @Inject constructor(
|
||||
}
|
||||
|
||||
notificationManager.notify(threadId.toInt(), notification.build())
|
||||
|
||||
// Wake screen
|
||||
if (prefs.wakeScreen(threadId).get()) {
|
||||
context.getSystemService<PowerManager>()?.let { powerManager ->
|
||||
if (!powerManager.isInteractive) {
|
||||
val flags = PowerManager.SCREEN_DIM_WAKE_LOCK or PowerManager.ACQUIRE_CAUSES_WAKEUP
|
||||
val wakeLock = powerManager.newWakeLock(flags, context.packageName)
|
||||
wakeLock.acquire(5000)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun notifyFailed(msgId: Long) {
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
|
||||
+1
@@ -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 = "",
|
||||
|
||||
+6
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user