Skip to content

Conversation

@People-11
Copy link
Contributor

@People-11 People-11 commented Nov 10, 2025

I think moving from containerView to videoPlayerControlFrameLayout will make more changes, so I tried to dynamically set the icon. But the current seekbar length calculation isn't quite right, maybe it needs dynamic calculation too? I'm not sure. Please let NA take a look(.

Summary by Sourcery

Move the fullscreen toggle into the progress bar UI, dynamically display the appropriate icon, refine seekbar sizing, and overhaul orientation handling for fullscreen mode

New Features:

  • Embed fullscreen toggle within the video progress bar control
  • Dynamically switch fullscreen button icon based on video orientation

Enhancements:

  • Adjust seekbar sizing offsets to account for the fullscreen button in both orientations
  • Use GONE instead of INVISIBLE when hiding the exit-fullscreen button and set its icon resource dynamically
  • Eliminate legacy fullscreenButton reposition logic and track video dimensions in checkFullscreenButton
  • Update fullscreen-entry logic to programmatically set the correct screen orientation and hide the action bar based on display rotation

I think moving from containerView to videoPlayerControlFrameLayout will make more changes, so I tried to dynamically set the icon. But the current seekbar length calculation isn't quite right, maybe it needs dynamic calculation too? I'm not sure. Please let NA take a look(.
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 10, 2025

Reviewer's Guide

This PR moves fullscreen control into the VideoPlayerControlFrameLayout by dynamically setting the fullscreen icon and visibility, refactors seekbar sizing offsets, and overhauls orientation toggling logic to rely on runtime display dimensions.

Sequence diagram for fullscreen button visibility and orientation logic

sequenceDiagram
participant PV as PhotoViewer
participant VPCL as VideoPlayerControlFrameLayout
participant Activity
participant WindowManager

PV->>VPCL: checkFullscreenButton()
VPCL->>PVCL: onMeasure()
PVCL->>PVCL: Set exitFullscreenButton visibility and icon
PVCL->>PVCL: Adjust seekbar size
PVCL->>PVCL: Set videoWidth/videoHeight if needed
PVCL->>PVCL: Hide fullscreenButton
PVCL->>Activity: setRequestedOrientation (based on display dimensions)
alt Landscape
    Activity->>WindowManager: getDefaultDisplay().getRotation()
    Activity->>Activity: setRequestedOrientation (LANDSCAPE/REVERSE_LANDSCAPE)
    PVCL->>PVCL: toggleActionBar(false, false)
else Portrait
    Activity->>Activity: setRequestedOrientation (PORTRAIT)
end
Loading

Class diagram for updated fullscreen and seekbar logic in PhotoViewer

classDiagram
class PhotoViewer {
  - int videoWidth
  - int videoHeight
  - int parentWidth
  - int parentHeight
  - boolean wasRotated
  - int fullscreenedByButton
  - int prevOrientation
  + void checkFullscreenButton()
  + void setVisibility(int visibility)
}
class VideoPlayerControlFrameLayout {
  + VideoPlayerControlFrameLayout(Context context)
  + void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
}
PhotoViewer "1" *-- "1" VideoPlayerControlFrameLayout : contains
PhotoViewer o-- "1" videoPlayerSeekbar
PhotoViewer o-- "1" exitFullscreenButton
PhotoViewer o-- "1" fullscreenButton
PhotoViewer o-- "1" videoPlayerTime
Loading

File-Level Changes

Change Details Files
Dynamic exitFullscreenButton icon and visibility handling moved into VideoPlayerControlFrameLayout
  • Include videoWidth/videoHeight in orientation check for extraWidth
  • Show exitFullscreenButton with VISIBLE state and select icon based on landscape/portrait
  • Hide exitFullscreenButton using GONE instead of INVISIBLE in non-fullscreen
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
Seekbar size calculations adjusted to use consistent dp(8) offset and account for extraWidth
  • Replace hardcoded dp(2+14) margin with dp(8) in both spring update and onMeasure branches
  • Factor computed extraWidth into videoPlayerSeekbar.setSize calls
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
Refactor fullscreen toggle behavior in setVisibility to use dynamic orientation
  • Determine fullscreenedByButton flag based on current display aspect
  • Request portrait or landscape orientation using display rotation for reverse landscape
  • Hide action bar when entering landscape fullscreen
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
Simplify fullscreenButton check logic and capture video dimensions
  • Remove manual layoutParams topMargin adjustments for fullscreenButton
  • Store videoWidth/videoHeight when first detecting landscape video
  • Always hide fullscreenButton after initial capture
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.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

@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 there - I've reviewed your changes - here's some feedback:

  • Extract the repeated dp-based size calculations (e.g. dp(8), dp(48), dp(47), dp(12)) into named constants or a helper method instead of using magic numbers scattered throughout.
  • Unify the orientation check logic (mixing parentWidth/parentHeight and videoWidth/videoHeight) into a single helper or state to avoid subtle inconsistencies and duplicated conditionals.
  • Remove or replace the "Need further adjust" inline comments by finalizing the seekbar sizing logic or linking to a tracked issue so that the code doesn’t ship with unresolved FIXMEs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Extract the repeated dp-based size calculations (e.g. dp(8), dp(48), dp(47), dp(12)) into named constants or a helper method instead of using magic numbers scattered throughout.
- Unify the orientation check logic (mixing parentWidth/parentHeight and videoWidth/videoHeight) into a single helper or state to avoid subtle inconsistencies and duplicated conditionals.
- Remove or replace the "Need further adjust" inline comments by finalizing the seekbar sizing logic or linking to a tracked issue so that the code doesn’t ship with unresolved FIXMEs.

## Individual Comments

### Comment 1
<location> `TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java:3504` </location>
<code_context>
                 if (exitFullscreenButton.getVisibility() != VISIBLE) {
                     exitFullscreenButton.setVisibility(VISIBLE);
                 }
+                exitFullscreenButton.setImageResource(parentWidth > parentHeight ? R.drawable.msg_minvideo : R.drawable.msg_maxvideo);
                 extraWidth = dp(48);
                 layoutParams.rightMargin = dp(47);
</code_context>

<issue_to_address>
**question:** Image resource selection logic may be unclear for edge cases.

If parent and video aspect ratios can differ, please clarify which should determine the icon, or add documentation for the intended behavior in such cases.
</issue_to_address>

### Comment 2
<location> `TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java:3542` </location>
<code_context>
                 timeSpring.start();
             } else {
-                videoPlayerSeekbar.setSize(getMeasuredWidth() - dp(2 + 14) - size - extraWidth, getMeasuredHeight());
+                videoPlayerSeekbar.setSize(getMeasuredWidth() - dp(8) - size - extraWidth, getMeasuredHeight()); //Need further adjust
                 timeValue.setValue(size);
             }
</code_context>

<issue_to_address>
**suggestion:** Repeated use of dp(8) for seekbar sizing may need centralization.

Consider defining dp(8) as a constant or utility to maintain consistency and simplify future changes.

Suggested implementation:

```java
                if (exitFullscreenButton.getVisibility() != GONE) { //see the video I sent in the group, I initially suspected the button wasn't fully hidden, so I made this change. Revert if necessary.
                    exitFullscreenButton.setVisibility(GONE);
                }
                extraWidth = 0;
                layoutParams.rightMargin = dp(12);
                timeSpring.getSpring().setFinalPosition(size);
                timeSpring.start();
            } else {

```

```java
                    videoPlayerSeekbar.setSize((int) (getMeasuredWidth() - dp(SEEKBAR_HORIZONTAL_PADDING) - value - extraWidth), getMeasuredHeight()); //Need further adjust
                });

```

```java
        // Centralized seekbar horizontal padding for sizing
        private static final int SEEKBAR_HORIZONTAL_PADDING = 8;

        public VideoPlayerControlFrameLayout(@NonNull Context context) {
            int extraWidth;
            ignoreLayout = true;
            LayoutParams layoutParams = (LayoutParams) videoPlayerTime.getLayoutParams();

```

If there are other usages of `dp(8)` for seekbar sizing elsewhere in the file, they should also be replaced with `dp(SEEKBAR_HORIZONTAL_PADDING)` for consistency.
</issue_to_address>

### Comment 3
<location> `TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java:9908-9910` </location>
<code_context>
+            if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
+                parentActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+            } else {
+                WindowManager manager = (WindowManager) parentActivity.getSystemService(Activity.WINDOW_SERVICE);
+                int displayRotation = manager.getDefaultDisplay().getRotation();
+                parentActivity.setRequestedOrientation(displayRotation == Surface.ROTATION_270 ?
+                    ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+                toggleActionBar(false, false);
</code_context>

<issue_to_address>
**question:** Orientation logic may not handle all rotation values.

Explicitly handle ROTATION_0 and ROTATION_90, or clarify why only ROTATION_270 is singled out.
</issue_to_address>

### Comment 4
<location> `TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java:11008` </location>
<code_context>
-                if (fullscreenButton[b].getVisibility() != View.GONE) {
-                    fullscreenButton[b].setVisibility(View.GONE);
-                }
+            if (AndroidUtilities.displaySize.y > AndroidUtilities.displaySize.x && w > h && b == 0) {
+                videoWidth = w;
+                videoHeight = h;
</code_context>

<issue_to_address>
**question:** videoWidth and videoHeight assignment is limited to b == 0.

Please verify that only the first fullscreen button should update videoWidth and videoHeight, and that this behavior is correct for all use cases.
</issue_to_address>

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 merged commit f8b6a42 into NextAlone:dev Nov 11, 2025
4 of 5 checks passed
@omg-xtao omg-xtao added the enhancement New feature or request label Nov 11, 2025
omg-xtao pushed a commit to PreviousAlone/Nnngram that referenced this pull request Nov 11, 2025
@People-11 People-11 deleted the upstream-pr branch November 18, 2025 07:46
seyrenus pushed a commit to seyrenus/Nnngram that referenced this pull request Nov 19, 2025
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