Skip to content
2 changes: 1 addition & 1 deletion ios-sdk
Submodule ios-sdk updated 30 files
+29 −25 doc/CONFIGURATION.json
+0 −33 ownCloudMocking/Cookie Redirect Simulator/OCHostSimulator+CookieRedirect.h
+0 −84 ownCloudMocking/Cookie Redirect Simulator/OCHostSimulator+CookieRedirect.m
+0 −2 ownCloudMocking/ownCloudMocking.h
+1 −17 ownCloudSDK.xcodeproj/project.pbxproj
+2 −2 ownCloudSDK.xcodeproj/xcshareddata/xcschemes/Ocean.xcscheme
+1 −1 ownCloudSDK/Authentication/OCAuthenticationMethod+OCTools.h
+5 −2 ownCloudSDK/Authentication/OCAuthenticationMethod+OCTools.m
+2 −2 ownCloudSDK/Authentication/OCAuthenticationMethod.h
+1 −1 ownCloudSDK/Authentication/OCAuthenticationMethod.m
+2 −2 ownCloudSDK/Authentication/OCAuthenticationMethodBasicAuth.m
+4 −4 ownCloudSDK/Authentication/OCAuthenticationMethodOAuth2.m
+5 −5 ownCloudSDK/Authentication/OCAuthenticationMethodOpenIDConnect.m
+48 −18 ownCloudSDK/Connection/OCConnection+Authentication.m
+2 −6 ownCloudSDK/Connection/OCConnection+Setup.m
+9 −0 ownCloudSDK/Connection/OCConnection+Tools.m
+12 −0 ownCloudSDK/Connection/OCConnection.h
+311 −34 ownCloudSDK/Connection/OCConnection.m
+18 −0 ownCloudSDK/Core/Connection Status/OCCore+ConnectionStatus.m
+4 −9 ownCloudSDK/Core/Connection Status/Server/OCCoreServerStatusSignalProvider.m
+1 −1 ownCloudSDK/Core/OCCore.m
+3 −1 ownCloudSDK/Errors/NSError+OCError.h
+4 −0 ownCloudSDK/Errors/NSError+OCError.m
+7 −4 ownCloudSDK/HTTP/Request/OCHTTPRequest.h
+22 −4 ownCloudSDK/HTTP/Request/OCHTTPRequest.m
+1 −0 ownCloudSDK/HTTP/Status/OCHTTPStatus.h
+6 −0 ownCloudSDK/Host Simulator/OCHostSimulator+BuiltIn.h
+101 −0 ownCloudSDK/Host Simulator/OCHostSimulator+BuiltIn.m
+3 −0 ownCloudSDK/Resources/en.lproj/Localizable.strings
+1 −0 ownCloudSDK/ownCloudSDK.h
1 change: 0 additions & 1 deletion ownCloud/Client/Viewer/DisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,5 @@ extension DisplayViewController : Themeable {
metadataInfoLabel.applyThemeCollection(collection)
showPreviewButton.applyThemeCollection(collection)
infoLabel.applyThemeCollection(collection)
self.view.backgroundColor = collection.tableBackgroundColor
}
}
133 changes: 97 additions & 36 deletions ownCloud/Client/Viewer/PDF/PDFViewerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,25 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

static let PDFGoToPageNotification = Notification(name: Notification.Name(rawValue: "PDFGoToPageNotification"))

fileprivate var gotoPageNotificationObserver : Any?

fileprivate let searchAnnotationDelay = 3.0
fileprivate let thumbnailViewWidthMultiplier: CGFloat = 0.15
fileprivate let thumbnailViewHeightMultiplier: CGFloat = 0.1
fileprivate let thumbnailMargin: CGFloat = 32.0
fileprivate let filenameContainerTopMargin: CGFloat = 10.0
public let pdfView = PDFView()
fileprivate let thumbnailView = PDFThumbnailView()

fileprivate let containerView = UIStackView()
fileprivate let pageCountLabel = UILabel()
private var gotoPageNotificationObserver : Any?

private let searchAnnotationDelay = 3.0
private let thumbnailViewWidthMultiplier: CGFloat = 0.15
private let thumbnailViewHeightMultiplier: CGFloat = 0.1
private let filenameContainerTopMargin: CGFloat = 10.0
private let thumbnailView = PDFThumbnailView()

private let containerView = UIStackView()
private let pageCountLabel = UILabel()
private let pageCountContainerView = UIView()

fileprivate var searchButtonItem: UIBarButtonItem?
fileprivate var gotoButtonItem: UIBarButtonItem?
fileprivate var outlineItem: UIBarButtonItem?
private var searchButtonItem: UIBarButtonItem?
private var gotoButtonItem: UIBarButtonItem?
private var outlineItem: UIBarButtonItem?

fileprivate var thumbnailViewPosition : ThumbnailViewPosition = .bottom {
private var thumbnailViewPosition : ThumbnailViewPosition = .bottom {
didSet {
switch thumbnailViewPosition {
case .left, .right:
Expand All @@ -79,7 +80,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
}
}

fileprivate var activeViewConstraints: [NSLayoutConstraint] = [] {
private var activeViewConstraints: [NSLayoutConstraint] = [] {
willSet {
NSLayoutConstraint.deactivate(activeViewConstraints)
}
Expand All @@ -88,6 +89,15 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
}
}

private var fullScreen: Bool = false {
didSet {
self.navigationController?.setNavigationBarHidden(fullScreen, animated: true)
pageCountLabel.isHidden = fullScreen
pageCountContainerView.isHidden = fullScreen
setupConstraints()
}
}

// MARK: - DisplayExtension

static var customMatcher: OCExtensionCustomContextMatcher?
Expand All @@ -113,12 +123,10 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

setupToolbar()

self.view.backgroundColor = UIColor.gray
self.thumbnailViewPosition = .none

// Configure thumbnail view
thumbnailView.translatesAutoresizingMaskIntoConstraints = false
thumbnailView.backgroundColor = UIColor.gray
thumbnailView.pdfView = pdfView
thumbnailView.isExclusiveTouch = true

Expand All @@ -127,7 +135,6 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
containerView.spacing = UIStackView.spacingUseSystem
containerView.isLayoutMarginsRelativeArrangement = true
containerView.directionalLayoutMargins = NSDirectionalEdgeInsets(top: filenameContainerTopMargin, leading: 0, bottom: 0, trailing: 0)
containerView.backgroundColor = UIColor.lightGray
containerView.translatesAutoresizingMaskIntoConstraints = false
containerView.axis = .vertical
containerView.distribution = .fill
Expand All @@ -138,21 +145,29 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
pdfView.usePageViewController(true, withViewOptions: nil)
containerView.addArrangedSubview(pdfView)

let pageCountContainerView = UIView()
pageCountContainerView.backgroundColor = UIColor.gray
pageCountContainerView.translatesAutoresizingMaskIntoConstraints = false
pageCountContainerView.addSubview(pageCountLabel)

pageCountLabel._setupPdfInfoLabel()

pageCountLabel.centerXAnchor.constraint(equalTo: pageCountContainerView.centerXAnchor).isActive = true
pageCountLabel.centerYAnchor.constraint(equalTo: pageCountContainerView.centerYAnchor).isActive = true
pageCountLabel.widthAnchor.constraint(equalTo: pageCountContainerView.widthAnchor, multiplier: 0.25).isActive = true
pageCountLabel.heightAnchor.constraint(equalTo: pageCountContainerView.heightAnchor, multiplier: 0.9).isActive = true

containerView.addArrangedSubview(pageCountContainerView)

self.view.addSubview(containerView)

if #available(iOS 13, *) {
self.view.backgroundColor = self.pdfView.backgroundColor
thumbnailView.backgroundColor = self.pdfView.backgroundColor
pageCountContainerView.backgroundColor = self.pdfView.backgroundColor
} else {
self.view.backgroundColor = .gray
thumbnailView.backgroundColor = .gray
pageCountContainerView.backgroundColor = .gray
}

setupConstraints()

self.view.layoutIfNeeded()
Expand All @@ -165,8 +180,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
pdfView.scaleFactor = pdfView.scaleFactorForSizeToFit
pdfView.autoScales = true
updatePageLabel()

adjustThumbnailsSize()
setThumbnailPosition()

completion(true)

Expand All @@ -187,14 +201,49 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
self?.pdfView.go(to: page)
}
}

if #available(iOS 13, *) {
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.toggleFullscreen(_:)))
tapRecognizer.numberOfTapsRequired = 1
pdfView.addGestureRecognizer(tapRecognizer)
}
//pdfView.isUserInteractionEnabled = true
}

@objc func toggleFullscreen(_ sender: UITapGestureRecognizer) {
self.fullScreen.toggle()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.thumbnailViewPosition = .bottom

pdfView.scaleFactor = pdfView.scaleFactorForSizeToFit
pdfView.autoScales = true
if #available(iOS 13, *) {
self.calculateThumbnailSize()
}
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
// Crashes on pre-iOS 13
if #available(iOS 13, *) {
coordinator.animate(alongsideTransition: nil) { (_) in
self.calculateThumbnailSize()
}
}
}

override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
if #available(iOS 13, *) {
coordinator.animate(alongsideTransition: nil) { (_) in
self.setThumbnailPosition()
self.calculateThumbnailSize()
}
}
}

func save(item: OCItem) {
Expand Down Expand Up @@ -277,13 +326,20 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

// MARK: - Private helpers

fileprivate func adjustThumbnailsSize() {
let maxHeight = floor(self.view.bounds.height * thumbnailViewHeightMultiplier - thumbnailMargin)
let maxWidth = floor(self.view.bounds.width * thumbnailViewWidthMultiplier - thumbnailMargin)
thumbnailView.thumbnailSize = CGSize(width: maxWidth, height: maxHeight)
private func setThumbnailPosition() {
if UIScreen.main.traitCollection.verticalSizeClass == .regular {
self.thumbnailViewPosition = .bottom
} else {
self.thumbnailViewPosition = .right
}
}

private func calculateThumbnailSize() {
let maxHeight = floor( min(self.thumbnailView.bounds.size.height, self.thumbnailView.bounds.size.width) * 0.6)
self.thumbnailView.thumbnailSize = CGSize(width: maxHeight, height: maxHeight)
}

fileprivate func setupConstraints() {
private func setupConstraints() {

if thumbnailView.superview == nil || pdfView.superview == nil {
return
Expand All @@ -296,8 +352,13 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

thumbnailView.isHidden = false

switch thumbnailViewPosition {
case .left:
switch (thumbnailViewPosition, fullScreen) {
case (_, true):
constraints.append(containerView.leadingAnchor.constraint(equalTo: guide.leadingAnchor))
constraints.append(containerView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
constraints.append(containerView.bottomAnchor.constraint(equalTo: guide.bottomAnchor))
thumbnailView.isHidden = true
case (.left, false):
constraints.append(thumbnailView.topAnchor.constraint(equalTo: guide.topAnchor))
constraints.append(thumbnailView.leadingAnchor.constraint(equalTo: guide.leadingAnchor))
constraints.append(thumbnailView.bottomAnchor.constraint(equalTo: guide.bottomAnchor))
Expand All @@ -307,7 +368,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
constraints.append(containerView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
constraints.append(containerView.bottomAnchor.constraint(equalTo: guide.bottomAnchor))

case .right:
case (.right, false):
constraints.append(thumbnailView.topAnchor.constraint(equalTo: guide.topAnchor))
constraints.append(thumbnailView.leadingAnchor.constraint(equalTo: containerView.trailingAnchor))
constraints.append(thumbnailView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
Expand All @@ -318,7 +379,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
constraints.append(containerView.trailingAnchor.constraint(equalTo: thumbnailView.leadingAnchor))
constraints.append(containerView.bottomAnchor.constraint(equalTo: guide.bottomAnchor))

case .bottom:
case (.bottom, false):
constraints.append(thumbnailView.topAnchor.constraint(equalTo: containerView.bottomAnchor))
constraints.append(thumbnailView.leadingAnchor.constraint(equalTo: guide.leadingAnchor))
constraints.append(thumbnailView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
Expand All @@ -329,7 +390,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {
constraints.append(containerView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
constraints.append(containerView.bottomAnchor.constraint(equalTo: thumbnailView.topAnchor))

case .none:
case (.none, _):
constraints.append(containerView.leadingAnchor.constraint(equalTo: guide.leadingAnchor))
constraints.append(containerView.trailingAnchor.constraint(equalTo: guide.trailingAnchor))
constraints.append(containerView.bottomAnchor.constraint(equalTo: guide.bottomAnchor))
Expand All @@ -340,7 +401,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

}

fileprivate func setupToolbar() {
private func setupToolbar() {
searchButtonItem = UIBarButtonItem(barButtonSystemItem: .search, target: self, action: #selector(search))
gotoButtonItem = UIBarButtonItem(image: UIImage(named: "ic_pdf_go_to_page"), style: .plain, target: self, action: #selector(goToPage))
outlineItem = UIBarButtonItem(image: UIImage(named: "ic_pdf_outline"), style: .plain, target: self, action: #selector(showOutline))
Expand Down