Skip to content

Commit c2628e1

Browse files
committed
Bug 1158508 - Reading List cell actions not invokable with VoiceOver
Also fixes Switch Control
1 parent 4b64b15 commit c2628e1

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Client/Frontend/Home/ReaderPanel.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,13 @@ class ReadingListTableViewCell: SWTableViewCell {
6060
titleLabel.textColor = unread ? ReadingListTableViewCellUX.ActiveTextColor : ReadingListTableViewCellUX.DimmedTextColor
6161
hostnameLabel.textColor = unread ? ReadingListTableViewCellUX.ActiveTextColor : ReadingListTableViewCellUX.DimmedTextColor
6262
markAsReadButton.setTitle(unread ? ReadingListTableViewCellUX.MarkAsReadButtonTitleText : ReadingListTableViewCellUX.MarkAsUnreadButtonTitleText, forState: UIControlState.Normal)
63+
markAsReadAction.name = markAsReadButton.titleLabel!.text
6364
}
6465
}
6566

67+
private let deleteAction: UIAccessibilityCustomAction
68+
private let markAsReadAction: UIAccessibilityCustomAction
69+
6670
let readStatusImageView: UIImageView!
6771
let titleLabel: UILabel!
6872
let hostnameLabel: UILabel!
@@ -75,6 +79,8 @@ class ReadingListTableViewCell: SWTableViewCell {
7579
hostnameLabel = UILabel()
7680
deleteButton = UIButton()
7781
markAsReadButton = UIButton()
82+
deleteAction = UIAccessibilityCustomAction()
83+
markAsReadAction = UIAccessibilityCustomAction()
7884

7985
super.init(style: style, reuseIdentifier: reuseIdentifier)
8086

@@ -117,6 +123,9 @@ class ReadingListTableViewCell: SWTableViewCell {
117123
deleteButton.setTitle(ReadingListTableViewCellUX.DeleteButtonTitleText, forState: UIControlState.Normal)
118124
deleteButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
119125
deleteButton.titleEdgeInsets = ReadingListTableViewCellUX.DeleteButtonTitleEdgeInsets
126+
deleteAction.name = deleteButton.titleLabel!.text
127+
deleteAction.target = self
128+
deleteAction.selector = "deleteActionActivated"
120129
rightUtilityButtons = [deleteButton]
121130

122131
markAsReadButton.backgroundColor = ReadingListTableViewCellUX.MarkAsReadButtonBackgroundColor
@@ -127,7 +136,12 @@ class ReadingListTableViewCell: SWTableViewCell {
127136
markAsReadButton.setTitle(ReadingListTableViewCellUX.MarkAsReadButtonTitleText, forState: UIControlState.Normal)
128137
markAsReadButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
129138
markAsReadButton.titleEdgeInsets = ReadingListTableViewCellUX.MarkAsReadButtonTitleEdgeInsets
139+
markAsReadAction.name = markAsReadButton.titleLabel!.text
140+
markAsReadAction.target = self
141+
markAsReadAction.selector = "markAsReadActionActivated"
130142
leftUtilityButtons = [markAsReadButton]
143+
144+
accessibilityCustomActions = [deleteAction, markAsReadAction]
131145
}
132146

133147
required init(coder aDecoder: NSCoder) {
@@ -145,6 +159,16 @@ class ReadingListTableViewCell: SWTableViewCell {
145159
}
146160
return hostname
147161
}
162+
163+
@objc private func markAsReadActionActivated() -> Bool {
164+
self.delegate?.swipeableTableViewCell?(self, didTriggerLeftUtilityButtonWithIndex: 0)
165+
return true
166+
}
167+
168+
@objc private func deleteActionActivated() -> Bool {
169+
self.delegate?.swipeableTableViewCell?(self, didTriggerRightUtilityButtonWithIndex: 0)
170+
return true
171+
}
148172
}
149173

150174
class ReadingListPanel: UITableViewController, HomePanel, SWTableViewCellDelegate {

0 commit comments

Comments
 (0)