From 630972033b12d3e744b6dd477a503081b844d902 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Mon, 14 Feb 2022 07:43:51 +0800 Subject: [PATCH] Aa as More Menu More now includes feed inspector's actions to manage notifications and reader view. Subtitles removed. First time full screen view shows, an alert is displayed to explain how to exit full screen. --- iOS/AppDefaults.swift | 10 +++++ iOS/Article/ArticleViewController.swift | 59 ++++++++++++++++++++++--- iOS/Base.lproj/Main.storyboard | 6 +-- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 1d29bbc41..4c6ec9d75 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -51,6 +51,7 @@ final class AppDefaults { static let timelineSortDirection = "timelineSortDirection" static let articleFullscreenAvailable = "articleFullscreenAvailable" static let articleFullscreenEnabled = "articleFullscreenEnabled" + static let hasUsedFullScreenPreviously = "hasUsedFullScreenPreviously" static let confirmMarkAllAsRead = "confirmMarkAllAsRead" static let lastRefresh = "lastRefresh" static let addWebFeedAccountID = "addWebFeedAccountID" @@ -123,6 +124,15 @@ final class AppDefaults { } } + var hasUsedFullScreenPreviously: Bool { + get { + return UserDefaults.standard.bool(forKey: Key.hasUsedFullScreenPreviously) + } + set { + UserDefaults.standard.set(newValue, forKey: Key.hasUsedFullScreenPreviously) + } + } + var useSystemBrowser: Bool { get { return UserDefaults.standard.bool(forKey: Key.useSystemBrowser) diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 08aee3429..1da544502 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -265,9 +265,8 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { let customThemeMenu = UIMenu(title: "", image: nil, identifier: nil, options: .displayInline, children: themeActions) let themeMenu = UIMenu(title: "Theme", image: AppAssets.themeImage, identifier: nil, options: .singleSelection, children: [ defaultThemeMenu, customThemeMenu]) - themeMenu.subtitle = NSLocalizedString("Change the look of articles.", comment: "Change theme") - var children: [UIMenuElement] = [themeMenu] + var appearanceChildren: [UIMenuElement] = [themeMenu] if let currentWebViewController = currentWebViewController { if currentWebViewController.isFullScreenAvailable { @@ -278,18 +277,66 @@ class ArticleViewController: UIViewController, MainControllerIdentifiable { attributes: [], state: .off) { [weak self] _ in self?.currentWebViewController?.hideBars() + if AppDefaults.shared.hasUsedFullScreenPreviously == false { + let alert = UIAlertController(title: NSLocalizedString("Exit Full Screen", comment: "Full Screen"), + message: NSLocalizedString("To exit Full Screen mode tap the top of the screen.\n\nYou'll only see this message once.", comment: "Full screen explainer."), + preferredStyle: .alert) + alert.addAction(UIAlertAction(title: NSLocalizedString("Dismiss", comment: "Dismiss"), style: .default, handler: { _ in + AppDefaults.shared.hasUsedFullScreenPreviously = true + })) + self?.present(alert, animated: true, completion: nil) + } } - fullScreenAction.subtitle = NSLocalizedString("Tap the top of the screen to exit Full Screen.", comment: "Exit criteria.") - children.append(fullScreenAction) + appearanceChildren.append(fullScreenAction) } } - let appearanceMenu = UIMenu(title: NSLocalizedString("Article Appearance", comment: "Appearance"), image: UIImage(systemName: "textformat.size") , identifier: nil, options: .displayInline, children: children) + var feedManagementChildren = [UIMenuElement]() - appearanceBarButtonItem.menu = appearanceMenu + if let feed = article?.webFeed { + let extractorOn = feed.isArticleExtractorAlwaysOn ?? false + let readerAction = UIAction(title: NSLocalizedString("Always Use Reader View", comment: "Always Use Reader View"), + image: AppAssets.articleExtractorOffSF, + identifier: nil, + discoverabilityTitle: nil, + attributes: [], + state: extractorOn ? .on : .off) { [weak self] _ in + if feed.isArticleExtractorAlwaysOn == nil { + feed.isArticleExtractorAlwaysOn = true + } else { + feed.isArticleExtractorAlwaysOn?.toggle() + } + self?.configureAppearanceMenu() + } + feedManagementChildren.append(readerAction) + + let notifyOn = feed.isNotifyAboutNewArticles ?? false + let notifyAction = UIAction(title: NSLocalizedString("Notify About New Articles", comment: "Notify About New Articles"), + image: AppAssets.appBadgeImage, + identifier: nil, + discoverabilityTitle: nil, + attributes: [], + state: notifyOn ? .on : .off) { [weak self] _ in + if feed.isNotifyAboutNewArticles == nil { + feed.isNotifyAboutNewArticles = true + } else { + feed.isNotifyAboutNewArticles?.toggle() + } + self?.configureAppearanceMenu() + } + feedManagementChildren.append(notifyAction) + } + + let appearanceMenu = UIMenu(title: NSLocalizedString("Article Appearance", comment: "Appearance"), image: nil, identifier: nil, options: .displayInline, children: appearanceChildren) + let feedMgmtMenu = UIMenu(title: NSLocalizedString("Feed Management", comment: "Feed Management"), image: nil , identifier: nil, options: .displayInline, children: feedManagementChildren) + + let menu = UIMenu(title: "", image: nil, identifier: nil, options: .displayInline, children: [appearanceMenu, feedMgmtMenu]) + + appearanceBarButtonItem.menu = menu } + @objc func reloadDueToThemeChange(_ notification: Notification) { currentWebViewController?.fullReload() diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 268758478..1aaef03a2 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -17,7 +17,7 @@ -