mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	create a list of cells occupied by other items at resizing
This commit is contained in:
		| @@ -184,7 +184,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|             val viewX = widgetView.x.toInt() |             val viewX = widgetView.x.toInt() | ||||||
|             val viewY = widgetView.y.toInt() |             val viewY = widgetView.y.toInt() | ||||||
|             val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height) |             val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height) | ||||||
|             resize_frame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, appWidgetProviderInfo) |             val otherGridItems = gridItems.filter { it.widgetId != item.widgetId }.toMutableList() as ArrayList<HomeScreenGridItem> | ||||||
|  |             resize_frame.updateFrameCoords(frameRect, cellWidth, cellHeight, sideMargins, appWidgetProviderInfo, otherGridItems) | ||||||
|             resize_frame.beVisible() |             resize_frame.beVisible() | ||||||
|             resize_frame.z = 1f     // make sure the frame isnt behind the widget itself |             resize_frame.z = 1f     // make sure the frame isnt behind the widget itself | ||||||
|             resize_frame.onClickListener = { |             resize_frame.onClickListener = { | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ import com.simplemobiletools.launcher.extensions.getTileCount | |||||||
| import com.simplemobiletools.launcher.helpers.COLUMN_COUNT | import com.simplemobiletools.launcher.helpers.COLUMN_COUNT | ||||||
| import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION | import com.simplemobiletools.launcher.helpers.MAX_CLICK_DURATION | ||||||
| import com.simplemobiletools.launcher.helpers.ROW_COUNT | import com.simplemobiletools.launcher.helpers.ROW_COUNT | ||||||
|  | import com.simplemobiletools.launcher.models.HomeScreenGridItem | ||||||
|  |  | ||||||
| @SuppressLint("ViewConstructor") | @SuppressLint("ViewConstructor") | ||||||
| class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) { | class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: Int) : RelativeLayout(context, attrs, defStyle) { | ||||||
| @@ -27,6 +28,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | |||||||
|     private var cellHeight = 0 |     private var cellHeight = 0 | ||||||
|     private var minResizeWidthCells = 1 |     private var minResizeWidthCells = 1 | ||||||
|     private var minResizeHeightCells = 1 |     private var minResizeHeightCells = 1 | ||||||
|  |     private val occupiedCells = ArrayList<Pair<Int, Int>>() | ||||||
|     private var providerInfo: AppWidgetProviderInfo? = null |     private var providerInfo: AppWidgetProviderInfo? = null | ||||||
|     private var sideMargins = Rect() |     private var sideMargins = Rect() | ||||||
|     private val lineDotRadius = context.resources.getDimension(R.dimen.resize_frame_dot_radius) |     private val lineDotRadius = context.resources.getDimension(R.dimen.resize_frame_dot_radius) | ||||||
| @@ -54,7 +56,14 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun updateFrameCoords(coords: Rect, cellWidth: Int, cellHeight: Int, sideMargins: Rect, providerInfo: AppWidgetProviderInfo) { |     fun updateFrameCoords( | ||||||
|  |         coords: Rect, | ||||||
|  |         cellWidth: Int, | ||||||
|  |         cellHeight: Int, | ||||||
|  |         sideMargins: Rect, | ||||||
|  |         providerInfo: AppWidgetProviderInfo, | ||||||
|  |         allGridItems: ArrayList<HomeScreenGridItem> | ||||||
|  |     ) { | ||||||
|         frameRect = coords |         frameRect = coords | ||||||
|         this.cellWidth = cellWidth |         this.cellWidth = cellWidth | ||||||
|         this.cellHeight = cellHeight |         this.cellHeight = cellHeight | ||||||
| @@ -63,6 +72,15 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In | |||||||
|         minResizeWidthCells = Math.min(COLUMN_COUNT, context.getTileCount(providerInfo.minResizeWidth)) |         minResizeWidthCells = Math.min(COLUMN_COUNT, context.getTileCount(providerInfo.minResizeWidth)) | ||||||
|         minResizeHeightCells = Math.min(ROW_COUNT, context.getTileCount(providerInfo.minResizeHeight)) |         minResizeHeightCells = Math.min(ROW_COUNT, context.getTileCount(providerInfo.minResizeHeight)) | ||||||
|         redrawFrame() |         redrawFrame() | ||||||
|  |  | ||||||
|  |         occupiedCells.clear() | ||||||
|  |         allGridItems.forEach { item -> | ||||||
|  |             for (xCell in item.left until item.right) { | ||||||
|  |                 for (yCell in item.top until item.bottom) { | ||||||
|  |                     occupiedCells.add(Pair(xCell, yCell)) | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun redrawFrame() { |     private fun redrawFrame() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user