mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	Fix animation scaling when opening and closing folders
This commit is contained in:
		| @@ -270,7 +270,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         currentlyOpenFolder?.also { folder -> |         currentlyOpenFolder?.also { folder -> | ||||||
|             if (folder.getDrawingRect(overrideScale = 1f).contains(x.toFloat(), y.toFloat())) { |             if (folder.getDrawingRect().contains(x.toFloat(), y.toFloat())) { | ||||||
|                 draggingLeftFolderAt = null |                 draggingLeftFolderAt = null | ||||||
|             } else { |             } else { | ||||||
|                 draggingLeftFolderAt.also { |                 draggingLeftFolderAt.also { | ||||||
| @@ -1000,9 +1000,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|             val rectOffset = width * folder.item.page - currentViewPosition |             val rectOffset = width * folder.item.page - currentViewPosition | ||||||
|             folderRect.offset(rectOffset, 0f) |             folderRect.offset(rectOffset, 0f) | ||||||
|  |  | ||||||
|             canvas.drawRoundRect(folderRect, roundedCornerRadius, roundedCornerRadius, folderBackgroundPaint) |  | ||||||
|  |  | ||||||
|             canvas.withScale(folder.scale, folder.scale, folderRect.centerX(), folderRect.centerY()) { |             canvas.withScale(folder.scale, folder.scale, folderRect.centerX(), folderRect.centerY()) { | ||||||
|  |                 canvas.drawRoundRect(folderRect, roundedCornerRadius / folder.scale, roundedCornerRadius / folder.scale, folderBackgroundPaint) | ||||||
|                 val textX = folderRect.left + folderPadding |                 val textX = folderRect.left + folderPadding | ||||||
|                 val textY = folderRect.top + folderPadding + folderTitleTextPaint.textSize |                 val textY = folderRect.top + folderPadding + folderTitleTextPaint.textSize | ||||||
|                 val staticLayout = StaticLayout.Builder |                 val staticLayout = StaticLayout.Builder | ||||||
| @@ -1484,8 +1483,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|             return BitmapDrawable(resources, bitmap) |             return BitmapDrawable(resources, bitmap) | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         fun getDrawingRect(overrideScale: Float? = null): RectF { |         fun getDrawingRect(): RectF { | ||||||
|             val finalScale = overrideScale ?: scale |  | ||||||
|             val count = getItems().count() |             val count = getItems().count() | ||||||
|             if (count == 0) { |             if (count == 0) { | ||||||
|                 return RectF(0f, 0f, 0f, 0f) |                 return RectF(0f, 0f, 0f, 0f) | ||||||
| @@ -1495,8 +1493,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|             val cell = cells[item.getTopLeft()]!! |             val cell = cells[item.getTopLeft()]!! | ||||||
|             val centerX = sideMargins.left + cell.centerX() |             val centerX = sideMargins.left + cell.centerX() | ||||||
|             val centerY = sideMargins.top + cell.centerY() |             val centerY = sideMargins.top + cell.centerY() | ||||||
|             val folderDialogWidth = (columnsCount * cellWidth + 2 * folderPadding) * finalScale |             val folderDialogWidth = columnsCount * cellWidth + 2 * folderPadding | ||||||
|             val folderDialogHeight = (rowsCount * cellHeight + 3 * folderPadding + folderTitleTextPaint.textSize) * finalScale |             val folderDialogHeight = rowsCount * cellHeight + 3 * folderPadding + folderTitleTextPaint.textSize | ||||||
|             var folderDialogTop = centerY - folderDialogHeight / 2 |             var folderDialogTop = centerY - folderDialogHeight / 2 | ||||||
|             var folderDialogLeft = centerX - folderDialogWidth / 2 |             var folderDialogLeft = centerX - folderDialogWidth / 2 | ||||||
|  |  | ||||||
| @@ -1517,7 +1515,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         fun getItemsDrawingRect(): RectF { |         fun getItemsDrawingRect(): RectF { | ||||||
|             val folderRect = getDrawingRect(overrideScale = 1f) |             val folderRect = getDrawingRect() | ||||||
|             return RectF( |             return RectF( | ||||||
|                 folderRect.left + folderPadding, |                 folderRect.left + folderPadding, | ||||||
|                 folderRect.top + folderPadding * 2 + folderTitleTextPaint.textSize, |                 folderRect.top + folderPadding * 2 + folderTitleTextPaint.textSize, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user