forked from upstream-mirrors/quik
Merge branch 'octoshrimpy:master' into send_immediately_35
This commit is contained in:
@@ -52,6 +52,7 @@ import dev.octoshrimpy.quik.receiver.MarkReadReceiver
|
||||
import dev.octoshrimpy.quik.receiver.MarkSeenReceiver
|
||||
import dev.octoshrimpy.quik.receiver.RemoteMessagingReceiver
|
||||
import dev.octoshrimpy.quik.receiver.SpeakThreadsReceiver
|
||||
import dev.octoshrimpy.quik.repository.ContactRepository
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||
import dev.octoshrimpy.quik.util.GlideApp
|
||||
@@ -70,7 +71,8 @@ class NotificationManagerImpl @Inject constructor(
|
||||
private val prefs: Preferences,
|
||||
private val messageRepo: MessageRepository,
|
||||
private val permissions: PermissionManager,
|
||||
private val phoneNumberUtils: PhoneNumberUtils
|
||||
private val phoneNumberUtils: PhoneNumberUtils,
|
||||
private val contactRepo: ContactRepository,
|
||||
) : dev.octoshrimpy.quik.manager.NotificationManager {
|
||||
|
||||
companion object {
|
||||
@@ -145,12 +147,28 @@ class NotificationManagerImpl @Inject constructor(
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(contentPI)
|
||||
.setDeleteIntent(seenPI)
|
||||
.setSound(ringtone)
|
||||
.setLights(Color.WHITE, 500, 2000)
|
||||
.setWhen(conversation.lastMessage?.date ?: System.currentTimeMillis())
|
||||
.setVibrate(if (prefs.vibration(threadId).get()) VIBRATE_PATTERN else longArrayOf(0))
|
||||
|
||||
// Tell the notification if it's a group message
|
||||
// if preference set to silence notifications if no recipients in contacts
|
||||
if (prefs.silentNotContact.get() && run {
|
||||
val msgRecipientNumbers = conversation.recipients.map { it.address }
|
||||
|
||||
// true if any message recipients are in device's contacts
|
||||
!contactRepo
|
||||
.getUnmanagedAllContacts()
|
||||
.flatMap { it.numbers }
|
||||
.map { it.address }
|
||||
.any { contactNumber ->
|
||||
msgRecipientNumbers.any { phoneNumberUtils.compare(contactNumber, it) }
|
||||
}
|
||||
})
|
||||
notification.setSilent(true)
|
||||
else
|
||||
notification.setSound(ringtone)
|
||||
|
||||
// Tell the notification if it's a group message
|
||||
val messagingStyle = NotificationCompat.MessagingStyle("Me")
|
||||
if (conversation.recipients.size >= 2) {
|
||||
messagingStyle.isGroupConversation = true
|
||||
|
||||
+16
-14
@@ -39,24 +39,26 @@ class BlockedNumbersPresenter @Inject constructor(
|
||||
super.bindIntents(view)
|
||||
|
||||
view.unblockAddress()
|
||||
.doOnNext { id ->
|
||||
blockingRepo.getBlockedNumber(id)?.address
|
||||
?.let(conversationRepo::getThreadId)
|
||||
?.let { threadId -> markUnblocked.execute(listOf(threadId)) }
|
||||
}
|
||||
.doOnNext(blockingRepo::unblockNumber)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
.observeOn(Schedulers.io())
|
||||
.doOnNext { id ->
|
||||
blockingRepo.getBlockedNumber(id)?.address
|
||||
?.let(conversationRepo::getThreadId)
|
||||
?.let { threadId -> markUnblocked.execute(listOf(threadId)) }
|
||||
}
|
||||
.doOnNext(blockingRepo::unblockNumber)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe()
|
||||
|
||||
view.addAddress()
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showAddDialog() }
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { view.showAddDialog() }
|
||||
|
||||
view.saveAddress()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { address -> blockingRepo.blockNumber(address) }
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { address -> blockingRepo.blockNumber(address) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -99,6 +99,8 @@ class NotificationPrefsActivity : QkThemedActivity(), NotificationPrefsView {
|
||||
previews.summary = state.previewSummary
|
||||
previewModeDialog.adapter.selectedItem = state.previewId
|
||||
wake.checkbox.isChecked = state.wakeEnabled
|
||||
silentNotContact.checkbox.isChecked = state.silentNotContact
|
||||
silentNotContact.isVisible = state.threadId == 0L
|
||||
vibration.checkbox.isChecked = state.vibrationEnabled
|
||||
ringtone.summary = state.ringtoneName
|
||||
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ data class NotificationPrefsState(
|
||||
val previewSummary: String = "",
|
||||
val previewId: Int = Preferences.NOTIFICATION_PREVIEWS_ALL,
|
||||
val wakeEnabled: Boolean = false,
|
||||
val silentNotContact: Boolean = false,
|
||||
val action1Summary: String = "",
|
||||
val action2Summary: String = "",
|
||||
val action3Summary: String = "",
|
||||
|
||||
+5
@@ -79,6 +79,9 @@ class NotificationPrefsViewModel @Inject constructor(
|
||||
disposables += wake.asObservable()
|
||||
.subscribe { enabled -> newState { copy(wakeEnabled = enabled) } }
|
||||
|
||||
disposables += prefs.silentNotContact.asObservable()
|
||||
.subscribe { enabled -> newState { copy(silentNotContact = enabled) } }
|
||||
|
||||
disposables += vibration.asObservable()
|
||||
.subscribe { enabled -> newState { copy(vibrationEnabled = enabled) } }
|
||||
|
||||
@@ -113,6 +116,8 @@ class NotificationPrefsViewModel @Inject constructor(
|
||||
|
||||
R.id.wake -> wake.set(!wake.get())
|
||||
|
||||
R.id.silentNotContact -> prefs.silentNotContact.set(!prefs.silentNotContact.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