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

Commit ba5a642a authored by Alex Chau's avatar Alex Chau Committed by Automerger Merge Worker
Browse files

Merge "Add helper API in Task to avoid direct usage of lastSnapshotData in...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13582031

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I475184d612ff7d786a00862e12ea173c3b48db85
parents 7b1d7b37 22469170
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