show a shadow at dragging from All Apps Fragment too

This commit is contained in:
tibbi 2022-09-24 22:36:00 +02:00
parent 1ec3112032
commit 6cf61d534a

View File

@ -206,7 +206,10 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
}
item.drawable!!.draw(canvas)
} else if (draggedItemCurrentCoords.first != -1 && draggedItemCurrentCoords.second != -1) {
}
}
if (draggedItem != null && draggedItemCurrentCoords.first != -1 && draggedItemCurrentCoords.second != -1) {
// draw a circle under the current cell
val center = gridCenters.minBy { Math.abs(it.first - draggedItemCurrentCoords.first) + Math.abs(it.second - draggedItemCurrentCoords.second) }
val gridCells = getClosestGridCells(center)
@ -221,12 +224,11 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
canvas.drawCircle(shadowX, shadowY.toFloat(), iconSize / 2f, dragShadowCirclePaint)
}
// show the icon itself at dragging
// show the app icon itself at dragging
val drawableX = draggedItemCurrentCoords.first - iconSize
val drawableY = draggedItemCurrentCoords.second - (iconSize * 1.5f).toInt()
item.drawable!!.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
item.drawable!!.draw(canvas)
}
draggedItem!!.drawable!!.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
draggedItem!!.drawable!!.draw(canvas)
}
}