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

Commit 31a57f4b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Bypass resources in DropTargetView" into main

parents a440a7d4 126df206
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.util.TypedValue
import android.view.View
import com.android.wm.shell.shared.R

@@ -37,14 +38,21 @@ class DropTargetView(context: Context) : View(context) {
    private val strokePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
        color = context.getColor(com.android.internal.R.color.materialColorPrimaryContainer)
        style = Paint.Style.STROKE
        strokeWidth = context.resources.getDimensionPixelSize(R.dimen.drop_target_stroke).toFloat()
        strokeWidth = 1.dpToPx()
    }

    private val cornerRadius = context.resources.getDimensionPixelSize(
        R.dimen.drop_target_radius).toFloat()
    private val cornerRadius = 28.dpToPx()

    private val rect = RectF(0f, 0f, 0f, 0f)

    // TODO b/396539130: Use shared xml resources once we can access them in launcher
    private fun Int.dpToPx() =
        TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP,
                this.toFloat(),
                context.resources.displayMetrics
            )

    override fun onDraw(canvas: Canvas) {
        canvas.save()
        canvas.drawRoundRect(rect, cornerRadius, cornerRadius, rectPaint)