Create appshortcuts module
This commit is contained in:
@@ -112,7 +112,9 @@ fun AppItem(
|
||||
)
|
||||
}
|
||||
|
||||
for (shortcut in app.shortcuts.subList(0, min(app.shortcuts.size, 5))) {
|
||||
val shortcuts by viewModel.shortcuts.collectAsState(emptyList())
|
||||
|
||||
for (shortcut in shortcuts) {
|
||||
val title =
|
||||
shortcut.launcherShortcut.shortLabel
|
||||
?: shortcut.launcherShortcut.longLabel
|
||||
|
||||
@@ -10,14 +10,17 @@ import android.provider.Settings
|
||||
import android.service.notification.StatusBarNotification
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.content.getSystemService
|
||||
import de.mm20.launcher2.appshortcuts.AppShortcutRepository
|
||||
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||
import de.mm20.launcher2.ktx.tryStartActivity
|
||||
import de.mm20.launcher2.notifications.NotificationRepository
|
||||
import de.mm20.launcher2.search.data.AppShortcut
|
||||
import de.mm20.launcher2.search.data.Application
|
||||
import de.mm20.launcher2.search.data.LauncherApp
|
||||
import de.mm20.launcher2.ui.launcher.search.common.SearchableItemVM
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.core.component.inject
|
||||
@@ -26,6 +29,7 @@ class AppItemVM(
|
||||
private val app: Application
|
||||
) : SearchableItemVM(app) {
|
||||
private val notificationRepository: NotificationRepository by inject()
|
||||
private val appShortcutRepository: AppShortcutRepository by inject()
|
||||
|
||||
|
||||
val notifications =
|
||||
@@ -105,6 +109,12 @@ class AppItemVM(
|
||||
return launcherApps.getShortcutIconDrawable(shortcut, 0)
|
||||
}
|
||||
|
||||
val shortcuts = flow {
|
||||
if (app is LauncherApp) {
|
||||
emit(appShortcutRepository.getShortcutsForActivity(app.launcherActivityInfo, 5))
|
||||
}
|
||||
}
|
||||
|
||||
fun isShortcutPinned(shortcut: AppShortcut): Flow<Boolean> {
|
||||
return favoritesRepository.isPinned(shortcut)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user