forked from upstream-mirrors/quik
#848 - App shortcuts support
This commit is contained in:
@@ -22,6 +22,7 @@ import android.telephony.SmsMessage
|
||||
import com.moez.QKSMS.extensions.mapNotNull
|
||||
import com.moez.QKSMS.manager.ExternalBlockingManager
|
||||
import com.moez.QKSMS.manager.NotificationManager
|
||||
import com.moez.QKSMS.manager.ShortcutManager
|
||||
import com.moez.QKSMS.repository.ConversationRepository
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
@@ -33,7 +34,8 @@ class ReceiveSms @Inject constructor(
|
||||
private val externalBlockingManager: ExternalBlockingManager,
|
||||
private val messageRepo: MessageRepository,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val updateBadge: UpdateBadge
|
||||
private val updateBadge: UpdateBadge,
|
||||
private val shortcutManager: ShortcutManager
|
||||
) : Interactor<ReceiveSms.Params>() {
|
||||
|
||||
class Params(val subId: Int, val messages: Array<SmsMessage>)
|
||||
@@ -63,6 +65,7 @@ class ReceiveSms @Inject constructor(
|
||||
.map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread
|
||||
.delay(1, TimeUnit.SECONDS) // Wait one second before trying to notify, in case the foreground app marks it as read first
|
||||
.doOnNext { threadId -> notificationManager.update(threadId) } // Update the notification
|
||||
.doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts
|
||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||
}
|
||||
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
*/
|
||||
package com.moez.QKSMS.interactor
|
||||
|
||||
import com.moez.QKSMS.manager.ShortcutManager
|
||||
import com.moez.QKSMS.manager.WidgetManager
|
||||
import com.moez.QKSMS.repository.MessageRepository
|
||||
import io.reactivex.Flowable
|
||||
import javax.inject.Inject
|
||||
|
||||
class UpdateBadge @Inject constructor(
|
||||
private val messageRepo: MessageRepository,
|
||||
private val shortcutManager: ShortcutManager,
|
||||
private val widgetManager: WidgetManager
|
||||
) : Interactor<Unit>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<*> {
|
||||
return Flowable.just(params)
|
||||
.map { messageRepo.getUnreadCount() }
|
||||
.map { count -> count.toInt() }
|
||||
.doOnNext { count -> widgetManager.updateUnreadCount(count) }
|
||||
.doOnNext { shortcutManager.updateBadge() }
|
||||
.doOnNext { widgetManager.updateUnreadCount() }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user