Skip to content

feat: 优化歌词翻译/音译切换按钮UI布局 - #427

Merged
cwuom merged 4 commits into
cwuom:masterfrom
ycfeng666:feature/local-lyrics-priority
Sep 25, 2026
Merged

cwuom merged 4 commits into
cwuom:masterfrom
ycfeng666:feature/local-lyrics-priority

Conversation

@ycfeng666

@ycfeng666 ycfeng666 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

描述 / Description

优化歌词页面的"译/音"切换按钮UI,将其移至进度条上方左侧,与网易云音乐的布局保持一致。同时修复了SAF URI解析问题,使应用能够正确检测本地音译歌词文件(.roma.lrc)。

类型 / Type

  • Bug 修复 / Bug Fix
  • 新功能 / New Feature
  • 文档更新 / Documentation Update
  • 其他(请描述)/ Other (please describe):

修复或解决的问题 / Issues Fixed or Closed by This PR

  • 修复"译/音"切换按钮无法点击的问题(SAF URI无法解析为实际文件路径)
  • 优化歌词切换按钮的UI布局,提升用户体验

清单 / Checklist

  • 我已阅读并遵循贡献指南 / I have read and followed the contribution guidelines
  • 我已在本地测试这些更改 / I have tested these changes locally
  • 我已更新相关文档或注释(如适用) / I have updated relevant documentation or comments (if applicable)
  • 我确认本次更改没有破坏任何原有逻辑 / I confirm this change does not break existing behavior
  • 我确认本次更改保持向下兼容(如适用) / I confirm this change remains backward compatible (if applicable)
  • 我已运行必要的构建、测试或静态检查 / I have run the required build, tests, or static checks
  • 我确认没有提交密钥、Token 或其他敏感信息 / I confirm no secrets, tokens, or other sensitive information were committed
  • 涉及 UI 变更时,我已补充截图或录屏(如适用) / I have added screenshots or recordings for UI changes (if applicable)

其他信息 / Additional Information

UI 变更说明

  • 修改前:切换按钮位于进度条下方
  • 修改后:切换按钮位于进度条上方左侧,与网易云音乐布局一致

技术细节

  1. UI 调整:将"译/音"切换按钮从 LyricsProgressSection 内部移至进度条上方的独立 Row 中
  2. 字体高亮:当前激活状态(翻译或音译)的字体使用主题色高亮显示
  3. SAF URI 解析:添加 parseSafDocumentIdToPath 函数,从 SAF document ID 中提取实际文件路径
  4. 歌词检测优化:修改 inspectLyricsFast 函数,支持通过 context 参数解析 SAF URI

修改文件

  • LyricsScreen.kt - UI布局调整
  • LocalMediaSupport.kt - SAF URI解析和歌词文件检测
  • PlayerLyricsProvider.kt - 传递context参数
  • NowPlayingScreen.kt - 传递context参数

变更摘要

  • 歌词页在进度条上方提供翻译、音译和隐藏副行的切换选项。仅当当前歌曲的副歌词已解析且至少有一种可显示内容时显示。
  • 系统根据可用歌词和偏好选择副行内容。翻译不可用时,可改用音译。
  • 歌词设置会按可用内容调整选项文案;只有存在翻译歌词时才显示音译切换项。
  • 新增测试,覆盖模式切换、模式解析和翻译歌词可用性判断。

- 将译/音切换按钮移至进度条上方左侧,与网易云音乐布局一致
- 实现字体高亮效果:当前状态字体高亮显示
- 修复SAF URI解析问题,支持检测本地音译歌词文件
- 优化歌词文件检测逻辑,提高检测成功率
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: cwuom/NeriPlayer/.coderabbit.yaml

Review profile: QUIET

Plan: Advanced

Run ID: ea528ffa-fd33-479c-ac6c-2ede263f598d

📥 Commits

Reviewing files that changed from the base of the PR and between 855af9a and c7d4748.

⛔ Files ignored due to path filters (2)
  • README.md is excluded by !**/*.md
  • README_EN.md is excluded by !**/*.md
📒 Files selected for processing (7)
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/LyricsScreen.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/LyricsSecondaryLineMode.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/NowPlayingScreen.kt
  • app/src/main/res/values-en/strings_lyrics.xml
  • app/src/main/res/values-zh/strings_lyrics.xml
  • app/src/main/res/values/strings_lyrics.xml
  • app/src/test/java/moe/ouom/neriplayer/ui/screen/LyricsSecondaryLineModeTest.kt

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

新增次级歌词模式解析,用于根据翻译和音标歌词的可用性选择显示内容。播放页、横屏歌词视图和全屏歌词页使用解析后的模式控制副歌词显示。全屏歌词页新增模式切换控件,并将选择写入设置。更多选项中的歌词设置会根据当前歌词内容调整文案和选项。

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to c7d47

The previously reported local-lyrics lookup failures are addressed, and no actionable issue remains in the secondary-lyrics controls. The change is ready for normal merge checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to c7d47

The change appears limited to lyric display and preferences, with no identified security-sensitive action. An interrupted preference update could nevertheless leave the display choice inconsistent across views.

Retained concerns

  • Low · reliability · inferred: A translation or phonetic selection writes two shared preferences separately. Failure or cancellation after the first write can leave a partially applied choice visible to other lyric views; clearing the local request does not restore the completed write.
Security review details

Security Blast Radius

  • inferred — The identified partial-write effect is confined to shared on-device lyric-display choices across views; the inspected changed path shows no permission, identity, network, or privileged-operation sink.

Trust Boundaries and Controls

  • observed — Source-key matching and resolved-content checks gate the control’s visibility; a mutex and latest-request check constrain queued writes. Those checks do not make the two preference writes atomic.

Hardening Proposals

  • proposed — Persist a selected lyric mode as one operation, or provide compensation when the second preference write fails, so a displayed choice has a recoverable shared state.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 6 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确描述了歌词翻译/音译切换按钮的主要 UI 布局改动,内容简洁且与变更相关。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 6 files. (3 skipped: 3 unsupported.)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (2)
app/src/main/java/moe/ouom/neriplayer/data/local/media/LocalMediaSupport.kt-660-660 (1)

660-660: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

避免对非文档 URI 调用 getDocumentId。

当 source 是普通 content:// URI 且 resolveLocalFile 返回 null 时,inspectLyricsFast 会调用 parseSafDocumentIdToPath。该函数直接调用 android.provider.DocumentsContract.getDocumentId(uri);非文档 URI 会抛出 IllegalArgumentException。PlayerLyricsProvider 的本地歌词路径未捕获该异常,因此本地歌词读取会失败。

请先使用 DocumentsContract.isDocumentUri(context, uri) 检查 URI,或捕获异常并返回 null。

app/src/main/java/moe/ouom/neriplayer/data/local/media/LocalMediaSupport.kt-1218-1221 (1)

1218-1221: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

将 home: 映射到 Documents 目录。

对于 Android 内置 ExternalStorageProvider,home: 的根目录是 Environment.DIRECTORY_DOCUMENTS。当前代码会把 home:track.mp3 映射到外部存储根目录下的 track.mp3。当该路径不存在时,parseSafDocumentIdToPath 返回 null,因此 inspectLyricsFromDirectFile 不会调用 findNearbyLyricFiles,同目录的 .roma.lrc 也无法被发现。

                File(
                    File(
                        Environment.getExternalStorageDirectory(),
                        Environment.DIRECTORY_DOCUMENTS
                    ),
                    relativePath
                )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: cwuom/NeriPlayer/.coderabbit.yaml

Review profile: QUIET

Plan: Advanced

Run ID: caa15f84-bb5a-4bc1-b419-ac6816255167

📥 Commits

Reviewing files that changed from the base of the PR and between ac7bdea and 855af9a.

📒 Files selected for processing (4)
  • app/src/main/java/moe/ouom/neriplayer/core/player/metadata/PlayerLyricsProvider.kt
  • app/src/main/java/moe/ouom/neriplayer/data/local/media/LocalMediaSupport.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/LyricsScreen.kt
  • app/src/main/java/moe/ouom/neriplayer/ui/screen/NowPlayingScreen.kt

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@cwuom
cwuom merged commit 2fe5996 into cwuom:master Sep 25, 2026
10 of 12 checks passed
xu-qian123 pushed a commit to xu-qian123/NeriPlayer that referenced this pull request Sep 28, 2026
…erence, offset & secondary line toggle)

- Merge upstream PR cwuom#417: support lyric source preference order and default lyric offset settings
- Merge upstream PR cwuom#427: add secondary lyric toggle button (translation / romanized phonetic) and UI layout improvements
- Preserve local modifications including word-timed lyric fallback chain (Kugou -> QQ -> AMLL -> CloudMusic), home roaming, and custom playback action toolbar buttons
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.

2 participants