Skip to content

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

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

Vinson1014 wants to merge 28 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.48%. Comparing base (5b3a103) to head (824fa11).

☔ 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 修正一起處理。

謝謝!

@YinCheng0106

Copy link
Copy Markdown
Member

Android Weather Widget Screenshots

Widget Preview

Theme Small Small Tall Medium Large
Light Small Light Small Tall Light Medium Light Large Light
Dark Small Dark Small Tall Dark Medium Dark Large Dark

這次新增 Small Tall,因為我發現在 Small Widget 在 Android 端是可以拉長的,故作出一個新的 Widget 樣式 (Small Tall)

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

LGTM

Vinson1014 and others added 16 commits October 24, 2026 22:16
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
Platform: android

Optimization(zh-Hant): 天氣小工具以 HH:mm 顯示觀測時間,並改善各尺寸版面與窄版體感溫度顯示
Optimization(en-US): Show HH:mm observation times and improve weather widget layouts and narrow apparent-temperature readings
Fix(zh-Hant): 天氣小工具僅在需要時顯示重新整理按鈕,暫時無法取得位置時可再次重試
Fix(en-US): Show widget refresh controls when needed and allow retries after temporary location failures
Platform: android

New(zh-Hant): 小型天氣小工具新增直向加高版型,依可用高度切換
New(en-US): Small weather widgets adapt to taller available space
Optimization(zh-Hant): 調整小型天氣小工具的資訊排列與天氣圖示大小
Optimization(en-US): improve Small weather widget information layout and icon sizes
Fix(zh-Hant): 修正大型天氣圖示尺寸與小型小工具泰文提示字形裁切
Fix(en-US): correct Large weather icon sizing and Thai status glyph clipping in Small widgets
YinCheng0106 and others added 12 commits October 24, 2026 22:16
Platform: android

New(zh-Hant): 小型緊湊天氣小工具新增無障礙自適應版型
New(en-US): Add an accessible adaptive Compact weather widget layout
Optimization(zh-Hant): 根據實際排版量測決定資訊降級,避免過早隱藏天氣資料
Optimization(en-US): Use native layout measurements to avoid unnecessary information fallback
Fix(zh-Hant): 修正大字體下溫度裁切與泰文字形顯示問題
Fix(en-US): Fix temperature clipping at large font scales and Thai glyph clipping
Platform: android

Fix(zh-Hant): 修正大型緊湊天氣小工具逐時預報降雨機率裁切問題
Fix(en-US): Fix hourly precipitation probability clipping in Large Tight weather widgets
Optimization(zh-Hant): 調整大型緊湊版區段間距,保留完整預報資訊
Optimization(en-US): Optimize Large Tight section spacing to preserve complete forecast information
Platform: android

Fix(zh-Hant): 修正大型天氣小工具在最小高度下逐時預報降雨機率遭裁切的問題
Fix(en-US): Fix hourly precipitation probability clipping in minimum-height Large weather widgets
Optimization(zh-Hant): 優化大型版型區段間距,確保五欄逐時預報完整顯示
Optimization(en-US): Optimize Large widget spacing to keep all five hourly forecasts visible
Platform: android

Fix(zh-Hant): 修正 Android 8.0 天氣小工具泰文狀態提示文字上緣裁切問題
Fix(en-US): Fix top-edge clipping of Thai status text in Android 8.0 weather widgets
Platform: android

Fix(zh-Hant): 修正 Android 天氣小工具在不顯示預報時仍反覆重新抓取預報
Fix(en-US): Stop Android weather widgets re-fetching a forecast they no longer show
Platform: android

Fix(zh-Hant): 修正 App 未開啟時點擊 Android 天氣小工具不會回到首頁
Fix(en-US): Fix tapping an Android weather widget not opening Home when the app was closed
Platform: android

Fix(zh-Hant): 修正部分啟動器旋轉後 Android 天氣小工具內容被裁切
Fix(en-US): Fix clipped Android weather widget content after rotation on some launchers
Platform: android

Fix(zh-Hant): 修正資料暫時讀取失敗時 Android 天氣小工具誤要求重新設定
Fix(en-US): Stop Android weather widgets asking to be reconfigured after a temporary read failure

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.

4 participants