Merge "Add option in Task.getVisibleThumbnailRatio to disregard insets" into sc-dev

This commit is contained in:
Zak Cohen
2021-03-12 04:51:58 +00:00
committed by Android (Google) Code Review

View File

@@ -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;
}