Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 12: clean up old available checks #458

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 5 additions & 9 deletions Buildsystem/Fastlane/SnapshotHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,11 @@ open class Snapshot: NSObject {
#if os(watchOS)
return image
#else
if #available(iOS 10.0, *) {
let format = UIGraphicsImageRendererFormat()
format.scale = image.scale
let renderer = UIGraphicsImageRenderer(size: image.size, format: format)
return renderer.image { context in
image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
}
} else {
return image
let format = UIGraphicsImageRendererFormat()
format.scale = image.scale
let renderer = UIGraphicsImageRenderer(size: image.size, format: format)
return renderer.image { context in
image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height))
}
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ SPEC CHECKSUMS:
MetaDataFetcherKit: bfe763f41e25eef64f40d205f9afdc1080d6df2e
ObjectiveDropboxOfficial: 8699fa65969a94f8305d8dabf9c9a8dd856ac598
OBSlider: 490f108007bfdd5414a38650b211fe403a95b8a0
OneDriveSDK: fbb41c73c36a23a580d172657c67c47dbb8f8e24
OneDriveSDK: 17f6861ca3e224c38e7637b5fa93b03c97906006
SimulatorStatusMagic: 4e15e56530b367e90dcd3b94fd272e833e9d8a44
SwiftLint: f80f1be7fa96d30e0aa68e58d45d4ea1ccaac519
VLCKit: 80332c6fbe83e9278aca1b7e27799f2b521a7f76
Expand All @@ -180,4 +180,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: b3faa067594e458bfec6754b5898d7564ccda8b3

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
12 changes: 3 additions & 9 deletions Sources/About/AboutController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI
}

@objc private func sendFeedbackEmail() {
if #available(iOS 10, *) {
ImpactFeedbackGenerator().selectionChanged()
}
ImpactFeedbackGenerator().selectionChanged()

if MFMailComposeViewController.canSendMail() {
let mailComposerVC = MFMailComposeViewController()
Expand Down Expand Up @@ -215,9 +213,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI


@objc private func dismissView() {
if #available(iOS 10, *) {
ImpactFeedbackGenerator().selectionChanged()
}
ImpactFeedbackGenerator().selectionChanged()
dismiss(animated: true)
}
}
Expand Down Expand Up @@ -255,8 +251,6 @@ class AboutNavigationController: UINavigationController {

override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 11.0, *) {
navigationBar.prefersLargeTitles = false
}
navigationBar.prefersLargeTitles = false
}
}
13 changes: 3 additions & 10 deletions Sources/App/iOS/TabBarCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ class TabBarCoordinator: NSObject {
navController.navigationBar.barTintColor = colors.navigationbarColor
navController.navigationBar.tintColor = colors.orangeUI
navController.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: colors.navigationbarTextColor]

if #available(iOS 11.0, *) {
navController.navigationBar.prefersLargeTitles = false
}
navController.navigationBar.prefersLargeTitles = false
if #available(iOS 13.0, *) {
navController.navigationBar.standardAppearance = AppearanceManager.navigationbarAppearance()
navController.navigationBar.scrollEdgeAppearance = AppearanceManager.navigationbarAppearance()
Expand Down Expand Up @@ -121,16 +118,12 @@ private extension TabBarCoordinator {
tabBarController.tabBar.bringSubviewToFront(editToolbar)

let view = tabBarController.tabBar
var guide: LayoutAnchorContainer = view
if #available(iOS 11.0, *) {
guide = view.safeAreaLayoutGuide
}

NSLayoutConstraint.activate([
editToolbar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
editToolbar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
editToolbar.topAnchor.constraint(equalTo: guide.topAnchor),
editToolbar.bottomAnchor.constraint(equalTo: guide.bottomAnchor),
editToolbar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
editToolbar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
])
}
}
Expand Down
7 changes: 2 additions & 5 deletions Sources/Extensions/Devices/UIDevice+VLC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@

@objc(VLCDeviceHasSafeArea)
static var hasSafeArea: Bool {
if #available(iOS 11.0, *) {
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
return keyWindow?.safeAreaInsets.bottom ?? 0 > 0
}
return false
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
return keyWindow?.safeAreaInsets.bottom ?? 0 > 0
}

static var hasNotch: Bool {
Expand Down
13 changes: 1 addition & 12 deletions Sources/Extensions/URLs/URL+isExcludedFromBackup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,7 @@ extension URL {

resourceValue.isExcludedFromBackup = excluded
if path == documentPath {
// iOS 11+ : Never exclude the Documents folder from backup, it makes iOS Files app hide VLC.
// iOS 9 / 10 : usually not powerful old devices, the Files app is not available.
// Exclude Documents anyway, do not exclude its content though, it would be useless.
if #available(iOS 11.0, *) {
resourceValue.isExcludedFromBackup = false
} else if excluded {
// If we have an iOS 9 / 10 device and want to exclude from backup, no need to be recursive,
// excluding the Documents folder will be enough.
// If we are including into the backup, we will stay recursive, all files get reincluded, as
// older VLC iOS versions used per-file exclusion.
recursive = false
}
resourceValue.isExcludedFromBackup = false
}
do {
try setResourceValues(resourceValue)
Expand Down
13 changes: 4 additions & 9 deletions Sources/Helpers/AppearanceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ class AppearanceManager: NSObject {
UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).barTintColor = nil
UINavigationBar.appearance().tintColor = theme.colors.orangeUI
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: theme.colors.navigationbarTextColor]

if #available(iOS 11.0, *) {
UINavigationBar.appearance().prefersLargeTitles = true
UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).prefersLargeTitles = false
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: theme.colors.navigationbarTextColor]
}
UINavigationBar.appearance().prefersLargeTitles = true
UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).prefersLargeTitles = false
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: theme.colors.navigationbarTextColor]

let selectedBackgroundView = UIView()
selectedBackgroundView.backgroundColor = theme.colors.mediaCategorySeparatorColor
Expand All @@ -49,9 +46,7 @@ class AppearanceManager: NSObject {
UILabel.appearance(whenContainedInInstancesOf: [UISegmentedControl.self]).lineBreakMode = .byWordWrapping

UITabBar.appearance().tintColor = theme.colors.orangeUI
if #available(iOS 10.0, *) {
UITabBar.appearance().unselectedItemTintColor = theme.colors.cellDetailTextColor
}
UITabBar.appearance().unselectedItemTintColor = theme.colors.cellDetailTextColor

UIPageControl.appearance().pageIndicatorTintColor = .lightGray
UIPageControl.appearance().currentPageIndicatorTintColor = theme.colors.orangeUI
Expand Down
4 changes: 2 additions & 2 deletions Sources/Helpers/KeychainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KeychainCoordinator: NSObject {
var touchIDEnabled = UserDefaults.standard.bool(forKey: kVLCSettingPasscodeAllowTouchID)
let laContext = LAContext()

if #available(iOS 11.0.1, *), laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
if laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
touchIDEnabled = touchIDEnabled && laContext.biometryType == .touchID
}
return touchIDEnabled
Expand All @@ -38,7 +38,7 @@ class KeychainCoordinator: NSObject {
var faceIDEnabled = UserDefaults.standard.bool(forKey: kVLCSettingPasscodeAllowFaceID)
let laContext = LAContext()

if #available(iOS 11.0.1, *), laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
if laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) {
faceIDEnabled = faceIDEnabled && laContext.biometryType == .faceID
}
return faceIDEnabled
Expand Down
10 changes: 3 additions & 7 deletions Sources/Helpers/Network/URLHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,9 @@ extension VLCURLHandler {
return
}

if #available(iOS 10, *) {
UIApplication.shared.open(callback,
options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]),
completionHandler: nil)
} else {
UIApplication.shared.openURL(callback)
}
UIApplication.shared.open(callback,
options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]),
completionHandler: nil)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class AddToCollectionViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = false
}
navigationController?.navigationBar.prefersLargeTitles = false
navigationController?.navigationBar.isTranslucent = false
collectionView.reloadData()
}
Expand Down
7 changes: 1 addition & 6 deletions Sources/Media Library/Editing/EditController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,7 @@ extension EditController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
var toWidth = collectionView.frame.size.width
if #available(iOS 11.0, *) {
toWidth = collectionView.safeAreaLayoutGuide.layoutFrame.width
}

return model.cellType.cellSizeForWidth(toWidth)
model.cellType.cellSizeForWidth(collectionView.safeAreaLayoutGuide.layoutFrame.width)
}

func collectionView(_ collectionView: UICollectionView,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Media Library/MediaCategories/AlbumHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AlbumHeader: UICollectionReusableView {
private func setupConstraints() {
let buttonSize: CGFloat = 50.0
let playShuffleTrailingAnchor: NSLayoutConstraint
if let parentView = parentView, #available(iOS 11.0, *) {
if let parentView {
playShuffleTrailingAnchor = playShuffleButton.trailingAnchor.constraint(equalTo: parentView.safeAreaLayoutGuide.trailingAnchor, constant: -20)
} else {
playShuffleTrailingAnchor = playShuffleButton.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega
searchBar.translatesAutoresizingMaskIntoConstraints = false
searchBar.placeholder = NSLocalizedString("SEARCH", comment: "")
searchBar.backgroundColor = PresentationTheme.current.colors.background
if #available(iOS 11.0, *) {
navigationItem.largeTitleDisplayMode = .never
}
navigationItem.largeTitleDisplayMode = .never
if let textfield = searchBar.value(forKey: "searchField") as? UITextField {
if let backgroundview = textfield.subviews.first {
backgroundview.backgroundColor = UIColor.white
Expand Down Expand Up @@ -816,9 +814,7 @@ extension MediaCategoryViewController {

@objc func handleSortLongPress(sender: UILongPressGestureRecognizer) {
if sender.state == .began {
if #available(iOS 10.0, *) {
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
}
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
handleSortShortcut()
}
}
Expand Down Expand Up @@ -1263,12 +1259,10 @@ extension MediaCategoryViewController: UICollectionViewDelegateFlowLayout {
//For iOS 10 when rotating we take the value from willTransition to size, for the first layout pass that value is 0 though,
//so we need the frame.size width. For rotation on iOS 11 this approach doesn't work because at the time when this is called
//we don't have yet the updated safeare layout frame. This is addressed by relayouting from viewSafeAreaInsetsDidChange
var toWidth = toSize.width != 0 ? toSize.width : collectionView.frame.size.width
if #available(iOS 11.0, *) {
// In case of nested views, the safe area may not be updated.
// Getting its parent's safe area gives us the true updated safe area.
toWidth = parent?.view.safeAreaLayoutGuide.layoutFrame.width ?? collectionView.safeAreaLayoutGuide.layoutFrame.width
}

// In case of nested views, the safe area may not be updated.
// Getting its parent's safe area gives us the true updated safe area.
let toWidth = parent?.view.safeAreaLayoutGuide.layoutFrame.width ?? collectionView.safeAreaLayoutGuide.layoutFrame.width
cachedCellSize = model.cellType.cellSizeForWidth(toWidth)
}
return cachedCellSize
Expand Down Expand Up @@ -1557,11 +1551,7 @@ private extension MediaCategoryViewController {
longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongGesture(gesture:)))
longPressGesture.minimumPressDuration = 0.2
collectionView?.addGestureRecognizer(longPressGesture)
if #available(iOS 11.0, *) {
collectionView?.contentInsetAdjustmentBehavior = .always
// collectionView?.dragDelegate = dragAndDropManager
// collectionView?.dropDelegate = dragAndDropManager
}
collectionView?.contentInsetAdjustmentBehavior = .always
}

func constrainOnX(_ location: CGPoint, for width: CGFloat) -> CGPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ class MediaCollectionViewCell: BaseCollectionViewCell, UIScrollViewDelegate {

override func awakeFromNib() {
super.awakeFromNib()
if #available(iOS 11.0, *) {
thumbnailView.accessibilityIgnoresInvertColors = true
}
thumbnailView.accessibilityIgnoresInvertColors = true

newLabel.text = NSLocalizedString("NEW", comment: "")
newLabel.textColor = PresentationTheme.current.colors.orangeUI
Expand Down Expand Up @@ -224,11 +222,9 @@ class MediaCollectionViewCell: BaseCollectionViewCell, UIScrollViewDelegate {
}

if scrollView.contentOffset.x >= deleteButton.frame.size.width + 30 {
if #available(iOS 10.0, *), !vibrationTriggered {
let impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)
impactFeedbackGenerator.prepare()
impactFeedbackGenerator.impactOccurred()
}
let impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light)
impactFeedbackGenerator.prepare()
impactFeedbackGenerator.impactOccurred()

vibrationTriggered = true
scrollContentView.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ class MediaGridCollectionCell: BaseCollectionViewCell {

override func awakeFromNib() {
super.awakeFromNib()
if #available(iOS 11.0, *) {
thumbnailView.accessibilityIgnoresInvertColors = true
}
thumbnailView.accessibilityIgnoresInvertColors = true
clipsToBounds = true
layer.cornerRadius = 2
titleLabel.labelize = enableMarquee
Expand All @@ -182,11 +180,6 @@ class MediaGridCollectionCell: BaseCollectionViewCell {
}

private func setupUI() {
var guide: LayoutAnchorContainer = self
if #available(iOS 11.0, *) {
guide = safeAreaLayoutGuide
}

thumbnailView.addSubview(checkboxImageView)
addSubview(contentStackView)
addSubview(selectionOverlay)
Expand All @@ -206,9 +199,9 @@ class MediaGridCollectionCell: BaseCollectionViewCell {
thumbnailView.heightAnchor.constraint(equalTo: thumbnailView.widthAnchor),
checkboxImageView.bottomAnchor.constraint(equalTo: thumbnailView.bottomAnchor, constant: -5),
checkboxImageView.trailingAnchor.constraint(equalTo: thumbnailView.trailingAnchor, constant: -5),
contentStackView.topAnchor.constraint(equalTo: guide.topAnchor),
contentStackView.leadingAnchor.constraint(equalTo: guide.leadingAnchor),
contentStackView.trailingAnchor.constraint(equalTo: guide.trailingAnchor),
contentStackView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
contentStackView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor),
contentStackView.trailingAnchor.constraint(equalTo: safeAreaLayoutGuide.trailingAnchor),
selectionOverlay.leadingAnchor.constraint(equalTo: thumbnailView.leadingAnchor),
selectionOverlay.trailingAnchor.constraint(equalTo: thumbnailView.trailingAnchor),
selectionOverlay.topAnchor.constraint(equalTo: thumbnailView.topAnchor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class MovieCollectionViewCell: BaseCollectionViewCell {

override func awakeFromNib() {
super.awakeFromNib()
if #available(iOS 11.0, *) {
thumbnailView.accessibilityIgnoresInvertColors = true
}
thumbnailView.accessibilityIgnoresInvertColors = true

clipsToBounds = true
layer.cornerRadius = 2
Expand Down Expand Up @@ -180,18 +178,9 @@ class MovieCollectionViewCell: BaseCollectionViewCell {
progressView.progressViewStyle = .bar

if !progressView.isHidden {
if #available(iOS 11.0, *) {
progressView.layer.cornerRadius = itemCornerRadius
progressView.clipsToBounds = true
progressView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
} else {
let path = UIBezierPath(roundedRect: progressView.bounds,
byRoundingCorners: [.bottomLeft, .bottomRight],
cornerRadii: CGSize(width: 7, height: 7))
let maskLayer = CAShapeLayer()
maskLayer.path = path.cgPath
progressView.layer.mask = maskLayer
}
progressView.layer.cornerRadius = itemCornerRadius
progressView.clipsToBounds = true
progressView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ class MediaViewController: VLCPagingViewController<VLCLabelCell> {
}

private func setupNavigationBar() {
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = false
}
navigationController?.navigationBar.prefersLargeTitles = false
if #available(iOS 13.0, *) {
navigationController?.navigationBar.standardAppearance = AppearanceManager.navigationbarAppearance()
navigationController?.navigationBar.scrollEdgeAppearance = AppearanceManager.navigationbarAppearance()
Expand Down
Loading