mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-14 09:13:25 +01:00
Fix enum to objc core data for app permission
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// AppDelegate+BackgroundFetch.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Joseph Mattiello on 3/2/23.
|
||||
// Copyright © 2023 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -10,13 +10,13 @@ import AVFoundation
|
||||
import Intents
|
||||
import UIKit
|
||||
import UserNotifications
|
||||
import os.log
|
||||
|
||||
import AltSign
|
||||
import SideStoreCore
|
||||
import SideStoreAppKit
|
||||
import EmotionalDamage
|
||||
import RoxasUIKit
|
||||
import os.log
|
||||
|
||||
@UIApplicationMain
|
||||
final class AppDelegate: SideStoreAppDelegate {
|
||||
@@ -53,6 +53,8 @@ final class AppDelegate: SideStoreAppDelegate {
|
||||
os_log("Failed to start DatabaseManager. Error: %@", type: .error , error.localizedDescription)
|
||||
} else {
|
||||
os_log("Started DatabaseManager.", type: .info)
|
||||
let transformer = ALTAppPermissionTypeTransformer()
|
||||
ValueTransformer.setValueTransformer(transformer, forName: NSValueTransformerName(rawValue: "ALTAppPermissionTypeTransformer"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.kernel.increased-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.siri</key>
|
||||
<true/>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>application-identifier</key>
|
||||
<string>A72ZC8AJ5X.com.SideStore.SideStore</string>
|
||||
<string>S32Z3HMYVQ.com.SideStore.SideStore</string>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
<key>com.apple.developer.siri</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.kernel.increased-memory-limit</key>
|
||||
<true/>
|
||||
<key>com.apple.developer.team-identifier</key>
|
||||
<string>A72ZC8AJ5X</string>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.SideStore.SideStore</string>
|
||||
<string>group.$(APP_GROUP_IDENTIFIER)</string>
|
||||
</array>
|
||||
<key>get-task-allow</key>
|
||||
<true/>
|
||||
|
||||
@@ -10,7 +10,9 @@ import UIKit
|
||||
|
||||
import RoxasUIKit
|
||||
|
||||
@objc
|
||||
final class NavigationBar: UINavigationBar {
|
||||
@objc
|
||||
@IBInspectable var automaticallyAdjustsItemPositions: Bool = true
|
||||
|
||||
private let backgroundColorView = UIView()
|
||||
|
||||
@@ -68,9 +68,30 @@ public extension ALTAppPermissionType {
|
||||
}
|
||||
|
||||
@objc(AppPermission)
|
||||
public class AppPermission: NSManagedObject, Decodable, Fetchable {
|
||||
public class AppPermission: NSManagedObject, Decodable, Fetchable, NSKeyValueObservingCustomization {
|
||||
public static func keyPathsAffectingValue(for key: AnyKeyPath) -> Set<AnyKeyPath> {
|
||||
print("keyPathsAffectingValue: \(String(describing: key))")
|
||||
return Set<AnyKeyPath>([key])
|
||||
}
|
||||
|
||||
public static func automaticallyNotifiesObservers(for key: AnyKeyPath) -> Bool {
|
||||
print("automaticallyNotifiesObservers: \(String(describing: key))")
|
||||
return true
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
@NSManaged public var type: ALTAppPermissionType
|
||||
@objc(type)
|
||||
@NSManaged public var _type: String
|
||||
@nonobjc
|
||||
public var type: ALTAppPermissionType {
|
||||
get {
|
||||
ALTAppPermissionType(rawValue: _type)
|
||||
}
|
||||
set {
|
||||
_type = newValue.stringValue
|
||||
}
|
||||
}
|
||||
|
||||
@NSManaged public var usageDescription: String
|
||||
|
||||
/* Relationships */
|
||||
@@ -95,11 +116,13 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable {
|
||||
usageDescription = try container.decode(String.self, forKey: .usageDescription)
|
||||
|
||||
let rawType = try container.decode(String.self, forKey: .type)
|
||||
guard let type = ALTAppPermissionType(rawValue: rawType) else {
|
||||
throw DecodingError.dataCorrupted(
|
||||
DecodingError.Context(codingPath: [CodingKeys.type],
|
||||
debugDescription: "Invalid value for `ALTAppPermissionType` \"\(rawType)\""))
|
||||
}
|
||||
// guard
|
||||
let type = ALTAppPermissionType(rawValue: rawType)
|
||||
// else {
|
||||
// throw DecodingError.dataCorrupted(
|
||||
// DecodingError.Context(codingPath: [CodingKeys.type],
|
||||
// debugDescription: "Invalid value for `ALTAppPermissionType` \"\(rawType)\""))
|
||||
// }
|
||||
self.type = type
|
||||
} catch {
|
||||
if let context = managedObjectContext {
|
||||
|
||||
@@ -27,8 +27,9 @@ public enum ALTAppPermissionType: Int, CaseIterable {
|
||||
case faceID
|
||||
case siri
|
||||
case motion
|
||||
case null
|
||||
|
||||
public init?(rawValue: String) {
|
||||
public init(rawValue: String) {
|
||||
switch rawValue {
|
||||
case "photos": self = .photos
|
||||
case "camera": self = .camera
|
||||
@@ -47,7 +48,7 @@ public enum ALTAppPermissionType: Int, CaseIterable {
|
||||
case "faceID", "faceid": self = .faceID
|
||||
case "siri": self = .siri
|
||||
case "motion": self = .motion
|
||||
default: return nil
|
||||
default: self = .null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +88,21 @@ public enum ALTAppPermissionType: Int, CaseIterable {
|
||||
return "siri"
|
||||
case .motion:
|
||||
return "motion"
|
||||
}
|
||||
case .null:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
public final class ALTAppPermissionTypeTransformer: ValueTransformer {
|
||||
public override func transformedValue(_ value: Any?) -> Any? {
|
||||
guard let enumValue = value as? ALTAppPermissionType else { return "" }
|
||||
return enumValue.rawValue
|
||||
}
|
||||
|
||||
public override func reverseTransformedValue(_ value: Any?) -> Any? {
|
||||
guard let rawValue = value as? String else { return ALTAppPermissionType.null }
|
||||
return ALTAppPermissionType(rawValue: rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -23,6 +23,11 @@
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>INIntentsSupported</key>
|
||||
<array>
|
||||
<string>RefreshAllIntent</string>
|
||||
<string>ViewAppIntent</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
|
||||
Reference in New Issue
Block a user