diff --git a/Mac/MainWindow/Sidebar/UnreadCountView.swift b/Mac/MainWindow/Sidebar/UnreadCountView.swift index 25ee1c2a4..f253c3ae5 100644 --- a/Mac/MainWindow/Sidebar/UnreadCountView.swift +++ b/Mac/MainWindow/Sidebar/UnreadCountView.swift @@ -27,7 +27,7 @@ class UnreadCountView : NSView { } } var unreadCountString: String { - return unreadCount < 1 ? "" : "\(unreadCount)" + return unreadCount < 1 ? "" : "\(unreadCount.formatted())" } private var intrinsicContentSizeIsValid = false diff --git a/Modules/Account/Sources/Account/Account.swift b/Modules/Account/Sources/Account/Account.swift index 12dee3eaf..b1065e690 100644 --- a/Modules/Account/Sources/Account/Account.swift +++ b/Modules/Account/Sources/Account/Account.swift @@ -76,21 +76,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, public static let webFeeds = "webFeeds" // AccountDidDownloadArticles, StatusesDidChange public static let syncErrors = "syncErrors" // AccountsDidFailToSyncWithErrors } - - public static let defaultLocalAccountName: String = { - let defaultName: String - #if os(macOS) - defaultName = NSLocalizedString("On My Mac", comment: "Account name") - #else - if UIDevice.current.userInterfaceIdiom == .pad { - defaultName = NSLocalizedString("On My iPad", comment: "Account name") - } else { - defaultName = NSLocalizedString("On My iPhone", comment: "Account name") - } - #endif - - return defaultName - }() + + public static let defaultLocalAccountName = NSLocalizedString("account.name.on-my-device", tableName: "DefaultAccountNames", comment: "Device specific default account name, e.g: On My iPhone") var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "account") diff --git a/Shared/AccountType+Helpers.swift b/Shared/AccountType+Helpers.swift index dd5d04083..3c88d5d75 100644 --- a/Shared/AccountType+Helpers.swift +++ b/Shared/AccountType+Helpers.swift @@ -23,17 +23,7 @@ extension AccountType { switch self { case .onMyMac: - let defaultName: String - #if os(macOS) - defaultName = NSLocalizedString("On My Mac", comment: "Account name") - #else - if UIDevice.current.userInterfaceIdiom == .pad { - defaultName = NSLocalizedString("On My iPad", comment: "Account name") - } else { - defaultName = NSLocalizedString("On My iPhone", comment: "Account name") - } - #endif - return defaultName + return NSLocalizedString("account.name.on-my-device", tableName: "DefaultAccountNames", comment: "Device specific default account name, e.g: On my iPhone") case .bazQux: return NSLocalizedString("BazQux", comment: "Account name") case .cloudKit: diff --git a/Shared/DefaultAccountNames.xcstrings b/Shared/DefaultAccountNames.xcstrings new file mode 100644 index 000000000..647f037b5 --- /dev/null +++ b/Shared/DefaultAccountNames.xcstrings @@ -0,0 +1,65 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "account.name.on-my-device" : { + "comment" : "Device specific default account name, e.g: On my iPhone", + "localizations" : { + "en" : { + "variations" : { + "device" : { + "appletv" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My Apple TV" + } + }, + "applevision" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My Apple Vision" + } + }, + "applewatch" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My Apple Watch" + } + }, + "ipad" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My iPad" + } + }, + "iphone" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My iPhone" + } + }, + "ipod" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My iPod" + } + }, + "mac" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My Mac" + } + }, + "other" : { + "stringUnit" : { + "state" : "translated", + "value" : "On My Device" + } + } + } + } + } + } + } + }, + "version" : "1.1" +} \ No newline at end of file diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 35ffe3df4..e598be869 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -57,6 +57,7 @@ final class AppDefaults { static let addFolderAccountID = "addFolderAccountID" static let useSystemBrowser = "useSystemBrowser" static let currentThemeName = "currentThemeName" + static let articleContentJavascriptEnabled = "articleContentJavascriptEnabled" } let isDeveloperBuild: Bool = { @@ -189,6 +190,15 @@ final class AppDefaults { } } + var isArticleContentJavascriptEnabled: Bool { + get { + return AppDefaults.bool(for: Key.articleContentJavascriptEnabled) + } + set { + AppDefaults.setBool(for: Key.articleContentJavascriptEnabled, newValue) + } + } + var lastRefresh: Date? { get { return AppDefaults.date(for: Key.lastRefresh) @@ -236,6 +246,7 @@ final class AppDefaults { Key.articleFullscreenAvailable: false, Key.articleFullscreenEnabled: false, Key.confirmMarkAllAsRead: true, + Key.articleContentJavascriptEnabled: true, Key.currentThemeName: Self.defaultThemeName] AppDefaults.store.register(defaults: defaults) } diff --git a/iOS/Article/PreloadedWebView.swift b/iOS/Article/PreloadedWebView.swift index fd407ca0b..af74cf783 100644 --- a/iOS/Article/PreloadedWebView.swift +++ b/iOS/Article/PreloadedWebView.swift @@ -20,17 +20,19 @@ class PreloadedWebView: WKWebView { let configuration = WKWebViewConfiguration() configuration.preferences = preferences - configuration.defaultWebpagePreferences.allowsContentJavaScript = true + configuration.defaultWebpagePreferences.allowsContentJavaScript = AppDefaults.shared.isArticleContentJavascriptEnabled configuration.setValue(true, forKey: "allowUniversalAccessFromFileURLs") configuration.allowsInlineMediaPlayback = true configuration.mediaTypesRequiringUserActionForPlayback = .audio configuration.setURLSchemeHandler(articleIconSchemeHandler, forURLScheme: ArticleRenderer.imageIconScheme) super.init(frame: .zero, configuration: configuration) + NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil) } required init?(coder: NSCoder) { super.init(coder: coder) + } func preload() { @@ -46,6 +48,13 @@ class PreloadedWebView: WKWebView { } } + @objc func userDefaultsDidChange(_ sender: Any) { + if configuration.defaultWebpagePreferences.allowsContentJavaScript != AppDefaults.shared.isArticleContentJavascriptEnabled { + configuration.defaultWebpagePreferences.allowsContentJavaScript = AppDefaults.shared.isArticleContentJavascriptEnabled + reload() + } + } + } // MARK: WKScriptMessageHandler diff --git a/iOS/MainFeed/Cell/MainFeedUnreadCountView.swift b/iOS/MainFeed/Cell/MainFeedUnreadCountView.swift index 9f2919343..0030e9ff4 100644 --- a/iOS/MainFeed/Cell/MainFeedUnreadCountView.swift +++ b/iOS/MainFeed/Cell/MainFeedUnreadCountView.swift @@ -35,7 +35,7 @@ class MainFeedUnreadCountView : UIView { } var unreadCountString: String { - return unreadCount < 1 ? "" : "\(unreadCount)" + return unreadCount < 1 ? "" : "\(unreadCount.formatted())" } private var contentSizeIsValid = false diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 946605ce2..d41681a75 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -1,8 +1,8 @@ - + - + @@ -20,14 +20,14 @@ - + - +