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

Commit 3e85f9e4 authored by Winson's avatar Winson
Browse files

Drawing thumbnail background color for empty space in view.

- When showing landscape thumbnails in portrait, the thumbnails are
  aspect scaled to fit the width of the view, this change will draw
  a solid color to fill the other part so that we don't see the
  current edge-clamp texture effect.

Change-Id: Icf08239942f9179c66ba0f8d8ddd00f7d2a09d3c
parent 9bbd2861
Loading
Loading
Loading
Loading
+34 −4
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.LightingColorFilter;
import android.graphics.Matrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;
@@ -48,6 +49,7 @@ public class TaskViewThumbnail extends View {
    float mDimAlpha;
    float mDimAlpha;
    Matrix mScaleMatrix = new Matrix();
    Matrix mScaleMatrix = new Matrix();
    Paint mDrawPaint = new Paint();
    Paint mDrawPaint = new Paint();
    Paint mBgFillPaint = new Paint();
    BitmapShader mBitmapShader;
    BitmapShader mBitmapShader;
    LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0);
    LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0);


@@ -79,6 +81,7 @@ public class TaskViewThumbnail extends View {
        mDrawPaint.setAntiAlias(true);
        mDrawPaint.setAntiAlias(true);
        mCornerRadius = getResources().getDimensionPixelSize(
        mCornerRadius = getResources().getDimensionPixelSize(
                R.dimen.recents_task_view_rounded_corners_radius);
                R.dimen.recents_task_view_rounded_corners_radius);
        mBgFillPaint.setColor(Color.WHITE);
    }
    }


    /**
    /**
@@ -100,10 +103,37 @@ public class TaskViewThumbnail extends View {
        if (mInvisible) {
        if (mInvisible) {
            return;
            return;
        }
        }
        // Draw the thumbnail with the rounded corners

        if (mThumbnailRect.width() <= 0 || mThumbnailRect.height() <= 0 ||
                mTaskViewRect.width() <= 0 || mTaskViewRect.height() <= 0) {
            return;
        }

        int thumbnailHeight = (int) (((float) mTaskViewRect.width() / mThumbnailRect.width()) *
                mThumbnailRect.height());
        if (thumbnailHeight >= mTaskViewRect.height()) {
            // The thumbnail fills the full task view bounds, so just draw it
            canvas.drawRoundRect(0, 0, mTaskViewRect.width(), mTaskViewRect.height(),
            canvas.drawRoundRect(0, 0, mTaskViewRect.width(), mTaskViewRect.height(),
                mCornerRadius,
                    mCornerRadius, mCornerRadius, mDrawPaint);
                mCornerRadius, mDrawPaint);
        } else {
            // The thumbnail only covers part of the task view bounds, so fill in the non-thumbnail
            // space with the default background color.  This is the equivalent of the GL border
            // texture mode.
            int count = canvas.save(Canvas.CLIP_SAVE_FLAG);

            // Since we want the top corners to be rounded, just clip at the thumbnail height
            canvas.clipRect(0, 0, mTaskViewRect.width(), thumbnailHeight, Region.Op.REPLACE);
            canvas.drawRoundRect(0, 0, mTaskViewRect.width(), thumbnailHeight + mCornerRadius,
                    mCornerRadius, mCornerRadius, mDrawPaint);

            // In the remaining space, draw the background color
            canvas.clipRect(0, thumbnailHeight, mTaskViewRect.width(), mTaskViewRect.height(),
                    Region.Op.REPLACE);
            canvas.drawRoundRect(0, thumbnailHeight - mCornerRadius, mTaskViewRect.width(),
                    mTaskViewRect.height(), mCornerRadius, mCornerRadius, mBgFillPaint);

            canvas.restoreToCount(count);
        }
    }
    }


    /** Sets the thumbnail to a given bitmap. */
    /** Sets the thumbnail to a given bitmap. */