mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-13 08:15:15 +00:00
* Resolve #359 Optional Missing Alt-Text warning Add toggle in settings to require alt text (default off) If setting is enabled, posting show an error if any attached media is missing alt text * Re-localized strings
This commit is contained in:
parent
13af2d7e3f
commit
ed9a4a598d
5 changed files with 286 additions and 1 deletions
|
@ -59,6 +59,7 @@ struct ContentSettingsView: View {
|
||||||
userPreferences.appAutoExpandMedia = userPreferences.autoExpandMedia
|
userPreferences.appAutoExpandMedia = userPreferences.autoExpandMedia
|
||||||
userPreferences.appDefaultPostsSensitive = userPreferences.postIsSensitive
|
userPreferences.appDefaultPostsSensitive = userPreferences.postIsSensitive
|
||||||
userPreferences.appDefaultPostVisibility = userPreferences.postVisibility
|
userPreferences.appDefaultPostVisibility = userPreferences.postVisibility
|
||||||
|
userPreferences.appRequireAltText = userPreferences.appRequireAltText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +113,10 @@ struct ContentSettingsView: View {
|
||||||
Text("settings.content.default-sensitive")
|
Text("settings.content.default-sensitive")
|
||||||
}
|
}
|
||||||
.disabled(userPreferences.useInstanceContentSettings)
|
.disabled(userPreferences.useInstanceContentSettings)
|
||||||
|
|
||||||
|
Toggle(isOn: $userPreferences.appRequireAltText) {
|
||||||
|
Text("settings.content.require-alt-text")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if !os(visionOS)
|
#if !os(visionOS)
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
|
|
@ -41561,6 +41561,124 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"settings.content.require-alt-text" : {
|
||||||
|
"localizations" : {
|
||||||
|
"be" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ca" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en-GB" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eu" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"it" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ja" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ko" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nb" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pt-BR" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uk" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Require Alt Text to Post"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"settings.content.sharing" : {
|
"settings.content.sharing" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"be" : {
|
"be" : {
|
||||||
|
@ -66055,6 +66173,125 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"status.error.no-alt-text" : {
|
||||||
|
"extractionState" : "manual",
|
||||||
|
"localizations" : {
|
||||||
|
"be" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ca" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"en-GB" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eu" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"it" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ja" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ko" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nb" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pl" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pt-BR" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uk" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hans" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"zh-Hant" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Your settings require alt text on all media before posting"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"status.error.posting.title" : {
|
"status.error.posting.title" : {
|
||||||
"extractionState" : "manual",
|
"extractionState" : "manual",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import SwiftUI
|
||||||
@AppStorage("app_default_post_visibility") public var appDefaultPostVisibility: Models.Visibility = .pub
|
@AppStorage("app_default_post_visibility") public var appDefaultPostVisibility: Models.Visibility = .pub
|
||||||
@AppStorage("app_default_reply_visibility") public var appDefaultReplyVisibility: Models.Visibility = .pub
|
@AppStorage("app_default_reply_visibility") public var appDefaultReplyVisibility: Models.Visibility = .pub
|
||||||
@AppStorage("app_default_posts_sensitive") public var appDefaultPostsSensitive = false
|
@AppStorage("app_default_posts_sensitive") public var appDefaultPostsSensitive = false
|
||||||
|
@AppStorage("app_require_alt_text") public var appRequireAltText = false
|
||||||
@AppStorage("autoplay_video") public var autoPlayVideo = true
|
@AppStorage("autoplay_video") public var autoPlayVideo = true
|
||||||
@AppStorage("mute_video") public var muteVideo = true
|
@AppStorage("mute_video") public var muteVideo = true
|
||||||
@AppStorage("always_use_deepl") public var alwaysUseDeepl = false
|
@AppStorage("always_use_deepl") public var alwaysUseDeepl = false
|
||||||
|
@ -164,6 +165,12 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var appRequireAltText: Bool {
|
||||||
|
didSet {
|
||||||
|
storage.appRequireAltText = appRequireAltText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var autoPlayVideo: Bool {
|
public var autoPlayVideo: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
storage.autoPlayVideo = autoPlayVideo
|
storage.autoPlayVideo = autoPlayVideo
|
||||||
|
@ -466,6 +473,7 @@ import SwiftUI
|
||||||
appDefaultPostVisibility = storage.appDefaultPostVisibility
|
appDefaultPostVisibility = storage.appDefaultPostVisibility
|
||||||
appDefaultReplyVisibility = storage.appDefaultReplyVisibility
|
appDefaultReplyVisibility = storage.appDefaultReplyVisibility
|
||||||
appDefaultPostsSensitive = storage.appDefaultPostsSensitive
|
appDefaultPostsSensitive = storage.appDefaultPostsSensitive
|
||||||
|
appRequireAltText = storage.appRequireAltText
|
||||||
autoPlayVideo = storage.autoPlayVideo
|
autoPlayVideo = storage.autoPlayVideo
|
||||||
alwaysUseDeepl = storage.alwaysUseDeepl
|
alwaysUseDeepl = storage.alwaysUseDeepl
|
||||||
userDeeplAPIFree = storage.userDeeplAPIFree
|
userDeeplAPIFree = storage.userDeeplAPIFree
|
||||||
|
|
15
Packages/Models/Sources/Models/PostError.swift
Normal file
15
Packages/Models/Sources/Models/PostError.swift
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public enum PostError: Error {
|
||||||
|
// Throw when any attached media is missing media description (alt text)
|
||||||
|
case missingAltText
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PostError: CustomStringConvertible {
|
||||||
|
public var description: String {
|
||||||
|
switch self {
|
||||||
|
case .missingAltText:
|
||||||
|
return NSLocalizedString("status.error.no-alt-text", comment: "media does not have media description")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -131,6 +131,18 @@ extension StatusEditor {
|
||||||
!mediaContainers.isEmpty
|
!mediaContainers.isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allMediaHasDescription: Bool {
|
||||||
|
var everyMediaHasAltText: Bool = true;
|
||||||
|
mediaContainers.forEach { mediaContainer in
|
||||||
|
if (((mediaContainer.mediaAttachment?.description) == nil) ||
|
||||||
|
mediaContainer.mediaAttachment?.description?.count == 0) {
|
||||||
|
everyMediaHasAltText = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return everyMediaHasAltText;
|
||||||
|
}
|
||||||
|
|
||||||
var shouldDisplayDismissWarning: Bool {
|
var shouldDisplayDismissWarning: Bool {
|
||||||
var modifiedStatusText = statusText.string.trimmingCharacters(in: .whitespaces)
|
var modifiedStatusText = statusText.string.trimmingCharacters(in: .whitespaces)
|
||||||
|
|
||||||
|
@ -188,6 +200,10 @@ extension StatusEditor {
|
||||||
func postStatus() async -> Status? {
|
func postStatus() async -> Status? {
|
||||||
guard let client else { return nil }
|
guard let client else { return nil }
|
||||||
do {
|
do {
|
||||||
|
if (!allMediaHasDescription && UserPreferences.shared.appRequireAltText) {
|
||||||
|
throw PostError.missingAltText
|
||||||
|
}
|
||||||
|
|
||||||
if postingTimer == nil {
|
if postingTimer == nil {
|
||||||
Timer.scheduledTimer(withTimeInterval: 0.05, repeats: true) { timer in
|
Timer.scheduledTimer(withTimeInterval: 0.05, repeats: true) { timer in
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
|
@ -250,6 +266,10 @@ extension StatusEditor {
|
||||||
postingError = error.error
|
postingError = error.error
|
||||||
showPostingErrorAlert = true
|
showPostingErrorAlert = true
|
||||||
}
|
}
|
||||||
|
if let postError = error as? PostError {
|
||||||
|
postingError = postError.description
|
||||||
|
showPostingErrorAlert = true
|
||||||
|
}
|
||||||
isPosting = false
|
isPosting = false
|
||||||
HapticManager.shared.fireHaptic(.notification(.error))
|
HapticManager.shared.fireHaptic(.notification(.error))
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue