fix bug in widget resizing logic, see #207
Some checks failed
Android CI / build (push) Has been cancelled

This commit is contained in:
Josia Pietsch 2025-06-30 11:53:51 +02:00
parent b9792e9942
commit abf57760e9
Signed by: jrpie
GPG key ID: E70B571D66986A2D

View file

@ -54,22 +54,36 @@ class WidgetManagerView(widgetPanelId: Int, context: Context, attrs: AttributeSe
Rect(rect.left + cdx, rect.top + cdy, rect.right + cdx, rect.bottom + cdy) Rect(rect.left + cdx, rect.top + cdy, rect.right + cdx, rect.bottom + cdy)
}), }),
TOP({ _, dy, _, sh, rect -> TOP({ _, dy, _, sh, rect ->
val cdy = dy.coerceIn(-rect.top, rect.bottom - rect.top - (2 * sh / GRID_SIZE) + 5) val range = (-rect.top)..(rect.bottom - rect.top - (2 * sh / GRID_SIZE) + 5)
Rect(rect.left, rect.top + cdy, rect.right, rect.bottom) if (range.isEmpty()) {
rect
} else {
Rect(rect.left, rect.top + dy.coerceIn(range), rect.right, rect.bottom)
}
}), }),
BOTTOM({ _, dy, _, sh, rect -> BOTTOM({ _, dy, _, sh, rect ->
val cdy = val range = ((2 * sh / GRID_SIZE) + 5 + rect.top - rect.bottom)..(sh - rect.bottom)
dy.coerceIn((2 * sh / GRID_SIZE) + 5 + rect.top - rect.bottom, sh - rect.bottom) if (range.isEmpty()) {
Rect(rect.left, rect.top, rect.right, rect.bottom + cdy) rect
} else {
Rect(rect.left, rect.top, rect.right, rect.bottom + dy.coerceIn(range))
}
}), }),
LEFT({ dx, _, sw, _, rect -> LEFT({ dx, _, sw, _, rect ->
val cdx = dx.coerceIn(-rect.left, rect.right - rect.left - (2 * sw / GRID_SIZE) + 5) val range = (-rect.left)..(rect.right - rect.left - (2 * sw / GRID_SIZE) + 5)
Rect(rect.left + cdx, rect.top, rect.right, rect.bottom) if (range.isEmpty()) {
rect
} else {
Rect(rect.left + dx.coerceIn(range), rect.top, rect.right, rect.bottom)
}
}), }),
RIGHT({ dx, _, sw, _, rect -> RIGHT({ dx, _, sw, _, rect ->
val cdx = val range = ((2 * sw / GRID_SIZE) + 5 + rect.left - rect.right)..(sw - rect.right)
dx.coerceIn((2 * sw / GRID_SIZE) + 5 + rect.left - rect.right, sw - rect.right) if (range.isEmpty()) {
Rect(rect.left, rect.top, rect.right + cdx, rect.bottom) rect
} else {
Rect(rect.left, rect.top, rect.right + dx.coerceIn(range), rect.bottom)
}
}), }),
} }