Prevent widget long press while changing pages
This commit is contained in:
parent
75aeade4af
commit
3f146c7618
|
@ -75,7 +75,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
getWidth = { width },
|
getWidth = { width },
|
||||||
getHandler = { handler },
|
getHandler = { handler },
|
||||||
getNextPageBound = { right - sideMargins.right - cellWidth / 2 },
|
getNextPageBound = { right - sideMargins.right - cellWidth / 2 },
|
||||||
getPrevPageBound = { left + sideMargins.left + cellWidth / 2 }
|
getPrevPageBound = { left + sideMargins.left + cellWidth / 2 },
|
||||||
|
pageChangeStarted = { widgetViews.forEach { it.resetTouches() } }
|
||||||
)
|
)
|
||||||
|
|
||||||
// apply fake margins at the home screen. Real ones would cause the icons be cut at dragging at screen sides
|
// apply fake margins at the home screen. Real ones would cause the icons be cut at dragging at screen sides
|
||||||
|
@ -862,6 +863,10 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isClickingGridItem(x: Int, y: Int): HomeScreenGridItem? {
|
fun isClickingGridItem(x: Int, y: Int): HomeScreenGridItem? {
|
||||||
|
if (pager.isAnimatingPageChange() || pager.isSwiped()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
for (gridItem in gridItems.filter { it.page == pager.getCurrentPage() || it.docked }) {
|
for (gridItem in gridItems.filter { it.page == pager.getCurrentPage() || it.docked }) {
|
||||||
if (gridItem.outOfBounds()) {
|
if (gridItem.outOfBounds()) {
|
||||||
continue
|
continue
|
||||||
|
@ -995,6 +1000,7 @@ private class AnimatedGridPager(
|
||||||
private val getHandler: () -> Handler,
|
private val getHandler: () -> Handler,
|
||||||
private val getNextPageBound: () -> Int,
|
private val getNextPageBound: () -> Int,
|
||||||
private val getPrevPageBound: () -> Int,
|
private val getPrevPageBound: () -> Int,
|
||||||
|
private val pageChangeStarted: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -1244,6 +1250,7 @@ private class AnimatedGridPager(
|
||||||
val startingAt = 1 - abs(pageChangeSwipedPercentage)
|
val startingAt = 1 - abs(pageChangeSwipedPercentage)
|
||||||
pageChangeSwipedPercentage = 0f
|
pageChangeSwipedPercentage = 0f
|
||||||
getHandler().removeCallbacks(startFadingIndicators)
|
getHandler().removeCallbacks(startFadingIndicators)
|
||||||
|
pageChangeStarted()
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
redrawGrid()
|
redrawGrid()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,8 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
|
||||||
longPressListener?.invoke(actionDownCoords.x, actionDownCoords.y)
|
longPressListener?.invoke(actionDownCoords.x, actionDownCoords.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetTouches() {
|
||||||
|
longPressHandler.removeCallbacksAndMessages(null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue