React to changing profile availability

This commit is contained in:
MM20
2024-07-07 14:29:42 +02:00
parent 84f3d9f825
commit 5a28eb584e
29 changed files with 424 additions and 77 deletions
+1
View File
@@ -152,6 +152,7 @@ dependencies {
implementation(project(":data:notifications"))
implementation(project(":libs:owncloud"))
implementation(project(":core:permissions"))
implementation(project(":core:profiles"))
implementation(project(":core:preferences"))
implementation(project(":services:search"))
implementation(project(":services:tags"))
@@ -32,6 +32,7 @@ import de.mm20.launcher2.data.plugins.dataPluginsModule
import de.mm20.launcher2.devicepose.devicePoseModule
import de.mm20.launcher2.plugins.servicesPluginsModule
import de.mm20.launcher2.preferences.preferencesModule
import de.mm20.launcher2.profiles.profilesModule
import de.mm20.launcher2.searchactions.searchActionsModule
import de.mm20.launcher2.services.favorites.favoritesModule
import de.mm20.launcher2.services.tags.servicesTagsModule
@@ -94,6 +95,7 @@ class LauncherApplication : Application(), CoroutineScope, ImageLoaderFactory {
servicesPluginsModule,
backupModule,
devicePoseModule,
profilesModule,
)
)
}
@@ -1,6 +1,7 @@
package de.mm20.launcher2.ui.launcher.search
import android.content.Context
import android.os.Process
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
@@ -16,7 +17,6 @@ import de.mm20.launcher2.preferences.search.LocationSearchSettings
import de.mm20.launcher2.preferences.search.SearchFilterSettings
import de.mm20.launcher2.preferences.search.ShortcutSearchSettings
import de.mm20.launcher2.preferences.ui.SearchUiSettings
import de.mm20.launcher2.search.AppProfile
import de.mm20.launcher2.search.AppShortcut
import de.mm20.launcher2.search.Application
import de.mm20.launcher2.search.Article
@@ -268,7 +268,7 @@ class SearchVM : ViewModel(), KoinComponent {
r is SavableSearchable && hiddenKeys.contains(r.key) && !filters.hiddenItems -> {
hidden.add(r)
}
r is Application && r.profile == AppProfile.Work -> workApps.add(r)
r is Application && r.user != Process.myUserHandle() -> workApps.add(r)
r is Application -> apps.add(r)
r is AppShortcut -> shortcuts.add(r)
r is File -> files.add(r)
@@ -1,5 +1,6 @@
package de.mm20.launcher2.ui.settings.media
import android.os.Process
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
@@ -12,7 +13,6 @@ import de.mm20.launcher2.music.MusicService
import de.mm20.launcher2.permissions.PermissionGroup
import de.mm20.launcher2.permissions.PermissionsManager
import de.mm20.launcher2.preferences.media.MediaSettings
import de.mm20.launcher2.search.AppProfile
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
@@ -51,7 +51,7 @@ class MediaIntegrationSettingsScreenVM : ViewModel(), KoinComponent {
loading.value = true
viewModelScope.launch(Dispatchers.Default) {
val musicApps = musicService.getInstalledPlayerPackages()
val allApps = appRepository.findMany().first { it.isNotEmpty() }.filter { it.profile == AppProfile.Personal }
val allApps = appRepository.findMany().first { it.isNotEmpty() }.filter { it.user == Process.myUserHandle() }
.distinctBy { it.componentName.packageName }
val settings = mediaSettings.first()
val allowList = settings.allowList