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 90ac07d..52d577e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -184,7 +184,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel val viewX = widgetView.x.toInt() val viewY = widgetView.y.toInt() val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height) - resize_frame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, appWidgetProviderInfo) + val otherGridItems = gridItems.filter { it.widgetId != item.widgetId }.toMutableList() as ArrayList + resize_frame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, appWidgetProviderInfo, otherGridItems) resize_frame.beVisible() resize_frame.z = 1f // make sure the frame isnt behind the widget itself resize_frame.onClickListener = { diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetResizeFrame.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetResizeFrame.kt index 3e61e15..5e610aa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetResizeFrame.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/MyAppWidgetResizeFrame.kt @@ -13,6 +13,7 @@ import com.simplemobiletools.launcher.extensions.getTileCount import com.simplemobiletools.launcher.helpers.COLUMN_COUNT import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION import com.simplemobiletools.launcher.helpers.ROW_COUNT +import com.simplemobiletools.launcher.models.HomeScreenGridItem @SuppressLint("ViewConstructor") class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) { @@ -27,6 +28,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In private var cellHeight = 0 private var minResizeWidthCells = 1 private var minResizeHeightCells = 1 + private val occupiedCells = ArrayList>() private var providerInfo: AppWidgetProviderInfo? = null private var sideMargins = Rect() private val lineDotRadius = context.resources.getDimension(R.dimen.resize_frame_dot_radius) @@ -54,7 +56,14 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In } } - fun updateFrameCoords(coords: Rect, cellWidth: Int, cellHeight: Int, sideMargins: Rect, providerInfo: AppWidgetProviderInfo) { + fun updateFrameCoords( + coords: Rect, + cellWidth: Int, + cellHeight: Int, + sideMargins: Rect, + providerInfo: AppWidgetProviderInfo, + allGridItems: ArrayList + ) { frameRect = coords this.cellWidth = cellWidth this.cellHeight = cellHeight @@ -63,6 +72,15 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In minResizeWidthCells = Math.min(COLUMN_COUNT, context.getTileCount(providerInfo.minResizeWidth)) minResizeHeightCells = Math.min(ROW_COUNT, context.getTileCount(providerInfo.minResizeHeight)) redrawFrame() + + occupiedCells.clear() + allGridItems.forEach { item -> + for (xCell in item.left until item.right) { + for (yCell in item.top until item.bottom) { + occupiedCells.add(Pair(xCell, yCell)) + } + } + } } private fun redrawFrame() {