Skip to content

Add a grid density setting - #17543

Open
sandbranch wants to merge 2 commits into
nextcloud:masterfrom
sandbranch:grid-density-setting
Open

Add a grid density setting#17543
sandbranch wants to merge 2 commits into
nextcloud:masterfrom
sandbranch:grid-density-setting

Conversation

@sandbranch

Copy link
Copy Markdown

Depends on #17542. This branch contains that commit as well; it will show only its own change once #17542 is merged. Please review that one first.

Problem

The grid cell size can only be changed by pinching the file list, which is easy to miss and awkward to land on a particular size.

Fix

Add a density setting (Spacious / Default / Compact) under Settings → Files. It writes the same stored value the pinch gesture uses, so the two stay in step and neither overrides the other.

The options set how large the cells are rather than a fixed column count, deliberately: a column count that suits a tablet leaves a phone with cells too narrow to read, which is the problem #17542 fixes. Expressed as cell size, one stored value works correctly on every screen.

The file list only read that value while creating its view, so a density picked in the settings did not reach a list that was already open, and the list then wrote its stale value back when it saved its state. It now reads the value again on resume.

Testing

On a Samsung S23 the three options give 2 / 3 / 4 columns in portrait; on a Lenovo Tab P11 Pro (2nd gen) 4 / 5 / 7. Changing the setting takes effect on returning to the list, and the choice survives a restart.

New strings are added to values/strings.xml only.

The number of grid columns came straight from the stored zoom
preference and never looked at how wide the window actually is, so a
phone in portrait and a tablet in landscape both showed the same three
columns. onConfigurationChanged only ever clamped the count downwards,
which meant rotating to landscape raised the limit but never added a
column.

Add a GridLayoutManager that works out its own column count from the
width it is given during layout, and hand it a target column width
instead of a column count. The target width is a dimension resource, so
it can be adjusted per screen size later without touching this code.

The width has to be read during layout. The display metrics are not a
usable substitute: they describe the display rather than the space the
list occupies, they are not yet meaningful while the view is being
created, and during a rotation they can still describe the previous
orientation, which produced a portrait grid laid out to the width of a
landscape screen.

Pinch to zoom keeps working and is still persisted. It now sets how
large the cells are rather than a fixed column count, so a zoom level
chosen in portrait carries over to landscape instead of being lost.

Addresses part of the grid item of nextcloud#6769.

Signed-off-by: David Sandquist <sandquist@gmail.com>
The grid cell size could only be changed by pinching the file list,
which is easy to miss and awkward to land on a particular size.

Add a density setting that writes the same stored value the pinch
gesture uses, so the two stay in step and neither overrides the other.
The options set how large the cells are rather than a fixed column
count, because a column count that suits a tablet leaves a phone with
cells too narrow to read.

The file list only read that value while creating its view, so a density
picked in the settings did not reach a list that was already open, and
the list then wrote its stale value back when it saved its state. Read
the value again on resume so the change takes effect on the way back.

Signed-off-by: David Sandquist <sandquist@gmail.com>
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