From ed0ae4e2ce9f790f683901e6dc1ce0494b72c840 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 15:30:43 -0400 Subject: [PATCH 1/7] Add accessibility ids to sticker pack view. --- .../Stickers/StickerPackViewController.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SignalMessaging/ViewControllers/Stickers/StickerPackViewController.swift b/SignalMessaging/ViewControllers/Stickers/StickerPackViewController.swift index 71a58cda03..4ee5733915 100644 --- a/SignalMessaging/ViewControllers/Stickers/StickerPackViewController.swift +++ b/SignalMessaging/ViewControllers/Stickers/StickerPackViewController.swift @@ -78,6 +78,7 @@ public class StickerPackViewController: OWSViewController { dismissButton.setTemplateImageName("x-24", tintColor: Theme.darkThemePrimaryColor) dismissButton.addTarget(self, action: #selector(dismissButtonPressed(sender:)), for: .touchUpInside) dismissButton.contentEdgeInsets = UIEdgeInsets(top: 20, leading: hMargin, bottom: 20, trailing: hMargin) + dismissButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "dismissButton") coverView.autoSetDimensions(to: CGSize(width: 48, height: 48)) coverView.setCompressionResistanceHigh() @@ -95,6 +96,7 @@ public class StickerPackViewController: OWSViewController { if FeatureFlags.stickerSharing { shareButton.setTemplateImageName("forward-outline-24", tintColor: Theme.darkThemePrimaryColor) shareButton.addTarget(self, action: #selector(shareButtonPressed(sender:)), for: .touchUpInside) + shareButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "shareButton") } view.addSubview(dismissButton) @@ -131,23 +133,23 @@ public class StickerPackViewController: OWSViewController { stickerCollectionView.autoPinEdge(.top, to: .bottom, of: headerStack) stickerCollectionView.autoPinEdge(toSuperviewMargin: .bottom) - installButton = OWSFlatButton.button(title: NSLocalizedString("STICKERS_INSTALL_BUTTON", comment: "Label for the 'install sticker pack' button."), + let installButton = OWSFlatButton.button(title: NSLocalizedString("STICKERS_INSTALL_BUTTON", comment: "Label for the 'install sticker pack' button."), font: UIFont.ows_dynamicTypeBody.ows_mediumWeight(), titleColor: UIColor.ows_materialBlue, backgroundColor: UIColor.white, target: self, selector: #selector(didTapInstall)) - uninstallButton = OWSFlatButton.button(title: NSLocalizedString("STICKERS_UNINSTALL_BUTTON", comment: "Label for the 'uninstall sticker pack' button."), + self.installButton = installButton + installButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "installButton") + let uninstallButton = OWSFlatButton.button(title: NSLocalizedString("STICKERS_UNINSTALL_BUTTON", comment: "Label for the 'uninstall sticker pack' button."), font: UIFont.ows_dynamicTypeBody.ows_mediumWeight(), titleColor: UIColor.ows_materialBlue, backgroundColor: UIColor.white, target: self, selector: #selector(didTapUninstall)) + self.uninstallButton = uninstallButton + uninstallButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "uninstallButton") for button in [installButton, uninstallButton] { - guard let button = button else { - owsFailDebug("Missing button.") - continue - } view.addSubview(button) button.autoPin(toBottomLayoutGuideOf: self, withInset: 0) button.autoPinWidthToSuperview(withMargin: hMargin) From f1129cb5634f1876ab45e4eb335e6bf80acaf624 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 15:42:34 -0400 Subject: [PATCH 2/7] Add accessibility ids to sticker keyboard. --- .../Stickers/StickerHorizontalListView.swift | 14 ++++++++++++++ .../ViewControllers/Stickers/StickerKeyboard.swift | 2 ++ .../Stickers/StickerPackCollectionView.swift | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/SignalMessaging/ViewControllers/Stickers/StickerHorizontalListView.swift b/SignalMessaging/ViewControllers/Stickers/StickerHorizontalListView.swift index c87b58e9f1..32b96289ad 100644 --- a/SignalMessaging/ViewControllers/Stickers/StickerHorizontalListView.swift +++ b/SignalMessaging/ViewControllers/Stickers/StickerHorizontalListView.swift @@ -9,6 +9,7 @@ public protocol StickerHorizontalListViewItem { var view: UIView { get } var didSelectBlock: () -> Void { get } var isSelected: Bool { get } + var accessibilityName: String { get } } // MARK: - @@ -43,6 +44,11 @@ public class StickerHorizontalListViewItemSticker: NSObject, StickerHorizontalLi public var isSelected: Bool { return isSelectedBlock() } + + public var accessibilityName: String { + // We just need a stable identifier. + return "pack." + stickerInfo.asKey() + } } // MARK: - @@ -67,6 +73,10 @@ public class StickerHorizontalListViewItemRecents: NSObject, StickerHorizontalLi public var isSelected: Bool { return isSelectedBlock() } + + public var accessibilityName: String { + return "recents" + } } // MARK: - @@ -198,6 +208,10 @@ extension StickerHorizontalListView: UICollectionViewDataSource { let itemView = item.view cell.contentView.addSubview(itemView) itemView.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: cellInset, leading: cellInset, bottom: cellInset, trailing: cellInset)) + + itemView.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: item.accessibilityName + ".item") + cell.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: item.accessibilityName + ".cell") + return cell } } diff --git a/SignalMessaging/ViewControllers/Stickers/StickerKeyboard.swift b/SignalMessaging/ViewControllers/Stickers/StickerKeyboard.swift index e2d7afcc00..f84959a764 100644 --- a/SignalMessaging/ViewControllers/Stickers/StickerKeyboard.swift +++ b/SignalMessaging/ViewControllers/Stickers/StickerKeyboard.swift @@ -162,6 +162,7 @@ public class StickerKeyboard: UIStackView { self?.searchButtonWasTapped() } headerView.addArrangedSubview(searchButton) + searchButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "searchButton") } packsCollectionView.backgroundColor = keyboardBackgroundColor @@ -171,6 +172,7 @@ public class StickerKeyboard: UIStackView { self?.manageButtonWasTapped() } headerView.addArrangedSubview(manageButton) + manageButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "manageButton") updateHeaderView() } diff --git a/SignalMessaging/ViewControllers/Stickers/StickerPackCollectionView.swift b/SignalMessaging/ViewControllers/Stickers/StickerPackCollectionView.swift index 4e3414da35..c931c66f36 100644 --- a/SignalMessaging/ViewControllers/Stickers/StickerPackCollectionView.swift +++ b/SignalMessaging/ViewControllers/Stickers/StickerPackCollectionView.swift @@ -287,6 +287,10 @@ extension StickerPackCollectionView: UICollectionViewDataSource { cell.contentView.addSubview(stickerView) stickerView.autoPinEdgesToSuperviewEdges() + let accessibilityName = "sticker." + stickerInfo.asKey() + cell.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: accessibilityName + ".cell") + stickerView.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: accessibilityName + ".item") + return cell } } From bd62adedfa258cfb27c92057d3f0324b5b8a4e4b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 15:42:41 -0400 Subject: [PATCH 3/7] Add accessibility ids to call view. --- .../Call/CallViewController.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Signal/src/ViewControllers/Call/CallViewController.swift b/Signal/src/ViewControllers/Call/CallViewController.swift index b587c7cf05..39a68a7192 100644 --- a/Signal/src/ViewControllers/Call/CallViewController.swift +++ b/Signal/src/ViewControllers/Call/CallViewController.swift @@ -263,6 +263,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, remoteVideoView = RemoteVideoView() remoteVideoView.isUserInteractionEnabled = false localVideoView = RTCCameraPreviewView() + remoteVideoView.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "remoteVideoView") + localVideoView.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "localVideoView") remoteVideoView.isHidden = true localVideoView.isHidden = true @@ -315,6 +317,11 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, self.view.addSubview(contactAvatarContainerView) contactAvatarView = AvatarImageView() contactAvatarContainerView.addSubview(contactAvatarView) + + leaveCallViewButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "leaveCallViewButton") + contactNameLabel.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "contactNameLabel") + callStatusLabel.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "callStatusLabel") + contactAvatarView.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "contactAvatarView") } func createSettingsNagViews() { @@ -365,6 +372,10 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, notNowButton.autoPinWidthToSuperview() notNowButton.autoPinEdge(toSuperviewEdge: .bottom) notNowButton.autoPinEdge(.top, to: .bottom, of: callSettingsButton, withOffset: 12) + + settingsNagDescriptionLabel.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "settingsNagDescriptionLabel") + callSettingsButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "callSettingsButton") + notNowButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "notNowButton") } func buttonSize() -> CGFloat { @@ -429,6 +440,14 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, ongoingVideoCallControls = UIStackView(arrangedSubviews: [videoModeMuteButton, videoModeFlipCameraButton, videoModeVideoButton]) ongoingAudioCallControls.distribution = .equalSpacing ongoingVideoCallControls.axis = .horizontal + + audioSourceButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "audioSourceButton") + hangUpButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "hangUpButton") + audioModeMuteButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "audioModeMuteButton") + audioModeVideoButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "audioModeVideoButton") + videoModeMuteButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "videoModeMuteButton") + videoModeFlipCameraButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "videoModeFlipCameraButton") + videoModeVideoButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "videoModeVideoButton") } func presentAudioSourcePicker() { @@ -482,6 +501,9 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, incomingCallControls.distribution = .equalSpacing view.addSubview(incomingCallControls) + + acceptIncomingButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "acceptIncomingButton") + declineIncomingButton.accessibilityIdentifier = UIView.accessibilityIdentifier(in: self, name: "declineIncomingButton") } func createButton(image: UIImage, action: Selector) -> UIButton { From 1810e947f462032cc721ca1d053c9f71a810c2a4 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 15:53:55 -0400 Subject: [PATCH 4/7] Add accessibility ids to conversation view cells. --- .../ConversationView/ConversationViewController.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 9a7276e747..f95a06c886 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4596,9 +4596,14 @@ typedef enum : NSUInteger { [cell loadForDisplay]; +#ifdef DEBUG // TODO: Confirm with nancy if this will work. NSString *cellName = [NSString stringWithFormat:@"interaction.%@", NSUUID.UUID.UUIDString]; + if (viewItem.displayableBodyText.displayText.length > 0) { + cellName = [NSString stringWithFormat:@"interaction.%@", viewItem.displayableBodyText.displayText]; + } cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, cellName); +#endif return cell; } From 158cf4e395232d1ed727785d18e5b9b76cca893b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 15:59:16 -0400 Subject: [PATCH 5/7] Add accessibility ids to conversation view cells. --- .../ConversationView/ConversationViewController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index f95a06c886..6403459486 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4600,7 +4600,9 @@ typedef enum : NSUInteger { // TODO: Confirm with nancy if this will work. NSString *cellName = [NSString stringWithFormat:@"interaction.%@", NSUUID.UUID.UUIDString]; if (viewItem.displayableBodyText.displayText.length > 0) { - cellName = [NSString stringWithFormat:@"interaction.%@", viewItem.displayableBodyText.displayText]; + cellName = [NSString stringWithFormat:@"message.text.%@", viewItem.displayableBodyText.displayText]; + } else if (viewItem.stickerInfo) { + cellName = [NSString stringWithFormat:@"message.sticker.%@", [viewItem.stickerInfo asKey]]; } cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, cellName); #endif From 32a76da0bbcc97cf891edd3f90226d190647ddfe Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 16:01:33 -0400 Subject: [PATCH 6/7] Add accessibility ids to conversation view cells. --- .../ConversationView/ConversationViewController.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 6403459486..f4ae2582d4 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4600,7 +4600,9 @@ typedef enum : NSUInteger { // TODO: Confirm with nancy if this will work. NSString *cellName = [NSString stringWithFormat:@"interaction.%@", NSUUID.UUID.UUIDString]; if (viewItem.displayableBodyText.displayText.length > 0) { - cellName = [NSString stringWithFormat:@"message.text.%@", viewItem.displayableBodyText.displayText]; + NSString *textForId = + [viewItem.displayableBodyText.displayText stringByReplacingOccurrencesOfString:@" " withString:@"_"]; + cellName = [NSString stringWithFormat:@"message.text.%@", textForId]; } else if (viewItem.stickerInfo) { cellName = [NSString stringWithFormat:@"message.sticker.%@", [viewItem.stickerInfo asKey]]; } From 9dd80cd2c6a3d9c1ca27c36cc0aaee700909e79d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 26 Jun 2019 17:18:16 -0400 Subject: [PATCH 7/7] Fix assert in conversation view item. --- .../ConversationView/ConversationViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index f4ae2582d4..bc42455183 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -4599,7 +4599,7 @@ typedef enum : NSUInteger { #ifdef DEBUG // TODO: Confirm with nancy if this will work. NSString *cellName = [NSString stringWithFormat:@"interaction.%@", NSUUID.UUID.UUIDString]; - if (viewItem.displayableBodyText.displayText.length > 0) { + if (viewItem.hasBodyText && viewItem.displayableBodyText.displayText.length > 0) { NSString *textForId = [viewItem.displayableBodyText.displayText stringByReplacingOccurrencesOfString:@" " withString:@"_"]; cellName = [NSString stringWithFormat:@"message.text.%@", textForId];