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

Commit 97376cfe authored by Winson Chung's avatar Winson Chung
Browse files

Ensure that the thumbnail path is valid even without a thumbnail.

- When there is no thumbnail snapshot, an empty sized thumbnail path is
  created since thumbnailWidth/Height are zero.  Instead, like the parent
  class, the path should default to the view width/height in such a case.

Bug: 66938643
Test: Launch PlayMovies video anew, go home, then to overview
Change-Id: I354ff0716ee44149f50ff11fa435161cf466c0cc
parent 7c112b73
Loading
Loading
Loading
Loading
+45 −37
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import com.android.systemui.recents.views.TaskViewThumbnail;

public class GridTaskViewThumbnail extends TaskViewThumbnail {

    private Path mThumbnailOutline;
    private Path mRestBackgroundOutline;
    private final Path mThumbnailOutline = new Path();
    private final Path mRestBackgroundOutline = new Path();
    // True if either this view's size or thumbnail scale has changed and mThumbnailOutline should
    // be updated.
    private boolean mUpdateThumbnailOutline = true;
@@ -77,6 +77,8 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail {
            (int) (mThumbnailRect.width() * mThumbnailScale));
        final int thumbnailHeight = Math.min(viewHeight,
            (int) (mThumbnailRect.height() * mThumbnailScale));

        if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
            // Draw the thumbnail, we only round the bottom corners:
            //
            // outerLeft                outerRight
@@ -99,25 +101,14 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail {
            final int outerTop = 0;
            final int outerRight = outerLeft + thumbnailWidth;
            final int outerBottom = outerTop + thumbnailHeight;
        mThumbnailOutline = new Path();
        mThumbnailOutline.moveTo(outerLeft, outerTop);
        mThumbnailOutline.lineTo(outerRight, outerTop);
        mThumbnailOutline.lineTo(outerRight, outerBottom - mCornerRadius);
        mThumbnailOutline.arcTo(outerRight -  2 * mCornerRadius, outerBottom - 2 * mCornerRadius,
                outerRight, outerBottom, 0, 90, false);
        mThumbnailOutline.lineTo(outerLeft + mCornerRadius, outerBottom);
        mThumbnailOutline.arcTo(outerLeft, outerBottom - 2 * mCornerRadius,
                outerLeft + 2 * mCornerRadius, outerBottom, 90, 90, false);
        mThumbnailOutline.lineTo(outerLeft, outerTop);
        mThumbnailOutline.close();
            createThumbnailPath(outerLeft, outerTop, outerRight, outerBottom, mThumbnailOutline);

        if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
            if (thumbnailWidth < viewWidth) {
                final int l = Math.max(0, outerRight - mCornerRadius);
                final int r = outerRight;
                final int t = outerTop;
                final int b = outerBottom;
                mRestBackgroundOutline = new Path();
                mRestBackgroundOutline.reset();
                mRestBackgroundOutline.moveTo(l, t); // A
                mRestBackgroundOutline.lineTo(r, t); // B
                mRestBackgroundOutline.lineTo(r, b - mCornerRadius); // C
@@ -133,7 +124,7 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail {
                final int r = outerRight;
                final int t = Math.max(0, thumbnailHeight - mCornerRadius);
                final int b = outerBottom;
                mRestBackgroundOutline = new Path();
                mRestBackgroundOutline.reset();
                mRestBackgroundOutline.moveTo(l, t); // A
                mRestBackgroundOutline.lineTo(r, t); // B
                mRestBackgroundOutline.lineTo(r, b - mCornerRadius); // C
@@ -145,7 +136,24 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail {
                mRestBackgroundOutline.lineTo(l, t); // A
                mRestBackgroundOutline.close();
            }
        }
        } else {
            createThumbnailPath(0, 0, viewWidth, viewHeight, mThumbnailOutline);
        }
    }

    private void createThumbnailPath(int outerLeft, int outerTop, int outerRight, int outerBottom,
            Path outPath) {
        outPath.reset();
        outPath.moveTo(outerLeft, outerTop);
        outPath.lineTo(outerRight, outerTop);
        outPath.lineTo(outerRight, outerBottom - mCornerRadius);
        outPath.arcTo(outerRight -  2 * mCornerRadius, outerBottom - 2 * mCornerRadius, outerRight,
                outerBottom, 0, 90, false);
        outPath.lineTo(outerLeft + mCornerRadius, outerBottom);
        outPath.arcTo(outerLeft, outerBottom - 2 * mCornerRadius, outerLeft + 2 * mCornerRadius,
                outerBottom, 90, 90, false);
        outPath.lineTo(outerLeft, outerTop);
        outPath.close();
    }

    @Override