forked from zelo72/mastodon-ios
feat: add emoji animation preference
This commit is contained in:
parent
cfc5987528
commit
fff4f0a204
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="18154" systemVersion="20F71" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="18154" systemVersion="20G71" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Application" representedClassName=".Application" syncable="YES">
|
||||
<attribute name="identifier" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
|
||||
<attribute name="name" attributeType="String"/>
|
||||
|
@ -195,6 +195,7 @@
|
|||
<attribute name="createdAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="domain" attributeType="String"/>
|
||||
<attribute name="preferredStaticAvatar" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="preferredStaticEmoji" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="preferredTrueBlackDarkMode" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="preferredUsingDefaultBrowser" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="updatedAt" attributeType="Date" usesScalarValueType="NO"/>
|
||||
|
@ -290,7 +291,7 @@
|
|||
<element name="PollOption" positionX="0" positionY="0" width="128" height="134"/>
|
||||
<element name="PrivateNote" positionX="0" positionY="0" width="128" height="89"/>
|
||||
<element name="SearchHistory" positionX="0" positionY="0" width="128" height="149"/>
|
||||
<element name="Setting" positionX="72" positionY="162" width="128" height="164"/>
|
||||
<element name="Setting" positionX="72" positionY="162" width="128" height="179"/>
|
||||
<element name="Status" positionX="0" positionY="0" width="128" height="614"/>
|
||||
<element name="Subscription" positionX="81" positionY="171" width="128" height="179"/>
|
||||
<element name="SubscriptionAlerts" positionX="72" positionY="162" width="128" height="14"/>
|
||||
|
|
|
@ -16,6 +16,7 @@ public final class Setting: NSManagedObject {
|
|||
@NSManaged public var appearanceRaw: String
|
||||
@NSManaged public var preferredTrueBlackDarkMode: Bool
|
||||
@NSManaged public var preferredStaticAvatar: Bool
|
||||
@NSManaged public var preferredStaticEmoji: Bool
|
||||
@NSManaged public var preferredUsingDefaultBrowser: Bool
|
||||
|
||||
@NSManaged public private(set) var createdAt: Date
|
||||
|
@ -64,6 +65,12 @@ extension Setting {
|
|||
didUpdate(at: Date())
|
||||
}
|
||||
|
||||
public func update(preferredStaticEmoji: Bool) {
|
||||
guard preferredStaticEmoji != self.preferredStaticEmoji else { return }
|
||||
self.preferredStaticEmoji = preferredStaticEmoji
|
||||
didUpdate(at: Date())
|
||||
}
|
||||
|
||||
public func update(preferredUsingDefaultBrowser: Bool) {
|
||||
guard preferredUsingDefaultBrowser != self.preferredUsingDefaultBrowser else { return }
|
||||
self.preferredUsingDefaultBrowser = preferredUsingDefaultBrowser
|
||||
|
|
|
@ -500,10 +500,6 @@
|
|||
"light": "Always Light",
|
||||
"dark": "Always Dark"
|
||||
},
|
||||
"appearance_settings": {
|
||||
"true_black_dark_mode": "True black dark mode",
|
||||
"disable_avatar_animation": "Disable animated avatars"
|
||||
},
|
||||
"notifications": {
|
||||
"title": "Notifications",
|
||||
"favorites": "Favorites my post",
|
||||
|
@ -520,6 +516,9 @@
|
|||
},
|
||||
"preference": {
|
||||
"title": "Preferences",
|
||||
"true_black_dark_mode": "True black dark mode",
|
||||
"disable_avatar_animation": "Disable animated avatars",
|
||||
"disable_emoji_animation": "Disable animated emojis",
|
||||
"using_default_browser": "Use default browser to open links"
|
||||
},
|
||||
"boring_zone": {
|
||||
|
|
|
@ -43,12 +43,14 @@ extension SettingsItem {
|
|||
enum PreferenceType: CaseIterable {
|
||||
case darkMode
|
||||
case disableAvatarAnimation
|
||||
case disableEmojiAnimation
|
||||
case useDefaultBrowser
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .darkMode: return L10n.Scene.Settings.Section.AppearanceSettings.trueBlackDarkMode
|
||||
case .disableAvatarAnimation: return L10n.Scene.Settings.Section.AppearanceSettings.disableAvatarAnimation
|
||||
case .darkMode: return L10n.Scene.Settings.Section.Preference.trueBlackDarkMode
|
||||
case .disableAvatarAnimation: return L10n.Scene.Settings.Section.Preference.disableAvatarAnimation
|
||||
case .disableEmojiAnimation: return L10n.Scene.Settings.Section.Preference.disableEmojiAnimation
|
||||
case .useDefaultBrowser: return L10n.Scene.Settings.Section.Preference.usingDefaultBrowser
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ extension CustomEmojiPickerSection {
|
|||
let placeholder = UIImage.placeholder(size: CustomEmojiPickerItemCollectionViewCell.itemSize, color: .systemFill)
|
||||
.af.imageRounded(withCornerRadius: 4)
|
||||
|
||||
let url = URL(string: attribute.emoji.url)
|
||||
let isAnimated = !UserDefaults.shared.preferredStaticEmoji
|
||||
let url = URL(string: isAnimated ? attribute.emoji.url : attribute.emoji.staticURL)
|
||||
cell.emojiImageView.sd_setImage(
|
||||
with: url,
|
||||
placeholderImage: placeholder,
|
||||
|
|
|
@ -125,6 +125,8 @@ extension SettingsSection {
|
|||
cell.switchButton.isOn = setting.preferredTrueBlackDarkMode
|
||||
case .disableAvatarAnimation:
|
||||
cell.switchButton.isOn = setting.preferredStaticAvatar
|
||||
case .disableEmojiAnimation:
|
||||
cell.switchButton.isOn = setting.preferredStaticEmoji
|
||||
case .useDefaultBrowser:
|
||||
cell.switchButton.isOn = setting.preferredUsingDefaultBrowser
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ protocol EmojiContainer {
|
|||
var emojisData: Data? { get }
|
||||
}
|
||||
|
||||
// FIXME: `Mastodon.Entity.Account` extension
|
||||
|
||||
extension EmojiContainer {
|
||||
|
||||
static func encode(emojis: [Mastodon.Entity.Emoji]) -> Data? {
|
||||
|
@ -25,9 +27,11 @@ extension EmojiContainer {
|
|||
}
|
||||
|
||||
var emojiMeta: MastodonContent.Emojis {
|
||||
let isAnimated = !UserDefaults.shared.preferredStaticEmoji
|
||||
|
||||
var dict = MastodonContent.Emojis()
|
||||
for emoji in emojis ?? [] {
|
||||
dict[emoji.shortcode] = emoji.url
|
||||
dict[emoji.shortcode] = isAnimated ? emoji.url : emoji.staticURL
|
||||
}
|
||||
return dict
|
||||
}
|
||||
|
|
|
@ -32,9 +32,11 @@ extension Mastodon.Entity.Account {
|
|||
|
||||
extension Mastodon.Entity.Account {
|
||||
var emojiMeta: MastodonContent.Emojis {
|
||||
let isAnimated = !UserDefaults.shared.preferredStaticEmoji
|
||||
|
||||
var dict = MastodonContent.Emojis()
|
||||
for emoji in emojis ?? [] {
|
||||
dict[emoji.shortcode] = emoji.url
|
||||
dict[emoji.shortcode] = isAnimated ? emoji.url : emoji.staticURL
|
||||
}
|
||||
return dict
|
||||
}
|
||||
|
|
|
@ -943,12 +943,6 @@ internal enum L10n {
|
|||
/// Appearance
|
||||
internal static let title = L10n.tr("Localizable", "Scene.Settings.Section.Appearance.Title")
|
||||
}
|
||||
internal enum AppearanceSettings {
|
||||
/// Disable animated avatars
|
||||
internal static let disableAvatarAnimation = L10n.tr("Localizable", "Scene.Settings.Section.AppearanceSettings.DisableAvatarAnimation")
|
||||
/// True black dark mode
|
||||
internal static let trueBlackDarkMode = L10n.tr("Localizable", "Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode")
|
||||
}
|
||||
internal enum BoringZone {
|
||||
/// Account Settings
|
||||
internal static let accountSettings = L10n.tr("Localizable", "Scene.Settings.Section.BoringZone.AccountSettings")
|
||||
|
@ -984,8 +978,14 @@ internal enum L10n {
|
|||
}
|
||||
}
|
||||
internal enum Preference {
|
||||
/// Disable animated avatars
|
||||
internal static let disableAvatarAnimation = L10n.tr("Localizable", "Scene.Settings.Section.Preference.DisableAvatarAnimation")
|
||||
/// Disable animated emojis
|
||||
internal static let disableEmojiAnimation = L10n.tr("Localizable", "Scene.Settings.Section.Preference.DisableEmojiAnimation")
|
||||
/// Preferences
|
||||
internal static let title = L10n.tr("Localizable", "Scene.Settings.Section.Preference.Title")
|
||||
/// True black dark mode
|
||||
internal static let trueBlackDarkMode = L10n.tr("Localizable", "Scene.Settings.Section.Preference.TrueBlackDarkMode")
|
||||
/// Use default browser to open links
|
||||
internal static let usingDefaultBrowser = L10n.tr("Localizable", "Scene.Settings.Section.Preference.UsingDefaultBrowser")
|
||||
}
|
||||
|
|
|
@ -26,4 +26,13 @@ extension UserDefaults {
|
|||
set { self[#function] = newValue }
|
||||
}
|
||||
|
||||
@objc dynamic var preferredStaticEmoji: Bool {
|
||||
get {
|
||||
// default false
|
||||
// without set register to profile timeline performance
|
||||
return bool(forKey: #function)
|
||||
}
|
||||
set { self[#function] = newValue }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -321,8 +321,6 @@ any server.";
|
|||
"Scene.Settings.Section.Appearance.Dark" = "Always Dark";
|
||||
"Scene.Settings.Section.Appearance.Light" = "Always Light";
|
||||
"Scene.Settings.Section.Appearance.Title" = "Appearance";
|
||||
"Scene.Settings.Section.AppearanceSettings.DisableAvatarAnimation" = "Disable animated avatars";
|
||||
"Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode" = "True black dark mode";
|
||||
"Scene.Settings.Section.BoringZone.AccountSettings" = "Account Settings";
|
||||
"Scene.Settings.Section.BoringZone.Privacy" = "Privacy Policy";
|
||||
"Scene.Settings.Section.BoringZone.Terms" = "Terms of Service";
|
||||
|
@ -337,7 +335,10 @@ any server.";
|
|||
"Scene.Settings.Section.Notifications.Trigger.Follower" = "a follower";
|
||||
"Scene.Settings.Section.Notifications.Trigger.Noone" = "no one";
|
||||
"Scene.Settings.Section.Notifications.Trigger.Title" = "Notify me when";
|
||||
"Scene.Settings.Section.Preference.DisableAvatarAnimation" = "Disable animated avatars";
|
||||
"Scene.Settings.Section.Preference.DisableEmojiAnimation" = "Disable animated emojis";
|
||||
"Scene.Settings.Section.Preference.Title" = "Preferences";
|
||||
"Scene.Settings.Section.Preference.TrueBlackDarkMode" = "True black dark mode";
|
||||
"Scene.Settings.Section.Preference.UsingDefaultBrowser" = "Use default browser to open links";
|
||||
"Scene.Settings.Section.SpicyZone.Clear" = "Clear Media Cache";
|
||||
"Scene.Settings.Section.SpicyZone.Signout" = "Sign Out";
|
||||
|
|
|
@ -321,8 +321,6 @@ any server.";
|
|||
"Scene.Settings.Section.Appearance.Dark" = "Always Dark";
|
||||
"Scene.Settings.Section.Appearance.Light" = "Always Light";
|
||||
"Scene.Settings.Section.Appearance.Title" = "Appearance";
|
||||
"Scene.Settings.Section.AppearanceSettings.DisableAvatarAnimation" = "Disable animated avatars";
|
||||
"Scene.Settings.Section.AppearanceSettings.TrueBlackDarkMode" = "True black dark mode";
|
||||
"Scene.Settings.Section.BoringZone.AccountSettings" = "Account Settings";
|
||||
"Scene.Settings.Section.BoringZone.Privacy" = "Privacy Policy";
|
||||
"Scene.Settings.Section.BoringZone.Terms" = "Terms of Service";
|
||||
|
@ -337,7 +335,10 @@ any server.";
|
|||
"Scene.Settings.Section.Notifications.Trigger.Follower" = "a follower";
|
||||
"Scene.Settings.Section.Notifications.Trigger.Noone" = "no one";
|
||||
"Scene.Settings.Section.Notifications.Trigger.Title" = "Notify me when";
|
||||
"Scene.Settings.Section.Preference.DisableAvatarAnimation" = "Disable animated avatars";
|
||||
"Scene.Settings.Section.Preference.DisableEmojiAnimation" = "Disable animated emojis";
|
||||
"Scene.Settings.Section.Preference.Title" = "Preferences";
|
||||
"Scene.Settings.Section.Preference.TrueBlackDarkMode" = "True black dark mode";
|
||||
"Scene.Settings.Section.Preference.UsingDefaultBrowser" = "Use default browser to open links";
|
||||
"Scene.Settings.Section.SpicyZone.Clear" = "Clear Media Cache";
|
||||
"Scene.Settings.Section.SpicyZone.Signout" = "Sign Out";
|
||||
|
|
|
@ -486,6 +486,8 @@ extension SettingsViewController: SettingsToggleCellDelegate {
|
|||
setting.update(preferredTrueBlackDarkMode: isOn)
|
||||
case .disableAvatarAnimation:
|
||||
setting.update(preferredStaticAvatar: isOn)
|
||||
case .disableEmojiAnimation:
|
||||
setting.update(preferredStaticEmoji: isOn)
|
||||
case .useDefaultBrowser:
|
||||
setting.update(preferredUsingDefaultBrowser: isOn)
|
||||
}
|
||||
|
@ -498,6 +500,8 @@ extension SettingsViewController: SettingsToggleCellDelegate {
|
|||
ThemeService.shared.set(themeName: isOn ? .system : .mastodon)
|
||||
case .disableAvatarAnimation:
|
||||
UserDefaults.shared.preferredStaticAvatar = isOn
|
||||
case .disableEmojiAnimation:
|
||||
UserDefaults.shared.preferredStaticEmoji = isOn
|
||||
case .useDefaultBrowser:
|
||||
UserDefaults.shared.preferredUsingDefaultBrowser = isOn
|
||||
}
|
||||
|
|
|
@ -121,11 +121,9 @@ extension SettingsViewModel {
|
|||
|
||||
// preference
|
||||
snapshot.appendSections([.preference])
|
||||
let preferenceItems: [SettingsItem] = [
|
||||
.preference(settingObjectID: setting.objectID, preferenceType: .darkMode),
|
||||
.preference(settingObjectID: setting.objectID, preferenceType: .disableAvatarAnimation),
|
||||
.preference(settingObjectID: setting.objectID, preferenceType: .useDefaultBrowser),
|
||||
]
|
||||
let preferenceItems: [SettingsItem] = SettingsItem.PreferenceType.allCases.map { preferenceType in
|
||||
SettingsItem.preference(settingObjectID: setting.objectID, preferenceType: preferenceType)
|
||||
}
|
||||
snapshot.appendItems(preferenceItems,toSection: .preference)
|
||||
|
||||
// boring zone
|
||||
|
|
|
@ -211,9 +211,15 @@ extension SettingService {
|
|||
UserDefaults.shared.preferredStaticAvatar = setting.preferredStaticAvatar
|
||||
}
|
||||
|
||||
// set emoji mode
|
||||
if UserDefaults.shared.preferredStaticEmoji != setting.preferredStaticEmoji {
|
||||
UserDefaults.shared.preferredStaticEmoji = setting.preferredStaticEmoji
|
||||
}
|
||||
|
||||
// set browser
|
||||
if UserDefaults.shared.preferredUsingDefaultBrowser != setting.preferredUsingDefaultBrowser {
|
||||
UserDefaults.shared.preferredUsingDefaultBrowser = setting.preferredUsingDefaultBrowser
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue