From 200109e5273081cf5c4ae05ce8a1f5ec8bca24f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 22 Sep 2023 13:27:26 +0200 Subject: [PATCH] Remove widgets that are out of bounds if they are blocking dropped icon --- .../launcher/views/HomeScreenGrid.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 89ebe4d..4c956d2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -532,7 +532,18 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel if (item.type != ITEM_TYPE_WIDGET && !item.docked) { potentialParent = item } else { - isDroppingPositionValid = false + if (item.type == ITEM_TYPE_WIDGET && item.outOfBounds()) { + ensureBackgroundThread { + removeItemFromHomeScreen(item) + post { + removeView(widgetViews.firstOrNull { it.tag == item.widgetId }) + widgetViews.removeIf { it.tag == item.widgetId } + } + gridItems.removeIf { it.id == item.id } + } + } else { + isDroppingPositionValid = false + } } return@forEach }