mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Add missing items in pop-up menu, if there are any
- Add feature flag to toggle legacy options migration - Move migration logic to be at launcher start - Add feature flag to manually edit popup items list
This commit is contained in:
@@ -45,6 +45,7 @@ import app.lawnchair.preferences2.PreferenceManager2
|
||||
import app.lawnchair.root.RootHelperManager
|
||||
import app.lawnchair.root.RootNotAvailableException
|
||||
import app.lawnchair.theme.ThemeProvider
|
||||
import app.lawnchair.ui.popup.LauncherOptionsPopup
|
||||
import app.lawnchair.ui.popup.LawnchairShortcut
|
||||
import app.lawnchair.util.getThemedIconPacksInstalled
|
||||
import app.lawnchair.util.unsafeLazy
|
||||
@@ -221,6 +222,9 @@ class LawnchairLauncher : QuickstepLauncher() {
|
||||
hasBackGesture = handler !is GestureHandlerConfig.NoOp
|
||||
}
|
||||
|
||||
LauncherOptionsPopup.restoreMissingPopupOptions(launcher)
|
||||
LauncherOptionsPopup.migrateLegacyPreferences(launcher)
|
||||
|
||||
// Handle update from version 12 Alpha 4 to version 12 Alpha 5.
|
||||
if (
|
||||
prefs.themedIcons.get() &&
|
||||
|
||||
@@ -34,6 +34,26 @@ object LauncherOptionsPopup {
|
||||
)
|
||||
}
|
||||
|
||||
fun restoreMissingPopupOptions(
|
||||
launcher: Launcher,
|
||||
) {
|
||||
val prefs2 = getInstance(launcher)
|
||||
|
||||
val currentOrder = prefs2.launcherPopupOrder.firstBlocking()
|
||||
|
||||
val defaultOptions = DEFAULT_ORDER.toLauncherOptions()
|
||||
val currentOptions = currentOrder.toLauncherOptions()
|
||||
|
||||
// check for missing items in current options; if so, add them
|
||||
val missingItems = defaultOptions.filter { defaultItem ->
|
||||
defaultItem.identifier !in currentOptions.map { it.identifier }
|
||||
}
|
||||
|
||||
prefs2.launcherPopupOrder.setBlocking(
|
||||
(missingItems + currentOptions).toOptionOrderString(),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported actions
|
||||
*/
|
||||
@@ -50,8 +70,6 @@ object LauncherOptionsPopup {
|
||||
val lockHomeScreen = prefs2.lockHomeScreen.firstBlocking()
|
||||
val optionOrder = prefs2.launcherPopupOrder.firstBlocking()
|
||||
|
||||
migrateLegacyPreferences(launcher)
|
||||
|
||||
val wallpaperResString =
|
||||
if (Utilities.existsStyleWallpapers(launcher)) R.string.styles_wallpaper_button_text else R.string.wallpapers
|
||||
val wallpaperResDrawable =
|
||||
@@ -154,7 +172,7 @@ object LauncherOptionsPopup {
|
||||
}
|
||||
}
|
||||
|
||||
private fun migrateLegacyPreferences(
|
||||
fun migrateLegacyPreferences(
|
||||
launcher: Launcher,
|
||||
) {
|
||||
val prefs2 = getInstance(launcher)
|
||||
|
||||
@@ -100,10 +100,10 @@ fun DebugMenuPreferences(
|
||||
}
|
||||
|
||||
private val PreferenceManager2.debugFlags: List<Preference<Boolean, Boolean, Preferences.Key<Boolean>>>
|
||||
get() = listOf(showComponentNames)
|
||||
get() = listOf(showComponentNames, legacyPopupOptionsMigrated)
|
||||
|
||||
private val PreferenceManager2.textFlags: List<Preference<String, String, Preferences.Key<String>>>
|
||||
get() = listOf(additionalFonts)
|
||||
get() = listOf(additionalFonts, launcherPopupOrder)
|
||||
|
||||
private val PreferenceManager.debugFlags
|
||||
get() = listOf(ignoreFeedWhitelist)
|
||||
|
||||
Reference in New Issue
Block a user