diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 39139d4..afd6d93 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -951,7 +951,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh } } - private suspend fun setupSearch() { + private fun setupSearch() { binding.appView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom -> if (bottom - top > oldBottom - oldTop) { @@ -1173,6 +1173,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh // Swipe left else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){ + println(leftSwipeActivity) if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) { canLaunchShortcut = false launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null) diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsFragment.kt index c1cef72..df96c80 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/GestureAppsFragment.kt @@ -49,7 +49,7 @@ class GestureAppsFragment(private val direction: String) : Fragment(), lifecycleScope.launch { adapter = GestureAppsAdapter( requireContext(), - appUtils.getInstalledApps().toMutableList(), + appUtils.getInstalledApps(true).toMutableList(), this@GestureAppsFragment ) @@ -102,7 +102,7 @@ class GestureAppsFragment(private val direction: String) : Fragment(), val cleanQuery = stringUtils.cleanString(query) val newFilteredApps = mutableListOf>() - val updatedApps = appUtils.getInstalledApps() + val updatedApps = appUtils.getInstalledApps(true) getFilteredApps(cleanQuery, newFilteredApps, updatedApps) diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt index 275d5ce..2b999ef 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt @@ -123,6 +123,11 @@ class SharedPreferenceManager (private val context: Context) { return preferences.getBoolean("lockShortcuts", false) } + // Show hidden apps in shortcut selection + fun showHiddenShortcuts(): Boolean { + return preferences.getBoolean("showHiddenShortcuts", true) + } + fun setPinnedApp(componentName: String, profile: Int) { val editor = preferences.edit() diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt index 325211f..acd2138 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt @@ -14,16 +14,16 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA private val sharedPreferenceManager = SharedPreferenceManager(context) - suspend fun getInstalledApps(): List> { + suspend fun getInstalledApps(showApps: Boolean = false): List> { val allApps = mutableListOf>() var sortedApps = listOf>() withContext(Dispatchers.Default) { for (i in launcherApps.profiles.indices) { // Check apps on both, normal and work profiles launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app -> - if (!sharedPreferenceManager.isAppHidden( // Only include the app if it isn't set as hidden + if ((!sharedPreferenceManager.isAppHidden( // Only include the app if it isn't set as hidden or in shortcut selection with the appropriate option enabled app.componentName.flattenToString(), i - ) && app.applicationInfo.packageName != context.applicationInfo.packageName // Hide the launcher itself + ) or showApps)&& app.applicationInfo.packageName != context.applicationInfo.packageName // Hide the launcher itself ) { allApps.add(Triple(app, launcherApps.profiles[i], i)) // The i variable gets used to determine whether an app is in the personal profile or work profile } diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/GestureUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/GestureUtils.kt index 69f9050..d2059f3 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/GestureUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/GestureUtils.kt @@ -3,6 +3,7 @@ package eu.ottop.yamlauncher.utils import android.accessibilityservice.AccessibilityService import android.accessibilityservice.AccessibilityServiceInfo import android.app.AlertDialog +import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.pm.LauncherActivityInfo @@ -20,15 +21,19 @@ class GestureUtils(private val context: Context) { fun getSwipeInfo(launcherApps: LauncherApps, direction: String): Pair { val app = sharedPreferenceManager.getGestureInfo(direction) - + println(app) if (app != null) { - if (app.size >= 3) - return Pair( - launcherApps.getActivityList( - app[1], launcherApps.profiles[app[2] - .toInt()] - ).firstOrNull(), app[2].toInt() - ) + if (app.size >= 3) { + val componentName = ComponentName.unflattenFromString(app[1]) + if (componentName != null) { + return Pair( + launcherApps.resolveActivity( + Intent().setComponent(componentName), launcherApps.profiles[app[2] + .toInt()] + ), app[2].toInt() + ) + } + } } return Pair(null, null) } diff --git a/app/src/main/res/xml/home_preferences.xml b/app/src/main/res/xml/home_preferences.xml index 6bc770d..82a6d3c 100644 --- a/app/src/main/res/xml/home_preferences.xml +++ b/app/src/main/res/xml/home_preferences.xml @@ -198,6 +198,12 @@ android:defaultValue="false" android:title="@string/lock_shortcuts" app:key="lockShortcuts" /> +