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

Commit 22469170 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Add helper API in Task to avoid direct usage of lastSnapshotData in Launcher" into sc-dev

parents ce0d6a33 337e10d2
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ public class Task {
    public Task(Task other) {
        this(other.key, other.colorPrimary, other.colorBackground, other.isDockable,
                other.isLocked, other.taskDescription, other.topActivity);
        lastSnapshotData.set(other.lastSnapshotData);
    }

    /**
@@ -281,6 +282,25 @@ public class Task {
                : key.baseIntent.getComponent();
    }

    public void setLastSnapshotData(ActivityManager.RecentTaskInfo rawTask) {
        lastSnapshotData.set(rawTask.lastSnapshotData);
    }

    /**
     * Returns the visible width to height ratio. Returns 0f if snapshot data is not available.
     */
    public float getVisibleThumbnailRatio() {
        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);
        return availableWidth / availableHeight;
    }

    @Override
    public boolean equals(Object o) {
        // Check that the id matches