fix duplicate pins (#1566)

This commit is contained in:
leekleak 2025-07-27 17:51:49 +03:00 committed by GitHub
parent 341259d09f
commit 457a924a51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 5 deletions

View File

@ -119,10 +119,13 @@ fun EditFavoritesSheet(
.align(Alignment.Center)
)
}
} else if (createShortcutTarget != null) {
ShortcutPicker(viewModel, it)
} else {
ReorderFavoritesGrid(viewModel, it)
if (createShortcutTarget != null) {
BottomSheetDialog({viewModel.cancelPickShortcut()}) {
ShortcutPicker(viewModel, it)
}
}
}
}
}

View File

@ -48,5 +48,6 @@ dependencies {
implementation(project(":core:ktx"))
implementation(project(":core:crashreporter"))
implementation(project(":core:preferences"))
implementation(project(":core:profiles"))
}

View File

@ -13,6 +13,7 @@ import de.mm20.launcher2.ktx.normalize
import de.mm20.launcher2.permissions.PermissionGroup
import de.mm20.launcher2.permissions.PermissionsManager
import de.mm20.launcher2.preferences.search.ShortcutSearchSettings
import de.mm20.launcher2.profiles.ProfileManager
import de.mm20.launcher2.search.AppShortcut
import de.mm20.launcher2.search.ResultScore
import de.mm20.launcher2.search.SearchableRepository
@ -27,6 +28,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
@ -54,6 +56,7 @@ internal class AppShortcutRepositoryImpl(
private val context: Context,
private val permissionsManager: PermissionsManager,
private val settings: ShortcutSearchSettings,
private val profileManager: ProfileManager,
) : AppShortcutRepository {
private val scope = CoroutineScope(Dispatchers.Default + Job())
@ -213,9 +216,9 @@ internal class AppShortcutRepositoryImpl(
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
if (!launcherApps.hasShortcutHostPermission()) return emptyList()
val results = mutableListOf<AppShortcutConfigActivity>()
val profiles = launcherApps.profiles
val profiles = profileManager.activeProfiles.first()
for (profile in profiles) {
val activities = launcherApps.getShortcutConfigActivityList(null, profile)
val activities = launcherApps.getShortcutConfigActivityList(null, profile.userHandle)
results.addAll(
activities.map {
AppShortcutConfigActivity(it)

View File

@ -8,7 +8,7 @@ import org.koin.core.qualifier.named
import org.koin.dsl.module
val appShortcutsModule = module {
factory<AppShortcutRepository> { AppShortcutRepositoryImpl(androidContext(), get(), get()) }
factory<AppShortcutRepository> { AppShortcutRepositoryImpl(androidContext(), get(), get(), get()) }
factory<SearchableRepository<AppShortcut>>(named<AppShortcut>()) { get<AppShortcutRepository>() }
factory<SearchableDeserializer>(named(LauncherShortcut.Domain)) { LauncherShortcutDeserializer(androidContext()) }
factory<SearchableDeserializer>(named(LegacyShortcut.Domain)) { LegacyShortcutDeserializer(androidContext()) }