Repository navigation
fix(map): stop shrinking intensity markers on dense Android screens - #661
Open
exptech-kitten[bot] wants to merge 1 commit into
Open
exptech-kitten[bot] wants to merge 1 commit into
exptech-kitten[bot] wants to merge 1 commit into
Conversation
Platform: android Fix(zh-Hant): 修正 Android 高解析度手機上地圖震度標記小到數字看不清 Fix(en-US): fix intensity markers rendering too small to read on high-resolution Android phones Requested-on-Discord: 靈靈 ⇛ 臺南新營 (@liangliang5102, 452103762320949248) https://discord.com/channels/926545182407688273/1570454137168994416/1570460309649367133 Co-Authored-By: lowrt <37591855+lowrt@users.noreply.github.com>
lowrt
force-pushed
the
kitten/stop-shrinking-intensity-markers-on-dens-mwdphs38
branch
from
November 13, 2026 04:14
a9b25dc to
190e955
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
whes1015
approved these changes
Nov 13, 2026
whes1015
left a comment
Member
There was a problem hiding this comment.
核准。程式邏輯沒問題,前提我也去對過原始碼:
- AOSP
BitmapFactory.setDensityFromOptions:inDensity = 0、沒有inBitmap時根本不會碰 density,bitmap 沿用Bitmap.getDefaultDensity(),也就是DisplayMetrics.DENSITY_DEVICE(qemu.sf.lcd_density/ro.sf.lcd_density),不是 160。 - MapLibre Android 13.5.0
Style.toImage:pixelRatio = bitmap.getDensity() / DisplayMetrics.DENSITY_DEFAULT。
所以舊的固定 1/3 在高密度機上確實會再縮一輪,devicePixelRatio / 3 的方向正確;mdpi 維持 1/3 也對。Android、iOS、build(含新測試)都綠了。
兩個不擋合併的小地方,之後有空再收就好:
lib/features/earthquake/presentation/pages/report_detail_page.dart約 294 行的註解還是舊說法(「Android 的addImage把 bitmap 釘在 density 160,不乘會比 3x iPhone 大 3 倍」),跟這支的結論剛好相反。那是 19ae25b 留下的,建議改掉,不然以後很容易照著它把1/3加回去。devicePixelRatio反映的是目前的顯示設定(DisplayMetrics.densityDpi),bitmap 的 density 是穩定的ro.sf.lcd_density;使用者調「顯示大小」時兩者可能差 10% 上下,標記會略大或略小。這不是這支要解的,知道就好。
另外 repo 規則要 2 個核准,我這顆只算一個,還要再一位。
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


這個 PR 做了什麼
Android 高解析度手機打開地震報告時,地圖上鄉鎮震度標記小到數字不好認。1080×2340 的畫面上,藍色 1、綠色 2、黃色 3 還在,比下方卡片和右側震度方塊小一截。
圖示曲線是對 3x iPhone 調的,要乘上「螢幕倍率 / 3」才會在每個密度都落在同一個 dp。iOS 有照
devicePixelRatio乘,Android 卻寫死1/3。這個常數只對得上 mdpi(先前 540×960 模擬器)。MapLibre 的圖示 pixel ratio 是bitmap.getDensity() / 160,style#addImage用inScaled = false、inDensity = 0、inTargetDensity = 0解碼、不重採樣;高密度手機上 bitmap 的 density 跟著螢幕走,再乘一次1/3標記就再縮一輪。lib/shared/map/map_image_density.dart。Android 改成和 iOS 一樣用devicePixelRatio / 3。地震報告頁本來就把MediaQuery.devicePixelRatioOf傳進來,這次才會用到。強震監視器沒傳參數,改走 dispatcher 的倍率;同一條曲線,站點圓標也會一起變大。test/shared/map/map_image_density_test.dart。mdpi 維持 1/3、2x 是 2/3、3x 是 1,Android 的 platform divisor 改成螢幕倍率,和 iPhone 算出同一個點尺寸。沒做的:
lib/features/earthquake/presentation/pages/report_detail_page.dart約 294 行的註解仍寫 Android 把 bitmap 釘在 160dpi。行為已經由上面的函式改正,註解沒一起改。也還沒在 1080×2340 實機上量過標記實際像素;若 bitmap density 其實仍是 160,這次會把標記放大成約三倍,需要再收回。相關 issue
沒有對應的 GitHub issue。討論在 ET-2026-0210:https://discord.com/channels/926545182407688273/1570454137168994416
怎麼驗
tool/check.sh、tool/check/commits.sh或模擬器,測試還沒在本機執行。CI 的build會跑test/shared/map/map_image_density_test.dart。檢查清單
tool/check/commits.sh origin/main..HEAD通過(這台環境跑不了,等 CI 的 commit 檢查)mise exec -- flutter analyze與mise exec -- flutter test通過(這台環境跑不了)由 @lowrt(Discord 靈靈 ⇛ 臺南新營)透過 kitten 開的 PR,合併前請人工 review。
觸發訊息:https://discord.com/channels/926545182407688273/1570454137168994416/1570460309649367133