Account for all apps offset during taskbar layout
When laying out its contents, TaskBarView generally lays the icons so they get centered in the task bar - this is done by calculating the total size of all icons during layout (this will generally be transient taskbar icon sizes), and substracting extra margins that get removed from the divider view. After initial layout, `TaskbarViewController` adjusts the icon view positions to match expected icon sizes (it offsets icons horizontally reducing margins between icons to match intended icon sizes for the taskbar type). Additionally, `TaskbarViewController` translates all apps button container - this transformation is asymetric, and causes the task bar contents to become off-center. To account for this, update taskbar layout to reduce the total icon size used for centering icons by the amount all apps button is offset. This makes the taskbar off-center after initial layout, but by the amount by which all apps button is eventually offset (resulting in centered taskbar content). This alone worked for left-to-right UI direction, but not right-to-left. To fix this, correct the reference point from which TaskBarViewController offsets icon positions. The offset used to be calculated by distance of an icon index from half of the icon count - instead offset needs to be calculated relative to mid-index. For example, icon at index i needs to be offset by (mid_index - i) * difference_in_icon_size: ((n-1) / 2 - i) * diff). Code used to work for LTR UI layout because the list of icons contained invisible qsb view, which incresed both n and indices by 1, so (n' / 2 - i') * diff_in_icon_size worked fine, as it evaluated to ((n + 1) / 2 - i - 1) * diff = ((n - 1) / - i) * diff Bug: 372567501 Test: Verify that taskbar icons are centered when it needs to be, both with ltr and rtl language UI. Flag: EXEMPT bugfix Change-Id: Ic06873cc225a4361d9140d72c055db23f446a1ad
Loading
Please register or sign in to comment