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

Commit c7d676ce authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Improve splitscreen recents animation in seascape

* We need to swap the primary and secondary thumbnail
positions in fake seascape since the primary is the
visually left app (which is the bottom in portrait)

Bug: 249693334
Change-Id: I325133ab86e4fcd26c6162a3de007d68e9ba6bf1
parent d7a7bfc3
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -662,6 +662,16 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
            secondarySnapshotHeight = totalThumbnailHeight - primarySnapshotHeight - dividerBar;
            int translationY = primarySnapshotHeight + spaceAboveSnapshot + dividerBar;
            secondarySnapshot.setTranslationY(translationY);

            FrameLayout.LayoutParams primaryParams =
                    (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
            FrameLayout.LayoutParams secondaryParams =
                    (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();
            secondaryParams.topMargin = 0;
            primaryParams.topMargin = spaceAboveSnapshot;

            // Reset unused translations
            primarySnapshot.setTranslationY(0);
            secondarySnapshot.setTranslationX(0);
            primarySnapshot.setTranslationX(0);
        }
+45 −2
Original line number Diff line number Diff line
@@ -121,9 +121,9 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
        // the screen. This is to preserve consistency when the user rotates: From the user's POV,
        // the primary should always be on the left.
        if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
            outRect.top += (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent));
            outRect.top += (int) (outRect.height() * ((1 - topLeftTaskPercent)));
        } else {
            outRect.bottom = outRect.top + (int) (outRect.height() * topLeftTaskPercent);
            outRect.bottom -= (int) (outRect.height() * (topLeftTaskPercent + dividerBarPercent));
        }
    }

@@ -266,6 +266,49 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
        secondaryIconView.setLayoutParams(secondaryIconParams);
    }

    @Override
    public void measureGroupedTaskViewThumbnailBounds(View primarySnapshot, View secondarySnapshot,
            int parentWidth, int parentHeight, SplitBounds splitBoundsConfig, DeviceProfile dp,
            boolean isRtl) {
        FrameLayout.LayoutParams primaryParams =
                (FrameLayout.LayoutParams) primarySnapshot.getLayoutParams();
        FrameLayout.LayoutParams secondaryParams =
                (FrameLayout.LayoutParams) secondarySnapshot.getLayoutParams();

        // Swap the margins that are set in TaskView#setRecentsOrientedState()
        secondaryParams.topMargin = dp.overviewTaskThumbnailTopMarginPx;
        primaryParams.topMargin = 0;

        // Measure and layout the thumbnails bottom up, since the primary is on the visual left
        // (portrait bottom) and secondary is on the right (portrait top)
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
        int dividerBar = splitBoundsConfig.appsStackedVertically
                ? (int) (splitBoundsConfig.dividerHeightPercent * parentHeight)
                : (int) (splitBoundsConfig.dividerWidthPercent * parentWidth);
        int primarySnapshotHeight;
        int primarySnapshotWidth;
        int secondarySnapshotHeight;
        int secondarySnapshotWidth;

        float taskPercent = splitBoundsConfig.appsStackedVertically ?
                splitBoundsConfig.topTaskPercent : splitBoundsConfig.leftTaskPercent;
        primarySnapshotWidth = parentWidth;
        primarySnapshotHeight = (int) (totalThumbnailHeight * (taskPercent));

        secondarySnapshotWidth = parentWidth;
        secondarySnapshotHeight = totalThumbnailHeight - primarySnapshotHeight - dividerBar;
        secondarySnapshot.setTranslationY(0);
        primarySnapshot.setTranslationY(secondarySnapshotHeight + spaceAboveSnapshot + dividerBar);
        primarySnapshot.measure(
                View.MeasureSpec.makeMeasureSpec(primarySnapshotWidth, View.MeasureSpec.EXACTLY),
                View.MeasureSpec.makeMeasureSpec(primarySnapshotHeight, View.MeasureSpec.EXACTLY));
        secondarySnapshot.measure(
                View.MeasureSpec.makeMeasureSpec(secondarySnapshotWidth, View.MeasureSpec.EXACTLY),
                View.MeasureSpec.makeMeasureSpec(secondarySnapshotHeight,
                        View.MeasureSpec.EXACTLY));
    }

    /* ---------- The following are only used by TaskViewTouchHandler. ---------- */

    @Override