Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05b87afd authored by Cassy Chun-Crogan's avatar Cassy Chun-Crogan
Browse files

[DocsUI M3] Fix bugs when calculating column count for grid

When calculating the column count (the number of items that
can fit into a row) scaling needs to be taken into account.
E.g. if items are double the size, only half the number can fit.

There were three issues with this:
1. Previously all values (grid item width, grid item margin and view
padding) were scaled but the view width wasn't leading to an incorrect
column count. Fix this by scaling the view width too.
2. The view width was calculated with getWidth() but if layout
hadn't occurred yet, this value may be out of date and the number of
items that can fit in the post-layout view could be wrong. Use
getMeasuredWidth() instead to get the post-layout width.
3. The returned value was rounded rather than floored. E.g. if the
column count was 4.6, 5 would be returned.

See bug for demo.

Bug: 407851636
Test: m DocumentsUIGoogle && manual inspection
Flag: com.android.documentsui.flags.use_material3
Change-Id: If332b9c8cc4f3c7cf3bc040a451b780ef6c31ff3
parent 124782ad
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment