Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ extension UITextField {
/// Once we drop support for iOS 14, we could remove this extension entirely.
///
public class func shouldActivateWorkaroundForBulgarianKeyboardCrash() -> Bool {
if #available(iOS 14.0, *) {
return true
}

return false
return true
}

/// We're swizzling `UITextField.becomeFirstResponder()` so that we can fix an issue with
Expand Down
13 changes: 3 additions & 10 deletions WordPress/Classes/Services/Stories/WPMediaPicker+MediaPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class WPMediaPickerForKanvas: WPNavigationMediaPickerViewController, MediaPicker
photoPicker.dataSource = WPPHAssetDataSource.sharedInstance()
photoPicker.tabBarItem = UITabBarItem(title: Constants.photosTabBarTitle, image: Constants.photosTabBarIcon, tag: 0)

if #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled {
if FeatureFlag.mediaPickerPermissionsNotice.enabled {
photoPicker.mediaPicker.registerClass(forCustomHeaderView: DeviceMediaPermissionsHeader.self)
}

Expand Down Expand Up @@ -182,8 +181,7 @@ class MediaPickerDelegate: NSObject, WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerShouldShowCustomHeaderView(_ picker: WPMediaPickerViewController) -> Bool {
guard #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled,
guard FeatureFlag.mediaPickerPermissionsNotice.enabled,
picker.dataSource is WPPHAssetDataSource else {
return false
}
Expand All @@ -192,19 +190,14 @@ class MediaPickerDelegate: NSObject, WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerReferenceSize(forCustomHeaderView picker: WPMediaPickerViewController) -> CGSize {
guard #available(iOS 14.0, *) else {
return .zero
}

let header = DeviceMediaPermissionsHeader()
header.translatesAutoresizingMaskIntoConstraints = false

return header.referenceSizeInView(picker.view)
}

func mediaPickerController(_ picker: WPMediaPickerViewController, configureCustomHeaderView headerView: UICollectionReusableView) {
guard #available(iOS 14.0, *),
let headerView = headerView as? DeviceMediaPermissionsHeader else {
guard let headerView = headerView as? DeviceMediaPermissionsHeader else {
return
}

Expand Down
36 changes: 4 additions & 32 deletions WordPress/Classes/Stores/StatsWidgetsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,22 @@ class StatsWidgetsStore {

if let newTodayData = refreshStats(type: HomeWidgetTodayData.self) {
HomeWidgetTodayData.write(items: newTodayData)

if #available(iOS 14.0, *) {
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.todayKind)
}
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.todayKind)
}

if let newAllTimeData = refreshStats(type: HomeWidgetAllTimeData.self) {
HomeWidgetAllTimeData.write(items: newAllTimeData)

if #available(iOS 14.0, *) {
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.allTimeKind)
}
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.allTimeKind)
}

if let newThisWeekData = refreshStats(type: HomeWidgetThisWeekData.self) {
HomeWidgetThisWeekData.write(items: newThisWeekData)

if #available(iOS 14.0, *) {
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.thisWeekKind)
}
WidgetCenter.shared.reloadTimelines(ofKind: AppConfiguration.Widget.Stats.thisWeekKind)
}
}

/// Initialize the local cache for widgets, if it does not exist
func initializeStatsWidgetsIfNeeded() {
guard #available(iOS 14.0, *) else {
return
}
if HomeWidgetTodayData.read() == nil {
DDLogInfo("StatsWidgets: Writing initialization data into HomeWidgetTodayData.plist")
HomeWidgetTodayData.write(items: initializeHomeWidgetData(type: HomeWidgetTodayData.self))
Expand All @@ -70,8 +58,7 @@ class StatsWidgetsStore {
/// - widgetType: concrete type of the widget
/// - stats: stats to be stored
func storeHomeWidgetData<T: HomeWidgetData>(widgetType: T.Type, stats: Codable) {
guard #available(iOS 14.0, *),
let siteID = SiteStatsInformation.sharedInstance.siteID else {
guard let siteID = SiteStatsInformation.sharedInstance.siteID else {
return
}

Expand Down Expand Up @@ -243,9 +230,6 @@ private extension StatsWidgetsStore {
// MARK: - Extract this week data
extension StatsWidgetsStore {
func updateThisWeekHomeWidget(summary: StatsSummaryTimeIntervalData?) {
guard #available(iOS 14.0, *) else {
return
}
switch summary?.period {
case .day:
guard summary?.periodEndDate == StatsDataHelper.currentDateForSite().normalizedDate() else {
Expand All @@ -269,10 +253,6 @@ private extension StatsWidgetsStore {
/// Observes WPAccountDefaultWordPressComAccountChanged notification and reloads widget data based on the state of account.
/// The site data is not yet loaded after this notification and widget data cannot be cached for newly signed in account.
func observeAccountChangesForWidgets() {
guard #available(iOS 14.0, *) else {
return
}

NotificationCenter.default.addObserver(forName: .WPAccountDefaultWordPressComAccountChanged,
object: nil,
queue: nil) { notification in
Expand All @@ -294,10 +274,6 @@ private extension StatsWidgetsStore {
/// Observes WPSigninDidFinishNotification notification and initializes the widget.
/// The site data is loaded after this notification and widget data can be cached.
func observeAccountSignInForWidgets() {
guard #available(iOS 14.0, *) else {
return
}

NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: WordPressAuthenticator.WPSigninDidFinishNotification),
object: nil,
queue: nil) { [weak self] _ in
Expand All @@ -307,10 +283,6 @@ private extension StatsWidgetsStore {

/// Observes applicationLaunchCompleted notification and runs migration.
func observeApplicationLaunched() {
guard #available(iOS 14.0, *) else {
return
}

NotificationCenter.default.addObserver(forName: NSNotification.Name.applicationLaunchCompleted,
object: nil,
queue: nil) { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,7 @@ extension InteractiveNotificationsManager: UNUserNotificationCenterDelegate {
if notification.request.content.categoryIdentifier == NoteCategoryDefinition.bloggingReminderWeekly.rawValue
|| notification.request.content.categoryIdentifier == NoteCategoryDefinition.weeklyRoundup.rawValue {

if #available(iOS 14.0, *) {
completionHandler([.banner, .list, .sound])
} else {
completionHandler([.alert, .sound])
}
completionHandler([.banner, .list, .sound])
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,7 @@ class AztecPostViewController: UIViewController, PostEditor {

// Required to work around an issue present in iOS 14 beta 2
// https://github.com/wordpress-mobile/WordPress-iOS/issues/14460
if #available(iOS 14.0, *),
presentedViewController?.view.accessibilityIdentifier == MoreSheetAlert.accessibilityIdentifier {
if presentedViewController?.view.accessibilityIdentifier == MoreSheetAlert.accessibilityIdentifier {
dismiss(animated: true)
}
}
Expand Down Expand Up @@ -1326,8 +1325,7 @@ private extension AztecPostViewController {

alert.addCancelActionWithTitle(MoreSheetAlert.keepEditingTitle)

if #available(iOS 14.0, *),
let button = navigationBarManager.moreBarButtonItem.customView {
if let button = navigationBarManager.moreBarButtonItem.customView {
// Required to work around an issue present in iOS 14 beta 2
// https://github.com/wordpress-mobile/WordPress-iOS/issues/14460
alert.popoverPresentationController?.sourceRect = button.convert(button.bounds, to: navigationController?.navigationBar)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SwiftUI
import UIKit

@available(iOS 14.0, *)
struct SiteIconPickerView: View {
private let initialIcon = Image("blavatar-default")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ extension SitePickerViewController {
}

func showEmojiPicker() {
guard #available(iOS 14.0, *) else {
return
}

var pickerView = SiteIconPickerView()

pickerView.onCompletion = { [weak self] image in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ extension SitePickerViewController: BlogDetailHeaderViewDelegate {
showUpdateSiteIconAlert()
}

if #available(iOS 14.0, *) {
showSiteIconSelectionAlert()
} else {
showUpdateSiteIconAlert()
}
showSiteIconSelectionAlert()
Comment on lines 88 to +91
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code might possibly show two alerts? if FeatureFlag.siteIconCreator.enabled == false it'll call showUpdateSiteIconAlert() and showSiteIconSelectionAlert().

Is that right?

Or, should we add a return to the successful feature flag check branch?

cc @momo-ozawa who's the last one who touched this code. Thanks!

Copy link
Contributor

@momo-ozawa momo-ozawa Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - I totally missed this. Thanks @mokagio!

I've addressed this in a separate PR since this one already got merged to trunk. #19740

Copy link
Contributor Author

@mokagio mokagio Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great! 🙌

}

func siteIconReceivedDroppedImage(_ image: UIImage?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class GutenbergMediaPickerHelper: NSObject {
picker.delegate = self
picker.mediaPicker.registerClass(forReusableCellOverlayViews: DisabledVideoOverlay.self)

if #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled {
if FeatureFlag.mediaPickerPermissionsNotice.enabled {
picker.mediaPicker.registerClass(forCustomHeaderView: DeviceMediaPermissionsHeader.self)
}

Expand Down Expand Up @@ -137,8 +136,7 @@ extension GutenbergMediaPickerHelper: WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerShouldShowCustomHeaderView(_ picker: WPMediaPickerViewController) -> Bool {
guard #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled,
guard FeatureFlag.mediaPickerPermissionsNotice.enabled,
picker !== cameraPicker else {
return false
}
Expand All @@ -147,19 +145,14 @@ extension GutenbergMediaPickerHelper: WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerReferenceSize(forCustomHeaderView picker: WPMediaPickerViewController) -> CGSize {
guard #available(iOS 14.0, *) else {
return .zero
}

let header = DeviceMediaPermissionsHeader()
header.translatesAutoresizingMaskIntoConstraints = false

return header.referenceSizeInView(picker.view)
}

func mediaPickerController(_ picker: WPMediaPickerViewController, configureCustomHeaderView headerView: UICollectionReusableView) {
guard #available(iOS 14.0, *),
let headerView = headerView as? DeviceMediaPermissionsHeader else {
guard let headerView = headerView as? DeviceMediaPermissionsHeader else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ extension GutenbergViewController {
ActionDispatcher.dispatch(NoticeAction.unlock)
}

if #available(iOS 14.0, *),
let button = navigationBarManager.moreBarButtonItem.customView {
if let button = navigationBarManager.moreBarButtonItem.customView {
// Required to work around an issue present in iOS 14 beta 2
// https://github.com/wordpress-mobile/WordPress-iOS/issues/14460
alert.popoverPresentationController?.sourceRect = button.convert(button.bounds, to: navigationController?.navigationBar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ class GutenbergViewController: UIViewController, PostEditor, FeaturedImageDelega

// Required to work around an issue present in iOS 14 beta 2
// https://github.com/wordpress-mobile/WordPress-iOS/issues/14460
if #available(iOS 14.0, *),
presentedViewController?.view.accessibilityIdentifier == MoreSheetAlert.accessibilityIdentifier {
if presentedViewController?.view.accessibilityIdentifier == MoreSheetAlert.accessibilityIdentifier {
dismiss(animated: true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,16 @@ extension Gutenberg.MediaType {
private func getTypesFrom(_ allTypes: [String], conformingTo uttype: CFString) -> [String] {

return allTypes.filter {
if #available(iOS 14.0, *) {
guard let allowedType = UTType($0), let requiredType = UTType(uttype as String) else {
return false
}
// Sometimes the compared type could be a supertype
// For example a self-hosted site without Jetpack may have "public.content" as allowedType
// Although "public.audio" conforms to "public.content", it's not true the other way around
if allowedType.isSupertype(of: requiredType) {
return true
}
return allowedType.conforms(to: requiredType)
} else {
return UTTypeConformsTo($0 as CFString, uttype)
guard let allowedType = UTType($0), let requiredType = UTType(uttype as String) else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: this let requiredType = UTType(uttype as String) part can be moved outside of the loop.

return false
}
// Sometimes the compared type could be a supertype
// For example a self-hosted site without Jetpack may have "public.content" as allowedType
// Although "public.audio" conforms to "public.content", it's not true the other way around
if allowedType.isSupertype(of: requiredType) {
return true
}
return allowedType.conforms(to: requiredType)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PhotosUI
/// Displays a notice at the top of a media picker view in the event that the user has only given the app
/// limited photo library permissions. Contains buttons allowing the user to select more images or review their settings.
///
@available(iOS 14.0, *)
class DeviceMediaPermissionsHeader: UICollectionReusableView {

weak var presenter: UIViewController?
Expand Down
3 changes: 1 addition & 2 deletions WordPress/Classes/ViewRelated/Media/MediaLibraryPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ final class MediaLibraryPicker: NSObject {
picker.delegate = delegate
picker.mediaPicker.registerClass(forReusableCellOverlayViews: DisabledVideoOverlay.self)

if #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled {
if FeatureFlag.mediaPickerPermissionsNotice.enabled {
picker.mediaPicker.registerClass(forCustomHeaderView: DeviceMediaPermissionsHeader.self)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,7 @@ extension MediaLibraryViewController: WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerShouldShowCustomHeaderView(_ picker: WPMediaPickerViewController) -> Bool {
guard #available(iOS 14.0, *),
FeatureFlag.mediaPickerPermissionsNotice.enabled,
guard FeatureFlag.mediaPickerPermissionsNotice.enabled,
picker != self else {
return false
}
Expand All @@ -584,19 +583,14 @@ extension MediaLibraryViewController: WPMediaPickerViewControllerDelegate {
}

func mediaPickerControllerReferenceSize(forCustomHeaderView picker: WPMediaPickerViewController) -> CGSize {
guard #available(iOS 14.0, *) else {
return .zero
}

let header = DeviceMediaPermissionsHeader()
header.translatesAutoresizingMaskIntoConstraints = false

return header.referenceSizeInView(picker.view)
}

func mediaPickerController(_ picker: WPMediaPickerViewController, configureCustomHeaderView headerView: UICollectionReusableView) {
guard #available(iOS 14.0, *),
let headerView = headerView as? DeviceMediaPermissionsHeader else {
guard let headerView = headerView as? DeviceMediaPermissionsHeader else {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class DateCoordinator {

// MARK: - Date Picker

@available(iOS, introduced: 14.0)
class SchedulingDatePickerViewController: UIViewController, DatePickerSheet, DateCoordinatorHandler, UIViewControllerTransitioningDelegate, UIAdaptivePresentationControllerDelegate {

var coordinator: DateCoordinator? = nil
Expand Down Expand Up @@ -129,7 +128,6 @@ class SchedulingDatePickerViewController: UIViewController, DatePickerSheet, Dat
}
}

@available(iOS 14.0, *)
extension SchedulingDatePickerViewController {
@objc func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
let presentationController = PartScreenPresentationController(presentedViewController: presented, presenting: presenting)
Expand All @@ -143,7 +141,7 @@ extension SchedulingDatePickerViewController {
}

// MARK: Accessibility
@available(iOS 14.0, *)

private extension SchedulingDatePickerViewController {
func setupForAccessibility() {
let notificationNames = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ class ReaderTopicsTableCardCell: UITableViewCell {
setupTableView()
applyStyles()

// iOS 14 puts the contentView in the top of the view hierarchy
// This conflicts with the tableView interaction, so we disable it
if #available(iOS 14, *) {
contentView.isUserInteractionEnabled = false
}
// Since iOS 14, the contentView is in the top of the view hierarchy.
// This conflicts with the tableView interaction, so we disable it.
contentView.isUserInteractionEnabled = false
}

required init?(coder: NSCoder) {
Expand Down
Loading