Rename IconRepository -> IconService
This commit is contained in:
parent
e5a6043fe6
commit
68eece53f7
@ -5,10 +5,9 @@ import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.search.SearchService
|
||||
import de.mm20.launcher2.search.toList
|
||||
@ -17,10 +16,8 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.androidx.compose.inject
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
@ -28,7 +25,7 @@ class SearchablePickerVM: ViewModel(), KoinComponent {
|
||||
|
||||
private val dataStore: LauncherDataStore by inject()
|
||||
private val searchService: SearchService by inject()
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
|
||||
var searchQuery by mutableStateOf("")
|
||||
|
||||
@ -61,6 +58,6 @@ class SearchablePickerVM: ViewModel(), KoinComponent {
|
||||
}
|
||||
|
||||
fun getIcon(searchable: SavableSearchable, size: Int): Flow<LauncherIcon> {
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ import androidx.core.app.ActivityOptionsCompat
|
||||
import de.mm20.launcher2.badges.BadgeService
|
||||
import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
|
||||
import de.mm20.launcher2.searchable.SearchableRepository
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.search.data.AppShortcut
|
||||
@ -23,7 +23,7 @@ abstract class SearchableItemVM(
|
||||
protected val favoritesService: FavoritesService by inject()
|
||||
protected val searchableRepository: SearchableRepository by inject()
|
||||
protected val badgeService: BadgeService by inject()
|
||||
protected val iconRepository: IconRepository by inject()
|
||||
protected val iconService: IconService by inject()
|
||||
protected val customAttributesRepository: CustomAttributesRepository by inject()
|
||||
|
||||
val isPinned = searchableRepository.isPinned(searchable)
|
||||
@ -47,7 +47,7 @@ abstract class SearchableItemVM(
|
||||
val badge = badgeService.getBadge(searchable)
|
||||
|
||||
fun getIcon(size: Int): Flow<LauncherIcon> {
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
|
||||
fun getTags(): Flow<List<String>> {
|
||||
|
||||
@ -6,7 +6,7 @@ import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
|
||||
import de.mm20.launcher2.data.customattrs.CustomIcon
|
||||
import de.mm20.launcher2.icons.CustomIconWithPreview
|
||||
import de.mm20.launcher2.icons.IconPack
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import kotlinx.coroutines.Job
|
||||
@ -14,7 +14,6 @@ import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.core.component.KoinComponent
|
||||
@ -24,17 +23,17 @@ import kotlin.coroutines.coroutineContext
|
||||
class CustomizeSearchableSheetVM(
|
||||
private val searchable: SavableSearchable
|
||||
) : KoinComponent {
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
private val customAttributesRepository: CustomAttributesRepository by inject()
|
||||
|
||||
val isIconPickerOpen = mutableStateOf(false)
|
||||
|
||||
fun getIcon(size: Int): Flow<LauncherIcon> {
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
|
||||
fun getIconSuggestions(size: Int) = liveData {
|
||||
emit(iconRepository.getCustomIconSuggestions(searchable, size))
|
||||
emit(iconService.getCustomIconSuggestions(searchable, size))
|
||||
}
|
||||
|
||||
fun openIconPicker() {
|
||||
@ -46,18 +45,18 @@ class CustomizeSearchableSheetVM(
|
||||
}
|
||||
|
||||
fun pickIcon(icon: CustomIcon?) {
|
||||
iconRepository.setCustomIcon(searchable, icon)
|
||||
iconService.setCustomIcon(searchable, icon)
|
||||
closeIconPicker()
|
||||
}
|
||||
|
||||
fun getDefaultIcon(size: Int) = liveData {
|
||||
emit(iconRepository.getUncustomizedDefaultIcon(searchable, size))
|
||||
emit(iconService.getUncustomizedDefaultIcon(searchable, size))
|
||||
}
|
||||
|
||||
val iconSearchResults = mutableStateOf(emptyList<CustomIconWithPreview>())
|
||||
val isSearchingIcons = mutableStateOf(false)
|
||||
|
||||
val installedIconPacks = iconRepository.getInstalledIconPacks()
|
||||
val installedIconPacks = iconService.getInstalledIconPacks()
|
||||
|
||||
private var debounceSearchJob: Job? = null
|
||||
suspend fun searchIcon(query: String, iconPack: IconPack?) {
|
||||
@ -72,7 +71,7 @@ class CustomizeSearchableSheetVM(
|
||||
delay(500)
|
||||
isSearchingIcons.value = true
|
||||
iconSearchResults.value = emptyList()
|
||||
iconSearchResults.value = iconRepository.searchCustomIcons(query, iconPack)
|
||||
iconSearchResults.value = iconService.searchCustomIcons(query, iconPack)
|
||||
isSearchingIcons.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import de.mm20.launcher2.appshortcuts.AppShortcutRepository
|
||||
import de.mm20.launcher2.badges.Badge
|
||||
import de.mm20.launcher2.badges.BadgeService
|
||||
import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.ktx.normalize
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
@ -36,7 +36,7 @@ class EditFavoritesSheetVM : ViewModel(), KoinComponent {
|
||||
|
||||
private val favoritesService: FavoritesService by inject()
|
||||
private val shortcutRepository: AppShortcutRepository by inject()
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
private val badgeService: BadgeService by inject()
|
||||
private val customAttributesRepository: CustomAttributesRepository by inject()
|
||||
private val permissionsManager: PermissionsManager by inject()
|
||||
@ -181,7 +181,7 @@ class EditFavoritesSheetVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
|
||||
fun getIcon(searchable: SavableSearchable, size: Int): Flow<LauncherIcon?> {
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
|
||||
fun getBadge(searchable: Searchable): Flow<Badge?> {
|
||||
|
||||
@ -9,7 +9,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.icons.IconPack
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
@ -20,9 +20,7 @@ import de.mm20.launcher2.preferences.Settings.SearchBarSettings
|
||||
import de.mm20.launcher2.preferences.Settings.SearchBarSettings.SearchBarColors
|
||||
import de.mm20.launcher2.preferences.Settings.SystemBarsSettings
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.shareIn
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
@ -30,7 +28,7 @@ import org.koin.core.component.inject
|
||||
class AppearanceSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
private val dataStore: LauncherDataStore by inject()
|
||||
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
|
||||
val theme = dataStore.data.map { it.appearance.theme }.asLiveData()
|
||||
fun setTheme(theme: Theme) {
|
||||
@ -200,7 +198,7 @@ class AppearanceSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
}
|
||||
|
||||
val installedIconPacks: Flow<List<IconPack>> = iconRepository.getInstalledIconPacks().map {
|
||||
val installedIconPacks: Flow<List<IconPack>> = iconService.getInstalledIconPacks().map {
|
||||
listOf(
|
||||
IconPack(
|
||||
name = "System",
|
||||
|
||||
@ -5,7 +5,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.searchable.SearchableRepository
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
import de.mm20.launcher2.permissions.PermissionsManager
|
||||
@ -25,7 +25,7 @@ class GestureSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
private val dataStore: LauncherDataStore by inject()
|
||||
private val permissionsManager: PermissionsManager by inject()
|
||||
private val searchableRepository: SearchableRepository by inject()
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
|
||||
val hasPermission = permissionsManager.hasPermission(PermissionGroup.Accessibility).asLiveData()
|
||||
|
||||
@ -190,6 +190,6 @@ class GestureSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
|
||||
fun getIcon(searchable: SavableSearchable?, size: Int): Flow<LauncherIcon> {
|
||||
if (searchable == null) return emptyFlow()
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.liveData
|
||||
import de.mm20.launcher2.applications.AppRepository
|
||||
import de.mm20.launcher2.searchable.SearchableRepository
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
@ -27,7 +27,7 @@ import org.koin.core.component.inject
|
||||
class HiddenItemsSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
private val appRepository: AppRepository by inject()
|
||||
private val searchableRepository: SearchableRepository by inject()
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
|
||||
val allApps = appRepository.getAllInstalledApps().map {
|
||||
withContext(Dispatchers.Default) { it.sorted() }
|
||||
@ -50,7 +50,7 @@ class HiddenItemsSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
|
||||
fun getIcon(searchable: SavableSearchable, size: Int): Flow<LauncherIcon> {
|
||||
return iconRepository.getIcon(searchable, size)
|
||||
return iconService.getIcon(searchable, size)
|
||||
}
|
||||
|
||||
fun launch(context: Context, searchable: SavableSearchable) {
|
||||
|
||||
@ -9,7 +9,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.applications.AppRepository
|
||||
import de.mm20.launcher2.icons.IconRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.search.SearchService
|
||||
@ -25,7 +25,7 @@ class EditTagSheetVM : ViewModel(), KoinComponent {
|
||||
|
||||
private val tagService: TagsService by inject()
|
||||
private val searchService: SearchService by inject()
|
||||
private val iconRepository: IconRepository by inject()
|
||||
private val iconService: IconService by inject()
|
||||
private val appRepository: AppRepository by inject()
|
||||
|
||||
private var oldTagName by mutableStateOf<String?>(null)
|
||||
@ -82,7 +82,7 @@ class EditTagSheetVM : ViewModel(), KoinComponent {
|
||||
}
|
||||
|
||||
fun getIcon(item: SavableSearchable, size: Int): Flow<LauncherIcon> {
|
||||
return iconRepository.getIcon(item, size)
|
||||
return iconService.getIcon(item, size)
|
||||
}
|
||||
|
||||
fun openItemPicker() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package de.mm20.launcher2.icons
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
@ -45,11 +44,10 @@ import kotlinx.coroutines.flow.channelFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.internal.ChannelFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class IconRepository(
|
||||
class IconService(
|
||||
val context: Context,
|
||||
private val iconPackManager: IconPackManager,
|
||||
private val dataStore: LauncherDataStore,
|
||||
@ -133,9 +131,9 @@ class IconRepository(
|
||||
ForceThemedIconTransformation()
|
||||
)
|
||||
|
||||
this@IconRepository.placeholderProvider = placeholderProvider
|
||||
this@IconService.placeholderProvider = placeholderProvider
|
||||
iconProviders.value = providers
|
||||
this@IconRepository.transformations.value = transformations
|
||||
this@IconService.transformations.value = transformations
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,5 +5,5 @@ import org.koin.dsl.module
|
||||
|
||||
val iconsModule = module {
|
||||
single { IconPackManager(androidContext(), get()) }
|
||||
single { IconRepository(androidContext(), get(), get(), get()) }
|
||||
single { IconService(androidContext(), get(), get(), get()) }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user