forked from upstream-mirrors/quik
Enable shortcuts usage for android conversations features
This commit is contained in:
@@ -93,6 +93,7 @@ class ReceiveSms @Inject constructor(
|
|||||||
// update shortcuts
|
// update shortcuts
|
||||||
Timber.v("update shortcuts")
|
Timber.v("update shortcuts")
|
||||||
shortcutManager.updateShortcuts()
|
shortcutManager.updateShortcuts()
|
||||||
|
shortcutManager.reportShortcutUsed(it.id)
|
||||||
|
|
||||||
// update the badge and widget
|
// update the badge and widget
|
||||||
Timber.v("update badge and widget")
|
Timber.v("update badge and widget")
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package dev.octoshrimpy.quik.interactor
|
package dev.octoshrimpy.quik.interactor
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import dev.octoshrimpy.quik.manager.ShortcutManager
|
||||||
import dev.octoshrimpy.quik.model.Attachment
|
import dev.octoshrimpy.quik.model.Attachment
|
||||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||||
import dev.octoshrimpy.quik.repository.MessageRepository
|
import dev.octoshrimpy.quik.repository.MessageRepository
|
||||||
@@ -29,7 +30,8 @@ class SendMessage @Inject constructor(
|
|||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val conversationRepo: ConversationRepository,
|
private val conversationRepo: ConversationRepository,
|
||||||
private val messageRepo: MessageRepository,
|
private val messageRepo: MessageRepository,
|
||||||
private val updateBadge: UpdateBadge
|
private val updateBadge: UpdateBadge,
|
||||||
|
private val shortcutManager: ShortcutManager
|
||||||
) : Interactor<SendMessage.Params>() {
|
) : Interactor<SendMessage.Params>() {
|
||||||
|
|
||||||
data class Params(
|
data class Params(
|
||||||
@@ -62,6 +64,8 @@ class SendMessage @Inject constructor(
|
|||||||
|
|
||||||
conversationRepo.markUnarchived(threadId)
|
conversationRepo.markUnarchived(threadId)
|
||||||
|
|
||||||
|
shortcutManager.reportShortcutUsed(threadId)
|
||||||
|
|
||||||
// delete attachment local files, if any, because they're saved to mms db by now
|
// delete attachment local files, if any, because they're saved to mms db by now
|
||||||
params.attachments.forEach { it.removeCacheFile() }
|
params.attachments.forEach { it.removeCacheFile() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,20 +30,21 @@ import android.media.AudioAttributes
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.ContactsContract
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.app.Person
|
import androidx.core.app.Person
|
||||||
import androidx.core.app.RemoteInput
|
import androidx.core.app.RemoteInput
|
||||||
import androidx.core.app.TaskStackBuilder
|
import androidx.core.app.TaskStackBuilder
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.graphics.drawable.IconCompat
|
|
||||||
import dev.octoshrimpy.quik.R
|
import dev.octoshrimpy.quik.R
|
||||||
import dev.octoshrimpy.quik.common.util.extensions.dpToPx
|
import dev.octoshrimpy.quik.common.util.extensions.dpToPx
|
||||||
|
import dev.octoshrimpy.quik.common.util.extensions.fromRecipient
|
||||||
|
import dev.octoshrimpy.quik.common.util.extensions.toPerson
|
||||||
import dev.octoshrimpy.quik.extensions.isImage
|
import dev.octoshrimpy.quik.extensions.isImage
|
||||||
import dev.octoshrimpy.quik.feature.compose.ComposeActivity
|
import dev.octoshrimpy.quik.feature.compose.ComposeActivity
|
||||||
import dev.octoshrimpy.quik.feature.qkreply.QkReplyActivity
|
import dev.octoshrimpy.quik.feature.qkreply.QkReplyActivity
|
||||||
import dev.octoshrimpy.quik.manager.PermissionManager
|
import dev.octoshrimpy.quik.manager.PermissionManager
|
||||||
|
import dev.octoshrimpy.quik.manager.ShortcutManager
|
||||||
import dev.octoshrimpy.quik.mapper.CursorToPartImpl
|
import dev.octoshrimpy.quik.mapper.CursorToPartImpl
|
||||||
import dev.octoshrimpy.quik.receiver.BlockThreadReceiver
|
import dev.octoshrimpy.quik.receiver.BlockThreadReceiver
|
||||||
import dev.octoshrimpy.quik.receiver.DeleteMessagesReceiver
|
import dev.octoshrimpy.quik.receiver.DeleteMessagesReceiver
|
||||||
@@ -73,6 +74,7 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
private val permissions: PermissionManager,
|
private val permissions: PermissionManager,
|
||||||
private val phoneNumberUtils: PhoneNumberUtils,
|
private val phoneNumberUtils: PhoneNumberUtils,
|
||||||
private val contactRepo: ContactRepository,
|
private val contactRepo: ContactRepository,
|
||||||
|
private val shortcutManager: ShortcutManager
|
||||||
) : dev.octoshrimpy.quik.manager.NotificationManager {
|
) : dev.octoshrimpy.quik.manager.NotificationManager {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -184,18 +186,8 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
phoneNumberUtils.compare(recipient.address, message.address)
|
phoneNumberUtils.compare(recipient.address, message.address)
|
||||||
}
|
}
|
||||||
|
|
||||||
person.setName(recipient?.getDisplayName() ?: message.address)
|
if(recipient != null)
|
||||||
person.setIcon(GlideApp.with(context)
|
person.fromRecipient(recipient, context, colors)
|
||||||
.asBitmap()
|
|
||||||
.circleCrop()
|
|
||||||
.load(recipient?.contact?.photoUri)
|
|
||||||
.submit(64.dpToPx(context), 64.dpToPx(context))
|
|
||||||
.let { futureGet -> tryOrNull(false) { futureGet.get() } }
|
|
||||||
?.let(IconCompat::createWithBitmap))
|
|
||||||
|
|
||||||
recipient?.contact
|
|
||||||
?.let { contact -> "${ContactsContract.Contacts.CONTENT_LOOKUP_URI}/${contact.lookupKey}" }
|
|
||||||
?.let(person::setUri)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCompat.MessagingStyle.Message(message.getSummary(), message.date, person.build()).apply {
|
NotificationCompat.MessagingStyle.Message(message.getSummary(), message.date, person.build()).apply {
|
||||||
@@ -251,7 +243,7 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
// Add all of the people from this conversation to the notification, so that the system can
|
// Add all of the people from this conversation to the notification, so that the system can
|
||||||
// appropriately bypass DND mode
|
// appropriately bypass DND mode
|
||||||
conversation.recipients.forEach { recipient ->
|
conversation.recipients.forEach { recipient ->
|
||||||
notification.addPerson("tel:${recipient.address}")
|
notification.addPerson(recipient.toPerson(context, colors))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the action buttons
|
// Add the action buttons
|
||||||
@@ -341,7 +333,8 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
|
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
val sc = shortcutManager.getShortcut(threadId)
|
||||||
|
notification.setShortcutInfo(sc)
|
||||||
notificationManager.notify(threadId.toInt(), notification.build())
|
notificationManager.notify(threadId.toInt(), notification.build())
|
||||||
|
|
||||||
// Wake screen
|
// Wake screen
|
||||||
@@ -513,4 +506,4 @@ class NotificationManagerImpl @Inject constructor(
|
|||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user