mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	Fix folder opening and closing issues
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().contains(x.toFloat(), y.toFloat())) { |             if (folder.getDrawingRect(overrideScale = 1f).contains(x.toFloat(), y.toFloat())) { | ||||||
|                 draggingLeftFolderAt = null |                 draggingLeftFolderAt = null | ||||||
|             } else { |             } else { | ||||||
|                 draggingLeftFolderAt.also { |                 draggingLeftFolderAt.also { | ||||||
| @@ -296,6 +296,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|  |  | ||||||
|         draggedItemCurrentCoords = Pair(x, y) |         draggedItemCurrentCoords = Pair(x, y) | ||||||
|  |  | ||||||
|  |         if (draggedItem?.type != ITEM_TYPE_FOLDER && draggedItem?.type != ITEM_TYPE_WIDGET) { | ||||||
|             val center = gridCenters.minBy { |             val center = gridCenters.minBy { | ||||||
|                 abs(it.x - draggedItemCurrentCoords.first + sideMargins.left) + abs(it.y - draggedItemCurrentCoords.second + sideMargins.top) |                 abs(it.x - draggedItemCurrentCoords.first + sideMargins.left) + abs(it.y - draggedItemCurrentCoords.second + sideMargins.top) | ||||||
|             } |             } | ||||||
| @@ -323,6 +324,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|             } else { |             } else { | ||||||
|                 draggingEnteredNewFolderAt = null |                 draggingEnteredNewFolderAt = null | ||||||
|             } |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         pager.handleItemMovement(x, y) |         pager.handleItemMovement(x, y) | ||||||
|         redrawGrid() |         redrawGrid() | ||||||
| @@ -492,7 +494,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|                 // check if the destination cell is empty or a folder |                 // check if the destination cell is empty or a folder | ||||||
|                 isDroppingPositionValid = true |                 isDroppingPositionValid = true | ||||||
|                 val wantedCell = Pair(xIndex, yIndex) |                 val wantedCell = Pair(xIndex, yIndex) | ||||||
|                 gridItems.filterVisibleOnCurrentPageOnly().forEach { item -> |                 gridItems.filterVisibleOnCurrentPageOnly().filter { it.id != draggedItem?.id }.forEach { item -> | ||||||
|                     for (xCell in item.left..item.right) { |                     for (xCell in item.left..item.right) { | ||||||
|                         for (yCell in item.getDockAdjustedTop(rowCount)..item.getDockAdjustedBottom(rowCount)) { |                         for (yCell in item.getDockAdjustedTop(rowCount)..item.getDockAdjustedBottom(rowCount)) { | ||||||
|                             val cell = Pair(xCell, yCell) |                             val cell = Pair(xCell, yCell) | ||||||
| @@ -626,7 +628,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|                         context.homeScreenGridItemsDB.shiftFolderItems(oldParentId, oldLeft, -1, id) |                         context.homeScreenGridItemsDB.shiftFolderItems(oldParentId, oldLeft, -1, id) | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     if (newParentId != null && gridItems.any { it.parentId == newParentId && it.left == left }) { |                     if (newParentId != null && gridItems.any { it.parentId == newParentId && it.left == left } && (newParentId != oldParentId || left != oldLeft)) { | ||||||
|                         gridItems.filter { it.parentId == newParentId && it.left >= left && it.id != id }.forEach { |                         gridItems.filter { it.parentId == newParentId && it.left >= left && it.id != id }.forEach { | ||||||
|                             it.left += 1 |                             it.left += 1 | ||||||
|                         } |                         } | ||||||
| @@ -989,7 +991,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         val folder = currentlyOpenFolder |         val folder = currentlyOpenFolder | ||||||
|         if (folder != null) { |         if (folder != null && folder.getItems().isNotEmpty()) { | ||||||
|             val items = folder.getItems() |             val items = folder.getItems() | ||||||
|             val folderRect = folder.getDrawingRect() |             val folderRect = folder.getDrawingRect() | ||||||
|             val folderItemsRect = folder.getItemsDrawingRect() |             val folderItemsRect = folder.getItemsDrawingRect() | ||||||
| @@ -1344,7 +1346,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel | |||||||
|         if (currentlyOpenFolder == null) { |         if (currentlyOpenFolder == null) { | ||||||
|             currentlyOpenFolder = folder.toFolder(animateOpening = true) |             currentlyOpenFolder = folder.toFolder(animateOpening = true) | ||||||
|             redrawGrid() |             redrawGrid() | ||||||
|         } else { |         } else if (currentlyOpenFolder?.item?.id != folder.id ){ | ||||||
|             closeFolder() |             closeFolder() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user