Skip to content

Commit 5256a44

Browse files
authored
Merge pull request #5841 from nextcloud/fix/rescheduleNotifications
Able to reschedule messages with or without notifications
2 parents 6fb9e59 + f24281f commit 5256a44

2 files changed

Lines changed: 33 additions & 15 deletions

File tree

app/src/main/java/com/nextcloud/talk/chat/ScheduledMessagesActivity.kt

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import androidx.compose.foundation.lazy.items
3737
import androidx.compose.foundation.shape.RoundedCornerShape
3838
import androidx.compose.material.icons.Icons
3939
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
40+
import androidx.compose.material.icons.automirrored.outlined.ScheduleSend
4041
import androidx.compose.material.icons.automirrored.outlined.Send
41-
import androidx.compose.material.icons.outlined.AccessTime
4242
import androidx.compose.material.icons.outlined.Check
4343
import androidx.compose.material.icons.outlined.Close
4444
import androidx.compose.material.icons.outlined.ContentCopy
@@ -170,8 +170,8 @@ class ScheduledMessagesActivity : BaseActivity() {
170170
onSendNow = { message ->
171171
sendNow(message, user)
172172
},
173-
onReschedule = { message, sendAt ->
174-
reschedule(message, sendAt, user)
173+
onReschedule = { message, sendAt, sendWithoutNotification ->
174+
reschedule(message, sendAt, sendWithoutNotification, user)
175175
},
176176
onEdit = { message, sendAt ->
177177
edit(message, sendAt, user)
@@ -228,7 +228,7 @@ class ScheduledMessagesActivity : BaseActivity() {
228228
)
229229
}
230230

231-
private fun reschedule(message: ChatMessage, sendAt: Int, user: User) {
231+
private fun reschedule(message: ChatMessage, sendAt: Int, sendWithoutNotification: Boolean, user: User) {
232232
scheduledMessagesViewModel.reschedule(
233233
credentials = user.getCredentials(),
234234
url = ApiUtils.getUrlForScheduledMessage(
@@ -238,7 +238,7 @@ class ScheduledMessagesActivity : BaseActivity() {
238238
),
239239
message = message.message.orEmpty(),
240240
sendAt = sendAt,
241-
sendWithoutNotification = message.silent
241+
sendWithoutNotification = sendWithoutNotification
242242
)
243243
}
244244

@@ -289,7 +289,7 @@ class ScheduledMessagesActivity : BaseActivity() {
289289
onBack: () -> Unit,
290290
onLoadScheduledMessages: () -> Unit,
291291
onSendNow: (ChatMessage) -> Unit,
292-
onReschedule: (ChatMessage, Int) -> Unit,
292+
onReschedule: (ChatMessage, Int, Boolean) -> Unit,
293293
onEdit: (ChatMessage, Int) -> Unit,
294294
onDeleteScheduledMessage: (ChatMessage) -> Unit,
295295
onOpenParentMessage: (Long?) -> Unit,
@@ -313,6 +313,8 @@ class ScheduledMessagesActivity : BaseActivity() {
313313
var originalEditText by remember { mutableStateOf("") }
314314
var editValue by remember { mutableStateOf(TextFieldValue("")) }
315315

316+
var rescheduleWithoutNotification by remember { mutableStateOf(false) }
317+
316318
LaunchedEffect(Unit) { onLoadScheduledMessages() }
317319

318320
LaunchedEffect(sendNowState) {
@@ -478,7 +480,9 @@ class ScheduledMessagesActivity : BaseActivity() {
478480
)
479481
}
480482
}
483+
481484
val parentMessage = parentId?.let { parentMessages[it] }
485+
482486
val linkPreview = message.token?.let { linkPreviews[it] }
483487
ScheduledMessageBubble(
484488
message = message,
@@ -550,7 +554,13 @@ class ScheduledMessagesActivity : BaseActivity() {
550554
) {
551555
ScheduledMessageActionsSheet(
552556
scheduledTime = selectedTime,
553-
onReschedule = {
557+
onRescheduleWithNotification = {
558+
rescheduleWithoutNotification = false
559+
showScheduleDialogFor = selectedMessage
560+
showActionsSheet = false
561+
},
562+
onRescheduleWithoutNotification = {
563+
rescheduleWithoutNotification = true
554564
showScheduleDialogFor = selectedMessage
555565
showActionsSheet = false
556566
},
@@ -598,12 +608,12 @@ class ScheduledMessagesActivity : BaseActivity() {
598608
shouldDismiss.value = true
599609
showScheduleDialogFor = null
600610
},
601-
onSchedule = { scheduledTime, _ ->
602-
onReschedule(message, scheduledTime.toInt())
611+
onSchedule = { scheduledTime, sendWithoutNotification ->
612+
onReschedule(message, scheduledTime.toInt(), sendWithoutNotification)
603613
shouldDismiss.value = true
604614
showScheduleDialogFor = null
605615
},
606-
defaultSendWithoutNotification = message.silent
616+
defaultSendWithoutNotification = rescheduleWithoutNotification
607617
).GetScheduleDialog(shouldDismiss, LocalContext.current)
608618
}
609619
}
@@ -1053,7 +1063,8 @@ class ScheduledMessagesActivity : BaseActivity() {
10531063
@Composable
10541064
private fun ScheduledMessageActionsSheet(
10551065
scheduledTime: String,
1056-
onReschedule: () -> Unit,
1066+
onRescheduleWithNotification: () -> Unit,
1067+
onRescheduleWithoutNotification: () -> Unit,
10571068
onSendNow: () -> Unit,
10581069
onEdit: () -> Unit,
10591070
onDelete: () -> Unit,
@@ -1085,10 +1096,16 @@ class ScheduledMessagesActivity : BaseActivity() {
10851096
text = stringResource(R.string.nc_copy_message),
10861097
onClick = onCopy
10871098
)
1099+
1100+
ActionRow(
1101+
icon = Icons.AutoMirrored.Outlined.ScheduleSend,
1102+
text = stringResource(R.string.nc_reschedule_message_with_notification),
1103+
onClick = onRescheduleWithNotification
1104+
)
10881105
ActionRow(
1089-
icon = Icons.Outlined.AccessTime,
1090-
text = stringResource(R.string.nc_reschedule_message),
1091-
onClick = onReschedule
1106+
icon = Icons.AutoMirrored.Outlined.ScheduleSend,
1107+
text = stringResource(R.string.nc_reschedule_message_without_notification),
1108+
onClick = onRescheduleWithoutNotification
10921109
)
10931110
ActionRow(
10941111
icon = Icons.AutoMirrored.Outlined.Send,

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ How to translate with transifex:
926926
<string name="nc_message_scheduled">Message scheduled</string>
927927
<string name="nc_message_scheduled_at">Message scheduled for %1$s</string>
928928
<string name="nc_scheduled_time">Scheduled time</string>
929-
<string name="nc_reschedule_message">Reschedule</string>
929+
<string name="nc_reschedule_message_with_notification">Reschedule with notification</string>
930+
<string name="nc_reschedule_message_without_notification">Reschedule without notification</string>
930931
<string name="nc_send_now">Send now</string>
931932
<string name="nc_schedule_message_title">Schedule message</string>
932933
<string name="nc_scheduled_messages_empty">No scheduled messages</string>

0 commit comments

Comments
 (0)