Fix DWB placement in grouped task view

In grouped task view, DWB banners will now rotate properly when phone is
in landscape or seascape orientation. Also fixes a couple of minor
existing issues with the bottom task not displaying correctly in the
first place.

Fixes: 208357326
Fixes: 216218406

Test: Tested locally on Pixel 6, using landscape, seascape, and
portrait. Double-checked with task proportions changed, RtL/LtR, and
split top/split left/split right initialization.

Change-Id: I945f9937d2d4d784c0c74a006c7d0680daf628c2
This commit is contained in:
Jeremy Sim
2022-02-09 06:01:24 +00:00
parent e8b200eb6b
commit c78ac6277c
7 changed files with 52 additions and 20 deletions

View File

@@ -310,9 +310,10 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
}
@Override
public Pair<Float, Float> setDwbLayoutParamsAndGetTranslations(int taskViewWidth,
public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
int taskViewHeight, StagedSplitBounds splitBounds, DeviceProfile deviceProfile,
View[] thumbnailViews, int desiredTaskId, View banner) {
boolean isRtl = banner.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
float translationX = 0;
float translationY = 0;
FrameLayout.LayoutParams bannerParams = (FrameLayout.LayoutParams) banner.getLayoutParams();
@@ -323,7 +324,7 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
FrameLayout.LayoutParams snapshotParams =
(FrameLayout.LayoutParams) thumbnailViews[0]
.getLayoutParams();
bannerParams.gravity = TOP | START;
bannerParams.gravity = TOP | (isRtl ? END : START);
if (splitBounds == null) {
// Single, fullscreen case
bannerParams.width = taskViewHeight - snapshotParams.topMargin;
@@ -339,9 +340,11 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
// Set translations
if (desiredTaskId == splitBounds.rightBottomTaskId) {
translationY = (snapshotParams.topMargin + taskViewHeight)
* (splitBounds.leftTaskPercent) +
(taskViewHeight * splitBounds.dividerWidthPercent);
float topLeftTaskPlusDividerPercent = splitBounds.appsStackedVertically
? (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)
: (splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent);
translationY = snapshotParams.topMargin
+ ((taskViewHeight - snapshotParams.topMargin) * topLeftTaskPlusDividerPercent);
}
if (desiredTaskId == splitBounds.leftTopTaskId) {
translationY = snapshotParams.topMargin;
@@ -440,7 +443,9 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
StagedSplitBounds splitBoundsConfig, DeviceProfile dp) {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
int dividerBar = splitBoundsConfig.visualDividerBounds.width();
int dividerBar = splitBoundsConfig.appsStackedVertically
? splitBoundsConfig.visualDividerBounds.height()
: splitBoundsConfig.visualDividerBounds.width();
int primarySnapshotHeight;
int primarySnapshotWidth;
int secondarySnapshotHeight;