Ariver
2026-05-19 7c8c804dacd1747101c0949a3ca26c94c690af79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Foundation
 
enum AppDefaults {
    static let schemaVersionKey = "initialDefaultsSchemaVersion"
    static let currentSchemaVersion = 2
 
    static let tagFontSize: Double = 22
    static let iconSize: Double = 80
    static let tagPosition = "right"
    static let displayMode = "coloredGridContainer"
    static let hideAppNames = true
    static let showDockIcon = true
    static let launchAtLogin = true
    static let showUncommonAppBubbles = false
 
    static func register() {
        UserDefaults.standard.register(defaults: [
            "tagFontSize": tagFontSize,
            "iconSize": iconSize,
            "tagPosition": tagPosition,
            "displayMode": displayMode,
            "hideAppNames": hideAppNames,
            "showDockIcon": showDockIcon,
            "launchAtLogin": launchAtLogin,
            "showUncommonAppBubbles": showUncommonAppBubbles
        ])
        migrateShortcutDefaultsIfNeeded()
    }
 
    static func hasStoredValue(for key: String) -> Bool {
        let domain = Bundle.main.bundleIdentifier ?? "com.apptag.launcher"
        return UserDefaults.standard.persistentDomain(forName: domain)?[key] != nil
    }
 
    private static func migrateShortcutDefaultsIfNeeded() {
        let defaults = UserDefaults.standard
        guard defaults.integer(forKey: schemaVersionKey) < currentSchemaVersion else { return }
 
        defaults.set(LauncherHotkey.defaultMain.serialized, forKey: LauncherHotkeyKind.main.storageKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.pendingStorageKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.statusKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.conflictMessageKey)
 
        let quickSearchKey = LauncherHotkeyKind.quickSearch.storageKey
        let storedQuickSearch = defaults.string(forKey: quickSearchKey) ?? ""
        if storedQuickSearch.isEmpty {
            defaults.set(LauncherHotkey.defaultQuickSearch.serialized, forKey: quickSearchKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.pendingStorageKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.statusKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.conflictMessageKey)
        }
 
        defaults.set(currentSchemaVersion, forKey: schemaVersionKey)
    }
}