From 8a1485cac0ba781a2dc93c0892556f0b26cdcc69 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Mon, 16 Nov 2026 13:48:51 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=99=88=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=9C=84=EC=A0=AF=20=EC=9A=B0=EC=B8=A1/=ED=95=98=EB=8B=A8=20?= =?UTF-8?q?=EC=9E=98=EB=A6=BC=20=EB=B0=8F=20=EB=82=B4=EB=B6=80=20=EC=8B=9C?= =?UTF-8?q?=EC=8A=A4=ED=85=9C=20=ED=8C=A8=EB=94=A9=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - LauncherActivity.kt: * createWidget(): AppWidgetHostView 기본 시스템 패딩(보통 8dp)을 제거하기 위해 hostView.setPadding(0, 0, 0, 0) 적용 * setupWidgetResizeOverlay(): widgetContainer.clipChildren = false, clipToPadding = false 설정으로 경계 핸들 잘림 방지 * updateWidgetOptions(): 패딩을 제외한 순수 콘텐츠 영역 기준으로 Math.round(px / density) dp 계산 - WidgetResizeOverlay.kt: * onDraw(): 테두리 스트로크(halfStroke) 및 핸들 반지름(handleMargin)만큼 캔버스 경계 안쪽으로 클램핑해 우측/하단 끝선 및 핸들이 잘리지 않도록 개선 * ACTION_MOVE 리사이즈 중 v.requestLayout() 호출로 즉각 레이아웃 갱신 - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (19s, 133 actionable tasks) --- .../bums/lunatic/launcher/LauncherActivity.kt | 12 ++++++++---- .../launcher/feeds/WidgetResizeOverlay.kt | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt index 26af4f49..803df755 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/LauncherActivity.kt @@ -653,13 +653,13 @@ open class LauncherActivity : CommonActivity() { // } private fun updateWidgetOptions(appWidgetId: Int, hostView: AppWidgetHostView) { - val width = hostView.layoutParams.width - val height = hostView.layoutParams.height + val width = (hostView.layoutParams.width - hostView.paddingLeft - hostView.paddingRight).coerceAtLeast(1) + val height = (hostView.layoutParams.height - hostView.paddingTop - hostView.paddingBottom).coerceAtLeast(1) // DP 단위로 변환 (시스템은 픽셀이 아니라 DP를 기준으로 레이아웃을 결정함) val density = resources.displayMetrics.density - val widthDp = (width / density).toInt() - val heightDp = (height / density).toInt() + val widthDp = Math.round(width / density) + val heightDp = Math.round(height / density) val options = Bundle().apply { putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, widthDp) @@ -817,6 +817,8 @@ open class LauncherActivity : CommonActivity() { } } } + binding.widgetContainer.clipChildren = false + binding.widgetContainer.clipToPadding = false widgetResizeOverlay = overlay binding.widgetContainer.addView(overlay) } @@ -828,6 +830,8 @@ open class LauncherActivity : CommonActivity() { val hostView = appWidgetHost?.createView(applicationContext, appWidgetId, appWidgetInfo) hostView?.setAppWidget(appWidgetId, appWidgetInfo) + // AppWidgetHostView 기본 시스템 패딩(보통 8dp) 제거로 우측/하단 잘림 방지 + hostView?.setPadding(0, 0, 0, 0) // 크기 및 위치 설정 val width = savedWidgetData?.width ?: appWidgetInfo.minWidth diff --git a/app/src/main/kotlin/bums/lunatic/launcher/feeds/WidgetResizeOverlay.kt b/app/src/main/kotlin/bums/lunatic/launcher/feeds/WidgetResizeOverlay.kt index eacb389b..7a6b2730 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/feeds/WidgetResizeOverlay.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/feeds/WidgetResizeOverlay.kt @@ -112,11 +112,21 @@ class WidgetResizeOverlay(context: Context) : View(context) { super.onDraw(canvas) val r = getTargetRect() ?: return - canvas.drawRect(r, borderPaint) + val halfStroke = borderPaint.strokeWidth / 2f + val drawRect = RectF( + r.left.coerceIn(halfStroke, max(halfStroke, width - halfStroke)), + r.top.coerceIn(halfStroke, max(halfStroke, height - halfStroke)), + r.right.coerceIn(halfStroke, max(halfStroke, width - halfStroke)), + r.bottom.coerceIn(halfStroke, max(halfStroke, height - halfStroke)) + ) + canvas.drawRect(drawRect, borderPaint) + val handleMargin = handleRadius + handleStrokePaint.strokeWidth / 2f for ((_, pt) in getHandlePoints(r)) { - canvas.drawCircle(pt.first, pt.second, handleRadius, handleFillPaint) - canvas.drawCircle(pt.first, pt.second, handleRadius, handleStrokePaint) + val cx = pt.first.coerceIn(handleMargin, max(handleMargin, width - handleMargin)) + val cy = pt.second.coerceIn(handleMargin, max(handleMargin, height - handleMargin)) + canvas.drawCircle(cx, cy, handleRadius, handleFillPaint) + canvas.drawCircle(cx, cy, handleRadius, handleStrokePaint) } val wDp = (r.width() / density).toInt() @@ -200,6 +210,7 @@ class WidgetResizeOverlay(context: Context) : View(context) { lp.width = (newRight - newLeft).toInt().coerceAtLeast(minSizePx) lp.height = (newBottom - newTop).toInt().coerceAtLeast(minSizePx) v.layoutParams = lp + v.requestLayout() } invalidate() return true