Skip to content

feat(player): drag subtitles to reposition them - #2067

Open
SairamVemula wants to merge 10 commits into
anilbeesetti:mainfrom
SairamVemula:feature/subtitle-reposition
Open

SairamVemula wants to merge 10 commits into
anilbeesetti:mainfrom
SairamVemula:feature/subtitle-reposition

Conversation

@SairamVemula

@SairamVemula SairamVemula commented Oct 31, 2026 •

Copy link
Copy Markdown

Problem

Subtitles are always drawn at the bottom of the screen. There is no way to move them out of the way of burned-in text or to put them where they are comfortable to read. This has been asked for repeatedly.

Solution

Touch a subtitle and drag your finger up or down to move it. The position is saved and used for every video. Subtitles only move vertically and stay centred horizontally.

  • Touch area: the touch area is the subtitle text as it is actually drawn (plus 16 dp of reach). Media3 does not expose the text bounds, so the subtitle layer is painted into a small bitmap on touch-down and the painted pixels are measured. Touches next to the text keep their normal behaviour (tap, double-tap, seek, volume, brightness, zoom).
  • No hold delay. The drag starts as soon as the finger passes the touch slop. The move that crosses the slop is consumed in the Initial pointer pass so the volume/seek swipes do not start on it too.
  • Feedback. A light translucent box appears behind the text from the first touch, the controls hide and a haptic tick fires when the move starts. Playback keeps running; the text on screen stays frozen until release, then the subtitles carry on from the current position (same behaviour as MX Player).
  • Storage. subtitleOffsetY in PlayerPreferences, saved as a fraction of the player height so the position holds across rotation and screen sizes. The offset is clamped so the subtitle cannot leave the screen and is ignored in picture-in-picture.
  • Reset. Settings → Subtitle → "Reset subtitle position".

Closes #1413, closes #1528, closes #1598. Related to #1327, #1576.

Verification

./gradlew ktlintCheck test assembleDebug
./gradlew :app:assembleRelease-with-debug-signing

ktlintCheck and assembleDebug pass. New unit tests: SubtitlePositionStateTest (offset maths, clamping, saving, hit-testing against the drawn text, highlight state) and a PlayerViewModelTest case for saving the offset.

test has 6 failures that are not related to this change and fail the same way on an unmodified main (1cf4c4ac): 4 in GetFolderTreeMediaUseCaseTest, 1 in PlaylistDetailViewModelTest, 1 in M3UParserTest.

Manual testing

  • Emulator Medium_Phone_API_37.0 (API 37, x86_64), landscape video with an embedded subtitle track:
    • touching the subtitle shows the highlight immediately;
    • touching 160 px above the text does nothing;
    • dragging moves the subtitle, controls hide, video keeps playing, controls return on release;
    • a diagonal drag moves the subtitle vertically only;
    • the position survives a full app restart;
    • after moving, only the new position is touchable;
    • "Reset subtitle position" restores the default.
  • Physical Android device: installed a minified release-with-debug-signing build and used it with real videos; behaves as above.

Not covered: image-based subtitles (PGS/DVD), picture-in-picture, and rotating with a saved position on a device. Before/after screenshots can be added as a comment.

🤖 Generated with Claude Code

SairamVemula and others added 10 commits October 31, 2026 18:21
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
awaitLongPressOrCancellation gives up when the tap detector has already
consumed the down event, so the drag never started on a device.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Playback keeps running. The grey box, haptic tick and hidden controls tell
the user the long-press landed on the subtitle.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
No long-press delay. The move that crosses the touch slop is consumed so the
volume, brightness and seek swipes do not start on it as well.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The touch area was a fixed strip at the bottom of the screen. Measure where
the subtitle view actually draws text and hit-test against that instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Drop the horizontal offset; subtitles stay centred and only move up or down.
Update the reset item description to match.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Subtitle position Feature request: Changing subtitle position [FEATURE] Subtitle position changing

1 participant