Skip to content

feat: ask before sending gif - #206

Merged
omg-xtao merged 1 commit into
NextAlone:devfrom
waifucon:feat-ask-before-sending-gif
Oct 10, 2026
Merged

omg-xtao merged 1 commit into
NextAlone:devfrom
waifucon:feat-ask-before-sending-gif

Conversation

@waifucon

@waifucon waifucon commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

added option to confirm sending gif, just like nagram desktop. in mobile screen things are easy to misclick. this could avoid the user sending a nsfw gif in a chat by accident.

Screen_Recording_20261010_163229_Nagram.mp4

Summary by Sourcery

Allow users to confirm GIF sends to reduce accidental sharing from mobile chats.

New Features:

  • Add an optional confirmation prompt before sending GIFs.
  • Expose the GIF confirmation preference in chat settings.

@sourcery-ai

sourcery-ai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implements an opt-in GIF-send confirmation flow: when enabled in chat settings, selecting a GIF opens a localized confirmation dialog before the existing send operation runs; cancellation prevents sending while the default behavior remains unchanged.

Sequence diagram for optional GIF send confirmation

sequenceDiagram
    participant User
    participant ChatActivityEnterView
    participant NaConfig
    participant AlertDialog
    participant SendOperation

    User->>ChatActivityEnterView: onGifSelected()
    ChatActivityEnterView->>NaConfig: getAskBeforeSendingGIF()
    alt confirmation enabled
        ChatActivityEnterView->>AlertDialog: show ConfirmSendGIF
        alt user confirms
            User->>AlertDialog: OK
            AlertDialog->>SendOperation: run()
        else user cancels
            User->>AlertDialog: Cancel
        end
    else confirmation disabled
        ChatActivityEnterView->>SendOperation: run()
    end
Loading

File-Level Changes

Change Details Files
Add an opt-in confirmation flow before sending GIFs from the chat composer.
  • Gate GIF sending behind a confirmation dialog when the new setting is enabled.
  • Preserve the existing send callback and execute it only after positive confirmation; allow cancellation.
  • Use the parent fragment or activity/context to display the dialog safely.
TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
Expose and persist a user-configurable setting for GIF send confirmation.
  • Register the disabled-by-default boolean configuration option.
  • Add the option to the chat settings confirmation section.
TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java
Add localized labels and dialog text for the new setting and confirmation prompt.
  • Add strings for the setting, dialog title, and confirmation message.
TMessagesProj/src/main/res/values/strings_na.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java" line_range="13452" />
<code_context>
                         };
                         if (!showConfirmAlert(runnable)) {
-                            runnable.run();
+                            if (NaConfig.INSTANCE.getAskBeforeSendingGIF().Bool()) {
+                                AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity != null ? parentActivity : getContext(), resourcesProvider);
+                                builder.setTitle(LocaleController.getString(R.string.ConfirmSendGIF));
</code_context>
<issue_to_address>
**Story replies bypass GIF confirmation**

When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in `PeerStoriesView`, `showConfirmAlert` delegates to `applyMessageToChat`, which runs the callback and returns `true` on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.

Ensure the GIF confirmation preference is checked for story-reply sends even when `showConfirmAlert` returns `true`.
</issue_to_address>

### Comment 2
<location path="TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java" line_range="13459" />
<code_context>
+                                builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> runnable.run());
+                                builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
+                                if (parentFragment != null) {
+                                    parentFragment.showDialog(builder.create());
+                                }
+                                if (parentFragment == null) {
</code_context>
<issue_to_address>
**GIF selection is silently dropped**

When the GIF confirmation is enabled and the parent fragment cannot show dialogs, `showDialog` returns without displaying the alert, but the fallback runs only when `parentFragment` is null, so the selection is dropped and no GIF is sent.

Fall back to showing the alert when `parentFragment.showDialog(...)` does not display it.

Also at `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460`.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13452, TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13459


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

};
if (!showConfirmAlert(runnable)) {
runnable.run();
if (NaConfig.INSTANCE.getAskBeforeSendingGIF().Bool()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Story replies bypass GIF confirmation

When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in PeerStoriesView, showConfirmAlert delegates to applyMessageToChat, which runs the callback and returns true on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.

Ensure the GIF confirmation preference is checked for story-reply sends even when showConfirmAlert returns true.

Prompt for AI agents
In `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java` at line 13452:

**Story replies bypass GIF confirmation**

When a GIF is sent from the story-reply input with Ask Before Sending GIF enabled, in `PeerStoriesView`, `showConfirmAlert` delegates to `applyMessageToChat`, which runs the callback and returns `true` on the normal path, so the GIF confirmation check is skipped and the GIF reaches the story recipient without confirmation.

Ensure the GIF confirmation preference is checked for story-reply sends even when `showConfirmAlert` returns `true`.

builder.setPositiveButton(LocaleController.getString(R.string.OK), (dialogInterface, i) -> runnable.run());
builder.setNegativeButton(LocaleController.getString(R.string.Cancel), null);
if (parentFragment != null) {
parentFragment.showDialog(builder.create());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · GIF selection is silently dropped

When the GIF confirmation is enabled and the parent fragment cannot show dialogs, showDialog returns without displaying the alert, but the fallback runs only when parentFragment is null, so the selection is dropped and no GIF is sent.

Fall back to showing the alert when parentFragment.showDialog(...) does not display it.

Also at TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460.

Prompt for AI agents
In `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java` at line 13459:

**GIF selection is silently dropped**

When the GIF confirmation is enabled and the parent fragment cannot show dialogs, `showDialog` returns without displaying the alert, but the fallback runs only when `parentFragment` is null, so the selection is dropped and no GIF is sent.

Fall back to showing the alert when `parentFragment.showDialog(...)` does not display it.

Also at `TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java:13460`.

@omg-xtao omg-xtao added the enhancement New feature or request label Oct 10, 2026
@omg-xtao
omg-xtao merged commit fae9f5e into NextAlone:dev Oct 10, 2026
3 checks passed
@waifucon
waifucon deleted the feat-ask-before-sending-gif branch October 10, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants