mirror of
https://github.com/SideStore/SideStore.git
synced 2026-04-04 01:35:39 +02:00
Merge branch 'widget' into develop
This commit is contained in:
@@ -33,10 +33,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
@available(iOS 14, *)
|
||||
private lazy var intentHandler = IntentHandler()
|
||||
|
||||
@available(iOS 14, *)
|
||||
private lazy var viewAppIntentHandler = ViewAppIntentHandler()
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
|
||||
{
|
||||
// Register default settings before doing anything else.
|
||||
UserDefaults.registerDefaults()
|
||||
|
||||
DatabaseManager.shared.start { (error) in
|
||||
if let error = error
|
||||
{
|
||||
@@ -54,9 +61,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
ServerManager.shared.startDiscovering()
|
||||
|
||||
SecureValueTransformer.register()
|
||||
|
||||
UserDefaults.standard.registerDefaults()
|
||||
SecureValueTransformer.register()
|
||||
|
||||
if UserDefaults.standard.firstLaunch == nil
|
||||
{
|
||||
@@ -95,8 +100,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any?
|
||||
{
|
||||
guard intent is RefreshAllIntent else { return nil }
|
||||
return self.intentHandler
|
||||
guard #available(iOS 14, *) else { return nil }
|
||||
|
||||
switch intent
|
||||
{
|
||||
case is RefreshAllIntent: return self.intentHandler
|
||||
case is ViewAppIntent: return self.viewAppIntentHandler
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// Date+RelativeDate.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 7/28/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Date
|
||||
{
|
||||
func numberOfCalendarDays(since date: Date) -> Int
|
||||
{
|
||||
let today = Calendar.current.startOfDay(for: self)
|
||||
let previousDay = Calendar.current.startOfDay(for: date)
|
||||
|
||||
let components = Calendar.current.dateComponents([.day], from: previousDay, to: today)
|
||||
return components.day!
|
||||
}
|
||||
|
||||
func relativeDateString(since date: Date, dateFormatter: DateFormatter) -> String
|
||||
{
|
||||
let numberOfDays = self.numberOfCalendarDays(since: date)
|
||||
|
||||
switch numberOfDays
|
||||
{
|
||||
case 0: return NSLocalizedString("Today", comment: "")
|
||||
case 1: return NSLocalizedString("Yesterday", comment: "")
|
||||
case 2...7: return String(format: NSLocalizedString("%@ days ago", comment: ""), NSNumber(value: numberOfDays))
|
||||
default: return dateFormatter.string(from: date)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// FileManager+SharedDirectories.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/14/20.
|
||||
// Copyright © 2020 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import AltStoreCore
|
||||
|
||||
extension FileManager
|
||||
{
|
||||
var altstoreSharedDirectory: URL? {
|
||||
guard let appGroup = Bundle.main.appGroups.first else { return nil }
|
||||
|
||||
let sharedDirectoryURL = self.containerURL(forSecurityApplicationGroupIdentifier: appGroup)
|
||||
return sharedDirectoryURL
|
||||
}
|
||||
|
||||
var appBackupsDirectory: URL? {
|
||||
let appBackupsDirectory = self.altstoreSharedDirectory?.appendingPathComponent("Backups", isDirectory: true)
|
||||
return appBackupsDirectory
|
||||
}
|
||||
|
||||
func backupDirectoryURL(for app: InstalledApp) -> URL?
|
||||
{
|
||||
let backupDirectoryURL = self.appBackupsDirectory?.appendingPathComponent(app.bundleIdentifier, isDirectory: true)
|
||||
return backupDirectoryURL
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// UIColor+AltStore.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 5/9/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIColor
|
||||
{
|
||||
static let altPrimary = UIColor(named: "Primary")!
|
||||
|
||||
static let altPink = UIColor(named: "Pink")!
|
||||
|
||||
static let refreshRed = UIColor(named: "RefreshRed")!
|
||||
static let refreshOrange = UIColor(named: "RefreshOrange")!
|
||||
static let refreshYellow = UIColor(named: "RefreshYellow")!
|
||||
static let refreshGreen = UIColor(named: "RefreshGreen")!
|
||||
}
|
||||
@@ -69,6 +69,7 @@
|
||||
<key>INIntentsSupported</key>
|
||||
<array>
|
||||
<string>RefreshAllIntent</string>
|
||||
<string>ViewAppIntent</string>
|
||||
</array>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
@@ -92,6 +93,7 @@
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>RefreshAllIntent</string>
|
||||
<string>ViewAppIntent</string>
|
||||
</array>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
|
||||
@@ -10,6 +10,7 @@ import Foundation
|
||||
|
||||
import AltStoreCore
|
||||
|
||||
@available(iOS 14, *)
|
||||
class IntentHandler: NSObject, RefreshAllIntentHandling
|
||||
{
|
||||
private let queue = DispatchQueue(label: "io.altstore.IntentHandler")
|
||||
@@ -75,6 +76,7 @@ class IntentHandler: NSObject, RefreshAllIntentHandling
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 14, *)
|
||||
private extension IntentHandler
|
||||
{
|
||||
func finish(_ intent: RefreshAllIntent, response: RefreshAllIntentResponse)
|
||||
|
||||
@@ -12,6 +12,7 @@ import UserNotifications
|
||||
import MobileCoreServices
|
||||
import Intents
|
||||
import Combine
|
||||
import WidgetKit
|
||||
|
||||
import AltStoreCore
|
||||
import AltSign
|
||||
@@ -76,16 +77,19 @@ class AppManager
|
||||
@available(iOS 13, *)
|
||||
func prepareSubscriptions()
|
||||
{
|
||||
/// Every time refreshProgress is changed, update all InstalledApps in memory
|
||||
/// so that app.isRefreshing == refreshProgress.keys.contains(app.bundleID)
|
||||
|
||||
self.publisher.$refreshProgress
|
||||
.receive(on: RunLoop.main)
|
||||
.map(\.keys)
|
||||
.flatMap { (bundleIDs) in
|
||||
DatabaseManager.shared.viewContext.registeredObjects.publisher
|
||||
.compactMap { $0 as? InstalledApp }
|
||||
.map { ($0, bundleIDs) }
|
||||
.map { ($0, bundleIDs.contains($0.bundleIdentifier)) }
|
||||
}
|
||||
.sink { (installedApp, bundleIDs) in
|
||||
installedApp.isRefreshing = bundleIDs.contains(installedApp.bundleIdentifier)
|
||||
.sink { (installedApp, isRefreshing) in
|
||||
installedApp.isRefreshing = isRefreshing
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
@@ -1343,6 +1347,16 @@ private extension AppManager
|
||||
AnalyticsManager.shared.trackEvent(event)
|
||||
}
|
||||
|
||||
if #available(iOS 14, *)
|
||||
{
|
||||
WidgetCenter.shared.getCurrentConfigurations { (result) in
|
||||
guard case .success(let widgets) = result else { return }
|
||||
|
||||
guard let widget = widgets.first(where: { $0.configuration is ViewAppIntent }) else { return }
|
||||
WidgetCenter.shared.reloadTimelines(ofKind: widget.kind)
|
||||
}
|
||||
}
|
||||
|
||||
do { try installedApp.managedObjectContext?.save() }
|
||||
catch { print("Error saving installed app.", error) }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "236",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "178",
|
||||
"green" : "65"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "1",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "132",
|
||||
"green" : "128"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "52",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "89",
|
||||
"green" : "199"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "255",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0",
|
||||
"green" : "149"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "255",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "48",
|
||||
"green" : "59"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"red" : "255",
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0",
|
||||
"green" : "204"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -133,6 +133,10 @@ extension ServerManager
|
||||
let connection = NWConnection(to: .service(name: service.name, type: service.type, domain: service.domain, interface: nil), using: parameters)
|
||||
start(connection)
|
||||
}
|
||||
else
|
||||
{
|
||||
finish(.failure(ALTServerError(.connectionFailed)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user