Skip to content

fix: show in chat on small tablets#64

Merged
omg-xtao merged 3 commits into
NextAlone:devfrom
mariodon:patch
May 10, 2026
Merged

fix: show in chat on small tablets#64
omg-xtao merged 3 commits into
NextAlone:devfrom
mariodon:patch

Conversation

@mariodon
Copy link
Copy Markdown
Contributor

@mariodon mariodon commented May 9, 2026

Fix Show in Chat navigation from PhotoViewer on small tablets.

On small tablets using the full-size tablet layout in portrait, Show in Chat could close the viewer and return to the chat list instead of opening the target message.

This was caused by posting closeChats before presenting the target ChatActivity, which could close the active chat and drop the navigation during transition.

This PR avoids posting closeChats when LaunchActivity is already using the full-size tablet layout. Split-view tablet and phone layouts keep the existing behavior.

Summary by Sourcery

Adjust chat navigation from PhotoViewer to respect tablet full-size layout and avoid unintended chat closure on small tablets.

Bug Fixes:

  • Prevent Show in Chat from closing the current chat and returning to the chat list on small tablets in full-size tablet portrait layout.

Enhancements:

  • Expose an isTabletFullSizeLayout helper on LaunchActivity to centralize full-size tablet layout checks.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 9, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts PhotoViewer’s Show in Chat navigation so that on full-size tablet layouts it doesn’t close existing chats before opening the target message, and adds a helper on LaunchActivity to detect full-size tablet layout usage.

Sequence diagram for updated Show in Chat navigation on tablets

sequenceDiagram
    actor User
    participant PhotoViewer
    participant LaunchActivity
    participant NotificationCenter
    participant ChatActivity

    User->>PhotoViewer: tapShowInChat()
    PhotoViewer->>PhotoViewer: buildChatArgs()
    PhotoViewer->>PhotoViewer: launchActivity = resolveLaunchActivity()

    alt Not_LaunchActivity
        PhotoViewer-->>User: no_navigation
    else LaunchActivity_and_not_full_size_tablet
        PhotoViewer->>NotificationCenter: postNotification(closeChats)
        PhotoViewer->>LaunchActivity: presentFragment(ChatActivity(args), remove, true)
        LaunchActivity->>ChatActivity: create_and_display()
    else LaunchActivity_and_full_size_tablet
        PhotoViewer->>LaunchActivity: isTabletFullSizeLayout()
        LaunchActivity-->>PhotoViewer: true
        PhotoViewer--xNotificationCenter: skip_closeChats()
        PhotoViewer->>LaunchActivity: presentFragment(ChatActivity(args), remove, true)
        LaunchActivity->>ChatActivity: create_and_display()
    end
Loading

Class diagram for updated PhotoViewer and LaunchActivity behavior

classDiagram
    class PhotoViewer {
        int currentAccount
        Object parentActivity
        MessageObject currentMessageObject
        onItemClick(int id)
    }

    class LaunchActivity {
        boolean tabletFullSize
        int getMainFragmentsCount()
        boolean isTabletFullSizeLayout()
        boolean presentFragment(ChatActivity fragment, boolean removeLast, boolean force)
    }

    class ChatActivity {
        ChatActivity(Bundle args)
    }

    class NotificationCenter {
        int closeChats
        static NotificationCenter getInstance(int account)
        void postNotificationName(int id)
    }

    class AndroidUtilities {
        static boolean isTablet()
    }

    class MessageObject {
        int getId()
    }

    class Bundle {
        void putInt(String key, int value)
    }

    PhotoViewer --> LaunchActivity : uses_parentActivity
    PhotoViewer --> NotificationCenter : postNotification(closeChats)
    PhotoViewer --> ChatActivity : create_for_navigation
    PhotoViewer --> Bundle : build_args
    PhotoViewer --> MessageObject : read_id
    LaunchActivity --> ChatActivity : presentFragment
    LaunchActivity --> AndroidUtilities : isTabletFullSizeLayout()
    LaunchActivity : isTabletFullSizeLayout() returns AndroidUtilities.isTablet() && tabletFullSize
    NotificationCenter --> NotificationCenter : getInstance(account)
    AndroidUtilities <.. PhotoViewer : static_call_isTablet()
Loading

File-Level Changes

Change Details Files
Guard closeChats notification and reuse LaunchActivity when presenting ChatActivity from PhotoViewer.
  • Capture parentActivity as a LaunchActivity instance when applicable instead of repeatedly type checking.
  • Post NotificationCenter.closeChats only when not on a full-size tablet layout, avoiding closure of the active chat on small tablets using the full-size layout.
  • Present ChatActivity only when a LaunchActivity instance is available, preserving existing remove logic based on fragment count and tablet checks.
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
Expose a helper to detect full-size tablet layout on LaunchActivity.
  • Add isTabletFullSizeLayout() method returning true when both AndroidUtilities.isTablet() and tabletFullSize are true.
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@omg-xtao omg-xtao added the bug Something isn't working label May 10, 2026
@omg-xtao omg-xtao merged commit 3f49000 into NextAlone:dev May 10, 2026
@mariodon mariodon deleted the patch branch May 22, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants