kennethnym / StarlightLauncher

A search-focused Android launcher
GNU General Public License v3.0
100 stars 7 forks source link

Opening and closing NewPipe changes it icon #47

Closed ayecptn closed 1 year ago

ayecptn commented 2 years ago

Opening and closing NewPipe will change it icon to the icon of the next app. This happens with NewPipe (org.schabi.newpipe) and "heise online" (de.heise.android.heiseonlineapp), but with "heise online" it does not happen everytime, while it happens everytime with NewPipe.

NewPipe is installed from the NewPipe upstream repository (https://archive.newpipe.net/fdroid/repo) with F-Droid. Heise online is installed from the Google Play Store with Aurora Store.

Android Version: 12 LineageOS: 19.1

https://user-images.githubusercontent.com/61555365/188715344-24b22392-5720-4907-89b3-1d4238748575.mp4

kennethnym commented 2 years ago

I noticed this too in app search result sometimes, really weird

kennethnym commented 2 years ago

I like your setup btw! Really clean

ayecptn commented 2 years ago

Thank you! Yeah, the icon pack I use really fits with the style of your launcher. Only thing bothering me is that there are a few apps left which don't have an icon yet. I use this icon pack, if you are interested.

kennethnym commented 2 years ago

Thanks! Will check it out

ayecptn commented 2 years ago

Hey, I debugged this today.

It appears that some apps launch the onPackageChanged Event in AppGridAdapter.kt, where it then does get removed from the apps list. Commenting out the removeAll call fixes this problem, but idk if this causes any other problems.

You should be able to reproduce this, by pinning Google Drive and any other app.

override fun onPackageChanged(packageName: String?, user: UserHandle?) {
    if (packageName == null) return
    launcherApps.getActivityList(packageName, user).forEach { launcherActivityInfo ->
        /*this@AppGridAdapter.apps.removeAll {
           it.applicationInfo.packageName == packageName &&
                  it.componentName == launcherActivityInfo.componentName
        }*/
        val i = visibleApps.indexOfFirst {
            it.applicationInfo.packageName == packageName &&
                    it.componentName == launcherActivityInfo.componentName
        }
        if (i >= 0) {
            visibleApps[i] = launcherActivityInfo
            notifyItemChanged(i)
        }
    }
}
kennethnym commented 2 years ago

Thank you so much, I think this is indeed what is causing the problem. I forgot to re-query the new package info after removing the outdated info from the list 😅

kennethnym commented 1 year ago

This is (inadvertently) fixed in the refactor work that I have recently merged in, because LauncherApps.Callback is moved out of AppGridAdapter into AppManager, which now handles querying/updating of apps.