mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
add delay send mms. add group send to individual recipients - sms and mms. add immediate show messages in convo, not wait for sent. new qktransaction that replaces android/smsmms transaction with mods for quik. lots of code cleanups and removing superfluous code. some bug fixes.
This commit is contained in:
@@ -6,13 +6,11 @@ import android.app.job.JobParameters
|
||||
import android.app.job.JobService
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import androidx.core.content.getSystemService
|
||||
import dev.octoshrimpy.quik.common.util.extensions.jobScheduler
|
||||
import dev.octoshrimpy.quik.interactor.DeleteOldMessages
|
||||
import dagger.android.AndroidInjection
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import kotlinx.coroutines.Job
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
@@ -20,13 +18,13 @@ import javax.inject.Inject
|
||||
class AutoDeleteService : JobService() {
|
||||
|
||||
companion object {
|
||||
private const val JobId = 8120235
|
||||
private const val JOB_ID = 8120235
|
||||
|
||||
@SuppressLint("MissingPermission") // Added in [presentation]'s AndroidManifest.xml
|
||||
fun scheduleJob(context: Context) {
|
||||
Timber.i("Scheduling job")
|
||||
val serviceComponent = ComponentName(context, AutoDeleteService::class.java)
|
||||
val periodicJob = JobInfo.Builder(JobId, serviceComponent)
|
||||
val periodicJob = JobInfo.Builder(JOB_ID, serviceComponent)
|
||||
.setPeriodic(TimeUnit.DAYS.toMillis(1))
|
||||
.setPersisted(true)
|
||||
.build()
|
||||
@@ -36,7 +34,7 @@ class AutoDeleteService : JobService() {
|
||||
|
||||
fun cancelJob(context: Context) {
|
||||
Timber.i("Canceling job")
|
||||
context.jobScheduler.cancel(JobId)
|
||||
context.jobScheduler.cancel(JOB_ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,25 +22,27 @@ import android.app.IntentService
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.telephony.TelephonyManager
|
||||
import dev.octoshrimpy.quik.interactor.SendMessage
|
||||
import dev.octoshrimpy.quik.interactor.SendNewMessage
|
||||
import dev.octoshrimpy.quik.repository.ConversationRepository
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class HeadlessSmsSendService : IntentService("HeadlessSmsSendService") {
|
||||
|
||||
@Inject lateinit var conversationRepo: ConversationRepository
|
||||
@Inject lateinit var sendMessage: SendMessage
|
||||
@Inject lateinit var sendNewMessage: SendNewMessage
|
||||
|
||||
override fun onHandleIntent(intent: Intent?) {
|
||||
if (intent?.action != TelephonyManager.ACTION_RESPOND_VIA_MESSAGE) return
|
||||
|
||||
AndroidInjection.inject(this)
|
||||
intent.extras?.getString(Intent.EXTRA_TEXT)?.takeIf { it.isNotBlank() }?.let { body ->
|
||||
val intentUri = intent.data
|
||||
val recipients = intentUri?.let(::getRecipients)?.split(";") ?: return@let
|
||||
val threadId = conversationRepo.getOrCreateConversation(recipients)?.id ?: 0L
|
||||
sendMessage.execute(SendMessage.Params(-1, threadId, recipients, body))
|
||||
val recipients = intent.data?.let(::getRecipients)?.split(";") ?: return@let
|
||||
|
||||
val conversation = conversationRepo.getOrCreateConversation(recipients)
|
||||
|
||||
sendNewMessage.execute(SendNewMessage.Params(
|
||||
-1, 0, recipients, body, conversation?.sendAsGroup ?: false
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user