mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Give the media upload preview a descriptive VoiceOver title
The QLPreviewItem used the media's file name as its title, which VoiceOver read as cryptic alt text. Provide a descriptive "Photo preview" / "Video preview" title based on the media type instead. Addresses #5240, #5241.
This commit is contained in:
@@ -70,6 +70,8 @@ internal nonisolated enum L10n {
|
||||
internal static func a11yPausedVoiceMessage(_ p1: Any, _ p2: Any) -> String {
|
||||
return L10n.tr("Localizable", "a11y_paused_voice_message", String(describing: p1), String(describing: p2))
|
||||
}
|
||||
/// Photo preview
|
||||
internal static var a11yPhotoPreview: String { return L10n.tr("Localizable", "a11y_photo_preview") }
|
||||
/// PIN field
|
||||
internal static var a11yPinField: String { return L10n.tr("Localizable", "a11y_pin_field") }
|
||||
/// Pinned location
|
||||
@@ -144,6 +146,8 @@ internal nonisolated enum L10n {
|
||||
internal static var a11yTombstonedRoom: String { return L10n.tr("Localizable", "a11y_tombstoned_room") }
|
||||
/// User menu
|
||||
internal static var a11yUserMenu: String { return L10n.tr("Localizable", "a11y_user_menu") }
|
||||
/// Video preview
|
||||
internal static var a11yVideoPreview: String { return L10n.tr("Localizable", "a11y_video_preview") }
|
||||
/// View avatar
|
||||
internal static var a11yViewAvatar: String { return L10n.tr("Localizable", "a11y_view_avatar") }
|
||||
/// View details
|
||||
@@ -3553,6 +3557,10 @@ internal nonisolated enum L10n {
|
||||
}
|
||||
/// On the map
|
||||
internal static var screenStaticLocationSheetTitle: String { return L10n.tr("Localizable", "screen_static_location_sheet_title") }
|
||||
/// Plural format key: "%#@COUNT@"
|
||||
internal static func screenTimelineActiveCallExtraJoinedCount(_ p1: Int) -> String {
|
||||
return L10n.tr("Localizable", "screen_timeline_active_call_extra_joined_count", p1)
|
||||
}
|
||||
/// Message not sent because %1$@’s verified digital identity was reset.
|
||||
internal static func screenTimelineItemMenuSendFailureChangedIdentity(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "screen_timeline_item_menu_send_failure_changed_identity", String(describing: p1))
|
||||
|
||||
+10
-1
@@ -264,7 +264,16 @@ private struct PreviewView: UIViewControllerRepresentable {
|
||||
}
|
||||
|
||||
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
|
||||
PreviewItem(previewItemURL: view.mediaURLs[index], previewItemTitle: view.title)
|
||||
let url = view.mediaURLs[index]
|
||||
// Use a descriptive title instead of the file name so VoiceOver doesn't read a cryptic name.
|
||||
return PreviewItem(previewItemURL: url, previewItemTitle: previewItemTitle(for: url))
|
||||
}
|
||||
|
||||
private func previewItemTitle(for url: URL) -> String? {
|
||||
guard let type = UTType(filenameExtension: url.pathExtension) else { return view.title }
|
||||
if type.conforms(to: .image) { return L10n.a11yPhotoPreview }
|
||||
if type.conforms(to: .movie) || type.conforms(to: .video) { return L10n.a11yVideoPreview }
|
||||
return view.title
|
||||
}
|
||||
|
||||
// MARK: - QLPreviewControllerDelegate
|
||||
|
||||
Reference in New Issue
Block a user