Skip to content

[BUG] Bad grid mode after changing orientation #4884

Description

@jesmrec

Steps to reproduce

  1. In list mode, set the device in landscape
  2. Change to grid
  3. Set the device in portrait

Actual behaviour

Icons and thumbnails are overlapped like:

Image

Expected behaviour

Correctly displayed like:

Image

Xiaomi Redmi Note 13
Android 15

Activity

  1. added this to the Backlog milestone on Jun 12, 2026
  2. DeepDiver1975 commented on Jul 6, 2026

    @DeepDiver1975
    Contributor

    Confirmed. Root cause: the grid column count is never recomputed on rotation.

    • spanCount for grid mode is set from ColumnQuantity.calculateNoOfColumns() only at init (MainFileListFragment.kt:394) and on the view-type toggle (MainFileListFragment.kt:1006).
    • onConfigurationChanged (MainFileListFragment.kt:332) calls updateConfigDependentSizes() (:337), which resizes only the space-header card and empty-state icon — it does not touch layoutManager.spanCount.
    • calculateNoOfColumns() is width-dependent (ColumnQuantity.kt:45, uses displayMetrics.widthPixels), so the count computed in landscape (wide → more columns) stays applied after rotating to portrait (narrow), overlapping items. Matches the repro (set grid in landscape, rotate to portrait).

    Fix outline: recompute and reapply the grid span in updateConfigDependentSizes() when the current view type is grid, e.g. if (viewType == ViewType.VIEW_TYPE_GRID) layoutManager.spanCount = ColumnQuantity(requireContext(), R.layout.grid_item).calculateNoOfColumns(), then re-lay-out.

    Same orientation/config-change area as #4803.

    Aside: calculateNoOfColumns() at ColumnQuantity.kt:48 computes numberOfColumns.minus(1) but discards the result (not reassigned) — the intended column reduction is a no-op. Worth fixing alongside.

    🤖 Generated with Claude Code

  3. modified the milestones: Backlog, 4.9 - Next on Jul 17, 2026
  4. self-assigned this
    on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions