remove home screen icons after uninstalling an app

This commit is contained in:
tibbi 2022-09-19 18:55:30 +02:00
parent 9c1458d89b
commit 4bcda4ba95
3 changed files with 11 additions and 0 deletions

View File

@ -160,12 +160,19 @@ class MainActivity : SimpleActivity(), FlingListener {
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
(widgets_fragment as WidgetsFragment).getAppWidgets()
var hasDeletedAnything = false
mCachedLaunchers.map { it.packageName }.forEach { packageName ->
if (!launchers.map { it.packageName }.contains(packageName)) {
hasDeletedAnything = true
launchersDB.deleteApp(packageName)
homeScreenGridItemsDB.deleteItem(packageName)
}
}
if (hasDeletedAnything) {
home_screen_grid.fetchAppIcons()
}
mCachedLaunchers = launchers
}

View File

@ -13,4 +13,7 @@ interface HomeScreenGridItemsDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(items: List<HomeScreenGridItem>)
@Query("DELETE FROM home_screen_grid_items WHERE package_name = :packageName")
fun deleteItem(packageName: String)
}

View File

@ -43,6 +43,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
fun fetchAppIcons() {
ensureBackgroundThread {
appIconDrawables.clear()
appIcons = context.homeScreenGridItemsDB.getAllItems() as ArrayList<HomeScreenGridItem>
appIcons.forEach { item ->
val drawable = context.getDrawableForPackageName(item.packageName)