From 4e295deb3ebcf4876cd8ceb83db3a9852503858a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 26 Sep 2022 22:00:14 +0200 Subject: [PATCH] adding some widget preview corrections --- .../simplemobiletools/launcher/views/HomeScreenGrid.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index 6ebe9f7..32b35f0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -319,13 +319,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie // show the widget preview itself at dragging val drawable = draggedItem!!.drawable!! + val aspectRatio = drawable.minimumHeight / drawable.minimumWidth.toFloat() val drawableX = (draggedItemCurrentCoords.first - drawable.minimumWidth / 2f).toInt() - val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 2f).toInt() + val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 3f).toInt() + val drawableWidth = draggedItem!!.widthCells * rowWidth - iconMargin * (draggedItem!!.widthCells - 1) drawable.setBounds( drawableX, drawableY, - drawableX + draggedItem!!.widthCells * rowWidth - iconMargin * 2, - drawableY + draggedItem!!.heightCells * rowHeight - iconMargin * 2 + drawableX + drawableWidth, + (drawableY + drawableWidth * aspectRatio).toInt() ) drawable.draw(canvas) }