From a28ff9e1a4890e0ad1cff5bb295050871683a995 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Tue, 22 Jan 2019 13:11:48 +0100 Subject: [PATCH 1/7] - Coded some accessibility labels and hints to made the app more accessible and with more accurate VoiceOver explanations. --- ownCloud/Bookmarks/BookmarkViewController.swift | 8 ++++---- ownCloud/Client/Actions/NamingViewController.swift | 1 + ownCloud/Client/ClientItemCell.swift | 1 + ownCloud/Client/ClientQueryViewController.swift | 3 +++ ownCloud/Client/SortBar.swift | 2 ++ ownCloud/Resources/en.lproj/Localizable.strings | 8 ++++++++ ownCloud/Server List/ServerListBookmarkCell.swift | 7 +++++-- ownCloud/Server List/ServerListTableViewController.swift | 4 +++- ownCloud/UI Elements/StaticTableViewRow.swift | 9 ++++++--- ownCloud/Viewer/DisplayViewController.swift | 4 +++- 10 files changed, 36 insertions(+), 11 deletions(-) diff --git a/ownCloud/Bookmarks/BookmarkViewController.swift b/ownCloud/Bookmarks/BookmarkViewController.swift index 26497f3f2..e2a7e02c5 100644 --- a/ownCloud/Bookmarks/BookmarkViewController.swift +++ b/ownCloud/Bookmarks/BookmarkViewController.swift @@ -74,7 +74,7 @@ class BookmarkViewController: StaticTableViewController { if let textField = sender as? UITextField { self?.bookmark?.name = (textField.text?.count == 0) ? nil : textField.text } - }, placeholder: "Name".localized, identifier: "row-name-name") + }, placeholder: "Name".localized, identifier: "row-name-name", accessibilityLabel: "Server name".localized) nameSection = StaticTableViewSection(headerTitle: "Name".localized, footerTitle: nil, identifier: "section-name", rows: [ nameRow! ]) @@ -116,7 +116,7 @@ class BookmarkViewController: StaticTableViewController { self?.nameRow?.textField?.attributedPlaceholder = NSAttributedString(string: placeholderString, attributes: [.foregroundColor : Theme.shared.activeCollection.tableRowColors.secondaryLabelColor]) } - }, placeholder: "https://", keyboardType: .URL, autocorrectionType: .no, identifier: "row-url-url") + }, placeholder: "https://", keyboardType: .URL, autocorrectionType: .no, identifier: "row-url-url", accessibilityLabel: "Sever url".localized) certificateRow = StaticTableViewRow(rowWithAction: { [weak self] (_, _) in if let certificate = self?.bookmark?.certificate { @@ -136,14 +136,14 @@ class BookmarkViewController: StaticTableViewController { self?.bookmark?.authenticationData = nil self?.composeSectionsAndRows(animated: true) } - }, placeholder: "Username".localized, autocorrectionType: .no, identifier: "row-credentials-username") + }, placeholder: "Username".localized, autocorrectionType: .no, identifier: "row-credentials-username", accessibilityLabel: "Server Username".localized) passwordRow = StaticTableViewRow(secureTextFieldWithAction: { [weak self] (_, sender) in if (sender as? UITextField) != nil, self?.bookmark?.authenticationData != nil { self?.bookmark?.authenticationData = nil self?.composeSectionsAndRows(animated: true) } - }, placeholder: "Password".localized, autocorrectionType: .no, identifier: "row-credentials-password") + }, placeholder: "Password".localized, autocorrectionType: .no, identifier: "row-credentials-password", accessibilityLabel: "Server Password".localized) addPasswordManagerButton() diff --git a/ownCloud/Client/Actions/NamingViewController.swift b/ownCloud/Client/Actions/NamingViewController.swift index 2b963c6ec..386c6f735 100644 --- a/ownCloud/Client/Actions/NamingViewController.swift +++ b/ownCloud/Client/Actions/NamingViewController.swift @@ -174,6 +174,7 @@ class NamingViewController: UIViewController { nameTextField.addTarget(self, action: #selector(textfieldDidChange(_:)), for: .editingChanged) nameTextField.enablesReturnKeyAutomatically = true nameTextField.autocorrectionType = .no + nameTextField.accessibilityLabel = "Folder name".localized // Name container view nameContainer.translatesAutoresizingMaskIntoConstraints = false diff --git a/ownCloud/Client/ClientItemCell.swift b/ownCloud/Client/ClientItemCell.swift index 91dc9b1ff..c7292415f 100644 --- a/ownCloud/Client/ClientItemCell.swift +++ b/ownCloud/Client/ClientItemCell.swift @@ -168,6 +168,7 @@ class ClientItemCell: ThemeTableViewCell { self.iconView.alpha = item.isPlaceholder ? 0.5 : 1.0 self.moreButton.isHidden = item.isPlaceholder ? true : false + self.moreButton.accessibilityLabel = item.name! + " " + "Actions".localized } // MARK: - Themeing diff --git a/ownCloud/Client/ClientQueryViewController.swift b/ownCloud/Client/ClientQueryViewController.swift index 40250ccf1..c7b5c1d16 100644 --- a/ownCloud/Client/ClientQueryViewController.swift +++ b/ownCloud/Client/ClientQueryViewController.swift @@ -147,6 +147,9 @@ class ClientQueryViewController: UITableViewController, Themeable { self.tableView.dragInteractionEnabled = true let actionsBarButton: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(uploadsBarButtonPressed)) + actionsBarButton.accessibilityLabel = "Upload files".localized + actionsBarButton.setTitleTextAttributes([.font :UIFont.systemFont(ofSize: 10)], for: .normal) + actionsBarButton.setTitleTextAttributes([.font :UIFont.systemFont(ofSize: 10)], for: .highlighted) self.navigationItem.rightBarButtonItem = actionsBarButton } diff --git a/ownCloud/Client/SortBar.swift b/ownCloud/Client/SortBar.swift index 3cb118534..7c9d9fc33 100644 --- a/ownCloud/Client/SortBar.swift +++ b/ownCloud/Client/SortBar.swift @@ -50,6 +50,7 @@ class SortBar: UIView, Themeable { let title = NSString(format: "Sorted by %@ ▼".localized as NSString, sortMethod.localizedName()) as String sortButton.setTitle(title, for: .normal) + sortButton.accessibilityLabel = NSString(format: "Sorted by %@".localized as NSString, sortMethod.localizedName()) as String sortSegmentedControl.selectedSegmentIndex = SortMethod.all.index(of: sortMethod)! @@ -73,6 +74,7 @@ class SortBar: UIView, Themeable { sortButton.accessibilityIdentifier = "sort-bar.sortButton" leftButtonImage = Theme.shared.image(for: "folder-create", size: CGSize(width: 30.0, height: 30.0))!.withRenderingMode(.alwaysTemplate) + leftButton.accessibilityLabel = "Create Folder".localized rightButtonImage = Theme.shared.image(for: "folder-create", size: CGSize(width: 30.0, height: 30.0))!.withRenderingMode(.alwaysTemplate) diff --git a/ownCloud/Resources/en.lproj/Localizable.strings b/ownCloud/Resources/en.lproj/Localizable.strings index 002c34915..10819405c 100644 --- a/ownCloud/Resources/en.lproj/Localizable.strings +++ b/ownCloud/Resources/en.lproj/Localizable.strings @@ -43,6 +43,10 @@ "Missing hostname" = "Missing hostname"; "The entered URL does not include a hostname." = "The entered URL does not include a hostname."; +"Add server" = "Add server"; +"Sever name" = "Sever name"; +"Server Password" = "Server Password"; +"Server Username" = "Server Username"; /* Client */ "Browse" = "Browse"; @@ -60,6 +64,7 @@ "Everything up-to-date." = "Everything up-to-date."; "Please wait…" = "Please wait…"; "Sorted by %@ ▼" = "Sorted by %@ ▼"; +"Sorted by %@" = "Sorted by %@"; "Sort by" = "Sort by"; "name (A-Z)" = "name (A-Z)"; @@ -86,6 +91,7 @@ "This permission is needed to upload photos and videos from your photo library." = "This permission is needed to upload photos and videos from your photo library."; "Not now" = "Not now"; "Upload file" = "Upload file"; +"Upload files" = "Upload files"; /* Server List*/ "Cancel" = "Cancel"; @@ -189,6 +195,7 @@ "Forbidden Characters" = "Forbidden Characters"; "File name cannot contain / or \\" = "File name cannot contain / or \\"; "New Folder" = "New Folder"; +"Folder name" = "Folder name"; "Rename" =" Rename"; "Create folder" =" Create folder"; "Duplicate" = "Duplicate"; @@ -198,6 +205,7 @@ "Copy here" = "Copy here"; "Cannot connect to " = "Cannot connect to "; " couldn't download this file" = " couldn't download this file"; +"Actions" = "Actions"; /* Directory Picker Messages */ "Move here" = "Move here"; diff --git a/ownCloud/Server List/ServerListBookmarkCell.swift b/ownCloud/Server List/ServerListBookmarkCell.swift index cd8bc4807..06b892048 100644 --- a/ownCloud/Server List/ServerListBookmarkCell.swift +++ b/ownCloud/Server List/ServerListBookmarkCell.swift @@ -40,8 +40,11 @@ class ServerListBookmarkCell : ThemeTableViewCell { iconView.translatesAutoresizingMaskIntoConstraints = false iconView.contentMode = .scaleAspectFit - titleLabel.font = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.semibold) - detailLabel.font = UIFont.systemFont(ofSize: 14) + titleLabel.font = UIFont.preferredFont(forTextStyle: .body) + titleLabel.adjustsFontForContentSizeCategory = true + + detailLabel.font = UIFont.preferredFont(forTextStyle: .subheadline) + detailLabel.adjustsFontForContentSizeCategory = true detailLabel.textColor = UIColor.gray diff --git a/ownCloud/Server List/ServerListTableViewController.swift b/ownCloud/Server List/ServerListTableViewController.swift index 95225c59e..7b1fdbe21 100644 --- a/ownCloud/Server List/ServerListTableViewController.swift +++ b/ownCloud/Server List/ServerListTableViewController.swift @@ -72,7 +72,9 @@ class ServerListTableViewController: UITableViewController, Themeable { self.tableView.estimatedRowHeight = 80 self.tableView.allowsSelectionDuringEditing = true - self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.add, target: self, action: #selector(addBookmark)) + let addServerBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.add, target: self, action: #selector(addBookmark)) + addServerBarButtonItem.accessibilityLabel = "Add Server".localized + self.navigationItem.rightBarButtonItem = addServerBarButtonItem welcomeOverlayView.translatesAutoresizingMaskIntoConstraints = false diff --git a/ownCloud/UI Elements/StaticTableViewRow.swift b/ownCloud/UI Elements/StaticTableViewRow.swift index 0f298d6ae..a91bcae22 100644 --- a/ownCloud/UI Elements/StaticTableViewRow.swift +++ b/ownCloud/UI Elements/StaticTableViewRow.swift @@ -151,7 +151,7 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { // MARK: - Text Field public var textField : UITextField? - convenience init(textFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", secureTextEntry : Bool = false, keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil) { + convenience init(textFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", secureTextEntry : Bool = false, keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { self.init() @@ -203,9 +203,11 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { cellTextField.textColor = (self?.enabled == true) ? themeCollection.tableRowColors.labelColor : themeCollection.tableRowColors.secondaryLabelColor cellTextField.attributedPlaceholder = NSAttributedString(string: placeholderString, attributes: [.foregroundColor : themeCollection.tableRowColors.secondaryLabelColor]) }) + + cellTextField.accessibilityLabel = accessibilityLabel } - convenience init(secureTextFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil) { + convenience init(secureTextFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { self.init(textFieldWithAction: action, placeholder: placeholderString, value: textValue, secureTextEntry: true, @@ -213,7 +215,8 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { autocorrectionType: autocorrectionType, autocapitalizationType: autocapitalizationType, enablesReturnKeyAutomatically: enablesReturnKeyAutomatically, - returnKeyType: returnKeyType, identifier : identifier) + returnKeyType: returnKeyType, identifier : identifier, + accessibilityLabel: accessibilityLabel) } @objc func textFieldContentChanged(_ sender: UITextField) { diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index 74e32f8fd..99aa1446a 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -213,7 +213,9 @@ class DisplayViewController: UIViewController { } parent.navigationItem.title = item.name - parent.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "•••", style: .plain, target: self, action: #selector(optionsBarButtonPressed)) + let actionsBarButtonItem = UIBarButtonItem(title: "•••", style: .plain, target: self, action: #selector(optionsBarButtonPressed)) + actionsBarButtonItem.accessibilityLabel = item.name + " " + "Actions".localized + parent.navigationItem.rightBarButtonItem = actionsBarButtonItem } // MARK: - Download actions From 1dee652efdf1bd39e7924397e9f3eed48f4facdd Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Fri, 25 Jan 2019 14:08:35 +0100 Subject: [PATCH 2/7] - Made dissapear all the non-needed UI elements in DisplayViewController when a file is presented. - Improved accessibility on some labels. --- ownCloud/Client/ClientItemCell.swift | 7 +++++-- ownCloud/Server List/ServerListBookmarkCell.swift | 2 +- ownCloud/Viewer/DisplayViewController.swift | 12 +++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ownCloud/Client/ClientItemCell.swift b/ownCloud/Client/ClientItemCell.swift index c7292415f..3ee34e160 100644 --- a/ownCloud/Client/ClientItemCell.swift +++ b/ownCloud/Client/ClientItemCell.swift @@ -54,8 +54,11 @@ class ClientItemCell: ThemeTableViewCell { iconView.contentMode = .scaleAspectFit moreButton.translatesAutoresizingMaskIntoConstraints = false - titleLabel.font = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.semibold) - detailLabel.font = UIFont.systemFont(ofSize: 14) + titleLabel.font = UIFont.preferredFont(forTextStyle: .headline) + titleLabel.adjustsFontForContentSizeCategory = true + + detailLabel.font = UIFont.preferredFont(forTextStyle: .footnote) + detailLabel.adjustsFontForContentSizeCategory = true detailLabel.textColor = UIColor.gray diff --git a/ownCloud/Server List/ServerListBookmarkCell.swift b/ownCloud/Server List/ServerListBookmarkCell.swift index 06b892048..21500bdea 100644 --- a/ownCloud/Server List/ServerListBookmarkCell.swift +++ b/ownCloud/Server List/ServerListBookmarkCell.swift @@ -40,7 +40,7 @@ class ServerListBookmarkCell : ThemeTableViewCell { iconView.translatesAutoresizingMaskIntoConstraints = false iconView.contentMode = .scaleAspectFit - titleLabel.font = UIFont.preferredFont(forTextStyle: .body) + titleLabel.font = UIFont.preferredFont(forTextStyle: .headline) titleLabel.adjustsFontForContentSizeCategory = true detailLabel.font = UIFont.preferredFont(forTextStyle: .subheadline) diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index 99aa1446a..9374cfcb8 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -55,6 +55,7 @@ class DisplayViewController: UIViewController { OnMainThread { self.iconImageView.isHidden = true } + hideUIElements() renderSpecificView() } } @@ -214,7 +215,7 @@ class DisplayViewController: UIViewController { parent.navigationItem.title = item.name let actionsBarButtonItem = UIBarButtonItem(title: "•••", style: .plain, target: self, action: #selector(optionsBarButtonPressed)) - actionsBarButtonItem.accessibilityLabel = item.name + " " + "Actions".localized + actionsBarButtonItem.accessibilityLabel = item.name! + " " + "Actions".localized parent.navigationItem.rightBarButtonItem = actionsBarButtonItem } @@ -248,6 +249,15 @@ class DisplayViewController: UIViewController { // This function is intended to be overwritten by the subclases to implement a custom view based on the source property.s } + func hideUIElements() { + iconImageView.isHidden = true + progressView?.isHidden = true + cancelButton?.isHidden = true + metadataInfoLabel?.isHidden = true + showPreviewButton?.isHidden = true + noNetworkLabel?.isHidden = true + } + // MARK: - KVO observing // swiftlint:disable block_based_kvo override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { From 0f8b6dc507ca9517c85a267d7647db2a0862bdb0 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Mon, 28 Jan 2019 08:52:40 +0100 Subject: [PATCH 3/7] - New accessibility font size in ClientItemCell --- ownCloud/Client/ClientItemCell.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ownCloud/Client/ClientItemCell.swift b/ownCloud/Client/ClientItemCell.swift index 3ee34e160..b474f1691 100644 --- a/ownCloud/Client/ClientItemCell.swift +++ b/ownCloud/Client/ClientItemCell.swift @@ -72,7 +72,8 @@ class ClientItemCell: ThemeTableViewCell { iconView.rightAnchor.constraint(equalTo: detailLabel.leftAnchor, constant: -15).isActive = true moreButton.setAttributedTitle(NSAttributedString(string: "● ● ●", attributes: - [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 10)]), for: .normal) + [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption2)]), for: .normal) + moreButton.titleLabel?.adjustsFontForContentSizeCategory = true moreButton.contentMode = .scaleToFill From 7229bc596b2a1e2337fad5528aea0d2965192cc4 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Tue, 29 Jan 2019 08:28:57 +0100 Subject: [PATCH 4/7] - More Dynamic Fonts --- ownCloud/Theming/NSObject+ThemeApplication.swift | 3 ++- ownCloud/Theming/UI/ThemeButton.swift | 3 ++- ownCloud/Viewer/DisplayViewController.swift | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ownCloud/Theming/NSObject+ThemeApplication.swift b/ownCloud/Theming/NSObject+ThemeApplication.swift index 5a3c0b287..0532d7a38 100644 --- a/ownCloud/Theming/NSObject+ThemeApplication.swift +++ b/ownCloud/Theming/NSObject+ThemeApplication.swift @@ -154,7 +154,8 @@ extension NSObject { case .bigMessage: label.font = UIFont.systemFont(ofSize: 17) - default: break + default: + break } switch itemState { diff --git a/ownCloud/Theming/UI/ThemeButton.swift b/ownCloud/Theming/UI/ThemeButton.swift index dd92b83e0..9bba19174 100644 --- a/ownCloud/Theming/UI/ThemeButton.swift +++ b/ownCloud/Theming/UI/ThemeButton.swift @@ -86,7 +86,8 @@ class ThemeButton : UIButton { private func styleButton() { self.layer.cornerRadius = 5 - self.titleLabel!.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold) + self.titleLabel!.font = UIFont.preferredFont(forTextStyle: .headline) + self.titleLabel!.adjustsFontForContentSizeCategory = true } override init(frame: CGRect) { diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index 9374cfcb8..e55d5f033 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -80,9 +80,9 @@ class DisplayViewController: UIViewController { // MARK: - Views private var iconImageView: UIImageView! private var progressView : UIProgressView? - private var cancelButton : UIButton? + private var cancelButton : ThemeButton? private var metadataInfoLabel: UILabel? - private var showPreviewButton: UIButton? + private var showPreviewButton: ThemeButton? private var noNetworkLabel : UILabel? // MARK: - Delegate @@ -119,6 +119,8 @@ class DisplayViewController: UIViewController { metadataInfoLabel?.isHidden = false metadataInfoLabel?.text = item.sizeLocalized + " - " + item.lastModifiedLocalized metadataInfoLabel?.textAlignment = .center + metadataInfoLabel?.adjustsFontForContentSizeCategory = true + metadataInfoLabel?.font = UIFont.preferredFont(forTextStyle: .headline) view.addSubview(metadataInfoLabel!) @@ -130,7 +132,7 @@ class DisplayViewController: UIViewController { view.addSubview(progressView!) - cancelButton = ThemeButton(type: .system) + cancelButton = ThemeButton(type: .custom) cancelButton?.translatesAutoresizingMaskIntoConstraints = false cancelButton?.setTitle("Cancel".localized, for: .normal) cancelButton?.isHidden = (downloadProgress != nil) @@ -138,7 +140,7 @@ class DisplayViewController: UIViewController { view.addSubview(cancelButton!) - showPreviewButton = ThemeButton(type: .system) + showPreviewButton = ThemeButton(type: .custom) showPreviewButton?.translatesAutoresizingMaskIntoConstraints = false showPreviewButton?.setTitle("Open file".localized, for: .normal) showPreviewButton?.isHidden = true @@ -148,8 +150,10 @@ class DisplayViewController: UIViewController { noNetworkLabel = UILabel() noNetworkLabel?.translatesAutoresizingMaskIntoConstraints = false noNetworkLabel?.isHidden = true + noNetworkLabel?.adjustsFontForContentSizeCategory = true noNetworkLabel?.text = "There is no network".localized noNetworkLabel?.textAlignment = .center + noNetworkLabel?.font = UIFont.preferredFont(forTextStyle: .headline) view.addSubview(noNetworkLabel!) NSLayoutConstraint.activate([ @@ -160,7 +164,8 @@ class DisplayViewController: UIViewController { metadataInfoLabel!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: 10), - metadataInfoLabel!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor), + metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 10), + metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -10), progressView!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), progressView!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor), From 4b7aa074b152aa7135564555b9ba48727bede07c Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Thu, 31 Jan 2019 09:49:07 +0100 Subject: [PATCH 5/7] - Code improvements from code review. --- .swiftlint.yml | 2 +- .../Client/ClientQueryViewController.swift | 2 - ownCloud/Client/SortBar.swift | 7 +- ownCloud/UI Elements/StaticTableViewRow.swift | 78 ++++++++++--------- ownCloud/Viewer/DisplayViewController.swift | 26 ++++--- 5 files changed, 64 insertions(+), 51 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index f78e62541..117242117 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -26,7 +26,7 @@ disabled_rules: - type_body_length - line_length - type_name - + - vertical_parameter_alignment custom_rules: empty_line_after_guard_statement: included: ".*\\.swift" diff --git a/ownCloud/Client/ClientQueryViewController.swift b/ownCloud/Client/ClientQueryViewController.swift index c7b5c1d16..d2615cbbb 100644 --- a/ownCloud/Client/ClientQueryViewController.swift +++ b/ownCloud/Client/ClientQueryViewController.swift @@ -148,8 +148,6 @@ class ClientQueryViewController: UITableViewController, Themeable { let actionsBarButton: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(uploadsBarButtonPressed)) actionsBarButton.accessibilityLabel = "Upload files".localized - actionsBarButton.setTitleTextAttributes([.font :UIFont.systemFont(ofSize: 10)], for: .normal) - actionsBarButton.setTitleTextAttributes([.font :UIFont.systemFont(ofSize: 10)], for: .highlighted) self.navigationItem.rightBarButtonItem = actionsBarButton } diff --git a/ownCloud/Client/SortBar.swift b/ownCloud/Client/SortBar.swift index 7c9d9fc33..10bb3413e 100644 --- a/ownCloud/Client/SortBar.swift +++ b/ownCloud/Client/SortBar.swift @@ -32,6 +32,9 @@ class SortBar: UIView, Themeable { weak var delegate: SortBarDelegate? + // MARK: - Constants + let sideButtonsSize: CGSize = CGSize(width: 30.0, height: 30.0) + // MARK: - Instance variables. var stackView: UIStackView @@ -73,10 +76,10 @@ class SortBar: UIView, Themeable { sortButton = ThemeButton() sortButton.accessibilityIdentifier = "sort-bar.sortButton" - leftButtonImage = Theme.shared.image(for: "folder-create", size: CGSize(width: 30.0, height: 30.0))!.withRenderingMode(.alwaysTemplate) + leftButtonImage = Theme.shared.image(for: "folder-create", size: sideButtonsSize)!.withRenderingMode(.alwaysTemplate) leftButton.accessibilityLabel = "Create Folder".localized - rightButtonImage = Theme.shared.image(for: "folder-create", size: CGSize(width: 30.0, height: 30.0))!.withRenderingMode(.alwaysTemplate) + rightButtonImage = Theme.shared.image(for: "folder-create", size: sideButtonsSize)!.withRenderingMode(.alwaysTemplate) self.sortMethod = sortMethod diff --git a/ownCloud/UI Elements/StaticTableViewRow.swift b/ownCloud/UI Elements/StaticTableViewRow.swift index a91bcae22..2edf03747 100644 --- a/ownCloud/UI Elements/StaticTableViewRow.swift +++ b/ownCloud/UI Elements/StaticTableViewRow.swift @@ -7,14 +7,14 @@ // /* - * Copyright (C) 2018, 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 . - * - */ +* Copyright (C) 2018, 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 . +* +*/ import UIKit @@ -151,7 +151,10 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { // MARK: - Text Field public var textField : UITextField? - convenience init(textFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", secureTextEntry : Bool = false, keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { + convenience init(textFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", + secureTextEntry : Bool = false, keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, + autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, + returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { self.init() @@ -207,15 +210,18 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { cellTextField.accessibilityLabel = accessibilityLabel } - convenience init(secureTextFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { + convenience init(secureTextFieldWithAction action: StaticTableViewRowAction?, placeholder placeholderString: String = "", value textValue: String = "", + keyboardType: UIKeyboardType = UIKeyboardType.default, autocorrectionType: UITextAutocorrectionType = UITextAutocorrectionType.default, + autocapitalizationType: UITextAutocapitalizationType = UITextAutocapitalizationType.none, enablesReturnKeyAutomatically: Bool = true, + returnKeyType : UIReturnKeyType = UIReturnKeyType.default, identifier : String? = nil, accessibilityLabel: String? = nil) { self.init(textFieldWithAction: action, - placeholder: placeholderString, - value: textValue, secureTextEntry: true, - keyboardType: keyboardType, - autocorrectionType: autocorrectionType, - autocapitalizationType: autocapitalizationType, - enablesReturnKeyAutomatically: enablesReturnKeyAutomatically, - returnKeyType: returnKeyType, identifier : identifier, + placeholder: placeholderString, + value: textValue, secureTextEntry: true, + keyboardType: keyboardType, + autocorrectionType: autocorrectionType, + autocapitalizationType: autocapitalizationType, + enablesReturnKeyAutomatically: enablesReturnKeyAutomatically, + returnKeyType: returnKeyType, identifier : identifier, accessibilityLabel: accessibilityLabel) } @@ -306,28 +312,28 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { var textColor, selectedTextColor, backgroundColor, selectedBackgroundColor : UIColor? switch style { - case .plain: - textColor = themeCollection.tintColor - backgroundColor = themeCollection.tableRowColors.backgroundColor + case .plain: + textColor = themeCollection.tintColor + backgroundColor = themeCollection.tableRowColors.backgroundColor - case .plainNonOpaque: - textColor = themeCollection.tableRowColors.tintColor - backgroundColor = themeCollection.tableRowColors.backgroundColor + case .plainNonOpaque: + textColor = themeCollection.tableRowColors.tintColor + backgroundColor = themeCollection.tableRowColors.backgroundColor - case .proceed: - textColor = themeCollection.neutralColors.normal.foreground - backgroundColor = themeCollection.neutralColors.normal.background - selectedBackgroundColor = themeCollection.neutralColors.highlighted.background + case .proceed: + textColor = themeCollection.neutralColors.normal.foreground + backgroundColor = themeCollection.neutralColors.normal.background + selectedBackgroundColor = themeCollection.neutralColors.highlighted.background - case .destructive: - textColor = UIColor.red - backgroundColor = themeCollection.tableRowColors.backgroundColor + case .destructive: + textColor = UIColor.red + backgroundColor = themeCollection.tableRowColors.backgroundColor - case let .custom(customTextColor, customSelectedTextColor, customBackgroundColor, customSelectedBackgroundColor): - textColor = customTextColor - selectedTextColor = customSelectedTextColor - backgroundColor = customBackgroundColor - selectedBackgroundColor = customSelectedBackgroundColor + case let .custom(customTextColor, customSelectedTextColor, customBackgroundColor, customSelectedBackgroundColor): + textColor = customTextColor + selectedTextColor = customSelectedTextColor + backgroundColor = customBackgroundColor + selectedBackgroundColor = customSelectedBackgroundColor } @@ -350,7 +356,7 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate { self?.cell?.selectedBackgroundView? = selectedBackgroundView } - }, applyImmediately: true) + }, applyImmediately: true) self.action = action } diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index e55d5f033..d9ec8526a 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -41,6 +41,12 @@ protocol DisplayViewEditingDelegate: class { class DisplayViewController: UIViewController { private let iconImageSize: CGSize = CGSize(width: 200.0, height: 200.0) + private let iconImageViewCenterYConstraintConstant: CGFloat = -60.0 + private let metadataInfoLabelMarginAndTopConstraintConstant: CGFloat = 10.0 + private let noNetworkLabelTopConstraintConstant: CGFloat = 10.0 + private let showPreviewButtonTopConstraintConstant: CGFloat = 10.0 + private let cancelButtonTopConstraintConstant: CGFloat = 10.0 + private let progressViewTopConstraintConstant: CGFloat = 20.0 // MARK: - Configuration weak var item: OCItem! @@ -55,7 +61,7 @@ class DisplayViewController: UIViewController { OnMainThread { self.iconImageView.isHidden = true } - hideUIElements() + hideItemMetadataUIElements() renderSpecificView() } } @@ -158,27 +164,27 @@ class DisplayViewController: UIViewController { NSLayoutConstraint.activate([ iconImageView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), - iconImageView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor, constant: -60), + iconImageView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor, constant: iconImageViewCenterYConstraintConstant), iconImageView.heightAnchor.constraint(equalToConstant: iconImageSize.height), iconImageView.widthAnchor.constraint(equalTo: iconImageView.heightAnchor), metadataInfoLabel!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: 10), - metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 10), - metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -10), + metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: metadataInfoLabelMarginAndTopConstraintConstant), + metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: metadataInfoLabelMarginAndTopConstraintConstant), + metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -metadataInfoLabelMarginAndTopConstraintConstant), progressView!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), progressView!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor), - progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: 20), + progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: progressViewTopConstraintConstant), cancelButton!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - cancelButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: 10), + cancelButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: cancelButtonTopConstraintConstant), showPreviewButton!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - showPreviewButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: 10), + showPreviewButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: showPreviewButtonTopConstraintConstant), noNetworkLabel!.centerXAnchor.constraint(equalTo: metadataInfoLabel!.centerXAnchor), - noNetworkLabel!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: 10), + noNetworkLabel!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: noNetworkLabelTopConstraintConstant), noNetworkLabel!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor) ]) } @@ -254,7 +260,7 @@ class DisplayViewController: UIViewController { // This function is intended to be overwritten by the subclases to implement a custom view based on the source property.s } - func hideUIElements() { + func hideItemMetadataUIElements() { iconImageView.isHidden = true progressView?.isHidden = true cancelButton?.isHidden = true From 284d8ae7be01af96a00f7618dc2ff1cd06633b03 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Fri, 1 Feb 2019 13:46:25 +0100 Subject: [PATCH 6/7] - Code review changes --- ownCloud/Viewer/DisplayViewController.swift | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index d9ec8526a..471c06dda 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -41,12 +41,10 @@ protocol DisplayViewEditingDelegate: class { class DisplayViewController: UIViewController { private let iconImageSize: CGSize = CGSize(width: 200.0, height: 200.0) - private let iconImageViewCenterYConstraintConstant: CGFloat = -60.0 - private let metadataInfoLabelMarginAndTopConstraintConstant: CGFloat = 10.0 - private let noNetworkLabelTopConstraintConstant: CGFloat = 10.0 - private let showPreviewButtonTopConstraintConstant: CGFloat = 10.0 - private let cancelButtonTopConstraintConstant: CGFloat = 10.0 - private let progressViewTopConstraintConstant: CGFloat = 20.0 + private let bottomMarginToYAxis: CGFloat = -60.0 + private let verticalSpacing: CGFloat = 10.0 + private let lateralSpacing: CGFloat = 10 + private let progressViewVerticalSpacing: CGFloat = 20.0 // MARK: - Configuration weak var item: OCItem! @@ -164,27 +162,27 @@ class DisplayViewController: UIViewController { NSLayoutConstraint.activate([ iconImageView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), - iconImageView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor, constant: iconImageViewCenterYConstraintConstant), + iconImageView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor, constant: bottomMarginToYAxis), iconImageView.heightAnchor.constraint(equalToConstant: iconImageSize.height), iconImageView.widthAnchor.constraint(equalTo: iconImageView.heightAnchor), metadataInfoLabel!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: metadataInfoLabelMarginAndTopConstraintConstant), - metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: metadataInfoLabelMarginAndTopConstraintConstant), - metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -metadataInfoLabelMarginAndTopConstraintConstant), + metadataInfoLabel!.topAnchor.constraint(equalTo: iconImageView!.bottomAnchor, constant: verticalSpacing), + metadataInfoLabel!.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: lateralSpacing), + metadataInfoLabel!.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: -lateralSpacing), progressView!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), progressView!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor), - progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: progressViewTopConstraintConstant), + progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: verticalSpacing), cancelButton!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - cancelButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: cancelButtonTopConstraintConstant), + cancelButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: verticalSpacing), showPreviewButton!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), - showPreviewButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: showPreviewButtonTopConstraintConstant), + showPreviewButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: verticalSpacing), noNetworkLabel!.centerXAnchor.constraint(equalTo: metadataInfoLabel!.centerXAnchor), - noNetworkLabel!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: noNetworkLabelTopConstraintConstant), + noNetworkLabel!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: verticalSpacing), noNetworkLabel!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor) ]) } From b6f589073dc6d5b8cf721d54556a24efd5430ceb Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Fri, 1 Feb 2019 14:01:16 +0100 Subject: [PATCH 7/7] - Change one constrait to a defined one --- ownCloud/Viewer/DisplayViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ownCloud/Viewer/DisplayViewController.swift b/ownCloud/Viewer/DisplayViewController.swift index 471c06dda..0dccdada4 100644 --- a/ownCloud/Viewer/DisplayViewController.swift +++ b/ownCloud/Viewer/DisplayViewController.swift @@ -173,7 +173,7 @@ class DisplayViewController: UIViewController { progressView!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), progressView!.widthAnchor.constraint(equalTo: iconImageView.widthAnchor), - progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: verticalSpacing), + progressView!.topAnchor.constraint(equalTo: metadataInfoLabel!.bottomAnchor, constant: progressViewVerticalSpacing), cancelButton!.centerXAnchor.constraint(equalTo: iconImageView.centerXAnchor), cancelButton!.topAnchor.constraint(equalTo: progressView!.bottomAnchor, constant: verticalSpacing),