forked from upstream-mirrors/quik
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:
@@ -25,9 +25,9 @@ import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.moez.QKSMS.util.Constants
|
||||
import com.moez.QKSMS.manager.MediaRecorderManager
|
||||
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
|
||||
import dev.octoshrimpy.quik.util.Constants
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
@@ -77,6 +77,8 @@ class HousekeepingWorker(appContext: Context, workerParams: WorkerParameters)
|
||||
|
||||
removeSavedMessagesTexts(twoHoursAgo)
|
||||
|
||||
removeOrphanedComposeDelayCancelledAttachments(twoHoursAgo)
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
@@ -87,7 +89,7 @@ class HousekeepingWorker(appContext: Context, workerParams: WorkerParameters)
|
||||
// remove orphaned scheduled message dirs in files dir
|
||||
File(applicationContext.filesDir,"")
|
||||
// get dirs that match prefix 'scheduled-'
|
||||
.listFiles { entry -> entry.isDirectory && entry.name.startsWith("scheduled-") }
|
||||
.listFiles { entry -> entry.isDirectory && entry.name.startsWith(Constants.SCHEDULED_MESSAGE_FILE_PREFIX) }
|
||||
// filter out any dirs that have an associated scheduled message in db
|
||||
?.filterNot {
|
||||
scheduledMessageIds.contains(it.name.substringAfter('-').toLong())
|
||||
@@ -113,4 +115,12 @@ class HousekeepingWorker(appContext: Context, workerParams: WorkerParameters)
|
||||
(entry.lastModified() < removeOlderThan)
|
||||
}?.forEach { it.delete() } // delete message text file
|
||||
|
||||
private fun removeOrphanedComposeDelayCancelledAttachments(removeOlderThan: Long) =
|
||||
// find dirs in cache dir
|
||||
applicationContext.cacheDir.listFiles { entry ->
|
||||
entry.isDirectory &&
|
||||
entry.name.startsWith(Constants.DELAY_CANCELLED_CACHED_ATTACHMENTS_FILE_PREFIX)
|
||||
(entry.lastModified() < removeOlderThan)
|
||||
}?.forEach { it.deleteRecursively() } // recursively delete dir
|
||||
|
||||
}
|
||||
@@ -23,15 +23,16 @@ import androidx.work.ListenableWorker
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerFactory
|
||||
import androidx.work.WorkerParameters
|
||||
import dev.octoshrimpy.quik.interactor.ReceiveMms
|
||||
import dev.octoshrimpy.quik.interactor.ReceiveSms
|
||||
import dev.octoshrimpy.quik.repository.ScheduledMessageRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
class InjectionWorkerFactory @Inject constructor(
|
||||
private val receiveSms: ReceiveSms,
|
||||
private val scheduledMessageRepository: ScheduledMessageRepository
|
||||
)
|
||||
: WorkerFactory() {
|
||||
private val receiveMms: ReceiveMms,
|
||||
private val scheduledMessageRepository: ScheduledMessageRepository,
|
||||
) : WorkerFactory() {
|
||||
override fun createWorker(
|
||||
appContext: Context,
|
||||
workerClassName: String,
|
||||
@@ -44,12 +45,12 @@ class InjectionWorkerFactory @Inject constructor(
|
||||
.newInstance(appContext, workerParameters)
|
||||
|
||||
when (instance) {
|
||||
is HousekeepingWorker -> {
|
||||
is HousekeepingWorker ->
|
||||
instance.scheduledMessageRepository = scheduledMessageRepository
|
||||
}
|
||||
is ReceiveSmsWorker -> {
|
||||
is ReceiveSmsWorker ->
|
||||
instance.receiveSms = receiveSms
|
||||
}
|
||||
is ReceiveMmsWorker ->
|
||||
instance.receiveMms = receiveMms
|
||||
}
|
||||
|
||||
return instance
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.worker
|
||||
|
||||
import android.content.Context
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import dev.octoshrimpy.quik.interactor.ReceiveMms
|
||||
import dev.octoshrimpy.quik.receiver.MmsReceivedReceiver
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class ReceiveMmsWorker(appContext: Context, workerParams: WorkerParameters)
|
||||
: Worker(appContext, workerParams) {
|
||||
companion object {
|
||||
const val INPUT_DATA_SUBSCRIPTION_ID = "subscriptionId"
|
||||
const val INPUT_DATA_EXTRA_FILE_PATH = "filePath"
|
||||
const val INPUT_DATA_EXTRA_LOCATION_URL = "locationUrl"
|
||||
const val INPUT_DATA_EXTRA_MMS_HTTP_STATUS = "mmsHttpStatus"
|
||||
const val INPUT_DATA_EXTRA_URI = "extraUri"
|
||||
}
|
||||
|
||||
@Inject lateinit var receiveMms: ReceiveMms
|
||||
|
||||
override fun doWork(): Result {
|
||||
Timber.v("started")
|
||||
|
||||
|
||||
MmsReceivedReceiver.onReceiveWorker(
|
||||
applicationContext,
|
||||
inputData.getInt(INPUT_DATA_SUBSCRIPTION_ID, -1),
|
||||
inputData.getString(INPUT_DATA_EXTRA_FILE_PATH) ?: "",
|
||||
inputData.getString(INPUT_DATA_EXTRA_LOCATION_URL) ?: "",
|
||||
inputData.getInt(INPUT_DATA_EXTRA_MMS_HTTP_STATUS, 0),
|
||||
inputData.getString(INPUT_DATA_EXTRA_URI) ?: "",
|
||||
receiveMms
|
||||
)
|
||||
|
||||
Timber.v("finished")
|
||||
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user