From c2d0c7987e4f8c672b3ef3bccf7c6b91f9b8b5dc Mon Sep 17 00:00:00 2001 From: briandr97 Date: Mon, 6 Nov 2023 17:15:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=81=B4=EB=A6=AD=EC=9D=B4=20=EC=98=81?= =?UTF-8?q?=EC=97=AD=EC=9D=84=20=EB=B2=97=EC=96=B4=EB=82=98=EB=A9=B4=20?= =?UTF-8?q?=EC=9E=91=EB=8F=99=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/now/naaga/presentation/custom/GameButton.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/now/naaga/presentation/custom/GameButton.kt b/android/app/src/main/java/com/now/naaga/presentation/custom/GameButton.kt index 27feb76ad..6e1636774 100644 --- a/android/app/src/main/java/com/now/naaga/presentation/custom/GameButton.kt +++ b/android/app/src/main/java/com/now/naaga/presentation/custom/GameButton.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint +import android.graphics.Point import android.graphics.RectF import android.util.AttributeSet import android.view.MotionEvent @@ -55,7 +56,7 @@ class GameButton(context: Context, attrs: AttributeSet? = null) : AppCompatButto } private val ripplePaint = Paint().apply { - this.color = Color.parseColor("#4D000000") + this.color = ContextCompat.getColor(this@GameButton.context, R.color.custom_button_ripple) } override fun onDraw(canvas: Canvas) { @@ -75,7 +76,9 @@ class GameButton(context: Context, attrs: AttributeSet? = null) : AppCompatButto MotionEvent.ACTION_UP -> { isClicked = false invalidate() - clickAction?.onClick(this) + if (isClickInsideButton(Point(event.x.toInt(), event.y.toInt()))) { + clickAction?.onClick(this) + } } } return true @@ -85,6 +88,12 @@ class GameButton(context: Context, attrs: AttributeSet? = null) : AppCompatButto clickAction = l } + private fun isClickInsideButton(point: Point): Boolean { + val isXInside = point.x in 0..this.width + val isYInside = point.y in 0..this.height + return isXInside && isYInside + } + private fun drawRipple(canvas: Canvas) { canvas.drawRoundRect(getBottomRect(), radius, radius, ripplePaint) }