Skip to content

feat: Attachments reminder alert added#2857

Open
amariaux wants to merge 99 commits intorich-editorfrom
attachements-reminder
Open

feat: Attachments reminder alert added#2857
amariaux wants to merge 99 commits intorich-editorfrom
attachements-reminder

Conversation

@amariaux
Copy link
Copy Markdown

Ajout d'une boîte de dialogue lorsqu'une mention de pièce jointe (ou équivalent) est détectée par une expression régulière, afin de prévenir un éventuel oubli.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

PR Reviewer Guide 🔍

(Review updated until commit d822e16)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Regex Boundary Bug

The regex patterns using [^\\w] (e.g., [^\\w]jointe?s?[^\\w], [^\\w]attached[^\\w], etc.) require a non-word character on both sides of the keyword. This means they will fail to match keywords appearing at the very beginning or end of the email body. For example, the text "I have attached the file" would match, but "attached" alone at the start of the body would not. Consider using (?:^|[^\\w])...(?:[^\\w]|$) or word boundaries with proper Unicode handling to fix this.

"[^\\w]jointe?s?[^\\w]"
Suspend Function Implementation

The showSubjectDialog and showAttachmentDialog functions are marked as suspend but manually manage a CompletableDeferred. While functional, this is less robust than using suspendCancellableCoroutine, which properly handles coroutine cancellation and cleanup if the fragment is destroyed while the dialog is showing.

suspend fun showSubjectDialog(scheduled : Boolean): Boolean {
    trackNewMessageEvent(MatomoName.SendWithoutSubject)

    var isConfirm = false
    val isSendingCanceled = CompletableDeferred<Boolean>()
    descriptionDialog.show(
        title = getString(R.string.emailWithoutSubjectTitle),
        description = getString(R.string.emailWithoutSubjectDescription),
        positiveButtonText = R.string.buttonContinue,
        displayLoader = false,
        onPositiveButtonClicked = {
            trackNewMessageEvent(MatomoName.SendWithoutSubjectConfirm)
            isConfirm = true
        },
        onCancel = {
            if (scheduled) newMessageViewModel.resetScheduledDate()
       },
        onDismiss = {
            isSendingCanceled.complete(!isConfirm)
        })

    return isSendingCanceled.await()
}

suspend fun showAttachmentDialog(scheduled : Boolean): Boolean {
    trackNewMessageEvent(MatomoName.SendWithoutAttachment)

    var isConfirm = false
    val isSendingCanceled = CompletableDeferred<Boolean>()
    descriptionDialog.show(
        title = getString(R.string.attachmentsReminderTitle),
        description = getString(R.string.attachmentsReminderDescription),
        positiveButtonText = R.string.buttonContinue,
        displayLoader = false,
        onPositiveButtonClicked = {
            trackNewMessageEvent(MatomoName.SendWithoutAttachmentConfirm)
            isConfirm = true
        },
        onCancel = {
            if (scheduled) newMessageViewModel.resetScheduledDate()
        },
        onDismiss = {
            isSendingCanceled.complete(!isConfirm)
        })

    return isSendingCanceled.await()
}

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@amariaux amariaux force-pushed the attachements-reminder branch from b1e411e to 8626072 Compare April 10, 2026 12:58
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@amariaux amariaux force-pushed the attachements-reminder branch from 0507f65 to b06d87c Compare April 13, 2026 09:25
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@aymericmariaux aymericmariaux changed the base branch from main to rich-editor April 21, 2026 14:46
Ajout des regex dans les 13 langues pour détecter dans le corp du mail l'intention d'envoyer une piece jointe
Récupération des textes de descriptions pour la boite de dialogue depuis loco
Ajout des variable dans Matomo
Ajout du OnDismiss dans les DescriptionAlertDialog
Use a JS function to retrieve only the body instead of everything
@aymericmariaux aymericmariaux force-pushed the attachements-reminder branch from 902aa96 to d822e16 Compare April 21, 2026 15:09
@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit d822e16

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@aymericmariaux aymericmariaux force-pushed the attachements-reminder branch from fd4c9cf to 433c325 Compare April 22, 2026 06:32
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an “attachment reminder” flow in the new-message composer: when the user mentions an attachment (via regex detection) but hasn’t added any file, the app prompts before sending.

Changes:

  • Introduce a multi-language attachment-keyword regex utility and wire it into the send flow to show a confirmation dialog when no attachments are present.
  • Replace the previous “is editor body empty” JS with a getEditorBody() function used for both AI proposition logic and attachment detection.
  • Add localized strings and Matomo tracking events for the new reminder dialog.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
settings.gradle.kts Adds mavenLocal() to dependency resolution repositories.
app/src/main/res/values*/strings.xml Adds title/description strings for the attachment reminder dialog (multiple locales).
app/src/main/res/raw/get_editor_body.js Introduces getEditorBody() JS helper returning editor text (excluding signature/quotes).
app/src/main/java/com/infomaniak/mail/utils/HtmlFormatter.kt Renames script loader to getEditorBodyScript() and points to the new raw script.
app/src/main/java/com/infomaniak/mail/utils/AttachmentsReminderRegex.kt Adds AttachmentReminderUtils.hasAttachmentKeyword() with a combined multi-language regex.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageViewModel.kt Adds shouldShowAttachmentReminder() to centralize reminder condition.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Fetches editor body via JS and shows subject/attachment confirmation dialogs before send.
app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageAiManager.kt Switches AI “body blank” calculation to getEditorBody() result.
app/src/main/java/com/infomaniak/mail/ui/alertDialogs/DescriptionAlertDialog.kt Adds optional onDismiss callback support to dialog API.
app/src/main/java/com/infomaniak/mail/MatomoMail.kt Adds Matomo events for sending without attachment (prompt + confirm).
Comments suppressed due to low confidence (1)

app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageAiManager.kt:48

  • There are now unused imports (getEditorBodyScript and the INFOMANIAK_* class name constants) after switching to calling getEditorBody() directly. Kotlin treats unused imports as compilation errors, so these should be removed.
import com.infomaniak.mail.utils.HtmlFormatter.Companion.getEditorBodyScript
import com.infomaniak.mail.utils.MessageBodyUtils.INFOMANIAK_FORWARD_QUOTE_HTML_CLASS_NAME
import com.infomaniak.mail.utils.MessageBodyUtils.INFOMANIAK_REPLY_QUOTE_HTML_CLASS_NAME
import com.infomaniak.mail.utils.MessageBodyUtils.INFOMANIAK_SIGNATURE_HTML_CLASS_NAME
import com.infomaniak.mail.utils.WebViewUtils.Companion.evaluateJs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageAiManager.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/AttachmentsReminderRegex.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/AttachmentsReminderRegex.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/utils/AttachmentsReminderUtils.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
…clarity

- Change visibility of showSubjectDialog and showSubjectDialog from public to private
- Rename regex variable from ALL_CAPS_WITH_UNDERSCORES to lowerCamelCase
- Update body to isBodyBlank to better reflect its purpose
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

Comment thread app/src/test/java/com/infomaniak/mail/AttachmentsReminderRegexTest.kt Outdated
Comment thread app/src/test/java/com/infomaniak/mail/AttachmentsReminderRegexTest.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
Comment thread app/src/main/java/com/infomaniak/mail/ui/newMessage/NewMessageFragment.kt Outdated
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants