Don't unpin shortcuts when they are unavailable
This commit is contained in:
@@ -18,6 +18,8 @@ import de.mm20.launcher2.files.FileRepository
|
||||
import de.mm20.launcher2.icons.IconService
|
||||
import de.mm20.launcher2.notifications.Notification
|
||||
import de.mm20.launcher2.notifications.NotificationRepository
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
import de.mm20.launcher2.permissions.PermissionsManager
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.search.data.AppShortcut
|
||||
import de.mm20.launcher2.search.data.File
|
||||
@@ -45,6 +47,7 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
|
||||
private val notificationRepository: NotificationRepository by inject()
|
||||
private val appShortcutRepository: AppShortcutRepository by inject()
|
||||
private val fileRepository: FileRepository by inject()
|
||||
private val permissionsManager: PermissionsManager by inject()
|
||||
|
||||
private val searchable = MutableStateFlow<SavableSearchable?>(null)
|
||||
private val iconSize = MutableStateFlow<Int>(0)
|
||||
@@ -154,4 +157,8 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
|
||||
if (searchable is LauncherShortcut) appShortcutRepository.removePinnedShortcut(searchable)
|
||||
favoritesService.reset(searchable)
|
||||
}
|
||||
|
||||
fun requestShortcutPermission(activity: AppCompatActivity) {
|
||||
permissionsManager.requestPermission(activity, PermissionGroup.AppShortcuts)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package de.mm20.launcher2.ui.launcher.search.shortcut
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.provider.Settings
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.MutableTransitionState
|
||||
import androidx.compose.animation.core.animateDp
|
||||
@@ -55,9 +56,11 @@ import de.mm20.launcher2.ktx.tryStartActivity
|
||||
import de.mm20.launcher2.search.data.AppShortcut
|
||||
import de.mm20.launcher2.search.data.LauncherShortcut
|
||||
import de.mm20.launcher2.search.data.LegacyShortcut
|
||||
import de.mm20.launcher2.search.data.UnavailableShortcut
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.animation.animateTextStyleAsState
|
||||
import de.mm20.launcher2.ui.component.DefaultToolbarAction
|
||||
import de.mm20.launcher2.ui.component.MissingPermissionBanner
|
||||
import de.mm20.launcher2.ui.component.ShapedLauncherIcon
|
||||
import de.mm20.launcher2.ui.component.Toolbar
|
||||
import de.mm20.launcher2.ui.component.ToolbarAction
|
||||
@@ -98,6 +101,15 @@ fun AppShortcutItem(
|
||||
Column(
|
||||
modifier = modifier
|
||||
) {
|
||||
AnimatedVisibility(showDetails && shortcut is UnavailableShortcut) {
|
||||
MissingPermissionBanner(
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 16.dp),
|
||||
text = stringResource(R.string.shortcut_unavailable_description, stringResource(R.string.app_name)),
|
||||
onClick = {
|
||||
viewModel.requestShortcutPermission(context as AppCompatActivity)
|
||||
}
|
||||
)
|
||||
}
|
||||
Row {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -154,7 +166,6 @@ fun AppShortcutItem(
|
||||
|
||||
|
||||
AnimatedVisibility(showDetails) {
|
||||
|
||||
val toolbarActions = mutableListOf<ToolbarAction>()
|
||||
|
||||
if (LocalFavoritesEnabled.current) {
|
||||
|
||||
Reference in New Issue
Block a user