Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility improvements #239

Merged
merged 7 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions ownCloud/Bookmarks/BookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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! ])

Expand Down Expand Up @@ -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 {
Expand All @@ -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()

Expand Down
1 change: 1 addition & 0 deletions ownCloud/Client/Actions/NamingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions ownCloud/Client/ClientItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -69,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

Expand Down Expand Up @@ -168,6 +172,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
Expand Down
1 change: 1 addition & 0 deletions ownCloud/Client/ClientQueryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class ClientQueryViewController: UITableViewController, Themeable {
self.tableView.dragInteractionEnabled = true

let actionsBarButton: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(uploadsBarButtonPressed))
actionsBarButton.accessibilityLabel = "Upload files".localized
self.navigationItem.rightBarButtonItem = actionsBarButton
}

Expand Down
9 changes: 7 additions & 2 deletions ownCloud/Client/SortBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,6 +53,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)!

Expand All @@ -72,9 +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

Expand Down
8 changes: 8 additions & 0 deletions ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down
7 changes: 5 additions & 2 deletions ownCloud/Server List/ServerListBookmarkCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: .headline)
titleLabel.adjustsFontForContentSizeCategory = true

detailLabel.font = UIFont.preferredFont(forTextStyle: .subheadline)
detailLabel.adjustsFontForContentSizeCategory = true

detailLabel.textColor = UIColor.gray

Expand Down
4 changes: 3 additions & 1 deletion ownCloud/Server List/ServerListTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion ownCloud/Theming/NSObject+ThemeApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ extension NSObject {
case .bigMessage:
label.font = UIFont.systemFont(ofSize: 17)

default: break
default:
break
}

switch itemState {
Expand Down
3 changes: 2 additions & 1 deletion ownCloud/Theming/UI/ThemeButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
81 changes: 45 additions & 36 deletions ownCloud/UI Elements/StaticTableViewRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/
* 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 <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

import UIKit

Expand Down Expand Up @@ -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) {
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()

Expand Down Expand Up @@ -203,17 +206,23 @@ 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,
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)
}

@objc func textFieldContentChanged(_ sender: UITextField) {
Expand Down Expand Up @@ -303,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

}

Expand All @@ -347,7 +356,7 @@ class StaticTableViewRow : NSObject, UITextFieldDelegate {

self?.cell?.selectedBackgroundView? = selectedBackgroundView
}
}, applyImmediately: true)
}, applyImmediately: true)

self.action = action
}
Expand Down
Loading