LawnchairLauncher / lawnchair

No clever tagline needed.
https://lawnchair.app
Other
8.92k stars 1.17k forks source link

[BUG] Smartspace causes WorkspaceItemSpaceFinder to fail and collide #4111

Open richardioo opened 4 months ago

richardioo commented 4 months ago

Describe the bug

The function WorkspaceItemSpaceFinder.findSpaceForItem is working correctly, except when having Smartspace ("At a Glance") enabled and added to the workspace. The function findNextAvailableIconSpaceInScreen calculates which grid cells are already occupied - by occupiedPos items array. However, it does not "know" about the Smartspace widget and therefore consider its cells as 0s instead of 1s.

image

occupiedPos is the result of screenItems.get(screenId) and it's missing the Smartspace widget.

Steps to reproduce

Steps to reproduce the behavior:

  1. Start with a clean installation of Lawnchair
  2. Disable the feature topQsbOnFirstScreenEnabled so findSpaceForItem works on screen 0. Or comment out line 70 in WorkspaceItemSpaceFinder.java
  3. Call WorkspaceItemSpaceFinder.findSpaceForItem - this can be done via queueItem
  4. It returns screenId=0 and coordinates=[0,0] while that space is actually occupied by Smartspace
  5. Later, you'll see a log removing items from db ... Collision while binding workspace item ... Collides with null

Code snippet

Comment out line 70 in WorkspaceItemSpaceFinder.java.
Add that to LoaderTask.run in line 255 - before bindAllApps();:

ItemInstallQueue.INSTANCE.get(mApp.getContext())
    .queueItem("com.facebook.katana", UserHandle.getUserHandleForUid(mUserManager.getUserHandle()));

Expected behavior

Suggested fix: make findNextAvailableIconSpaceInScreen know about the Smartspace widget and consider its cells as occupied. Make screenItems.get(0) to include the Smartspace widget in its result.

Screenshots

No response

Device information

Additional context

No response

MrSluffy commented 4 months ago

12.1-dev is no longer active branch please use 14-dev

richardioo commented 4 months ago

It's on 14-dev. not outdated @MrSluffy

MrSluffy commented 4 months ago

It's on 14-dev. not outdated @MrSluffy

Screenshot_20240308-034238_Chrome

richardioo commented 4 months ago

Someone wants to look at that bug? Very easy to solve

MrSluffy commented 4 months ago

Someone wants to look at that bug? Very easy to solve

Why not solve it and do the PR?

richardioo commented 4 months ago

I don't know how to edit the code properly, I never written in Android. Can you guide me please?