Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
This commit is contained in:
Marino Faggiana 2022-10-27 14:38:17 +02:00
Родитель ef887e71b1
Коммит db0b9b72a8
11 изменённых файлов: 279 добавлений и 23 удалений

Просмотреть файл

@ -241,6 +241,9 @@
F75B0ABD244C4DBB00E58DCA /* NCFunctionCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75B0ABC244C4DBB00E58DCA /* NCFunctionCenter.swift */; };
F75C0C4823D1FAE300163CC8 /* NCRichWorkspaceCommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */; };
F75D19E325EFE09000D74598 /* NCTrash+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = F75D19E225EFE09000D74598 /* NCTrash+Menu.swift */; };
F75DD75C290AAD5C002EB562 /* Lockscreen.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = F75DD75B290AAD5C002EB562 /* Lockscreen.intentdefinition */; };
F75DD75D290AAD5F002EB562 /* Lockscreen.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = F75DD75B290AAD5C002EB562 /* Lockscreen.intentdefinition */; };
F75DD75E290AAD60002EB562 /* Lockscreen.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = F75DD75B290AAD5C002EB562 /* Lockscreen.intentdefinition */; };
F75E57BD25BF0EC1002B72C2 /* SVGKit in Frameworks */ = {isa = PBXBuildFile; productRef = F75E57BC25BF0EC1002B72C2 /* SVGKit */; };
F75E57BF25BF0EC8002B72C2 /* SVGKit in Frameworks */ = {isa = PBXBuildFile; productRef = F75E57BE25BF0EC8002B72C2 /* SVGKit */; };
F75E57C125BF0ECD002B72C2 /* SVGKit in Frameworks */ = {isa = PBXBuildFile; productRef = F75E57C025BF0ECD002B72C2 /* SVGKit */; };
@ -871,6 +874,7 @@
F75B923D1ECAE55E00199C96 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
F75C0C4723D1FAE300163CC8 /* NCRichWorkspaceCommon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCRichWorkspaceCommon.swift; sourceTree = "<group>"; };
F75D19E225EFE09000D74598 /* NCTrash+Menu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NCTrash+Menu.swift"; sourceTree = "<group>"; };
F75DD75B290AAD5C002EB562 /* Lockscreen.intentdefinition */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; path = Lockscreen.intentdefinition; sourceTree = "<group>"; };
F75EDFBC1E8C112F00E6F369 /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; };
F75EDFBE1E8C116D00E6F369 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
F760329D252F0F8E0015A421 /* NCTransferCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NCTransferCell.swift; path = iOSClient/Transfers/NCTransferCell.swift; sourceTree = SOURCE_ROOT; };
@ -1551,6 +1555,14 @@
path = ScanDocument;
sourceTree = "<group>";
};
F75DD75F290AAF6B002EB562 /* Intent */ = {
isa = PBXGroup;
children = (
F75DD75B290AAD5C002EB562 /* Lockscreen.intentdefinition */,
);
path = Intent;
sourceTree = "<group>";
};
F7603298252F0E550015A421 /* Collection Common */ = {
isa = PBXGroup;
children = (
@ -1587,6 +1599,7 @@
F76DEE9A28F808BC0041B1C9 /* Lockscreen */ = {
isa = PBXGroup;
children = (
F75DD75F290AAF6B002EB562 /* Intent */,
F76DEE9428F808AF0041B1C9 /* LockscreenData.swift */,
F76DEE9528F808AF0041B1C9 /* LockscreenWidgetProvider.swift */,
F76DEE9628F808AF0041B1C9 /* LockscreenWidgetView.swift */,
@ -2850,6 +2863,7 @@
F76DEE9828F808AF0041B1C9 /* LockscreenWidgetProvider.swift in Sources */,
F78302FA28B4C3EA00B84583 /* NCManageDatabase+Metadata.swift in Sources */,
F783030728B4C52800B84583 /* UIColor+Extensions.swift in Sources */,
F75DD75C290AAD5C002EB562 /* Lockscreen.intentdefinition in Sources */,
F783030028B4C45800B84583 /* NCGlobal.swift in Sources */,
F793E59D28B761E7005E4B02 /* NCNetworking.swift in Sources */,
F78302FC28B4C3F300B84583 /* NCElementsJSON.swift in Sources */,
@ -2930,6 +2944,7 @@
F702F2CD25EE5B4F008F8E80 /* AppDelegate.swift in Sources */,
F769454022E9F077000A798A /* NCSharePaging.swift in Sources */,
F78ACD4221903CE00088454D /* NCListCell.swift in Sources */,
F75DD75D290AAD5F002EB562 /* Lockscreen.intentdefinition in Sources */,
F76D3CF12428B40E005DFA87 /* NCViewerPDFSearch.swift in Sources */,
F7245924289BB50C00474787 /* ThreadSafeDictionary.swift in Sources */,
F73F537F1E929C8500F8678D /* NCMore.swift in Sources */,
@ -3089,6 +3104,7 @@
F7A8D74428F1827B008BBE1C /* ThreadSafeDictionary.swift in Sources */,
F7C9739528F17131002C43E2 /* IntentHandler.swift in Sources */,
F7A8D73D28F181D3008BBE1C /* NCUtilityFileSystem.swift in Sources */,
F75DD75E290AAD60002EB562 /* Lockscreen.intentdefinition in Sources */,
F7A8D74528F1828E008BBE1C /* CCUtility.m in Sources */,
F7A8D73F28F181EF008BBE1C /* NCGlobal.swift in Sources */,
F7A8D74328F1826F008BBE1C /* String+Extensions.swift in Sources */,

Просмотреть файл

@ -22,6 +22,7 @@
//
import WidgetKit
import Intents
import NextcloudKit
import RealmSwift
import SVGKit
@ -80,7 +81,7 @@ func getDashboardItems(displaySize: CGSize, withButton: Bool) -> Int {
}
}
func getDashboardDataEntry(intent: DashboardIntent?, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, displaySize: CGSize, completion: @escaping (_ entry: DashboardDataEntry) -> Void) {
let dashboardItems = getDashboardItems(displaySize: displaySize, withButton: false)
let datasPlaceholder = Array(dashboardDatasTest[0...dashboardItems - 1])
@ -90,7 +91,7 @@ func getDashboardDataEntry(intent: DashboardIntent?, isPreview: Bool, displaySiz
return completion(DashboardDataEntry(date: Date(), datas: datasPlaceholder, dashboard: nil, buttons: nil, isPlaceholder: true, isEmpty: false, titleImage: UIImage(named: "widget")!, title: "Dashboard", footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " dashboard"))
}
let accountIdentifier: String = intent?.Accounts?.identifier ?? "active"
let accountIdentifier: String = configuration?.Accounts?.identifier ?? "active"
if accountIdentifier == "active" {
account = NCManageDatabase.shared.getActiveAccount()
} else {
@ -103,7 +104,7 @@ func getDashboardDataEntry(intent: DashboardIntent?, isPreview: Bool, displaySiz
// Default widget
let result = NCManageDatabase.shared.getDashboardWidgetApplications(account: account.account).first
let id: String = intent?.Applications?.identifier ?? (result?.id ?? "recommendations")
let id: String = configuration?.Applications?.identifier ?? (result?.id ?? "recommendations")
let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: account.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
guard serverVersionMajor >= NCGlobal.shared.nextcloudVersion25 else {

Просмотреть файл

@ -22,8 +22,8 @@
//
import WidgetKit
import SwiftUI
import Intents
import SwiftUI
struct DashboardWidgetProvider: IntentTimelineProvider {
@ -39,13 +39,13 @@ struct DashboardWidgetProvider: IntentTimelineProvider {
}
func getSnapshot(for configuration: DashboardIntent, in context: Context, completion: @escaping (DashboardDataEntry) -> Void) {
getDashboardDataEntry(intent: configuration, isPreview: false, displaySize: context.displaySize) { entry in
getDashboardDataEntry(configuration: configuration, isPreview: false, displaySize: context.displaySize) { entry in
completion(entry)
}
}
func getTimeline(for configuration: DashboardIntent, in context: Context, completion: @escaping (Timeline<DashboardDataEntry>) -> Void) {
getDashboardDataEntry(intent: configuration, isPreview: context.isPreview, displaySize: context.displaySize) { entry in
getDashboardDataEntry(configuration: configuration, isPreview: context.isPreview, displaySize: context.displaySize) { entry in
let timeLine = Timeline(entries: [entry], policy: .atEnd)
completion(timeLine)
}

Просмотреть файл

@ -45,7 +45,7 @@
<key>INIntentParameterName</key>
<string>Accounts</string>
<key>INIntentParameterObjectType</key>
<string>Accounts</string>
<string>AccountsDashboard</string>
<key>INIntentParameterObjectTypeNamespace</key>
<string>88xZPY</string>
<key>INIntentParameterPromptDialogs</key>
@ -209,7 +209,7 @@
<key>INTypeLastPropertyTag</key>
<integer>99</integer>
<key>INTypeName</key>
<string>Accounts</string>
<string>AccountsDashboard</string>
<key>INTypeProperties</key>
<array>
<dict>

Просмотреть файл

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>INEnums</key>
<array/>
<key>INIntentDefinitionModelVersion</key>
<string>1.2</string>
<key>INIntentDefinitionNamespace</key>
<string>PqCrom</string>
<key>INIntentDefinitionSystemVersion</key>
<string>22A380</string>
<key>INIntentDefinitionToolsBuildVersion</key>
<string>14A309</string>
<key>INIntentDefinitionToolsVersion</key>
<string>14.0</string>
<key>INIntents</key>
<array>
<dict>
<key>INIntentCategory</key>
<string>information</string>
<key>INIntentDescription</key>
<string>Lockscreen widget</string>
<key>INIntentDescriptionID</key>
<string>6G9C6n</string>
<key>INIntentEligibleForWidgets</key>
<true/>
<key>INIntentIneligibleForSuggestions</key>
<true/>
<key>INIntentLastParameterTag</key>
<integer>2</integer>
<key>INIntentName</key>
<string>Lockscreen</string>
<key>INIntentParameters</key>
<array>
<dict>
<key>INIntentParameterConfigurable</key>
<true/>
<key>INIntentParameterDisplayName</key>
<string>Accounts</string>
<key>INIntentParameterDisplayNameID</key>
<string>9wjBfU</string>
<key>INIntentParameterDisplayPriority</key>
<integer>1</integer>
<key>INIntentParameterName</key>
<string>Accounts</string>
<key>INIntentParameterObjectType</key>
<string>AccountsLockscreen</string>
<key>INIntentParameterObjectTypeNamespace</key>
<string>PqCrom</string>
<key>INIntentParameterPromptDialogs</key>
<array>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Configuration</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogType</key>
<string>Primary</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogFormatString</key>
<string>There are ${count} options matching ${Accounts}.</string>
<key>INIntentParameterPromptDialogFormatStringID</key>
<string>UBB5e1</string>
<key>INIntentParameterPromptDialogType</key>
<string>DisambiguationIntroduction</string>
</dict>
<dict>
<key>INIntentParameterPromptDialogCustom</key>
<true/>
<key>INIntentParameterPromptDialogFormatString</key>
<string>Just to confirm, you wanted ${Accounts}?</string>
<key>INIntentParameterPromptDialogFormatStringID</key>
<string>EsGCp1</string>
<key>INIntentParameterPromptDialogType</key>
<string>Confirmation</string>
</dict>
</array>
<key>INIntentParameterSupportsDynamicEnumeration</key>
<true/>
<key>INIntentParameterTag</key>
<integer>2</integer>
<key>INIntentParameterType</key>
<string>Object</string>
</dict>
</array>
<key>INIntentResponse</key>
<dict>
<key>INIntentResponseCodes</key>
<array>
<dict>
<key>INIntentResponseCodeName</key>
<string>success</string>
<key>INIntentResponseCodeSuccess</key>
<true/>
</dict>
<dict>
<key>INIntentResponseCodeName</key>
<string>failure</string>
</dict>
</array>
</dict>
<key>INIntentTitle</key>
<string>Lockscreen</string>
<key>INIntentTitleID</key>
<string>UABqHX</string>
<key>INIntentType</key>
<string>Custom</string>
<key>INIntentVerb</key>
<string>View</string>
</dict>
</array>
<key>INTypes</key>
<array>
<dict>
<key>INTypeDisplayName</key>
<string>Accounts</string>
<key>INTypeDisplayNameID</key>
<string>wGuPt6</string>
<key>INTypeLastPropertyTag</key>
<integer>99</integer>
<key>INTypeName</key>
<string>AccountsLockscreen</string>
<key>INTypeProperties</key>
<array>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>1</integer>
<key>INTypePropertyName</key>
<string>identifier</string>
<key>INTypePropertyTag</key>
<integer>1</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>2</integer>
<key>INTypePropertyName</key>
<string>displayString</string>
<key>INTypePropertyTag</key>
<integer>2</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>3</integer>
<key>INTypePropertyName</key>
<string>pronunciationHint</string>
<key>INTypePropertyTag</key>
<integer>3</integer>
<key>INTypePropertyType</key>
<string>String</string>
</dict>
<dict>
<key>INTypePropertyDefault</key>
<true/>
<key>INTypePropertyDisplayPriority</key>
<integer>4</integer>
<key>INTypePropertyName</key>
<string>alternativeSpeakableMatches</string>
<key>INTypePropertySupportsMultipleValues</key>
<true/>
<key>INTypePropertyTag</key>
<integer>4</integer>
<key>INTypePropertyType</key>
<string>SpeakableString</string>
</dict>
</array>
</dict>
</array>
</dict>
</plist>

Просмотреть файл

@ -34,13 +34,22 @@ struct LockscreenData: TimelineEntry {
let quotaTotal: String
}
func getLockscreenDataEntry(isPreview: Bool, completion: @escaping (_ entry: LockscreenData) -> Void) {
func getLockscreenDataEntry(configuration: LockscreenIntent?, isPreview: Bool, completion: @escaping (_ entry: LockscreenData) -> Void) {
var account: tableAccount?
if isPreview {
return completion(LockscreenData(date: Date(), isPlaceholder: true, activity: "", link: URL(string: "https://")!, quotaRelative: 0, quotaUsed: "", quotaTotal: ""))
}
guard let account = NCManageDatabase.shared.getActiveAccount() else {
let accountIdentifier: String = configuration?.Accounts?.identifier ?? "active"
if accountIdentifier == "active" {
account = NCManageDatabase.shared.getActiveAccount()
} else {
account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", accountIdentifier))
}
guard let account = account else {
return completion(LockscreenData(date: Date(), isPlaceholder: true, activity: "", link: URL(string: "https://")!, quotaRelative: 0, quotaUsed: "", quotaTotal: ""))
}

Просмотреть файл

@ -23,23 +23,26 @@
import WidgetKit
import SwiftUI
import Intents
struct LockscreenWidgetProvider: TimelineProvider {
struct LockscreenWidgetProvider: IntentTimelineProvider {
typealias Entry = LockscreenData
typealias Intent = LockscreenIntent
func placeholder(in context: Context) -> Entry {
return Entry(date: Date(), isPlaceholder: true, activity: "", link: URL(string: "https://")!, quotaRelative: 0, quotaUsed: "", quotaTotal: "")
}
func getSnapshot(in context: Context, completion: @escaping (Entry) -> Void) {
getLockscreenDataEntry(isPreview: false) { entry in
func getSnapshot(for configuration: LockscreenIntent, in context: Context, completion: @escaping (Entry) -> Void) {
getLockscreenDataEntry(configuration: configuration, isPreview: false) { entry in
completion(entry)
}
}
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
getLockscreenDataEntry(isPreview: context.isPreview) { entry in
func getTimeline(for configuration: LockscreenIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> Void) {
getLockscreenDataEntry(configuration: configuration, isPreview: context.isPreview) { entry in
let timeLine = Timeline(entries: [entry], policy: .atEnd)
completion(timeLine)
}

Просмотреть файл

@ -22,6 +22,7 @@
//
import WidgetKit
import Intents
import SwiftUI
@main
@ -80,7 +81,7 @@ struct LockscreenWidget: Widget {
var body: some WidgetConfiguration {
if #available(iOSApplicationExtension 16.0, *) {
return StaticConfiguration(kind: kind, provider: LockscreenWidgetProvider()) { entry in
return IntentConfiguration(kind: kind, intent: LockscreenIntent.self, provider: LockscreenWidgetProvider()) { entry in
LockscreenWidgetView(entry: entry)
}
.supportedFamilies([.accessoryRectangular, .accessoryCircular])

Просмотреть файл

@ -9,7 +9,43 @@
import Intents
import RealmSwift
class IntentHandler: INExtension, DashboardIntentHandling {
class IntentHandler: INExtension, DashboardIntentHandling, LockscreenIntentHandling {
// MARK: - Lockscreen
// Account
func provideAccountsOptionsCollection(for intent: LockscreenIntent, with completion: @escaping (INObjectCollection<AccountsLockscreen>?, Error?) -> Void) {
var accounts: [AccountsLockscreen] = []
let results = NCManageDatabase.shared.getAllAccount()
accounts.append(AccountsLockscreen(identifier: "active", display: NSLocalizedString("_account_active_", comment: "")))
if results.isEmpty {
return completion(nil, nil)
} else if results.count == 1 {
return completion(INObjectCollection(items: accounts), nil)
}
for result in results {
let display = (result.alias.isEmpty) ? result.account : result.alias
let account = AccountsLockscreen(identifier: result.account, display: display)
accounts.append(account)
}
completion(INObjectCollection(items: accounts), nil)
}
func defaultAccounts(for intent: LockscreenIntent) -> AccountsLockscreen? {
if NCManageDatabase.shared.getActiveAccount() == nil {
return nil
} else {
return AccountsLockscreen(identifier: "active", display: NSLocalizedString("_account_active_", comment: ""))
}
}
// MARK: - Dashboard
// Application
@ -43,32 +79,33 @@ class IntentHandler: INExtension, DashboardIntentHandling {
// Account
func provideAccountsOptionsCollection(for intent: DashboardIntent, with completion: @escaping (INObjectCollection<Accounts>?, Error?) -> Void) {
func provideAccountsOptionsCollection(for intent: DashboardIntent, with completion: @escaping (INObjectCollection<AccountsDashboard>?, Error?) -> Void) {
var accounts: [Accounts] = []
var accounts: [AccountsDashboard] = []
let results = NCManageDatabase.shared.getAllAccount()
accounts.append(AccountsDashboard(identifier: "active", display: NSLocalizedString("_account_active_", comment: "")))
if results.isEmpty {
return completion(nil, nil)
} else if results.count == 1 {
accounts.append(Accounts(identifier: "active", display: NSLocalizedString("_account_active_", comment: "")))
return completion(INObjectCollection(items: accounts), nil)
}
for result in results {
let display = (result.alias.isEmpty) ? result.account : result.alias
let account = Accounts(identifier: result.account, display: display)
let account = AccountsDashboard(identifier: result.account, display: display)
accounts.append(account)
}
completion(INObjectCollection(items: accounts), nil)
}
func defaultAccounts(for intent: DashboardIntent) -> Accounts? {
func defaultAccounts(for intent: DashboardIntent) -> AccountsDashboard? {
if NCManageDatabase.shared.getActiveAccount() == nil {
return nil
} else {
return Accounts(identifier: "active", display: NSLocalizedString("_account_active_", comment: ""))
return AccountsDashboard(identifier: "active", display: NSLocalizedString("_account_active_", comment: ""))
}
}
}

Просмотреть файл

@ -19,6 +19,7 @@
<array>
<string>DashboardIntent</string>
<string>IntentIntent</string>
<string>LockscreenIntent</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>

Просмотреть файл

@ -79,6 +79,7 @@
<array>
<string>DashboardIntent</string>
<string>IntentIntent</string>
<string>LockscreenIntent</string>
</array>
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
<true/>