Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Infomaniak Mail - Android
* Copyright (C) 2026 Infomaniak Network SA
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.mail.ui.alertDialogs

import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.infomaniak.mail.R
import com.infomaniak.mail.databinding.DialogSelectVisibilityReminderBinding
import dagger.hilt.android.qualifiers.ActivityContext
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

@ActivityScoped
class SelectVisibilityReminderDialog @Inject constructor(
@ActivityContext private val activityContext: Context,
) : BaseAlertDialog(activityContext) {
private val binding: DialogSelectVisibilityReminderBinding by lazy {
DialogSelectVisibilityReminderBinding.inflate(activity.layoutInflater)
}

override val alertDialog = initDialog()

private var isRecipientsAndMeSelected: Boolean = true

private var onVisibilitySelected: ((Boolean) -> Unit)? = null

private fun initDialog(): AlertDialog {
return MaterialAlertDialogBuilder(activityContext)
.setTitle(R.string.reminderVisibilityTitle)
.setView(binding.root)
.setPositiveButton(R.string.buttonConfirm, null)
.setNegativeButton(com.infomaniak.core.legacy.R.string.buttonCancel, null)
.create()
}

fun show(
selectRecipientsAndMe: Boolean = true,
onVisibilitySelected: (Boolean) -> Unit,
) {
this.onVisibilitySelected = onVisibilitySelected
alertDialog.show()
isRecipientsAndMeSelected = selectRecipientsAndMe
setupRadioGroup(selectRecipientsAndMe)
setupListeners()
}

override fun resetCallbacks() {
onVisibilitySelected = null
}

private fun setupRadioGroup(selectRecipientsAndMe: Boolean) = with(binding) {
val defaultSelection = if (selectRecipientsAndMe) {
R.id.selectionReminderRecipientsAndMe
} else {
R.id.selectionReminderMeOnly
}
reminderVisibilityGroup.check(defaultSelection)
}

private fun setupListeners() {
binding.reminderVisibilityGroup.onItemCheckedListener { id, _, _ ->
isRecipientsAndMeSelected = (id == R.id.selectionReminderRecipientsAndMe)
}

positiveButton.setOnClickListener {
onVisibilitySelected?.invoke(isRecipientsAndMeSelected)
alertDialog.dismiss()
}

negativeButton.setOnClickListener { alertDialog.cancel() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ class NewMessageFragment : Fragment() {

reminderAlert.apply {
onAction1 { navigateToScheduleSendBottomSheet() }
onAction2 { newMessageViewModel.setReminderConfig(ReminderConfig.None) }
onAction2 {
newMessageViewModel.setReminderConfig(ReminderConfig.None)
newMessageViewModel.setShouldRemindRecipient(true)
}
}

recipientFieldsManager.setupAutoCompletionFields()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class NewMessageViewModel @Inject constructor(
private val _reminderConfig = MutableStateFlow<ReminderConfig>(ReminderConfig.None)
val reminderConfig: StateFlow<ReminderConfig> = _reminderConfig.asStateFlow()

private val _shouldRemindRecipient = MutableStateFlow(true)
val shouldRemindRecipient: StateFlow<Boolean> = _shouldRemindRecipient.asStateFlow()

//region Check mailbox existence
private val exitSignal: CompletableJob = Job()

Expand Down Expand Up @@ -1236,7 +1239,10 @@ class NewMessageViewModel @Inject constructor(

updatedMentions
}
}

fun setShouldRemindRecipient(value: Boolean) {
_shouldRemindRecipient.value = value
}

fun setScheduleConfig(config: ScheduleConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.infomaniak.mail.data.models.FeatureFlag
import com.infomaniak.mail.databinding.FragmentSendOptionsBinding
import com.infomaniak.mail.ui.alertDialogs.CustomReminderPickerDialog
import com.infomaniak.mail.ui.alertDialogs.SelectDateAndTimeForScheduledDraftDialog
import com.infomaniak.mail.ui.alertDialogs.SelectVisibilityReminderDialog
import com.infomaniak.mail.ui.bottomSheetDialogs.ScheduleOption
import com.infomaniak.mail.ui.bottomSheetDialogs.ScheduleOptionUtils
import com.infomaniak.mail.ui.main.settings.SettingRadioButtonView
Expand Down Expand Up @@ -70,6 +71,9 @@ class DraftSendOptionsFragment : Fragment() {
@Inject
lateinit var customReminderPickerDialog: CustomReminderPickerDialog

@Inject
lateinit var selectVisibilityDialog: SelectVisibilityReminderDialog

@Inject
lateinit var localSettings: LocalSettings

Expand All @@ -79,13 +83,20 @@ class DraftSendOptionsFragment : Fragment() {
navigationArgs.currentlyScheduledEpochMillis.takeIf { it != 0L }
}

private var shouldRemindRecipient: Boolean
get() = newMessageViewModel.shouldRemindRecipient.value
set(value) {
newMessageViewModel.setShouldRemindRecipient(value)
}
Comment on lines +86 to +90

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the other, it should be a stateFlow in the viewModel that's observed and update the UI accordingly


override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return FragmentSendOptionsBinding.inflate(inflater, container, false).also { binding = it }.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
dateAndTimeScheduleDialog.bindAlertToLifecycle(viewLifecycleOwner)
customReminderPickerDialog.bindAlertToLifecycle(viewLifecycleOwner)
selectVisibilityDialog.bindAlertToLifecycle(viewLifecycleOwner)

setupScheduleOptions()
lastScheduleOption.associatedValue = lastSelectedEpoch?.toString()
Expand All @@ -100,6 +111,11 @@ class DraftSendOptionsFragment : Fragment() {
observeFeatureFlagUpdates()
observeScheduleConfig()
observeReminderConfig()
observeShouldRemindRecipient()
}

private fun observeShouldRemindRecipient() {
newMessageViewModel.shouldRemindRecipient.observe(viewLifecycleOwner) { updateReminderVisibilitySubtitle() }
}

private fun observeFeatureFlagUpdates() = with(binding) {
Expand Down Expand Up @@ -205,6 +221,7 @@ class DraftSendOptionsFragment : Fragment() {
}

customDelayReminder.setOnClickListener { onCustomDelayReminderClicked() }
reminderVisibility.setOnClickListener { showVisibilityReminderPicker() }
}

private fun setReminderOptionsVisible(isVisible: Boolean) {
Expand All @@ -215,11 +232,13 @@ class DraftSendOptionsFragment : Fragment() {
private fun removeReminderOptionsSelection() {
binding.optionsDelays.clearCheck()
newMessageViewModel.setReminderConfig(ReminderConfig.None)
shouldRemindRecipient = true
}

private fun defaultReminderSelection() = with(binding) {
optionsDelays.check(R.id.hours24)
newMessageViewModel.setReminderConfig(ReminderConfig.Delayed(ReminderPreset.HOURS_24.delayMinutes, isCustom = false))
shouldRemindRecipient = true
}

private fun defaultScheduleSelection() = with(binding) {
Expand Down Expand Up @@ -390,4 +409,21 @@ class DraftSendOptionsFragment : Fragment() {
)
}

private fun showVisibilityReminderPicker() {
selectVisibilityDialog.show(
selectRecipientsAndMe = shouldRemindRecipient,
onVisibilitySelected = { isRecipientsAndMe ->
shouldRemindRecipient = isRecipientsAndMe
},
)
}

private fun updateReminderVisibilitySubtitle() = with(binding) {
val subtitleRes = if (shouldRemindRecipient) {
R.string.selectionReminderRecipientsAndMe
} else {
R.string.selectionReminderMeOnly
}
reminderVisibility.setSubtitle(subtitleRes)
}
}
38 changes: 38 additions & 0 deletions app/src/main/res/layout/dialog_select_visibility_reminder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Infomaniak Mail - Android
~ Copyright (C) 2026 Infomaniak Network SA
~
~ This program 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.
~
~ This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
-->
<com.infomaniak.mail.ui.main.settings.SettingRadioGroupView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/reminderVisibilityGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/marginStandardMedium"
android:paddingTop="@dimen/marginStandardMedium">

<com.infomaniak.mail.ui.main.settings.SettingRadioButtonView
android:id="@+id/selectionReminderMeOnly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:text="@string/selectionReminderMeOnly" />

<com.infomaniak.mail.ui.main.settings.SettingRadioButtonView
android:id="@+id/selectionReminderRecipientsAndMe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:text="@string/selectionReminderRecipientsAndMe" />

</com.infomaniak.mail.ui.main.settings.SettingRadioGroupView>
1 change: 1 addition & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Vælg dato</string>
<string name="selectSignatureNone">Ingen signatur</string>
<string name="selectTimeDialogTitle">Vælg tidspunkt</string>
<string name="selectionReminderMeOnly">Kun mig</string>
<string name="selectionReminderRecipientsAndMe">Modtagere og mig</string>
<string name="send">Send</string>
<string name="sendConfirmationAction">Send bekræftelsen</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Datum auswählen</string>
<string name="selectSignatureNone">Keine Unterschrift</string>
<string name="selectTimeDialogTitle">Zeit auswählen</string>
<string name="selectionReminderMeOnly">Nur ich</string>
<string name="selectionReminderRecipientsAndMe">Empfänger und mich</string>
<string name="send">Senden Sie</string>
<string name="sendConfirmationAction">Senden Sie die Bestätigung</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Επιλέξτε ημερομηνία</string>
<string name="selectSignatureNone">Χωρίς υπογραφή</string>
<string name="selectTimeDialogTitle">Επιλέξτε ώρα</string>
<string name="selectionReminderMeOnly">Μόνο εγώ</string>
<string name="selectionReminderRecipientsAndMe">Οι παραλήπτες και εγώ</string>
<string name="send">Αποστολή</string>
<string name="sendConfirmationAction">Αποστολή επιβεβαίωσης</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Seleccione la fecha</string>
<string name="selectSignatureNone">Sin firma</string>
<string name="selectTimeDialogTitle">Seleccionar la hora</string>
<string name="selectionReminderMeOnly">Solo yo</string>
<string name="selectionReminderRecipientsAndMe">Los destinatarios y yo</string>
<string name="send">Enviar</string>
<string name="sendConfirmationAction">Enviar la confirmación</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Valitse päivämäärä</string>
<string name="selectSignatureNone">Ei allekirjoitusta</string>
<string name="selectTimeDialogTitle">Valitse aika</string>
<string name="selectionReminderMeOnly">Vain minä</string>
<string name="selectionReminderRecipientsAndMe">Vastaanottajat ja minä</string>
<string name="send">Lähetä</string>
<string name="sendConfirmationAction">Lähetä vahvistus</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Sélectionner la date</string>
<string name="selectSignatureNone">Aucune signature</string>
<string name="selectTimeDialogTitle">Sélectionner l’heure</string>
<string name="selectionReminderMeOnly">Moi uniquement</string>
<string name="selectionReminderRecipientsAndMe">Les destinataires et moi</string>
<string name="send">Envoyer</string>
<string name="sendConfirmationAction">Envoyer la confirmation</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Selezionare la data</string>
<string name="selectSignatureNone">Nessuna firma</string>
<string name="selectTimeDialogTitle">Selezionare l’ora</string>
<string name="selectionReminderMeOnly">Solo io</string>
<string name="selectionReminderRecipientsAndMe">I destinatari e io</string>
<string name="send">Invia</string>
<string name="sendConfirmationAction">Inviare la conferma</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Velg dato</string>
<string name="selectSignatureNone">Ingen signatur</string>
<string name="selectTimeDialogTitle">Velg tid</string>
<string name="selectionReminderMeOnly">Bare jeg</string>
<string name="selectionReminderRecipientsAndMe">Mottakere og meg</string>
<string name="send">Send</string>
<string name="sendConfirmationAction">Send bekreftelsen</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Datum selecteren</string>
<string name="selectSignatureNone">Geen handtekening</string>
<string name="selectTimeDialogTitle">Tijd selecteren</string>
<string name="selectionReminderMeOnly">Alleen ik</string>
<string name="selectionReminderRecipientsAndMe">Ontvangers en mij</string>
<string name="send">Verzenden</string>
<string name="sendConfirmationAction">De bevestiging verzenden</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@
<string name="selectDateDialogTitle">Wybierz datę</string>
<string name="selectSignatureNone">Brak podpisu</string>
<string name="selectTimeDialogTitle">Wybierz godzinę</string>
<string name="selectionReminderMeOnly">Tylko ja</string>
<string name="selectionReminderRecipientsAndMe">Odbiorcy i ja</string>
<string name="send">Wyślij</string>
<string name="sendConfirmationAction">Wyślij potwierdzenie</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Selecionar data</string>
<string name="selectSignatureNone">Sem assinatura</string>
<string name="selectTimeDialogTitle">Selecionar hora</string>
<string name="selectionReminderMeOnly">Só eu</string>
<string name="selectionReminderRecipientsAndMe">Os destinatários e eu</string>
<string name="send">Enviar</string>
<string name="sendConfirmationAction">Enviar a confirmação</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@
<string name="selectDateDialogTitle">Välj datum</string>
<string name="selectSignatureNone">Ingen signatur</string>
<string name="selectTimeDialogTitle">Välj tid</string>
<string name="selectionReminderMeOnly">Bara jag</string>
<string name="selectionReminderRecipientsAndMe">Mottagare och mig</string>
<string name="send">Skicka</string>
<string name="sendConfirmationAction">Skicka bekräftelsen</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@
<string name="selectDateDialogTitle">Select date</string>
<string name="selectSignatureNone">No signature</string>
<string name="selectTimeDialogTitle">Select time</string>
<string name="selectionReminderMeOnly">Me only</string>
<string name="selectionReminderRecipientsAndMe">Recipients and I</string>
<string name="send">Send</string>
<string name="sendConfirmationAction">Send the confirmation</string>
Expand Down
Loading