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
1 change: 1 addition & 0 deletions app/src/main/java/com/infomaniak/mail/MatomoMail.kt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ object MatomoMail : Matomo {
CustomFolder("customFolder"),
CustomFolders("customFolders"),
CustomSchedule("customSchedule"),
CustomReminder("customReminder"),
CustomScheduleConfirm("customScheduleConfirm"),
DailyLimitReachedUpgrade("dailyLimitReachedUpgrade"),
Delete("delete"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* 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 com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.infomaniak.mail.R
import com.infomaniak.mail.databinding.DialogCustomReminderPickerBinding
import com.infomaniak.mail.utils.date.DateFormatUtils.MINUTES_IN_AN_HOUR
import com.infomaniak.mail.utils.date.DateFormatUtils.MINUTES_IN_A_DAY
import dagger.hilt.android.qualifiers.ActivityContext
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

@ActivityScoped
class CustomReminderPickerDialog @Inject constructor(
@ActivityContext private val activityContext: Context,
) : BaseAlertDialog(activityContext) {

private val binding: DialogCustomReminderPickerBinding by lazy {
DialogCustomReminderPickerBinding.inflate(activity.layoutInflater)
}

override val alertDialog = initDialog()

private var onDelaySelected: ((Int) -> Unit)? = null

private val timeUnits = TimeUnit.entries.toTypedArray()

private fun initDialog() = with(binding) {
MaterialAlertDialogBuilder(activityContext)
.setTitle(R.string.buttonCustomReminder)
.setView(root)
.setPositiveButton(R.string.buttonConfirm, null)
.setNegativeButton(com.infomaniak.core.legacy.R.string.buttonCancel, null)
.create()
}

fun show(onDelaySelected: (Int) -> Unit) {
this.onDelaySelected = onDelaySelected
alertDialog.show()
setupPickers()
setupListeners()
}

override fun resetCallbacks() {
onDelaySelected = null
}

private fun setupPickers() = with(binding) {
numberPicker.minValue = 1
numberPicker.maxValue = timeUnits[unitPicker.value].maxValue
numberPicker.wrapSelectorWheel = true

unitPicker.minValue = 0
unitPicker.maxValue = timeUnits.size - 1
unitPicker.wrapSelectorWheel = false

updateUnitLabels(numberPicker.value)
}

private fun setupListeners() = with(binding) {
numberPicker.setOnValueChangedListener { _, oldVal, newVal ->
if ((oldVal == 1 && newVal > 1) || (oldVal > 1 && newVal == 1)) {
updateUnitLabels(newVal)
}
}

unitPicker.setOnValueChangedListener { _, _, newUnitIndex -> numberPicker.maxValue = timeUnits[newUnitIndex].maxValue }

positiveButton.setOnClickListener {
numberPicker.clearFocus()
unitPicker.clearFocus()
onDelaySelected?.invoke(getDelayMinutes())
alertDialog.dismiss()
}

negativeButton.setOnClickListener { alertDialog.cancel() }
}

private fun updateUnitLabels(currentNumber: Int) {
val displayedUnits = timeUnits.map {
activityContext.resources.getQuantityString(it.titleRes, currentNumber)
}.toTypedArray()

binding.unitPicker.displayedValues = displayedUnits
}

private fun getDelayMinutes(): Int {
val number = binding.numberPicker.value
val selectedUnit = timeUnits[binding.unitPicker.value]

return number * selectedUnit.multiplierInMinutes
}

companion object {
private const val MAX_HOURS = 23
private const val MAX_DAYS = 30
Comment thread
Elouan1411 marked this conversation as resolved.

enum class TimeUnit(
val titleRes: Int,
val maxValue: Int,
val multiplierInMinutes: Int
) {
Hours(R.plurals.unitHours, MAX_HOURS, MINUTES_IN_AN_HOUR),
Days(R.plurals.unitDays, MAX_DAYS, MINUTES_IN_A_DAY),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.infomaniak.mail.R
import com.infomaniak.mail.data.LocalSettings
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.bottomSheetDialogs.ScheduleOption
import com.infomaniak.mail.ui.bottomSheetDialogs.ScheduleOptionUtils
Expand Down Expand Up @@ -66,6 +67,9 @@ class DraftSendOptionsFragment : Fragment() {
@Inject
lateinit var dateAndTimeScheduleDialog: SelectDateAndTimeForScheduledDraftDialog

@Inject
lateinit var customReminderPickerDialog: CustomReminderPickerDialog

@Inject
lateinit var localSettings: LocalSettings

Expand All @@ -81,6 +85,7 @@ class DraftSendOptionsFragment : Fragment() {

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

setupScheduleOptions()
lastScheduleOption.associatedValue = lastSelectedEpoch?.toString()
Expand Down Expand Up @@ -372,7 +377,17 @@ class DraftSendOptionsFragment : Fragment() {
}

private fun showCustomDelayReminderDatePicker() {
// TODO
customReminderPickerDialog.show(
onDelaySelected = { delayMinutes ->
trackScheduleSendEvent(MatomoName.CustomReminder)
newMessageViewModel.setReminderConfig(ReminderConfig.Delayed(delayMinutes, isCustom = true))
binding.customDelayReminder.apply {
setSubtitle(requireContext().formatDelayText(delayMinutes))
setCheckMark(displayCheckMark = true)
}
binding.optionsDelays.clearCheck()
},
)
}

}
37 changes: 37 additions & 0 deletions app/src/main/res/layout/dialog_custom_reminder_picker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/marginStandard"
android:paddingVertical="@dimen/marginStandardSmall">

<NumberPicker
android:id="@+id/numberPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/marginStandardMedium" />

Comment on lines +18 to +31

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.

Remove one of these 2 layout

<NumberPicker
android:id="@+id/unitPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Papirkurv</string>
<string name="tryAgain">Prøv venligst igen.</string>
<string name="unblockButton">Fjern blokering</string>
<plurals name="unitDays">
<item quantity="one">Dag</item>
<item quantity="other">Dage</item>
</plurals>
<plurals name="unitHours">
Comment thread
Elouan1411 marked this conversation as resolved.
<item quantity="one">Time</item>
<item quantity="other">Timer</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Ukendt afsender</string>
<string name="unknownDialogTitleRecipient">Ukendt modtager</string>
<string name="unknownRecipientTitle">(ukendt)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Papierkorb</string>
<string name="tryAgain">Bitte versuchen Sie es erneut.</string>
<string name="unblockButton">Entsperren</string>
<plurals name="unitDays">
<item quantity="one">Tag</item>
<item quantity="other">Tage</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Stunde</item>
<item quantity="other">Stunden</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Unbekannter Spediteur</string>
<string name="unknownDialogTitleRecipient">Unbekannter Empfänger</string>
<string name="unknownRecipientTitle">(unbekannt)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Κάδος απορριμμάτων</string>
<string name="tryAgain">Παρακαλώ, δοκιμάστε ξανά.</string>
<string name="unblockButton">Ξεμπλοκάρισμα</string>
<plurals name="unitDays">
<item quantity="one">Ημέρα</item>
<item quantity="other">Ημέρες</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Ώρα</item>
<item quantity="other">Ώρες</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Άγνωστος αποστολέας</string>
<string name="unknownDialogTitleRecipient">Άγνωστος παραλήπτης</string>
<string name="unknownRecipientTitle">(άγνωστο)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Papelera</string>
<string name="tryAgain">Por favor, inténtelo de nuevo.</string>
<string name="unblockButton">Desbloquear</string>
<plurals name="unitDays">
<item quantity="one">Día</item>
<item quantity="other">Días</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Hora</item>
<item quantity="other">Horas</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Expedidor desconocido</string>
<string name="unknownDialogTitleRecipient">Destinatario desconocido</string>
<string name="unknownRecipientTitle">(desconocido)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Roskakori</string>
<string name="tryAgain">Yritä uudelleen.</string>
<string name="unblockButton">Poista esto</string>
<plurals name="unitDays">
<item quantity="one">Päivä</item>
<item quantity="other">Päivää</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Tunti</item>
<item quantity="other">Tuntia</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Tuntematon lähettäjä</string>
<string name="unknownDialogTitleRecipient">Tuntematon vastaanottaja</string>
<string name="unknownRecipientTitle">(tuntematon)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Corbeille</string>
<string name="tryAgain">Veuillez réessayer.</string>
<string name="unblockButton">Débloquer</string>
<plurals name="unitDays">
<item quantity="one">Jour</item>
<item quantity="other">Jours</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Heure</item>
<item quantity="other">Heures</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Expéditeur inconnu</string>
<string name="unknownDialogTitleRecipient">Destinataire inconnu</string>
<string name="unknownRecipientTitle">(inconnu)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Cestino</string>
<string name="tryAgain">Per favore, riprova.</string>
<string name="unblockButton">Sbloccare</string>
<plurals name="unitDays">
<item quantity="one">Giorno</item>
<item quantity="other">Giorni</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Ora</item>
<item quantity="other">Ore</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Spedizioniere sconosciuto</string>
<string name="unknownDialogTitleRecipient">Destinatario sconosciuto</string>
<string name="unknownRecipientTitle">(sconosciuto)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Papirkurv</string>
<string name="tryAgain">Vennligst prøv igjen.</string>
<string name="unblockButton">Opphev blokkering</string>
<plurals name="unitDays">
<item quantity="one">Dag</item>
<item quantity="other">Dager</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Time</item>
<item quantity="other">Timer</item>
Comment thread
Elouan1411 marked this conversation as resolved.
</plurals>
<string name="unknownDialogTitleExpeditor">Ukjent avsender</string>
<string name="unknownDialogTitleRecipient">Ukjent mottaker</string>
<string name="unknownRecipientTitle">(ukjent)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Prullenbak</string>
<string name="tryAgain">Probeer het opnieuw.</string>
<string name="unblockButton">Deblokkeren</string>
<plurals name="unitDays">
<item quantity="one">Dag</item>
<item quantity="other">Dagen</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Uur</item>
<item quantity="other">Uur</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Onbekende afzender</string>
<string name="unknownDialogTitleRecipient">Onbekende ontvanger</string>
<string name="unknownRecipientTitle">(onbekend)</string>
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,18 @@
<string name="trashFolder">Kosz</string>
<string name="tryAgain">Spróbuj ponownie.</string>
<string name="unblockButton">Odblokuj</string>
<plurals name="unitDays">
<item quantity="one">Dzień</item>
<item quantity="few">Dni</item>
<item quantity="many">Dni</item>
<item quantity="other">Dni</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Godzina</item>
<item quantity="few">Godziny</item>
<item quantity="many">Godzin</item>
<item quantity="other">Godzin</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Nieznany nadawca</string>
<string name="unknownDialogTitleRecipient">Nieznany odbiorca</string>
<string name="unknownRecipientTitle">(nieznany)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Lixo</string>
<string name="tryAgain">Por favor, tente novamente.</string>
<string name="unblockButton">Desbloquear</string>
<plurals name="unitDays">
<item quantity="one">Dia</item>
<item quantity="other">Dias</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Hora</item>
<item quantity="other">Horas</item>
</plurals>
<string name="unknownDialogTitleExpeditor">Remetente desconhecido</string>
<string name="unknownDialogTitleRecipient">Destinatário desconhecido</string>
<string name="unknownRecipientTitle">(desconhecido)</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@
<string name="trashFolder">Papperskorg</string>
<string name="tryAgain">Försök igen.</string>
<string name="unblockButton">Avblockera</string>
<plurals name="unitDays">
<item quantity="one">Dag</item>
<item quantity="other">Dagar</item>
</plurals>
<plurals name="unitHours">
<item quantity="one">Timme</item>
<item quantity="other">Timmar</item>
Comment thread
Elouan1411 marked this conversation as resolved.
</plurals>
<string name="unknownDialogTitleExpeditor">Okänd avsändare</string>
<string name="unknownDialogTitleRecipient">Okänd mottagare</string>
<string name="unknownRecipientTitle">(okänd)</string>
Expand Down
Loading
Loading