Skip to content

Commit

Permalink
Disable scheduling of voice note messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
clark-signal authored and greyson-signal committed Jan 27, 2023
1 parent 834283b commit b94f550
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class SendButton(context: Context, attributeSet: AttributeSet?) : AppCompatImage

val scheduleListener = scheduledSendListener
if (availableSendTypes.size == 1) {
return if (scheduleListener != null) {
return if (scheduleListener?.canSchedule() == true) {
scheduleListener.onSendScheduled()
true
} else if (!SignalStore.misc().smsExportPhase.allowSmsFeatures()) {
Expand Down Expand Up @@ -202,7 +202,7 @@ class SendButton(context: Context, attributeSet: AttributeSet?) : AppCompatImage
action = { setSendType(option) }
)
}.toMutableList()
if (allowScheduling && listener != null) {
if (allowScheduling && listener?.canSchedule() == true) {
items += ActionItem(
iconRes = R.drawable.ic_calendar_24,
title = context.getString(R.string.conversation_activity__option_schedule_message),
Expand All @@ -222,5 +222,6 @@ class SendButton(context: Context, attributeSet: AttributeSet?) : AppCompatImage

interface ScheduledSendListener {
fun onSendScheduled()
fun canSchedule(): Boolean
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2086,15 +2086,23 @@ private void initializeViews(View view) {
attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
sendButton.setOnClickListener(sendButtonListener);
if (FeatureFlags.scheduledMessageSends()) {
sendButton.setScheduledSendListener(() -> {
ScheduleMessageContextMenu.show(sendButton, (ViewGroup) requireView(), time -> {
if (time == -1) {
ScheduleMessageTimePickerBottomSheet.showSchedule(getChildFragmentManager());
} else {
sendMessage(null, time);
}
return Unit.INSTANCE;
});
sendButton.setScheduledSendListener(new SendButton.ScheduledSendListener() {
@Override
public void onSendScheduled() {
ScheduleMessageContextMenu.show(sendButton, (ViewGroup) requireView(), time -> {
if (time == -1) {
ScheduleMessageTimePickerBottomSheet.showSchedule(getChildFragmentManager());
} else {
sendMessage(null, time);
}
return Unit.INSTANCE;
});
}

@Override
public boolean canSchedule() {
return !(inputPanel.isRecordingInLockedMode() || draftViewModel.getVoiceNoteDraft() != null);
}
});
}
sendButton.setEnabled(true);
Expand Down

0 comments on commit b94f550

Please sign in to comment.