mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	adding some resizing improvements
This commit is contained in:
		| @@ -17,7 +17,6 @@ import androidx.core.graphics.drawable.toDrawable | ||||
| import com.simplemobiletools.commons.extensions.* | ||||
| import com.simplemobiletools.commons.helpers.ensureBackgroundThread | ||||
| import com.simplemobiletools.commons.helpers.isSPlus | ||||
| import com.simplemobiletools.commons.helpers.mydebug | ||||
| import com.simplemobiletools.launcher.R | ||||
| import com.simplemobiletools.launcher.activities.MainActivity | ||||
| import com.simplemobiletools.launcher.extensions.getDrawableForPackageName | ||||
| @@ -190,7 +189,6 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | ||||
|             } | ||||
|  | ||||
|             resize_frame.onResizeListener = { cellsRect -> | ||||
|                 mydebug("resized to $cellsRect") | ||||
|                 val minWidth = (cellsRect.width() + 1) * cellWidth | ||||
|                 val minHeight = (cellsRect.height() + 1) * cellHeight | ||||
|                 widgetView.updateAppWidgetSize(Bundle(), minWidth, minHeight, minWidth, minHeight) | ||||
| @@ -620,7 +618,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | ||||
|     // drag the center of the widget, not the top left corner | ||||
|     private fun getWidgetOccupiedRect(item: Pair<Int, Int>): Rect { | ||||
|         val left = item.first - Math.floor((draggedItem!!.getWidthInCells() - 1) / 2.0).toInt() | ||||
|         val rect = Rect(left, item.second, left + draggedItem!!.getWidthInCells(), item.second + draggedItem!!.getHeightInCells()) | ||||
|         val rect = Rect(left, item.second, left + draggedItem!!.getWidthInCells() - 1, item.second + draggedItem!!.getHeightInCells() - 1) | ||||
|         if (rect.left < 0) { | ||||
|             rect.right -= rect.left | ||||
|             rect.left = 0 | ||||
|   | ||||
| @@ -67,7 +67,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | ||||
|         allGridItems: ArrayList<HomeScreenGridItem> | ||||
|     ) { | ||||
|         frameRect = coords | ||||
|         cellsRect = Rect(gridItem.left, gridItem.top, gridItem.right - 1, gridItem.bottom - 1) | ||||
|         cellsRect = Rect(gridItem.left, gridItem.top, gridItem.right, gridItem.bottom) | ||||
|         this.cellWidth = cellWidth | ||||
|         this.cellHeight = cellHeight | ||||
|         this.sideMargins = sideMargins | ||||
| @@ -187,7 +187,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | ||||
|  | ||||
|                         val closestCellX = roundToClosestMultiplyOfNumber(wantedRight - sideMargins.left, cellWidth) / cellWidth - 1 | ||||
|                         var areAllCellsFree = true | ||||
|                         for (xCell in cellsRect.left..closestCellX + 1) { | ||||
|                         for (xCell in cellsRect.left..closestCellX) { | ||||
|                             for (yCell in cellsRect.top..cellsRect.bottom) { | ||||
|                                 if (occupiedCells.contains(Pair(xCell, yCell))) { | ||||
|                                     areAllCellsFree = false | ||||
| @@ -213,7 +213,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | ||||
|                         val closestCellY = roundToClosestMultiplyOfNumber(wantedBottom - sideMargins.top, cellHeight) / cellHeight - 1 | ||||
|                         var areAllCellsFree = true | ||||
|                         for (xCell in cellsRect.left..cellsRect.right) { | ||||
|                             for (yCell in cellsRect.top..closestCellY + 1) { | ||||
|                             for (yCell in cellsRect.top..closestCellY) { | ||||
|                                 if (occupiedCells.contains(Pair(xCell, yCell))) { | ||||
|                                     areAllCellsFree = false | ||||
|                                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user