Skip to content

Commit

Permalink
- Coded some accessibility labels and hints to made the app more
Browse files Browse the repository at this point in the history
accessible and with more accurate VoiceOver explanations.
  • Loading branch information
pablocarmu committed Jan 29, 2019
1 parent 20a0f4a commit 532b02c
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 11 deletions.
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
1 change: 1 addition & 0 deletions ownCloud/Client/ClientItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ownCloud/Client/ClientQueryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand All @@ -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)

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: .body)
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
9 changes: 6 additions & 3 deletions ownCloud/UI Elements/StaticTableViewRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -203,17 +203,20 @@ 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)
returnKeyType: returnKeyType, identifier : identifier,
accessibilityLabel: accessibilityLabel)
}

@objc func textFieldContentChanged(_ sender: UITextField) {
Expand Down
4 changes: 3 additions & 1 deletion ownCloud/Viewer/DisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 532b02c

Please sign in to comment.