Skip to content

Commit

Permalink
Add uninstall option to desktop popup. Fix #478
Browse files Browse the repository at this point in the history
Signed-off-by: saulhdev <[email protected]>
  • Loading branch information
saulhdev committed Oct 1, 2024
1 parent c02c97d commit 73506cc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
19 changes: 10 additions & 9 deletions Omega/src/com/saggitt/omega/popup/OmegaShortcuts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,18 @@ class OmegaShortcuts {
val APP_UNINSTALL =
SystemShortcut.Factory<NeoLauncher> { launcher, itemInfo, originalView ->
val prefs = NeoPrefs.getInstance()
var appUninstall: AppUninstall? = null
val inUninstallState =
(prefs.drawerPopupUninstall && launcher.isInState(LauncherState.ALL_APPS)) ||
(prefs.desktopPopupUninstall && !launcher.isInState(LauncherState.ALL_APPS))

if (prefs.drawerPopupUninstall && launcher.isInState(LauncherState.ALL_APPS)) {

if (itemInfo is ItemInfoWithIcon) {
if (!itemInfo.runtimeStatusFlags.hasFlags(FLAG_SYSTEM_YES)) {
appUninstall = AppUninstall(launcher, itemInfo, originalView)
}
}
if (inUninstallState && itemInfo is ItemInfoWithIcon && !itemInfo.runtimeStatusFlags.hasFlags(
FLAG_SYSTEM_YES
)
) {
AppUninstall(launcher, itemInfo, originalView)
} else {
null
}
appUninstall
}
}
}
6 changes: 5 additions & 1 deletion Omega/src/com/saggitt/omega/preferences/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ val themeItems = mutableMapOf(

const val PREFS_DESKTOP_POPUP_EDIT = "desktop_popup_edit"
const val PREFS_DESKTOP_POPUP_REMOVE = "desktop_popup_remove"
const val PREFS_DESKTOP_POPUP_UNINSTALL = "desktop_popup_uninstall"

const val PREFS_DRAWER_POPUP_EDIT = "drawer_popup_edit"
const val PREFS_DRAWER_POPUP_UNINSTALL = "drawer_popup_uninstall"
Expand All @@ -58,6 +59,7 @@ const val LAYOUT_CATEGORIZED = 4
val desktopPopupOptions = mutableMapOf(
PREFS_DESKTOP_POPUP_REMOVE to R.string.remove_drop_target_label,
PREFS_DESKTOP_POPUP_EDIT to R.string.action_preferences,
PREFS_DESKTOP_POPUP_UNINSTALL to R.string.uninstall_drop_target_label,
)

val drawerPopupOptions = mutableMapOf(
Expand All @@ -66,11 +68,11 @@ val drawerPopupOptions = mutableMapOf(
)

val drawerLayoutOptions = mutableMapOf(
LAYOUT_CUSTOM_CATEGORIES to R.string.title_drawer_custom_categories,
LAYOUT_VERTICAL to R.string.title_drawer_vertical,
LAYOUT_VERTICAL_ALPHABETICAL to R.string.title_drawer_vertical_list,
LAYOUT_HORIZONTAL to R.string.title_drawer_horizontal,
LAYOUT_CATEGORIZED to R.string.title_drawer_categorized,
LAYOUT_CUSTOM_CATEGORIES to R.string.title_drawer_custom_categories
)

val temperatureUnitOptions = listOfNotNull(
Expand All @@ -87,10 +89,12 @@ val temperatureUnitOptions = listOfNotNull(
valueTransform = { "${it.name} (${it.suffix})" }
)


val iconIds = mapOf(
// Desktop Popup
PREFS_DESKTOP_POPUP_REMOVE to R.drawable.ic_remove_no_shadow,
PREFS_DESKTOP_POPUP_EDIT to R.drawable.ic_edit_no_shadow,
PREFS_DESKTOP_POPUP_UNINSTALL to R.drawable.ic_uninstall_no_shadow,
// Drawer Popup
PREFS_DRAWER_POPUP_UNINSTALL to R.drawable.ic_uninstall_no_shadow,
PREFS_DRAWER_POPUP_EDIT to R.drawable.ic_edit_no_shadow,
Expand Down
25 changes: 21 additions & 4 deletions Omega/src/com/saggitt/omega/preferences/NeoPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import androidx.datastore.preferences.core.Preferences
Expand Down Expand Up @@ -324,6 +325,7 @@ class NeoPrefs private constructor(val context: Context) {
defaultValue = false,
)

// TODO fix this
var desktopAllowEmptyScreens = BooleanPref(
dataStore = dataStore,
key = PrefKey.DESKTOP_EMPTY_SCREENS_ALLOW,
Expand Down Expand Up @@ -385,6 +387,8 @@ class NeoPrefs private constructor(val context: Context) {
get() = desktopPopup.getValue().contains(PREFS_DESKTOP_POPUP_EDIT)
val desktopPopupRemove: Boolean
get() = desktopPopup.getValue().contains(PREFS_DESKTOP_POPUP_REMOVE)
val desktopPopupUninstall: Boolean
get() = desktopPopup.getValue().contains(PREFS_DESKTOP_POPUP_UNINSTALL)

private var desktopGridSizeDelegate = ResettableLazy {
GridSize2D(
Expand Down Expand Up @@ -629,7 +633,6 @@ class NeoPrefs private constructor(val context: Context) {
)

// Drawer
// TODO drawerLayout
var drawerSortMode = IntSelectionPref(
dataStore = dataStore,
titleId = R.string.title__sort_mode,
Expand Down Expand Up @@ -823,8 +826,22 @@ class NeoPrefs private constructor(val context: Context) {
dataStore = dataStore,
key = PrefKey.DRAWER_LAYOUT,
titleId = R.string.title_drawer_layout,
defaultValue = LAYOUT_CUSTOM_CATEGORIES,
entries = drawerLayoutOptions
defaultValue = LAYOUT_VERTICAL,
entries = drawerLayoutOptions,
onChange = {
Log.d("NeoPref", "Drawer layout changed to $it")
}
)

var categoriesLayout = StringMultiSelectionPref(
dataStore = dataStore,
key = PrefKey.DRAWER_LAYOUT_CATEGORIES,
titleId = R.string.title_drawer_layout_categories,
defaultValue = setOf(),
entries = Config.layoutCategories(context),
onChange = {
Log.d("NeoPref", "Categories layout changed to $it")
}
)

// Notifications & Widgets/Smartspace
Expand Down Expand Up @@ -922,7 +939,7 @@ class NeoPrefs private constructor(val context: Context) {
dataStore = dataStore,
key = PrefKey.WIDGETS_SMARTSPACE_BACKGROUND,
titleId = R.string.title_smartspace_background,
defaultValue = true,
defaultValue = false,
)

val smartspaceDate = BooleanPref(
Expand Down

0 comments on commit 73506cc

Please sign in to comment.