Skip to content

Androidで走行中画面のPiP表示に対応 - #6076

Merged
TinyKitten merged 2 commits into
devfrom
feature/android-pip
May 29, 2026
Merged

TinyKitten merged 2 commits into
devfrom
feature/android-pip

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 29, 2026 •

Copy link
Copy Markdown
Member

概要

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

closes #6035

スクリーンショット(任意)

Summary by CodeRabbit

  • New Features

    • Androidのピクチャーインピクチャー(PiP)対応を追加。PiP中は現在・次の停車駅情報を小画面で表示します
    • Android向け設定画面を追加し、PiPの有効/無効を切替・保存できます
    • PiP用の表示コンポーネントと制御フックを導入し、挙動を連携しました
  • Chores

    • 英語・日本語の翻訳キーを追加・整理しました

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35596bfd-9c00-497f-a658-6f04d2abef9b

📥 Commits

Reviewing files that changed from the base of the PR and between 24a2b6a and 847081a.

📒 Files selected for processing (1)
  • android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt

📝 Walkthrough

Walkthrough

Android向けPicture-in-Pictureをネイティブで有効化し、React Native側とJotaiで状態同期、PiP専用UIと設定画面、翻訳を追加してアプリに統合しています。

Changes

Android Picture-in-Picture機能

Layer / File(s) Summary
ネイティブAndroidの基盤とマニフェスト
android/app/src/main/AndroidManifest.xml, android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt, android/app/src/main/java/me/tinykitten/trainlcd/PictureInPictureModule.kt, android/app/src/main/java/me/tinykitten/trainlcd/TrainLCDPackage.kt
AndroidManifestにPiPフラグを追加、MainActivityでonUserLeaveHint/onPictureInPictureModeChangedを実装してenterPictureInPictureModeを試行。PictureInPictureModuleはRNブリッジで有効フラグ管理とTrainLCDPictureInPictureModeChangedイベントを送出。パッケージでモジュールを登録。
状態管理とネイティブユーティリティ
src/store/atoms/pictureInPicture.ts, src/constants/asyncStorage.ts, src/utils/native/android/pictureInPictureModule.ts, src/hooks/useAndroidPictureInPicture.ts, src/hooks/index.ts
JotaiのpictureInPictureAtomと型定義を追加、AsyncStorageキーを追加。Androidネイティブモジュールの型ラッパーを実装し、useAndroidPictureInPictureフックで駅情報からactivityStateを派生してatomに同期、ネイティブイベントを購読/解除する。
UI・設定・アプリ統合
src/components/AndroidPictureInPictureView.tsx, src/components/Permitted.tsx, src/screens/AndroidSettings.tsx, src/screens/AppSettings.tsx, src/screens/Main.tsx, src/stacks/MainStack.tsx
AndroidPictureInPictureViewを追加し、PiPアクティブ時に簡易表示を描画。Permittedで永続化設定を読み込みatom初期化。AndroidSettingsにPiPトグルを追加、AppSettingsのメニューにAndroid項目を追加。MainでPiPがアクティブならPiPビューを早期返却。MainStackに設定画面を追加。
多言語対応
assets/translations/en.json, assets/translations/ja.json
androidSettings, pictureInPictureTitle, pictureInPictureDescription, passingStation等の翻訳キーを追加・再配置。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 分

🐰 小さな窓で駅名がひかるよ
背景で動く列車の声が聴こえる 🛤️
マニフェストからAtomへ、そっとつながる
設定で許可して、窓は開くよ
旅は続く、ピクチャーの片隅で 🚆

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、Androidで走行中画面のPiP表示に対応という変更の主要な目的を正確に反映しており、簡潔で明確です。
Description check ✅ Passed PR説明は概要・変更の種類・テスト確認状況・関連Issueなどテンプレートの主要項目がすべて埋められており、変更内容の詳細記述のみ不完全ですが、大枠は満たしています。
Linked Issues check ✅ Passed PR内の全変更が#6035の受け入れ条件(設定ON/OFF対応、PiP専用簡易レイアウト表示、クラッシュ防止、バックグラウンド遷移時のPiP自動起動)を網羅して実装されています。
Out of Scope Changes check ✅ Passed すべての変更がAndroid PiP機能の実装に直結し、#6035で定義された範囲内に収まっています。不要な修正や関連性のない変更は含まれていません。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • ✅ Generated successfully - (🔄 Check to regenerate)
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/android-pip

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

@TinyKitten
TinyKitten force-pushed the feature/android-pip branch from 10c87f5 to 24a2b6a Compare May 29, 2026 04:53

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt`:
- Around line 77-85: Don't emit
PictureInPictureModule.emitPictureInPictureModeChanged(true) before attempting
PiP; instead call Activity.enterPictureInPictureMode(params) inside the posted
Runnable, capture its boolean return and only emit true when it returns true,
and emit false if it returns false or an IllegalStateException is thrown. Remove
the pre-enter emit, keep the try/catch around enterPictureInPictureMode(params)
(emit false in the catch), and ensure onPictureInPictureModeChanged(...) remains
the canonical source of PiP state changes so JS is ultimately synchronized.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53a55f3a-197d-4ab3-bdda-9e0c2c852a4a

📥 Commits

Reviewing files that changed from the base of the PR and between 1e53db9 and 24a2b6a.

📒 Files selected for processing (17)
  • android/app/src/main/AndroidManifest.xml
  • android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt
  • android/app/src/main/java/me/tinykitten/trainlcd/PictureInPictureModule.kt
  • android/app/src/main/java/me/tinykitten/trainlcd/TrainLCDPackage.kt
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/AndroidPictureInPictureView.tsx
  • src/components/Permitted.tsx
  • src/constants/asyncStorage.ts
  • src/hooks/index.ts
  • src/hooks/useAndroidPictureInPicture.ts
  • src/screens/AndroidSettings.tsx
  • src/screens/AppSettings.tsx
  • src/screens/Main.tsx
  • src/stacks/MainStack.tsx
  • src/store/atoms/pictureInPicture.ts
  • src/utils/native/android/pictureInPictureModule.ts

@TrainLCD TrainLCD deleted a comment from coderabbitai Bot May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt

Commit: 847081a2bb348a52b0bba90ba6766e13f60f3283

The changes have been pushed to the feature/android-pip branch.

Time taken: 1m 50s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <[email protected]>
@TinyKitten
TinyKitten merged commit 90ccf6e into dev May 29, 2026
3 checks passed
@TinyKitten
TinyKitten deleted the feature/android-pip branch May 29, 2026 05:08
@coderabbitai

coderabbitai Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #6082

coderabbitai Bot added a commit that referenced this pull request May 29, 2026
Docstrings generation was requested by @TinyKitten.

* #6076 (comment)

The following files were modified:

* `android/app/src/main/java/me/tinykitten/trainlcd/MainActivity.kt`
* `android/app/src/main/java/me/tinykitten/trainlcd/PictureInPictureModule.kt`
* `android/app/src/main/java/me/tinykitten/trainlcd/TrainLCDPackage.kt`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

走行中画面を Picture in Picture (Android) で表示できるようにする

1 participant