Skip to content

Commit

Permalink
Merge branch 'feature/app-provider' into milestone/12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-schwarz committed Dec 12, 2022
2 parents fdef948 + 4b9af63 commit 0a80962
Show file tree
Hide file tree
Showing 13 changed files with 659 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ios-sdk
Submodule ios-sdk updated 61 files
+11 −0 CHANGELOG.md
+86 −2 ownCloudSDK.xcodeproj/project.pbxproj
+1 −0 ownCloudSDK/App Identity/OCAppIdentity.h
+62 −0 ownCloudSDK/App Providers/OCAppProvider.h
+162 −0 ownCloudSDK/App Providers/OCAppProvider.m
+52 −0 ownCloudSDK/App Providers/OCAppProviderApp.h
+103 −0 ownCloudSDK/App Providers/OCAppProviderApp.m
+50 −0 ownCloudSDK/App Providers/OCAppProviderFileType.h
+60 −0 ownCloudSDK/App Providers/OCAppProviderFileType.m
+3 −1 ownCloudSDK/Categories/Foundation/NSArray+OCMapping.h
+19 −2 ownCloudSDK/Categories/Foundation/NSArray+OCMapping.m
+1 −1 ownCloudSDK/Categories/Foundation/NSArray+ObjCRuntime.m
+2 −0 ownCloudSDK/Categories/Foundation/NSDate+OCDateParser.h
+23 −0 ownCloudSDK/Categories/Foundation/NSDate+OCDateParser.m
+5 −0 ownCloudSDK/Connection/Capabilities/OCCapabilities.h
+73 −0 ownCloudSDK/Connection/Capabilities/OCCapabilities.m
+31 −0 ownCloudSDK/Connection/NSError+OCISError.h
+76 −0 ownCloudSDK/Connection/NSError+OCISError.m
+364 −0 ownCloudSDK/Connection/OCConnection+AppProviders.m
+17 −1 ownCloudSDK/Connection/OCConnection+Tools.m
+23 −0 ownCloudSDK/Connection/OCConnection.h
+4 −0 ownCloudSDK/Connection/OCConnection.m
+3 −0 ownCloudSDK/Core/OCCore.h
+24 −2 ownCloudSDK/Core/OCCore.m
+1 −0 ownCloudSDK/Core/Resources/Resource/OCResource.h
+1 −0 ownCloudSDK/Core/Resources/Resource/OCResource.m
+36 −0 ownCloudSDK/Core/Resources/URLItems/OCResourceRequestURLItem.h
+73 −0 ownCloudSDK/Core/Resources/URLItems/OCResourceRequestURLItem.m
+29 −0 ownCloudSDK/Core/Resources/URLItems/OCResourceSourceURLItems.h
+136 −0 ownCloudSDK/Core/Resources/URLItems/OCResourceSourceURLItems.m
+1 −1 ownCloudSDK/Core/Sync/Actions/CopyMove/OCSyncActionCopyMove.m
+4 −1 ownCloudSDK/Errors/NSError+OCError.h
+8 −0 ownCloudSDK/Errors/NSError+OCError.m
+5 −1 ownCloudSDK/Extensions/OCExtensionManager.h
+79 −0 ownCloudSDK/Extensions/OCExtensionManager.m
+1 −1 ownCloudSDK/File Handling/Checksums/OCChecksumAlgorithmSHA1.m
+29 −0 ownCloudSDK/HTTP/Request/NSDictionary+OCFormEncoding.h
+40 −0 ownCloudSDK/HTTP/Request/NSDictionary+OCFormEncoding.m
+1 −0 ownCloudSDK/HTTP/Request/OCHTTPDAVRequest.m
+1 −0 ownCloudSDK/HTTP/Request/OCHTTPRequest.h
+3 −16 ownCloudSDK/HTTP/Request/OCHTTPRequest.m
+10 −0 ownCloudSDK/Item/OCItem+OCFileURLMetadata.h
+10 −0 ownCloudSDK/Item/OCItem+OCFileURLMetadata.m
+37 −0 ownCloudSDK/Item/OCItem+OCTypeAlias.h
+167 −0 ownCloudSDK/Item/OCItem+OCTypeAlias.m
+2 −1 ownCloudSDK/Item/OCItem.h
+1 −0 ownCloudSDK/Item/OCItem.m
+4 −0 ownCloudSDK/OCTypes.h
+4 −0 ownCloudSDK/Query/Condition/OCQueryCondition.h
+4 −0 ownCloudSDK/Query/Condition/OCQueryCondition.m
+9 −0 ownCloudSDK/Resources/en.lproj/Localizable.strings
+148 −0 ownCloudSDK/Vaults/Database/OCDatabase+Schemas.m
+0 −2 ownCloudSDK/Vaults/Database/OCDatabase.h
+6 −0 ownCloudSDK/Vaults/Database/OCDatabase.m
+1 −0 ownCloudSDK/Vaults/Database/SQLite/OCSQLiteDB.h
+6 −0 ownCloudSDK/Vaults/Database/SQLite/OCSQLiteDB.m
+7 −0 ownCloudSDK/ownCloudSDK.h
+24 −0 ownCloudSDKTests/ConnectionTests.m
+3 −3 ownCloudSDKTests/DataSourceTests.m
+4 −0 ownCloudSDKTests/OCTestTarget.h
+10 −0 ownCloudSDKTests/OCTestTarget.m
12 changes: 12 additions & 0 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
DC0A35A124C1091400FB58FC /* UserInterfaceContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0A35A024C1091400FB58FC /* UserInterfaceContext.swift */; };
DC0A5C432550C70800E6674B /* class-settings-sdk in Resources */ = {isa = PBXBuildFile; fileRef = DC0A5C422550C70800E6674B /* class-settings-sdk */; };
DC0B379420514E4700189B9A /* ServerListBookmarkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0B379320514E4700189B9A /* ServerListBookmarkCell.swift */; };
DC0CE19228C7DBE3009ABDFB /* OpenInWebAppAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0CE19128C7DBE3009ABDFB /* OpenInWebAppAction.swift */; };
DC0CE19D28C89CD9009ABDFB /* CreateDocumentAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */; };
DC18898E218A773700CFB3F9 /* ownCloudMocking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC0196A620F754CA00C41B78 /* ownCloudMocking.framework */; };
DC1B270C209CF34B004715E1 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1B270B209CF34B004715E1 /* BookmarkViewController.swift */; };
DC20DE5C21C01A3D0096000B /* ownCloudMocking.framework in EarlGrey Copy Files */ = {isa = PBXBuildFile; fileRef = DC0196A620F754CA00C41B78 /* ownCloudMocking.framework */; };
Expand Down Expand Up @@ -555,6 +557,7 @@
DCFC9ED128002335005D9144 /* CollectionViewCellProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFC9ED028002335005D9144 /* CollectionViewCellProvider.swift */; };
DCFC9ED3280023BB005D9144 /* CollectionViewCellProvider+StandardImplementations.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFC9ED2280023BB005D9144 /* CollectionViewCellProvider+StandardImplementations.swift */; };
DCFC9ED528002F33005D9144 /* CollectionViewCellConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFC9ED428002F33005D9144 /* CollectionViewCellConfiguration.swift */; };
DCFE682728D869A400091D2A /* ClientWebAppViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFE682628D869A400091D2A /* ClientWebAppViewController.swift */; };
DCFEF90926EFA45A001DC7A4 /* VendorServices+App.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCFEF90526EFA45A001DC7A4 /* VendorServices+App.swift */; };
DCFEFE2A236876BD009A142F /* OCLicenseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DCFEFE28236876BD009A142F /* OCLicenseManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
DCFEFE2B236876BD009A142F /* OCLicenseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DCFEFE29236876BD009A142F /* OCLicenseManager.m */; };
Expand Down Expand Up @@ -1249,6 +1252,8 @@
DC0B379320514E4700189B9A /* ServerListBookmarkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerListBookmarkCell.swift; sourceTree = "<group>"; };
DC0B37952051541C00189B9A /* ownCloud.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ownCloud.entitlements; sourceTree = "<group>"; };
DC0B37962051681600189B9A /* ThemeButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeButton.swift; sourceTree = "<group>"; };
DC0CE19128C7DBE3009ABDFB /* OpenInWebAppAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenInWebAppAction.swift; sourceTree = "<group>"; };
DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateDocumentAction.swift; sourceTree = "<group>"; };
DC136581208223F000FC0F60 /* OCBookmark+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCBookmark+Extension.swift"; sourceTree = "<group>"; };
DC1AC7CF2319ADAE002B7892 /* ScanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanViewController.swift; sourceTree = "<group>"; };
DC1B270B209CF34B004715E1 /* BookmarkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1550,6 +1555,7 @@
DCFC9ED028002335005D9144 /* CollectionViewCellProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCellProvider.swift; sourceTree = "<group>"; };
DCFC9ED2280023BB005D9144 /* CollectionViewCellProvider+StandardImplementations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CollectionViewCellProvider+StandardImplementations.swift"; sourceTree = "<group>"; };
DCFC9ED428002F33005D9144 /* CollectionViewCellConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCellConfiguration.swift; sourceTree = "<group>"; };
DCFE682628D869A400091D2A /* ClientWebAppViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientWebAppViewController.swift; sourceTree = "<group>"; };
DCFED971208095E200A2D984 /* ClientItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientItemCell.swift; sourceTree = "<group>"; };
DCFED9B920809B8900A2D984 /* ThemeTVGResource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeTVGResource.swift; sourceTree = "<group>"; };
DCFEF90526EFA45A001DC7A4 /* VendorServices+App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "VendorServices+App.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2231,6 +2237,9 @@
0233F45D246E9D960095A799 /* UploadCameraMediaAction.swift */,
025F063224AA163C009D8FC5 /* DisplayExifMetadataAction.swift */,
39EF06AF25D6C3FC001E1E19 /* PresentationModeAction.swift */,
DC0CE19128C7DBE3009ABDFB /* OpenInWebAppAction.swift */,
DCFE682628D869A400091D2A /* ClientWebAppViewController.swift */,
DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */,
);
path = "Actions+Extensions";
sourceTree = "<group>";
Expand Down Expand Up @@ -4224,6 +4233,7 @@
396BE4CA2289500E00B254A9 /* RoundedLabel.swift in Sources */,
394E1FFF233E43F5009D2897 /* LinksAction.swift in Sources */,
392DDB1424CF024D009E5406 /* ImportFilesController.swift in Sources */,
DC0CE19228C7DBE3009ABDFB /* OpenInWebAppAction.swift in Sources */,
396C82FB2319AFDD00938262 /* CollaborateAction.swift in Sources */,
0233F45E246E9D960095A799 /* UploadCameraMediaAction.swift in Sources */,
DC854936218331CF00782BA8 /* UserInterfaceSettingsSection.swift in Sources */,
Expand Down Expand Up @@ -4285,12 +4295,14 @@
6E5FC172221590B000F60846 /* DisplayHostViewController.swift in Sources */,
4C51727F22DE04BD001BC97F /* ScheduledTaskManager.swift in Sources */,
39BC9C3023DB831F0097C52D /* DocumentEditingAction.swift in Sources */,
DCFE682728D869A400091D2A /* ClientWebAppViewController.swift in Sources */,
DCB6C4D72453A6CA00C1EAE1 /* ClientAuthenticationUpdater.swift in Sources */,
399697F5260255B100E5AEBA /* PDFGotoPageAction.swift in Sources */,
3998F5D522411EDF00B66713 /* BorderedLabel.swift in Sources */,
DCC3701624D4D365008B0DEB /* OCScanJobActivity+DiagnosticGenerator.swift in Sources */,
39A243C424BDD9E100F4441F /* StaticLoginBundle.swift in Sources */,
DC27A19D20CAB602008ACB6C /* FileProviderInterfaceManager.swift in Sources */,
DC0CE19D28C89CD9009ABDFB /* CreateDocumentAction.swift in Sources */,
4C51727D22DE04BD001BC97F /* ScheduledTaskExtension.swift in Sources */,
025F063324AA163C009D8FC5 /* DisplayExifMetadataAction.swift in Sources */,
DCC085512293ED52008CC05C /* DisplaySettingsSection.swift in Sources */,
Expand Down
15 changes: 15 additions & 0 deletions ownCloud.xcodeproj/xcshareddata/xcschemes/ownCloud.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,21 @@
value = "[com.owncloud.action.copy,com.owncloud.action.move]"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:action.open-in-web-app-mode"
value = "string:default-browser"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:action.open-in-web-app-mode"
value = "string:in-app"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:action.open-in-web-app-mode"
value = "string:in-app-with-default-browser-option"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:bookmark.prepopulation"
value = "string:streaming"
Expand Down
1 change: 1 addition & 0 deletions ownCloud/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
OCExtensionManager.shared.addExtension(PDFGoToPageAction.actionExtension)
OCExtensionManager.shared.addExtension(ImportPasteboardAction.actionExtension)
OCExtensionManager.shared.addExtension(CutAction.actionExtension)
OCExtensionManager.shared.addExtension(CreateDocumentAction.actionExtension)

if UIDevice.current.isIpad {
// iPad only
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//
// ClientWebAppViewController.swift
// ownCloud
//
// Created by Felix Schwarz on 19.09.22.
// Copyright © 2022 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2022, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

import UIKit
import WebKit
import ownCloudAppShared

class ClientWebAppViewController: UIViewController, WKUIDelegate {
var urlRequest: URLRequest
var webView: WKWebView?

var shouldSendCloseEvent: Bool = true

init(with urlRequest: URLRequest) {
self.urlRequest = urlRequest

super.init(nibName: nil, bundle: nil)

self.isModalInPresentation = true
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

var webViewConfiguration: WKWebViewConfiguration {
let configuration = WKWebViewConfiguration()
let webSiteDataStore = WKWebsiteDataStore.nonPersistent()

configuration.websiteDataStore = webSiteDataStore
configuration.applicationNameForUserAgent = "MobileSafari" // Needed for some web apps that will present the desktop UI otherwise (f.ex. OnlyOffice as of 2022-09-19)

return configuration
}

override func loadView() {
let rootView = UIView()

webView = WKWebView(frame: .zero, configuration: webViewConfiguration)
webView?.translatesAutoresizingMaskIntoConstraints = false
webView?.uiDelegate = self

rootView.addSubview(webView!)

NSLayoutConstraint.activate([
webView!.leadingAnchor.constraint(equalTo: rootView.safeAreaLayoutGuide.leadingAnchor),
webView!.trailingAnchor.constraint(equalTo: rootView.safeAreaLayoutGuide.trailingAnchor),
webView!.topAnchor.constraint(equalTo: rootView.safeAreaLayoutGuide.topAnchor),
webView!.bottomAnchor.constraint(equalTo: rootView.safeAreaLayoutGuide.bottomAnchor)
])

view = rootView
}

override func viewDidLoad() {
super.viewDidLoad()

navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .close, primaryAction: UIAction(handler: { [weak self] _ in
if self?.shouldSendCloseEvent == true {
// Close via window.close(), which is calling dismissSecurely() once done
self?.closeWebWindow()

// Call dismissOnce() after 10 seconds regardless
OnMainThread(after: 10) {
self?.dismissOnce()
}
} else {
// Close directly
self?.closeWebWindow()
}
}))
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
webView?.load(urlRequest)
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

// Drop web view
webView?.uiDelegate = nil
webView?.removeFromSuperview()
webView = nil
}

private var isDismissed = false
func dismissOnce() {
if !isDismissed {
isDismissed = true
self.dismiss(animated: true)
}
}

// window.close() handling
func closeWebWindow() {
webView?.evaluateJavaScript("window.close();")
}

// UI delegate
func webViewDidClose(_ webView: WKWebView) {
dismissOnce()
}
}
Loading

0 comments on commit 0a80962

Please sign in to comment.