kopia lustrzana https://github.com/ryukoposting/Signal-Android
Show will send immediately warning if scheduled send is in the past.
rodzic
b4c572678c
commit
4ad233c6d1
|
@ -9,6 +9,7 @@ import androidx.fragment.app.FragmentManager
|
|||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.android.material.datepicker.DateValidatorPointForward
|
||||
import com.google.android.material.datepicker.MaterialDatePicker
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.timepicker.MaterialTimePicker
|
||||
import com.google.android.material.timepicker.TimeFormat
|
||||
import org.thoughtcrime.securesms.R
|
||||
|
@ -64,15 +65,14 @@ class ScheduleMessageTimePickerBottomSheet : FixedRoundedCornerBottomSheetDialog
|
|||
scheduledMinute = scheduledLocalDateTime.minute
|
||||
|
||||
binding.scheduleSend.setOnClickListener {
|
||||
dismiss()
|
||||
val messageId = arguments?.getLong(KEY_MESSAGE_ID)
|
||||
if (messageId == null) {
|
||||
findListener<ScheduleCallback>()?.onScheduleSend(getSelectedTimestamp())
|
||||
if (getSelectedTimestamp() < System.currentTimeMillis()) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setMessage(R.string.ScheduleMessageTimePickerBottomSheet__select_time_in_past_dialog_warning)
|
||||
.setPositiveButton(R.string.ScheduleMessageTimePickerBottomSheet__select_time_in_past_dialog_positive_button) { _, _ -> scheduleMessageSend() }
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
} else {
|
||||
val selectedTime = getSelectedTimestamp()
|
||||
if (selectedTime != arguments?.getLong(KEY_INITIAL_TIME)) {
|
||||
findListener<RescheduleCallback>()?.onReschedule(selectedTime, messageId)
|
||||
}
|
||||
scheduleMessageSend()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,19 @@ class ScheduleMessageTimePickerBottomSheet : FixedRoundedCornerBottomSheetDialog
|
|||
binding.timeText.text = scheduledTime.formatHours(requireContext())
|
||||
}
|
||||
|
||||
private fun scheduleMessageSend() {
|
||||
dismissAllowingStateLoss()
|
||||
val messageId = arguments?.getLong(KEY_MESSAGE_ID)
|
||||
if (messageId == null) {
|
||||
findListener<ScheduleCallback>()?.onScheduleSend(getSelectedTimestamp())
|
||||
} else {
|
||||
val selectedTime = getSelectedTimestamp()
|
||||
if (selectedTime != arguments?.getLong(KEY_INITIAL_TIME)) {
|
||||
findListener<RescheduleCallback>()?.onReschedule(selectedTime, messageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ScheduleCallback {
|
||||
fun onScheduleSend(scheduledTime: Long)
|
||||
}
|
||||
|
|
|
@ -660,9 +660,12 @@
|
|||
<string name="ScheduleMessageTimePickerBottomSheet__dialog_title">Schedule message</string>
|
||||
<!-- Text for confirmation button when scheduling messages that allows the user to confirm and schedule the sending time -->
|
||||
<string name="ScheduleMessageTimePickerBottomSheet__schedule_send">Schedule send</string>
|
||||
|
||||
<!-- Disclaimer in message scheduling dialog. %1$s replaced with a GMT offset (e.g. GMT-05:00), and %2$s is replaced with the time zone name (e.g. Eastern Standard Time) -->
|
||||
<string name="ScheduleMessageTimePickerBottomSheet__timezone_disclaimer">All times in (%1$s) %2$s</string>
|
||||
<!-- Warning dialog message text shown when select time for scheduled send is in the past resulting in an immediate send if scheduled. -->
|
||||
<string name="ScheduleMessageTimePickerBottomSheet__select_time_in_past_dialog_warning">Selected time is in the past. This will send the message immediately.</string>
|
||||
<!-- Positive button text for warning dialog shown when scheduled send is in the past -->
|
||||
<string name="ScheduleMessageTimePickerBottomSheet__select_time_in_past_dialog_positive_button">Send immediately</string>
|
||||
|
||||
<!-- Context menu option to send a scheduled message now -->
|
||||
<string name="ScheduledMessagesBottomSheet_menu_send_now">Send now</string>
|
||||
|
|
Ładowanie…
Reference in New Issue