From 1097483ab9054fc542fef7dcf229711f20217af7 Mon Sep 17 00:00:00 2001 From: Kyle Agronick Date: Wed, 8 May 2024 10:36:07 -0400 Subject: [PATCH] fix: extra activities in main launcher --- app/src/main/AndroidManifest.xml | 4 --- .../com/agronick/launcher/AppListProvider.kt | 2 +- .../com/agronick/launcher/MainActivity.kt | 31 ++++++++++++++----- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bc42bdf..83f564d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -40,8 +40,6 @@ android:theme="@style/AppTheme"> - - - - , context: Context) { val positions = HashMap>().withDefault { HashMap() } - val filePath = "${context.dataDir}/appPositions2.json" + val filePath = "${context.dataDir}/appPositions.json" val mapping = appList.map { it.asKey() to it }.toMap().toMutableMap() diff --git a/app/src/main/java/com/agronick/launcher/MainActivity.kt b/app/src/main/java/com/agronick/launcher/MainActivity.kt index 616476a..041d12a 100644 --- a/app/src/main/java/com/agronick/launcher/MainActivity.kt +++ b/app/src/main/java/com/agronick/launcher/MainActivity.kt @@ -70,13 +70,11 @@ class MainActivity : Activity(), GestureDetector.OnGestureListener { private fun getInstalledApps(): List { val mainIntent = Intent(Intent.ACTION_MAIN, null) mainIntent.addCategory(Intent.CATEGORY_LAUNCHER) - return packageManager.queryIntentActivities(mainIntent, 0).mapNotNull { - /* This is commented out because the line of code hides both the launcher and settings - application. This bug would need to be fixed before uncommenting */ - - // if (it.activityInfo.packageName.startsWith("com.agronick.launcher")) { - // return@mapNotNull null - // } + val appName = applicationContext.packageName + val packages = packageManager.queryIntentActivities(mainIntent, 0).mapNotNull { + if (it.activityInfo.packageName == appName) { + return@mapNotNull null + } PInfo( appname = it.activityInfo.packageName, @@ -84,7 +82,24 @@ class MainActivity : Activity(), GestureDetector.OnGestureListener { icon = it.activityInfo.loadIcon(packageManager), activityName = it.activityInfo.name, ) - } + }.toMutableList() + packages.add( + PInfo( + appname = appName, + pname = appName, + icon = getDrawable(R.mipmap.clock), + activityName = "${appName}.presentation.BackToClock", + ) + ) + packages.add( + PInfo( + appname = appName, + pname = appName, + icon = getDrawable(R.mipmap.ic_settings), + activityName = "${appName}.presentation.LauncherSettings", + ) + ) + return packages } override fun onSaveInstanceState(outState: Bundle) {