mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-24 06:47:20 +02:00
automatically remove launchers of uninstalled apps
This commit is contained in:
parent
1d78da67a3
commit
cbb077de35
@ -54,6 +54,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
|||||||
|
|
||||||
private fun setupLaunchers() {
|
private fun setupLaunchers() {
|
||||||
launchers = dbHelper.getLaunchers()
|
launchers = dbHelper.getLaunchers()
|
||||||
|
checkInvalidApps()
|
||||||
launchers_holder.adapter = RecyclerAdapter(this, launchers) {
|
launchers_holder.adapter = RecyclerAdapter(this, launchers) {
|
||||||
val launchIntent = packageManager.getLaunchIntentForPackage(it.pkgName)
|
val launchIntent = packageManager.getLaunchIntentForPackage(it.pkgName)
|
||||||
if (launchIntent != null) {
|
if (launchIntent != null) {
|
||||||
@ -84,6 +85,18 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
|||||||
return filtered as ArrayList<AppLauncher>
|
return filtered as ArrayList<AppLauncher>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkInvalidApps() {
|
||||||
|
val invalidIds = ArrayList<String>()
|
||||||
|
for ((id, name, pkgName) in launchers) {
|
||||||
|
val launchIntent = packageManager.getLaunchIntentForPackage(pkgName)
|
||||||
|
if (launchIntent == null && !pkgName.startsWith("com.simplemobiletools")) {
|
||||||
|
invalidIds.add(id.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbHelper.deleteLaunchers(invalidIds)
|
||||||
|
launchers = launchers.filter { !invalidIds.contains(it.id.toString()) } as ArrayList<AppLauncher>
|
||||||
|
}
|
||||||
|
|
||||||
override fun selectedLaunchers(launchers: ArrayList<AppLauncher>) {
|
override fun selectedLaunchers(launchers: ArrayList<AppLauncher>) {
|
||||||
for ((id, name, pkgName) in launchers) {
|
for ((id, name, pkgName) in launchers) {
|
||||||
dbHelper.addLauncher(name, pkgName)
|
dbHelper.addLauncher(name, pkgName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user