Skip to content

feat(weather): add Android home screen weather widgets - #624

Open
Vinson1014 wants to merge 14 commits into
ExpTechTW:mainfrom
Vinson1014:android-widget
Open

Vinson1014 wants to merge 14 commits into
ExpTechTW:mainfrom
Vinson1014:android-widget

Conversation

@Vinson1014

@Vinson1014 Vinson1014 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

這個 PR 做了什麼

新增 Android 桌面天氣小工具,使用者可為每個小工具選擇目前位置或已儲存地點,並依小、中、大尺寸顯示即時天氣與預報。

  • 正式程式碼:新增原生 AppWidgetProvider、設定頁、RemoteViews 尺寸版型、背景更新與 WorkManager 排程、校時、定位與鄉鎮解析,以及 widget 專用 SQLite 快取與快照排序防護。
  • Flutter 與原生以 widget_snapshot channel 同步首頁天氣與已儲存地點;點擊 widget 可直接開啟 App 首頁。
  • Android widget 不會因首頁切換地點而清除其他獨立 widget 的快照。
  • 補齊 widget 多語字串、深色模式與 Android 12+ 動態色;Android CI 新增原生單元測試、instrumented test 與 lint。
  • 測試分開涵蓋 Dart platform channel/首頁整合,以及 Kotlin 單元、Robolectric、版面渲染與裝置測試。

相關 issue

  • 沒有對應的 issue

怎麼驗

  • tool/check/commits.sh origin/main..HEAD:13 個 commits 通過。
  • tool/check.sh:所有 CI gate 通過。
  • tool/dev/test_android.sh::app:testDebugUnitTest 通過,0 failures。
  • tool/dev/lint_android.sh::app:lintDebug 通過,無 lint error。
  • tool/dev/build.sh android:release APK 建置成功,輸出 build/app/outputs/flutter-apk/app-release.apk(86.8 MB)。
  • 實機以 Pixel Launcher 檢查小型淺色/深色、橫向淺色/深色與大型淺色/深色 widget;畫面未見明顯裁切,文字與圖示對比可接受。

實機截圖:

小型淺色 小型深色 橫向淺色 橫向深色
小型淺色 widget 小型深色 widget 橫向淺色 widget 橫向深色 widget
大型淺色 大型深色
大型淺色 widget 大型深色 widget

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
    —— commit 訊息就是更新日誌,格式見 commit.md
  • 一個 commit 一件事(這條 gate 驗不了,靠自己和 review)
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過
  • tool/dev/analyze.sh 與 tool/check.sh 通過
    —— 專案規範要求透過 tool/ 腳本使用 pinned Flutter;tool/check.sh 已執行 Dart 測試/coverage gate。
  • Android widget 原生字串使用 res/values*/widget_strings.xml,沒有寫死
  • CI 全部通過(gh pr checks:每一項都是 pass 或 skipped)—— 沒過不能合併,
    見 pr.md
  • 有 UI 變更:Android 原生 RemoteViews 使用集中於 res/values/widget_dimens.xml 的尺寸 token;已查看淺色/深色實機截圖,文字對比度可接受。

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.49%. Comparing base (bc4dc0e) to head (be10faa).
⚠️ Report is 1 commits behind head on main.

☔ 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.

@whes1015
whes1015 requested a review from YinCheng0106 October 16, 2026 12:04
@YinCheng0106 YinCheng0106 added the android Issues or pull requests related to the Android platform. label Oct 16, 2026
@YinCheng0106

Copy link
Copy Markdown
Member

CI 檢查未通過:請先 Rebase 至最新的 main

感謝這次新增 Android 天氣 Widget,以及補上原生測試的相關工作。

我確認了 PR #624 在 c9769cb 這個 commit 的 GitHub Actions 結果。目前 Android Build、Android Instrumented Tests 與 iOS Build 都已通過;未通過的是 CI / build,失敗步驟為 Branch is rebased on the base。

CI 日誌顯示:

this branch is behind main; rebase before merging
main is 13 commit(s) ahead of this branch

這次失敗的原因是 PR 分支尚未 Rebase 至最新的 main,並非 Kotlin 編譯錯誤或 Android Widget 測試失敗。上述落後 13 個 commit 是該次 CI 執行當下的數字,最新數量可能已經不同。

麻煩協助處理以下事項:

  1. Fetch 最新的 main,將 android-widget Rebase 到最新基底,請不要直接把 main Merge 進功能分支。
  2. 如果有衝突,請處理後再更新遠端分支。Rebase 會改寫 commit 歷史,若需要 --force-with-lease,請先確認沒有覆蓋其他協作者的提交。
  3. 更新後請重新執行 CI,確認所有必要的檢查皆為 Passed 或允許的 Skipped,再進行合併。由於此次 CI 在分支檢查階段就中止,後續部分檢查尚未執行,不能僅依 Android Build 通過就視為整體 CI 已通過。

失敗紀錄:CI / build — Branch is rebased on the base

另外,目前 Pixel 的 Widget 截圖可以作為第一階段的 UI 驗證,但 Samsung One UI、Xiaomi HyperOS 等不同 Launcher 的尺寸與排版仍需要後續確認。Android 專屬 UI 排版我會再另外調整,這部分不需要與本次 CI 修正一起處理。

謝謝!

Platform: android

New(zh-Hant): Android 桌面新增天氣小工具,可選擇地點並依尺寸顯示即時天氣與預報
New(en-US): add Android home screen weather widgets with location selection and size-adaptive weather and forecasts
Platform: android

New(zh-Hant): 首頁天氣更新會同步至 Android 小工具,切換首頁地點不會清除其他小工具的資料
New(en-US): sync Home weather updates to Android widgets without clearing their data when switching Home locations
Platform: android

New(zh-Hant): 點擊 Android 天氣小工具可直接開啟 App 首頁
New(en-US): open the app Home screen directly by tapping an Android weather widget
Platform: android

Fix(zh-Hant): Android 在粵語、簡體中文及香港繁體中文環境顯示在地化 App 名稱
Fix(en-US): show localized Android app names in Cantonese, Simplified Chinese and Hong Kong Traditional Chinese
Platform: android

Fix(zh-Hant): 修正天氣小工具偶爾錯判資料過期與預報時間
Fix(en-US): fix weather widgets occasionally misjudging data freshness and forecast timing
Platform: android

Fix(zh-Hant): 避免無效的小工具設定持續觸發背景更新
Fix(en-US): prevent invalid widget configurations from triggering ongoing background updates
Platform: android

Fix(zh-Hant): 修正天氣小工具在儲存暫時異常後無法自動恢復更新
Fix(en-US): restore automatic weather widget updates after temporary storage failures
@lowrt lowrt added this to the v26.4 milestone Oct 17, 2026

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

android Issues or pull requests related to the Android platform. size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants