Skip to content

Commit

Permalink
- ActionCell:
Browse files Browse the repository at this point in the history
	- add button trait (fixes #1341 sidebar issue)
	- fix warning, replace random number with UUID (even better)
- DriveGridCell: add role, use name of space as accessibility label, subtitle as accessibility hint and offer additional actions via accessibility custom actions.
- DriveListCell: add title for "moreAction" so that it can be converted to a accessibility custom action (which require a non-"" title)
- SavedSearchCell: consolidate accessibility elements, provide consolidated accessibility label derived from title and detail segment content
- OCShare+UniversalItemListCellContentProvider: provide VoiceOver-readable expiration date for links as accessibilityLabel (fixes #1341 issue)
- PopupButtonController: set accessibility label based on title so VoiceOver doesn't read out the rich-text image that is used
  • Loading branch information
felix-schwarz committed May 23, 2024
1 parent 6f11ba8 commit f1c1c10
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ extension ActionCell {
action?.run(options: options)
}), for: .primaryActionTriggered)

button.focusGroupIdentifier = "com.owncloud.accessory-action-button.\(arc4random())"
button.focusGroupIdentifier = "com.owncloud.accessory-action-button.\(UUID().uuidString)"
hasButton = true

accessories.append(.customView(configuration: UICellAccessory.CustomViewConfiguration(customView: button, placement: .trailing())))
} else {
cell.accessibilityTraits = .button
}
}

Expand All @@ -251,6 +253,8 @@ extension ActionCell {
if sidebarAction.childrenDataSource != nil {
let headerDisclosureOption = UICellAccessory.OutlineDisclosureOptions(style: .cell)
accessories.append(.outlineDisclosure(options: headerDisclosureOption))
} else {
cell.accessibilityTraits = .button
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class DriveGridCell: DriveHeaderCell {
var moreAction: OCAction? {
didSet {
moreButton.isHidden = (moreAction == nil)
if let moreAction {
accessibilityCustomActions = [ moreAction.accessibilityCustomAction() ]
} else {
accessibilityCustomActions = nil
}
}
}

Expand Down Expand Up @@ -55,6 +60,11 @@ class DriveGridCell: DriveHeaderCell {
moreButton.isHidden = true
moreButton.setContentCompressionResistancePriority(.required, for: .horizontal)

titleLabel.isAccessibilityElement = false
subtitleLabel.isAccessibilityElement = false
isAccessibilityElement = true
accessibilityTraits = .button

contentView.addSubview(moreButton)
}

Expand All @@ -76,9 +86,16 @@ class DriveGridCell: DriveHeaderCell {
])
}

override var title: String? {
didSet {
accessibilityLabel = title
}
}

override var subtitle: String? {
didSet {
subtitleLabel.text = subtitle ?? " " // Ensure the grid cells' titles align by always showing a subtitle - if necessary, an empty one
accessibilityHint = subtitle
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ extension DriveListCell {

// More item button action
if let clientContext = cellConfiguration.clientContext, let moreItemHandling = clientContext.moreItemHandler, let drive = driveItem as? OCDrive {
cell.moreAction = OCAction(title: "", icon: nil, action: { [weak moreItemHandling] (action, options, completion) in
cell.moreAction = OCAction(title: "Actions".localized, icon: nil, action: { [weak moreItemHandling] (action, options, completion) in
clientContext.core?.cachedItem(at: drive.rootLocation, resultHandler: { error, item in
if let item {
OnMainThread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SavedSearchCell: ThemeableCollectionViewCell {
var title: String? {
didSet {
titleLabel.text = title
updateAccessibilityLabel()
}
}
var icon: UIImage? {
Expand All @@ -54,9 +55,14 @@ class SavedSearchCell: ThemeableCollectionViewCell {
didSet {
segmentView.items = items ?? []
hasItemsConstraint?.isActive = segmentView.items.count > 0
updateAccessibilityLabel()
}
}

private func updateAccessibilityLabel() {
contentView.accessibilityLabel = "\(title ?? "") \(items?.accessibilityLabelSummary ?? "")"
}

private var sideButtonUIAction: UIAction?
var sideButtonAction: OCAction? {
didSet {
Expand Down Expand Up @@ -111,6 +117,8 @@ class SavedSearchCell: ThemeableCollectionViewCell {
titleLabel.lineBreakMode = .byWordWrapping
titleLabel.numberOfLines = 1

titleLabel.isAccessibilityElement = false

iconView.setContentHuggingPriority(.required, for: .horizontal)

sideButton.configuration = .tinted()
Expand All @@ -119,6 +127,9 @@ class SavedSearchCell: ThemeableCollectionViewCell {
var backgroundConfig = UIBackgroundConfiguration.clear()
backgroundConfig.cornerRadius = 10
backgroundConfiguration = backgroundConfig

contentView.isAccessibilityElement = true
contentView.accessibilityTraits = .button
}

func configureLayout() {
Expand Down Expand Up @@ -266,6 +277,7 @@ extension SavedSearchCell {

cell.backgroundConfiguration = .listSidebarCell()
cell.contentConfiguration = content
cell.accessibilityTraits = .button
cell.applyThemeCollection(theme: Theme.shared, collection: Theme.shared.activeCollection, event: .initial)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ extension OCShare: UniversalItemListCellContentProvider {

if let expirationDate {
let prettyExpirationDate = OCItem.compactDateFormatter.string(from: expirationDate)
let accessibleExpirationDate = OCItem.accessibilityDateFormatter.string(from: expirationDate)

let expirationDateIconSegment = SegmentViewItem(with: OCSymbol.icon(forSymbolName: "calendar"))
expirationDateIconSegment.insets = NSDirectionalEdgeInsets(top: 0, leading: 5, bottom: 0, trailing: 0)

let expirationDateSegment = SegmentViewItem(with: nil, title: "Expires {{expirationDate}}".localized(["expirationDate" : prettyExpirationDate]), style: .plain, titleTextStyle: .footnote)
let expirationDateSegment = SegmentViewItem(with: nil, title: "Expires {{expirationDate}}".localized(["expirationDate" : prettyExpirationDate]), style: .plain, titleTextStyle: .footnote, accessibilityLabel: "Expires {{expirationDate}}".localized(["expirationDate" : accessibleExpirationDate]))
expirationDateSegment.insets = .zero

detailExtraItems = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ open class PopupButtonController : NSObject, Themeable {

button.setAttributedTitle(attributedTitle, for: .normal)
button.sizeToFit()
button.accessibilityLabel = title
}
}

Expand Down

0 comments on commit f1c1c10

Please sign in to comment.