VoiceOver improvements

This commit is contained in:
Justin Mazzocchi 2021-02-02 23:24:45 -08:00
parent 48c014ba35
commit 9fbfdf0c20
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
5 changed files with 80 additions and 2 deletions

View File

@ -2,6 +2,7 @@
"about" = "About";
"about.acknowledgments" = "Acknowledgments";
"accessibility.activate-link-%@" = "Activate link: %@";
"account.%@-followers" = "%@'s Followers";
"account.accept-follow-request-button.accessibility-label" = "Accept follow request";
"account.avatar.accessibility-label-%@" = "Avatar: %@";
@ -11,7 +12,6 @@
"account.domain-block.confirm-%@" = "Block domain %@?";
"account.domain-unblock-%@" = "Unblock domain %@";
"account.domain-unblock.confirm-%@" = "Unblock domain %@?";
"account.field.activate-link-accessibility-action-%@" = "Activate link: %@";
"account.field.verified" = "Verified %@";
"account.follow" = "Follow";
"account.following" = "Following";
@ -237,6 +237,7 @@
"search.scope.statuses.toot" = "Toots";
"search.scope.tags" = "Hashtags";
"share-extension-error.no-account-found" = "No account found";
"status.accessibility.view-author-profile" = "View author's profile";
"status.bookmark" = "Bookmark";
"status.content-warning-abbreviation" = "CW";
"status.content-warning.accessibility" = "Content warning";

View File

@ -66,6 +66,22 @@
<string>%ld Favorites</string>
</dict>
</dict>
<key>status.replies-count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@replies@</string>
<key>replies</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>ld</string>
<key>one</key>
<string>%ld Reply</string>
<key>other</key>
<string>%ld Replies</string>
</dict>
</dict>
<key>account.followers-count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>

View File

@ -167,7 +167,7 @@ final class AccountFieldView: UIView {
accessibilityCustomActions.append(
UIAccessibilityCustomAction(
name: String.localizedStringWithFormat(
NSLocalizedString("account.field.activate-link-accessibility-action-%@", comment: ""),
NSLocalizedString("accessibility.activate-link-%@", comment: ""),
mutableValue.attributedSubstring(from: range).string)) { [weak self] _ in
guard let valueTextView = self?.valueTextView else { return false }

View File

@ -510,6 +510,29 @@ private extension StatusView {
accessibilityAttributedLabel.appendWithSeparator(accessibilityTime)
}
if viewModel.repliesCount > 0 {
accessibilityAttributedLabel.appendWithSeparator(
String.localizedStringWithFormat(
NSLocalizedString("status.replies-count", comment: ""),
viewModel.repliesCount))
}
if viewModel.identityContext.appPreferences.showReblogAndFavoriteCounts {
if viewModel.reblogsCount > 0 {
accessibilityAttributedLabel.appendWithSeparator(
String.localizedStringWithFormat(
NSLocalizedString("status.reblogs-count", comment: ""),
viewModel.reblogsCount))
}
if viewModel.favoritesCount > 0 {
accessibilityAttributedLabel.appendWithSeparator(
String.localizedStringWithFormat(
NSLocalizedString("status.favorites-count", comment: ""),
viewModel.favoritesCount))
}
}
self.accessibilityAttributedLabel = accessibilityAttributedLabel
configureUserInteractionEnabledForAccessibility()
@ -723,6 +746,17 @@ private extension StatusView {
})
}
actions.append(
UIAccessibilityCustomAction(
name: NSLocalizedString("status.accessibility.view-author-profile",
comment: "")) { [weak self] _ in
self?.statusConfiguration.viewModel.accountSelected()
return true
})
actions.append(contentsOf: bodyView.accessibilityCustomActions ?? [])
if menuButton.isEnabled {
actions.append(UIAccessibilityCustomAction(
name: viewModel.bookmarked

View File

@ -91,6 +91,33 @@ final class StatusBodyView: UIView {
}
self.accessibilityAttributedLabel = accessibilityAttributedLabel
var accessibilityCustomActions = [UIAccessibilityCustomAction]()
mutableContent.enumerateAttribute(
.link,
in: NSRange(location: 0, length: mutableContent.length),
options: []) { attribute, range, _ in
guard let url = attribute as? URL else { return }
accessibilityCustomActions.append(
UIAccessibilityCustomAction(
name: String.localizedStringWithFormat(
NSLocalizedString("accessibility.activate-link-%@", comment: ""),
mutableContent.attributedSubstring(from: range).string)) { [weak self] _ in
guard let contentTextView = self?.contentTextView else { return false }
_ = contentTextView.delegate?.textView?(
contentTextView,
shouldInteractWith: url,
in: range,
interaction: .invokeDefaultAction)
return true
})
}
self.accessibilityCustomActions = accessibilityCustomActions
}
}