remove hidden icons from cached ones too

This commit is contained in:
tibbi 2022-10-26 10:03:20 +02:00
parent 63bd57bd96
commit d1e615f55c
1 changed files with 22 additions and 5 deletions

View File

@ -175,7 +175,21 @@ class MainActivity : SimpleActivity(), FlingListener {
ensureBackgroundThread { ensureBackgroundThread {
if (mCachedLaunchers.isEmpty()) { if (mCachedLaunchers.isEmpty()) {
mCachedLaunchers = launchersDB.getAppLaunchers() as ArrayList<AppLauncher> val hiddenIcons = hiddenIconsDB.getHiddenIcons().map {
it.getIconIdentifier()
}
mCachedLaunchers = launchersDB.getAppLaunchers().filter {
val showIcon = !hiddenIcons.contains(it.getLauncherIdentifier())
if (!showIcon) {
try {
launchersDB.deleteById(it.id!!)
} catch (ignored: Exception) {
}
}
showIcon
}.toMutableList() as ArrayList<AppLauncher>
(all_apps_fragment as AllAppsFragment).gotLaunchers(mCachedLaunchers) (all_apps_fragment as AllAppsFragment).gotLaunchers(mCachedLaunchers)
} }
@ -327,9 +341,7 @@ class MainActivity : SimpleActivity(), FlingListener {
(Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold) (Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold)
private fun refetchLaunchers() { private fun refetchLaunchers() {
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map { it.getIconIdentifier() } val launchers = getAllAppLaunchers()
val launchers = getAllAppLaunchers().filter { !hiddenIcons.contains(it.getLauncherIdentifier()) }.toMutableList() as ArrayList<AppLauncher>
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers) (all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
(widgets_fragment as WidgetsFragment).getAppWidgets() (widgets_fragment as WidgetsFragment).getAppWidgets()
@ -632,6 +644,7 @@ class MainActivity : SimpleActivity(), FlingListener {
@SuppressLint("WrongConstant") @SuppressLint("WrongConstant")
fun getAllAppLaunchers(): ArrayList<AppLauncher> { fun getAllAppLaunchers(): ArrayList<AppLauncher> {
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map { it.getIconIdentifier() }
val allApps = ArrayList<AppLauncher>() val allApps = ArrayList<AppLauncher>()
val intent = Intent(Intent.ACTION_MAIN, null) val intent = Intent(Intent.ACTION_MAIN, null)
intent.addCategory(Intent.CATEGORY_LAUNCHER) intent.addCategory(Intent.CATEGORY_LAUNCHER)
@ -646,10 +659,14 @@ class MainActivity : SimpleActivity(), FlingListener {
continue continue
} }
val activityName = info.activityInfo.name
if (hiddenIcons.contains("$packageName/$activityName")) {
continue
}
val label = info.loadLabel(packageManager).toString() val label = info.loadLabel(packageManager).toString()
val drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName) ?: continue val drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName) ?: continue
val placeholderColor = calculateAverageColor(drawable.toBitmap()) val placeholderColor = calculateAverageColor(drawable.toBitmap())
val activityName = info.activityInfo.name
allApps.add(AppLauncher(null, label, packageName, activityName, 0, placeholderColor, drawable)) allApps.add(AppLauncher(null, label, packageName, activityName, 0, placeholderColor, drawable))
} }