do not allow dragging the widget outside of the sreen

This commit is contained in:
tibbi 2022-10-05 12:58:41 +02:00
parent 4b9c235750
commit 6fc579afe2

View File

@ -628,15 +628,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
if (rect.left < 0) { if (rect.left < 0) {
rect.right -= rect.left rect.right -= rect.left
rect.left = 0 rect.left = 0
} else if (rect.right > COLUMN_COUNT) { } else if (rect.right > COLUMN_COUNT - 1) {
val diff = rect.right - COLUMN_COUNT val diff = rect.right - COLUMN_COUNT + 1
rect.right -= diff rect.right -= diff
rect.left -= diff rect.left -= diff
} }
// do not allow placing widgets at the bottom row, that is for pinned default apps // do not allow placing widgets at the bottom row, that is for pinned default apps
if (rect.bottom >= ROW_COUNT) { if (rect.bottom >= ROW_COUNT - 1) {
val diff = rect.bottom - ROW_COUNT + 1 val diff = rect.bottom - ROW_COUNT + 2
rect.bottom -= diff rect.bottom -= diff
rect.top -= diff rect.top -= diff
} }