changes to allow editing of scheduled messages

This commit is contained in:
gavine99
2025-02-20 08:16:53 +11:00
parent ff5bafb00c
commit 1986f76356
8 changed files with 134 additions and 15 deletions
@@ -81,9 +81,24 @@ class ComposeActivityModule {
@Provides
@Named("mode")
fun provideSharedAction(activity: ComposeActivity): String {
return activity.intent.getStringExtra("mode") ?: "";
}
fun provideSharedAction(activity: ComposeActivity): String =
activity.intent.getStringExtra("mode") ?: ""
@Provides
@Named("subscriptionId")
fun provideSubscriptionId(activity: ComposeActivity): Int =
activity.intent.getIntExtra("subscriptionId", -1)
@Provides
@Named("sendAsGroup")
fun provideSendAsGroup(activity: ComposeActivity): Boolean? =
if (!activity.intent.hasExtra("sendAsGroup")) null
else activity.intent.getBooleanExtra("sendAsGroup", false)
@Provides
@Named("scheduleDateTime")
fun provideSharedScheduleDateTime(activity: ComposeActivity): Long =
activity.intent.getLongExtra("scheduleDateTime", 0L)
@Provides
@IntoMap
@@ -91,8 +91,11 @@ class ComposeViewModel @Inject constructor(
@Named("threadId") private val threadId: Long,
@Named("addresses") private val addresses: List<String>,
@Named("text") private val sharedText: String,
@Named("attachments") private val sharedAttachments: List<Attachment>,
@Named("attachments") val sharedAttachments: List<Attachment>,
@Named("mode") private val mode: String,
@Named("subscriptionId") val sharedSubscriptionId: Int,
@Named("sendAsGroup") val sharedSendAsGroup: Boolean?,
@Named("scheduleDateTime") val sharedScheduledDateTime: Long,
private val contactRepo: ContactRepository,
private val context: Context,
private val activeConversationManager: ActiveConversationManager,
@@ -134,7 +137,20 @@ class ComposeViewModel @Inject constructor(
private var bluetoothMicManager: BluetoothMicManager? = null
init {
// set shared attachments into state, if any
// set shared subscription into state if set
subscriptionManager.activeSubscriptionInfoList.firstOrNull {
it.subscriptionId == sharedSubscriptionId
}?.let { newState { copy(subscription = it)} }
// set shared scheduled datetime into state if set
if (sharedScheduledDateTime != 0L)
newState { copy (scheduled = sharedScheduledDateTime) }
// set shared sendAsGroup into state if set
if (sharedSendAsGroup != null)
newState { copy(sendAsGroup = sharedSendAsGroup) }
// set shared attachments into state
newState { copy(attachments = sharedAttachments) }
val initialConversation = threadId.takeIf { it != 0L }