Skip to content

fix(adaptive-window): refresh stale window bounds after configuration changes - #64

Merged
Moriafly merged 2 commits into
mainfrom
fix/android12-adaptive-window
Oct 24, 2026
Merged

Moriafly merged 2 commits into
mainfrom
fix/android12-adaptive-window

Conversation

@Moriafly

@Moriafly Moriafly commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

On Android API 32 and below, configuration changes can return stale window bounds. Adaptive layouts may retain the previous orientation after rotation, preventing phone landscape behavior from taking effect. This PR also fixes regular emulators being classified as foldables when they advertise the hinge-angle feature without exposing an actual hinge sensor.

Backport Google's pending-update flag and refresh window bounds after the next global layout pass. The condition matches upstream: SDK_INT < TIRAMISU, covering API 23–32 within SaltUI's supported range. Window sizing uses the same WindowMetricsCalculator, Context unwrapping, and unsupported-Context fallback as upstream to preserve window and split-screen semantics on older Android versions. Declare androidx.window:window:1.5.0, already a Compose UI runtime dependency, explicitly for compilation.

The host View owns the state. Listeners are removed on detach and restored on reattach. API 33+, Desktop, and iOS retain their existing paths. Upstream source references and Apache copyright notices are preserved.

Upstream fix: AndroidX 48413c3, addressing b/525259151, b/525284940, and b/508799456. Verified that Compose UI 1.13.0-alpha01 includes the fix, while the currently used 1.12.1 does not. The upstream compatibility range does not imply that the issue has been reproduced on every older Android version.

Validation:

  • Salt Adaptive Window local publication and the SPA build passed.
  • All 438 existing SPA unit tests passed.
  • After updating the window-size calculation path, repeated portrait/landscape transitions were checked in the main and player screens on an Android 12 emulator. Layout and system bar behavior were correct.
  • Earlier Android 12 checks covered window resizing without rotation, tablet-sized layouts, Activity recreation, and Chinese locale retention.
  • API 23–29 have not been verified at runtime. Android 16 runtime validation could not be completed because the emulator repeatedly disconnected.
  • No UI test code was added or modified.

Backport AndroidX 48413c3's pending-update flag and post-global-layout
refresh for API 32 and below, covering SaltUI's supported API 23-32 range.
Use the same WindowMetricsCalculator and supported-context unwrapping as
AndroidWindowInfo so older Android versions retain window and split-screen
semantics. Declare the existing Compose runtime dependency explicitly for
compilation, keeping its current 1.5.0 baseline.

Keep state on the host View, detach and restore listeners with its lifecycle,
and retain upstream source references and Apache attribution. Android 33+
and other platforms keep their existing window information path.

Require an actual hinge sensor to avoid misclassifying regular emulators
as foldables. Enable Android resources for a collision-free View tag ID.

Validation: module publication and SPA build passed; all 438 existing SPA
unit tests passed. Android 12 runtime checks covered repeated rotation in
the main and player screens. Earlier checks also covered window resizing,
tablet layout, Activity recreation and locale retention. API 23-29 have not
been runtime-verified; Android 16 emulator disconnects prevented validation.
@Moriafly
Moriafly force-pushed the fix/android12-adaptive-window branch from 21e7813 to 7bd23b4 Compare October 24, 2026 06:41
Remove redundant parentheses around the safe cast in the View-tag state lookup to satisfy CodeFactor detekt.UnnecessaryParentheses. The safe cast still binds before the Elvis fallback, preserving state reuse and initialization behavior.

Validation: :salt-adaptive-window:compileAndroidMain passed offline; git diff --check passed. This syntax-only change does not require additional tests.
@Moriafly Moriafly changed the title 修复:Android 12 旋转后自适应窗口尺寸不更新 fix(adaptive-window): refresh stale window bounds after configuration changes Oct 24, 2026
@Moriafly
Moriafly merged commit e943964 into main Oct 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant