Skip to content

Commit 681e509

Browse files
committed
Prevent mutating drawables for items in app drawer
1 parent 78d9459 commit 681e509

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,9 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
11101110
// show the app icon itself at dragging, move it above the finger a bit to make it visible
11111111
val drawableX = (draggedItemCurrentCoords.first - iconSize / 1.5f).toInt()
11121112
val drawableY = (draggedItemCurrentCoords.second - iconSize / 1.2f).toInt()
1113-
draggedItem!!.drawable?.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
1114-
draggedItem!!.drawable?.draw(canvas)
1113+
val newDrawable = draggedItem!!.drawable?.constantState?.newDrawable()?.mutate()
1114+
newDrawable?.setBounds(drawableX, drawableY, drawableX + iconSize, drawableY + iconSize)
1115+
newDrawable?.draw(canvas)
11151116
} else if (draggedItem!!.type == ITEM_TYPE_WIDGET) {
11161117
// at first draw we are loading the widget from the database at some exact spot, not dragging it
11171118
if (!isFirstDraw) {
@@ -1458,7 +1459,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
14581459
val drawable = if (item.type == ITEM_TYPE_FOLDER) {
14591460
item.toFolder().generateDrawable()
14601461
} else {
1461-
item.drawable
1462+
item.drawable?.constantState?.newDrawable()?.mutate()
14621463
}
14631464

14641465
if (item.docked) {

0 commit comments

Comments
 (0)