Merge branch 'master' into upgrade-smsmms-group-individual-send-no-wait-appear-delayed-mms-mms-receive-to-worker-send-ack-mmsc

This commit is contained in:
Inhishonor
2025-10-09 18:01:59 -07:00
254 changed files with 2886 additions and 1596 deletions
@@ -20,10 +20,10 @@ package dev.octoshrimpy.quik.experiment
import android.content.Context
import android.preference.PreferenceManager
import dev.octoshrimpy.quik.manager.AnalyticsManager
import java.util.*
import java.util.Locale
import java.util.Random
abstract class Experiment<T>(val context: Context, val analytics: AnalyticsManager) {
abstract class Experiment<T>(val context: Context) {
private val prefs by lazy { PreferenceManager.getDefaultSharedPreferences(context) }
private val prefKey: String
@@ -48,7 +48,6 @@ abstract class Experiment<T>(val context: Context, val analytics: AnalyticsManag
else -> { // Variant hasn't been set yet
variants[Random().nextInt(variants.size)].also { variant ->
analytics.setUserProperty("Experiment: $key", variant.key)
prefs.edit().putString(prefKey, variant.key).apply()
}.value
}
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.interactor
import android.annotation.SuppressLint
import android.content.Context
import android.net.Uri
import androidx.core.net.toUri
import dev.octoshrimpy.quik.extensions.getName
import dev.octoshrimpy.quik.extensions.getResourceBytes
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
@@ -42,7 +43,8 @@ class AddScheduledMessage @Inject constructor(
val recipients: List<String>,
val sendAsGroup: Boolean,
val body: String,
val attachments: List<Uri>
val attachments: List<Uri>,
val conversationId: Long
)
@SuppressLint("Range")
@@ -52,7 +54,13 @@ class AddScheduledMessage @Inject constructor(
.map { // step 1 - save, without attachments, to db to get primary key id which is
// needed for building the save file location dir name in step 2
scheduledMessageRepo.saveScheduledMessage(
it.date, it.subId, it.recipients, it.sendAsGroup, it.body, listOf()
it.date,
it.subId,
it.recipients,
it.sendAsGroup,
it.body,
listOf(),
it.conversationId
)
}
.map { scheduledMessage ->
@@ -86,5 +94,4 @@ class AddScheduledMessage @Inject constructor(
}
.flatMap { updateScheduledMessageAlarms.buildObservable(Unit) }
}
}
}
@@ -21,6 +21,7 @@ package dev.octoshrimpy.quik.interactor
import android.content.Context
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
import io.reactivex.Flowable
import timber.log.Timber
import java.io.File
import javax.inject.Inject
@@ -39,11 +40,12 @@ class DeleteScheduledMessages @Inject constructor(
val topDir = File(context.filesDir, "scheduled-${scheduledMessageId}")
topDir.exists() && topDir.deleteRecursively()
}
} catch (e: Exception) { /* nothing */ }
} catch (e: Exception) {
Timber.e("Unable to delete scheduled messages.")
}
// delete the db entries
scheduledMessageRepo.deleteScheduledMessages(params)
}
}
}
}
@@ -18,15 +18,22 @@
*/
package dev.octoshrimpy.quik.interactor
import dev.octoshrimpy.quik.manager.NotificationManager
import dev.octoshrimpy.quik.repository.MessageRepository
import io.reactivex.Flowable
import javax.inject.Inject
class SendExistingMessage @Inject constructor(
private val messageRepo: MessageRepository
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager
) : Interactor<Long>() {
override fun buildObservable(params: Long): Flowable<Long> =
Flowable.just(params)
.doOnNext { messageId -> messageRepo.sendMessage(messageId) }
.doOnNext { messageId ->
val message = messageRepo.getMessage(messageId)
messageRepo.sendMessage(messageId)
val threadId = message!!.threadId
notificationManager.cancel(threadId.toInt() + 100000)
}
}
@@ -35,4 +35,6 @@ interface NotificationManager {
fun getNotificationForBackup(): NotificationCompat.Builder
fun cancel(i: Int)
}
@@ -18,7 +18,6 @@
*/
package dev.octoshrimpy.quik.manager
import android.content.pm.ShortcutInfo
import androidx.core.content.pm.ShortcutInfoCompat
interface ShortcutManager {
@@ -19,7 +19,9 @@
package dev.octoshrimpy.quik.mapper
import android.database.Cursor
import android.provider.Telephony.*
import android.provider.Telephony.Mms
import android.provider.Telephony.MmsSms
import android.provider.Telephony.Sms
import dev.octoshrimpy.quik.model.Message
import timber.log.Timber
@@ -31,6 +31,7 @@ open class Conversation(
var recipients: RealmList<Recipient> = RealmList(),
var lastMessage: Message? = null,
var draft: String = "",
var draftDate: Long = 0,
var blockingClient: Int? = null,
var blockReason: String? = null,
@@ -40,7 +41,7 @@ open class Conversation(
var sendAsGroup: Boolean = false,
) : RealmObject() {
val date: Long get() = lastMessage?.date ?: 0
val date: Long get() = lastMessage?.date ?: if (draft.isNotEmpty()) draftDate else 0
val snippet: String? get() = lastMessage?.getSummary()
val unread: Boolean get() = lastMessage?.read == false
val me: Boolean get() = lastMessage?.isMe() == true
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2025
*
* This file is part of QUIK.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.model
import io.realm.RealmObject
import io.realm.annotations.Index
import io.realm.annotations.PrimaryKey
open class EmojiReaction : RealmObject() {
@PrimaryKey var id: Long = 0
/** The reaction message ID itself */
@Index var reactionMessageId: Long = 0
/** The sender's address (phone number) */
var senderAddress: String = ""
/** The emoji used in the reaction */
var emoji: String = ""
/** The original message text that was reacted to */
var originalMessageText: String = ""
/** Thread ID for easier querying */
@Index var threadId: Long = 0
}
@@ -0,0 +1,25 @@
/*
* Copyright (C) 2025
*
* This file is part of QUIK.
*
* QUIK is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QUIK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QUIK. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.model
import io.realm.RealmObject
open class EmojiSyncNeeded : RealmObject() {
var createdAt: Long = System.currentTimeMillis()
}
@@ -20,7 +20,9 @@ package dev.octoshrimpy.quik.model
import android.content.ContentUris
import android.net.Uri
import android.provider.Telephony.*
import android.provider.Telephony.Mms
import android.provider.Telephony.MmsSms
import android.provider.Telephony.Sms
import dev.octoshrimpy.quik.extensions.joinTo
import io.realm.RealmList
import io.realm.RealmObject
@@ -76,6 +78,8 @@ open class Message : RealmObject() {
var subject: String = ""
var textContentType: String = ""
var parts: RealmList<MmsPart> = RealmList()
var isEmojiReaction: Boolean = false
val emojiReactions: RealmList<EmojiReaction> = RealmList()
var sendAsGroup: Boolean = false
@@ -0,0 +1,20 @@
package dev.octoshrimpy.quik.model
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class MessageContentFilter(
@PrimaryKey var id: Long = 0,
var value: String = "",
var caseSensitive: Boolean = false,
var isRegex: Boolean = false,
var includeContacts: Boolean = false
) : RealmObject()
data class MessageContentFilterData(
var value: String = "",
var caseSensitive: Boolean = false,
var isRegex: Boolean = false,
var includeContacts: Boolean = false
)
@@ -21,7 +21,7 @@ package dev.octoshrimpy.quik.model
import android.telephony.PhoneNumberUtils
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
import java.util.Locale
open class Recipient(
@PrimaryKey var id: Long = 0,
@@ -29,7 +29,8 @@ open class ScheduledMessage(
var recipients: RealmList<String> = RealmList(),
var sendAsGroup: Boolean = true,
var body: String = "",
var attachments: RealmList<String> = RealmList()
var attachments: RealmList<String> = RealmList(),
var conversationId: Long = 0
) : RealmObject() {
fun copy(
@@ -39,10 +40,11 @@ open class ScheduledMessage(
recipients: RealmList<String> = this.recipients,
sendAsGroup: Boolean = this.sendAsGroup,
body: String = this.body,
attachments: RealmList<String> = this.attachments
attachments: RealmList<String> = this.attachments,
conversationId: Long = this.conversationId
): ScheduledMessage {
return ScheduledMessage(id, date, subId, recipients, sendAsGroup, body, attachments)
return ScheduledMessage(id, date, subId, recipients, sendAsGroup, body, attachments, conversationId)
}
}
@@ -41,4 +41,6 @@ interface ContactRepository {
fun setDefaultPhoneNumber(lookupKey: String, phoneNumberId: Long)
fun isContact(address: String): Boolean
}
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2025
*
* This file is part of QUIK.
*
* QUIK is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QUIK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QUIK. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.repository
import dev.octoshrimpy.quik.model.Message
import io.realm.Realm
data class ParsedEmojiReaction(val emoji: String, val originalMessage: String, val isRemoval: Boolean = false)
interface EmojiReactionRepository {
fun parseEmojiReaction(body: String): ParsedEmojiReaction?
fun findTargetMessage(threadId: Long, originalMessageText: String, realm: Realm): Message?
fun saveEmojiReaction(
reactionMessage: Message,
parsedReaction: ParsedEmojiReaction,
targetMessage: Message?,
realm: Realm,
)
fun deleteAndReparseAllEmojiReactions(realm: Realm)
}
@@ -16,12 +16,22 @@
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.manager
package dev.octoshrimpy.quik.repository
interface AnalyticsManager {
import dev.octoshrimpy.quik.model.MessageContentFilter
import dev.octoshrimpy.quik.model.MessageContentFilterData
import io.realm.RealmResults
fun track(event: String, vararg properties: Pair<String, Any>)
interface MessageContentFilterRepository {
fun setUserProperty(key: String, value: Any)
fun createFilter(data: MessageContentFilterData)
}
fun getMessageContentFilters(): RealmResults<MessageContentFilter>
fun getMessageContentFilter(id: Long): MessageContentFilter?
fun isBlocked(messageBody: String, address: String, contactsRepo: ContactRepository): Boolean
fun removeFilter(id: Long)
}
@@ -18,7 +18,9 @@
*/
package dev.octoshrimpy.quik.repository
import dev.octoshrimpy.quik.model.Recipient
import dev.octoshrimpy.quik.model.ScheduledMessage
import io.realm.RealmList
import io.realm.RealmResults
interface ScheduledMessageRepository {
@@ -32,9 +34,13 @@ interface ScheduledMessageRepository {
recipients: List<String>,
sendAsGroup: Boolean,
body: String,
attachments: List<String>
attachments: List<String>,
conversationId: Long
): ScheduledMessage
/**
* Updates scheduled messages with new uris
*/
fun updateScheduledMessage(scheduledMessage: ScheduledMessage)
/**
@@ -47,15 +53,24 @@ interface ScheduledMessageRepository {
*/
fun getScheduledMessage(id: Long): ScheduledMessage?
/**
* Returns all scheduled messages with the given [conversationId]
*/
fun getScheduledMessagesForConversation(conversationId: Long): RealmResults<ScheduledMessage>
/**
* Deletes the scheduled message with the given [id]
*/
fun deleteScheduledMessage(id: Long)
// delete multiple scheduled messages by id list
/**
* Delete multiple scheduled messages by id list
*/
fun deleteScheduledMessages(ids: List<Long>)
// get a list of all scheduled message ids (in scheduled date order)
/**
* Get a list of all scheduled message ids (in scheduled date order)
*/
fun getAllScheduledMessageIdsSnapshot(): List<Long>
}
}