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

Commit a67a82e0 authored by Alex Chau's avatar Alex Chau Committed by Zak Cohen
Browse files

Add option in Task.getVisibleThumbnailRatio to disregard insets

- Added an option to control if insets should be considered

Bug: 179922117
Test: manual
Change-Id: I9bbda52b9b417544338707bb53ef2568e63a6df6
parent bfd57931
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -289,15 +289,19 @@ public class Task {
    /**
     * Returns the visible width to height ratio. Returns 0f if snapshot data is not available.
     */
    public float getVisibleThumbnailRatio() {
    public float getVisibleThumbnailRatio(boolean clipInsets) {
        if (lastSnapshotData.taskSize == null || lastSnapshotData.contentInsets == null) {
            return 0f;
        }

        float availableWidth = lastSnapshotData.taskSize.x - (lastSnapshotData.contentInsets.left
                + lastSnapshotData.contentInsets.right);
        float availableHeight = lastSnapshotData.taskSize.y - (lastSnapshotData.contentInsets.top
                + lastSnapshotData.contentInsets.bottom);
        float availableWidth = lastSnapshotData.taskSize.x;
        float availableHeight = lastSnapshotData.taskSize.y;
        if (clipInsets) {
            availableWidth -=
                    (lastSnapshotData.contentInsets.left + lastSnapshotData.contentInsets.right);
            availableHeight -=
                    (lastSnapshotData.contentInsets.top + lastSnapshotData.contentInsets.bottom);
        }
        return availableWidth / availableHeight;
    }