Add private space support

This commit is contained in:
MM20
2024-07-19 17:13:06 +02:00
parent 99c98e4127
commit 3993f9505c
11 changed files with 206 additions and 101 deletions
@@ -5,6 +5,7 @@ import androidx.compose.material.icons.rounded.Lock
import androidx.compose.material.icons.rounded.Work
import de.mm20.launcher2.badges.Badge
import de.mm20.launcher2.badges.BadgeIcon
import de.mm20.launcher2.icons.PrivateSpace
import de.mm20.launcher2.profiles.Profile
import de.mm20.launcher2.profiles.ProfileManager
import de.mm20.launcher2.search.AppShortcut
@@ -47,7 +48,7 @@ class ProfileBadgeProvider : BadgeProvider, KoinComponent {
)
private val PrivateProfile = Badge(
icon = BadgeIcon(Icons.Rounded.Lock)
icon = BadgeIcon(Icons.Rounded.PrivateSpace)
)
}
}
@@ -259,13 +259,18 @@ internal class SearchServiceImpl(
val privateSpace = profiles.find { it.type == Profile.Type.Private }
appRepository.search("", false)
.withCustomLabels(customAttributesRepository)
.map {
val grouped = it.groupBy { it.user }
val standardProfileApps =
standardProfile?.let { grouped[it.userHandle] } ?: emptyList()
val workProfileApps = workProfile?.let { grouped[it.userHandle] } ?: emptyList()
val privateSpaceApps =
privateSpace?.let { grouped[it.userHandle] } ?: emptyList()
.map { apps ->
val standardProfileApps = mutableListOf<Application>()
val workProfileApps = mutableListOf<Application>()
val privateSpaceApps = mutableListOf<Application>()
for (app in apps) {
when {
standardProfile != null && app.user == standardProfile.userHandle -> standardProfileApps.add(app)
workProfile != null && app.user == workProfile.userHandle -> workProfileApps.add(app)
privateSpace != null && app.user == privateSpace.userHandle -> privateSpaceApps.add(app)
else -> standardProfileApps.add(app)
}
}
AllAppsResults(
standardProfileApps = standardProfileApps.sorted(),