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

Commit 7da344a4 authored by Michael Kolb's avatar Michael Kolb Committed by Android Git Automerger
Browse files

am 37be6658: Merge "Fix selection highlight for tablets" into gb-ub-photos-bryce

* commit '37be6658':
  Fix selection highlight for tablets
parents 550eefae 37be6658
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ public class CategoryView extends View implements View.OnClickListener {
    private Paint mSelectPaint;
    CategoryAdapter mAdapter;
    private int mSelectionStroke;
    private Paint mBorderPaint;
    private int mBorderStroke;

    public static void setTextSize(int size) {
        sTextSize = size;
@@ -63,6 +65,9 @@ public class CategoryView extends View implements View.OnClickListener {
        mSelectPaint = new Paint();
        mSelectPaint.setStyle(Paint.Style.FILL);
        mSelectPaint.setColor(res.getColor(R.color.filtershow_category_selection));
        mBorderPaint = new Paint(mSelectPaint);
        mBorderPaint.setColor(Color.BLACK);
        mBorderStroke = mSelectionStroke / 3;
    }

    public void drawText(Canvas canvas, String text) {
@@ -91,8 +96,10 @@ public class CategoryView extends View implements View.OnClickListener {
                Bitmap bitmap = mAction.getImage();
                canvas.drawBitmap(bitmap, 0, 0, mPaint);
                if (mAdapter.isSelected(this)) {
                    SelectionRenderer.drawSelection(canvas, 0, 0, bitmap.getWidth(),
                            bitmap.getHeight(), mSelectionStroke, mSelectPaint);
                    SelectionRenderer.drawSelection(canvas, 0, 0,
                            Math.min(bitmap.getWidth(), getWidth()),
                            Math.min(bitmap.getHeight(), getHeight()),
                            mSelectionStroke, mSelectPaint, mBorderStroke, mBorderPaint);
                }
            }
            mPaint.setColor(mBackgroundColor);
+16 −0
Original line number Diff line number Diff line
@@ -29,4 +29,20 @@ public class SelectionRenderer {
        canvas.drawRect(right - stroke, top, right, bottom, paint);
    }

    public static void drawSelection(Canvas canvas, int left, int top, int right, int bottom,
            int stroke, Paint selectPaint, int border, Paint borderPaint) {
        canvas.drawRect(left, top, right, top + stroke, selectPaint);
        canvas.drawRect(left, bottom - stroke, right, bottom, selectPaint);
        canvas.drawRect(left, top, left + stroke, bottom, selectPaint);
        canvas.drawRect(right - stroke, top, right, bottom, selectPaint);
        canvas.drawRect(left + stroke, top + stroke, right - stroke,
                top + stroke + border, borderPaint);
        canvas.drawRect(left + stroke, bottom - stroke - border, right - stroke,
                bottom - stroke, borderPaint);
        canvas.drawRect(left + stroke, top + stroke, left + stroke + border,
                bottom - stroke, borderPaint);
        canvas.drawRect(right - stroke - border, top + stroke, right - stroke,
                bottom - stroke, borderPaint);
    }

}