Skip to content

feat(earthquake): let the report image be saved to the gallery - #658

Open
whes1015 wants to merge 1 commit into
mainfrom
feat/report-image-save
Open

whes1015 wants to merge 1 commit into
mainfrom
feat/report-image-save

Conversation

@whes1015

@whes1015 whes1015 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

這個 PR 做了什麼

地震報告詳情頁最下方的「地震報告圖」重新可以儲存了:圖片下方多一顆「儲存圖片」按鈕,按下後把中央氣象署的原始報告 PNG 寫進系統相簿,並用 SnackBar 回報結果(已儲存/沒有相簿權限/儲存失敗)。

這是 Discord 問題回報 ET-2026-0197 的需求(3.2.0 版可以存,26.x 改版後不見了)。

正式程式碼

  • lib/core/platform/photo_library.dart(新):gal 的薄封裝。先 hasAccess,沒有才 requestAccess,被拒絕回 permissionDenied(不丟例外給 UI);GalException 一律映射成 PhotoSaveOutcome,並用 Log.error 留下紀錄。
  • lib/features/earthquake/presentation/pages/report_detail_page.dart:_ReportImageCard 載入成功時,圖片下方加一顆下載圖示的 TextButton。儲存中按鈕停用並顯示轉圈圈,避免連點寫兩張。
  • ios/Runner/Info.plist:NSPhotoLibraryAddUsageDescription(只申請「加入相簿」,不讀整個相簿)。
  • android/app/src/main/AndroidManifest.xml:WRITE_EXTERNAL_STORAGE 加 maxSdkVersion="28";Android 10+ 走 MediaStore 不需要權限,minSdk 26 才保留這行。
  • pubspec.yaml / pubspec.lock:加 gal ^2.3.3(2.3.1 起有 Swift Package Manager 支援,這個專案沒有 CocoaPods)。

測試

  • test/core/platform/photo_library_test.dart:mock gal 的 method channel,5 個案例(已授權、詢問後授權、拒絕、原生 ACCESS_DENIED、其他原生錯誤)。

l10n

  • 4 個新 key(reportDetailImageSave / reportDetailImageSaved / reportDetailImageSavePermission / reportDetailImageSaveFailed),12 個 ARB 都補齊,tool/check/l10n.sh 通過。

沒做的、要留意的

  • 儲存的是 CWA 原始 PNG bytes(reportImageUrl),不是截圖,所以畫質是原始解析度。
  • 沒做分享面板(那是 [Idea]: 新增地震報告與防災資訊分享圖片功能 #651 的範圍),也沒做長按儲存。
  • iOS 上 gal 把名字當 originalFilename 傳、不帶副檔名;內容本身是 PNG,相簿顯示正常。
  • 還沒在實機/模擬器驗過儲存流程,深色模式也沒有截圖。
  • 本機跑完整 flutter test 時有 13 個 test/tool/* 失敗,原因是這台環境沒有 mise(腳本回 126),與這個改動無關;CI 有 mise 會正常執行。

相關 issue

怎麼驗

  • dart analyze(全 repo):No issues found
  • flutter test test/core/platform/photo_library_test.dart:5 個通過
  • tool/check/{l10n,layering,storage,wall_clock,pubspec_lock,notification_sounds,tooling}.sh 全部通過
  • tool/check/commits.sh origin/main..HEAD:OK
  • 實機驗法:開任一地震報告 → 把底部 sheet 拉到「地震報告圖」 → 按「儲存圖片」 → 相簿多一張報告圖(第一次會跳相簿權限)

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
  • 一個 commit 一件事
  • dart analyze 與 flutter test(本機能跑的部分)通過
  • 新的使用者可見字串都走 AppLocalizations
  • CI 全部通過(Android / iOS / Instrumented / build / code-review / Codecov 都是 pass)
  • 有 UI 變更:間距沿用既有 AppSpacing,但深色模式尚未在實機看過

Platform: all

New(zh-Hant): 地震報告圖可以儲存到相簿了
New(en-US): the report image can now be saved to your photo library
@codecov

codecov Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.26316% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.39%. Comparing base (07c0c3d) to head (d723f65).

Files with missing lines Patch % Lines
...thquake/presentation/pages/report_detail_page.dart 46.87% 17 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant