mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-23 06:08:52 +01:00
Merge pull request #624 from Inhishonor/delayed-sending-icon
Fix the delayed sending icons not disappearing after hitting send
This commit is contained in:
@@ -767,6 +767,20 @@ open class MessageRepositoryImpl @Inject constructor(
|
|||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun markAsSendingNow(messageId: Long) =
|
||||||
|
Realm.getDefaultInstance().use { realm ->
|
||||||
|
realm.refresh()
|
||||||
|
realm.where(Message::class.java)
|
||||||
|
.equalTo("id", messageId)
|
||||||
|
.findFirst()
|
||||||
|
?.let { message ->
|
||||||
|
realm.executeTransaction {
|
||||||
|
message.date = System.currentTimeMillis()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the message as sending, in case we need to retry sending it
|
* Marks the message as sending, in case we need to retry sending it
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ActionDelayedMessage @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Action.Send -> {
|
Action.Send -> {
|
||||||
|
messageRepo.markAsSendingNow(message.id)
|
||||||
updateConversations.addAll(
|
updateConversations.addAll(
|
||||||
messageRepo.sendMessage(message).map { it.threadId }
|
messageRepo.sendMessage(message).map { it.threadId }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ 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
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -70,11 +71,14 @@ class SendNewMessage @Inject constructor(
|
|||||||
conversationRepo.updateConversations(threadIds)
|
conversationRepo.updateConversations(threadIds)
|
||||||
conversationRepo.markUnarchived(threadIds)
|
conversationRepo.markUnarchived(threadIds)
|
||||||
|
|
||||||
threadIds.forEach { threadId -> shortcutManager.reportShortcutUsed(threadId) }
|
AndroidSchedulers.mainThread().scheduleDirect {
|
||||||
|
threadIds.forEach { shortcutManager.reportShortcutUsed(it) }
|
||||||
|
}
|
||||||
|
|
||||||
// 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() }
|
||||||
}
|
}
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the widget
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the widget
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -88,4 +88,5 @@ interface MessageRepository {
|
|||||||
|
|
||||||
fun deleteOldMessages(maxAgeDays: Int)
|
fun deleteOldMessages(maxAgeDays: Int)
|
||||||
|
|
||||||
|
fun markAsSendingNow(messageId: Long)
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-6
@@ -6,6 +6,7 @@ import android.graphics.Bitmap
|
|||||||
import android.graphics.Path
|
import android.graphics.Path
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View.GONE
|
import android.view.View.GONE
|
||||||
@@ -28,11 +29,12 @@ import timber.log.Timber
|
|||||||
|
|
||||||
fun Recipient.getThemedIcon(context: Context, theme: Colors.Theme, width: Int, height: Int): IconCompat {
|
fun Recipient.getThemedIcon(context: Context, theme: Colors.Theme, width: Int, height: Int): IconCompat {
|
||||||
var icon : IconCompat? = null
|
var icon : IconCompat? = null
|
||||||
if(contact != null) {
|
val photoUri = contact?.photoUri
|
||||||
|
if (photoUri != null) {
|
||||||
val req = GlideApp.with(context)
|
val req = GlideApp.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.load(contact!!.photoUri)
|
.load(photoUri)
|
||||||
.submit(width, height)
|
.submit(width, height)
|
||||||
|
|
||||||
val bitmap = tryOrNull { req.get() }
|
val bitmap = tryOrNull { req.get() }
|
||||||
@@ -41,11 +43,12 @@ fun Recipient.getThemedIcon(context: Context, theme: Colors.Theme, width: Int, h
|
|||||||
else
|
else
|
||||||
icon = IconCompat.createWithBitmap(bitmap)
|
icon = IconCompat.createWithBitmap(bitmap)
|
||||||
}
|
}
|
||||||
if(icon == null) {
|
if (icon == null) {
|
||||||
// If there is no contact or no photo, create the default icon using the avatar_view layout
|
// If there is no contact or no photo, create the default icon using the avatar_view layout
|
||||||
try {
|
try {
|
||||||
val inflater = LayoutInflater.from(context)
|
val themedContext = ContextThemeWrapper(context, R.style.AppTheme)
|
||||||
val container = FrameLayout(context)
|
val inflater = LayoutInflater.from(themedContext)
|
||||||
|
val container = FrameLayout(themedContext)
|
||||||
container.layoutParams = FrameLayout.LayoutParams(width, height)
|
container.layoutParams = FrameLayout.LayoutParams(width, height)
|
||||||
val view = inflater.inflate(R.layout.avatar_view, container)
|
val view = inflater.inflate(R.layout.avatar_view, container)
|
||||||
val textView = view.findViewById<QkTextView>(R.id.initial)
|
val textView = view.findViewById<QkTextView>(R.id.initial)
|
||||||
@@ -61,7 +64,7 @@ fun Recipient.getThemedIcon(context: Context, theme: Colors.Theme, width: Int, h
|
|||||||
iconView.layoutParams = FrameLayout.LayoutParams((width * 0.5).toInt(), (height * 0.5).toInt(),
|
iconView.layoutParams = FrameLayout.LayoutParams((width * 0.5).toInt(), (height * 0.5).toInt(),
|
||||||
Gravity.CENTER)
|
Gravity.CENTER)
|
||||||
|
|
||||||
if(contact != null) {
|
if (contact != null) {
|
||||||
val initials = contact!!.name
|
val initials = contact!!.name
|
||||||
.substringBefore(',')
|
.substringBefore(',')
|
||||||
.split(" ")
|
.split(" ")
|
||||||
|
|||||||
Reference in New Issue
Block a user