Skip to content

Commit d1e615f

Browse files
committed
remove hidden icons from cached ones too
1 parent 63bd57b commit d1e615f

File tree

1 file changed

+22
-5
lines changed
  • app/src/main/kotlin/com/simplemobiletools/launcher/activities

1 file changed

+22
-5
lines changed

app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,21 @@ class MainActivity : SimpleActivity(), FlingListener {
175175

176176
ensureBackgroundThread {
177177
if (mCachedLaunchers.isEmpty()) {
178-
mCachedLaunchers = launchersDB.getAppLaunchers() as ArrayList<AppLauncher>
178+
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map {
179+
it.getIconIdentifier()
180+
}
181+
182+
mCachedLaunchers = launchersDB.getAppLaunchers().filter {
183+
val showIcon = !hiddenIcons.contains(it.getLauncherIdentifier())
184+
if (!showIcon) {
185+
try {
186+
launchersDB.deleteById(it.id!!)
187+
} catch (ignored: Exception) {
188+
}
189+
}
190+
showIcon
191+
}.toMutableList() as ArrayList<AppLauncher>
192+
179193
(all_apps_fragment as AllAppsFragment).gotLaunchers(mCachedLaunchers)
180194
}
181195

@@ -327,9 +341,7 @@ class MainActivity : SimpleActivity(), FlingListener {
327341
(Math.abs(mTouchDownX - event.x) > mMoveGestureThreshold) || (Math.abs(mTouchDownY - event.y) > mMoveGestureThreshold)
328342

329343
private fun refetchLaunchers() {
330-
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map { it.getIconIdentifier() }
331-
val launchers = getAllAppLaunchers().filter { !hiddenIcons.contains(it.getLauncherIdentifier()) }.toMutableList() as ArrayList<AppLauncher>
332-
344+
val launchers = getAllAppLaunchers()
333345
(all_apps_fragment as AllAppsFragment).gotLaunchers(launchers)
334346
(widgets_fragment as WidgetsFragment).getAppWidgets()
335347

@@ -632,6 +644,7 @@ class MainActivity : SimpleActivity(), FlingListener {
632644

633645
@SuppressLint("WrongConstant")
634646
fun getAllAppLaunchers(): ArrayList<AppLauncher> {
647+
val hiddenIcons = hiddenIconsDB.getHiddenIcons().map { it.getIconIdentifier() }
635648
val allApps = ArrayList<AppLauncher>()
636649
val intent = Intent(Intent.ACTION_MAIN, null)
637650
intent.addCategory(Intent.CATEGORY_LAUNCHER)
@@ -646,10 +659,14 @@ class MainActivity : SimpleActivity(), FlingListener {
646659
continue
647660
}
648661

662+
val activityName = info.activityInfo.name
663+
if (hiddenIcons.contains("$packageName/$activityName")) {
664+
continue
665+
}
666+
649667
val label = info.loadLabel(packageManager).toString()
650668
val drawable = info.loadIcon(packageManager) ?: getDrawableForPackageName(packageName) ?: continue
651669
val placeholderColor = calculateAverageColor(drawable.toBitmap())
652-
val activityName = info.activityInfo.name
653670
allApps.add(AppLauncher(null, label, packageName, activityName, 0, placeholderColor, drawable))
654671
}
655672

0 commit comments

Comments
 (0)